Several minor improvements to the status bar

* Remove "%3d" for integers (just use "%d"), this is a legacy format
  when the text was a monospace font (it was present from the very
  beginning of the times, when we used the Allegro font)
* New :delta: icon (before :offset: which didn't exist in the theme)
* Show useful info for MovingCelState: mainly cel bounds
master
David Capello 2022-07-15 16:32:49 -03:00
parent 7e19592470
commit f4e83371b8
10 changed files with 93 additions and 36 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -382,6 +382,8 @@
<part id="icon_save" x="232" y="264" w="8" h="8" />
<part id="icon_save_small" x="240" y="264" w="8" h="8" />
<part id="icon_slice" x="248" y="264" w="8" h="8" />
<part id="icon_aspect_ratio" x="256" y="264" w="10" h="8" />
<part id="icon_delta" x="266" y="264" w="6" h="8" />
<part id="tool_rectangular_marquee" x="144" y="0" w="16" h="16" />
<part id="tool_elliptical_marquee" x="160" y="0" w="16" h="16" />
<part id="tool_lasso" x="176" y="0" w="16" h="16" />
@ -414,7 +416,6 @@
<part id="aseprite_face" x="0" y="272" w="28" h="30" />
<part id="aseprite_face_mouse" x="28" y="272" w="28" h="30" />
<part id="aseprite_face_pushed" x="56" y="272" w="28" h="30" />
<part id="icon_aspect_ratio" x="256" y="264" w="10" h="8" />
<part id="linear_gradient" x="176" y="208" w="8" h="8" />
<part id="radial_gradient" x="184" y="208" w="8" h="8" />
<part id="folder_icon_small" x="144" y="272" w="10" h="8" />

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -94,7 +94,7 @@ public:
gfx::Point offset = loop->statusBarPositionOffset();
char buf[1024];
sprintf(buf, ":start: %3d %3d :end: %3d %3d",
sprintf(buf, ":start: %d %d :end: %d %d",
stroke.firstPoint().x+offset.x,
stroke.firstPoint().y+offset.y,
stroke.lastPoint().x+offset.x,
@ -259,7 +259,7 @@ public:
gfx::Point offset = loop->statusBarPositionOffset();
char buf[1024];
int gcd = base::gcd(w, h);
sprintf(buf, ":start: %3d %3d :end: %3d %3d :size: %3d %3d :distance: %.1f",
sprintf(buf, ":start: %d %d :end: %d %d :size: %d %d :distance: %.1f",
stroke[0].x+offset.x, stroke[0].y+offset.y,
stroke[1].x+offset.x, stroke[1].y+offset.y,
w, h, std::sqrt(w*w + h*h));
@ -362,7 +362,7 @@ public:
gfx::Point offset = loop->statusBarPositionOffset();
char buf[1024];
sprintf(buf, ":start: %3d %3d :end: %3d %3d",
sprintf(buf, ":start: %d %d :end: %d %d",
stroke.firstPoint().x+offset.x,
stroke.firstPoint().y+offset.y,
stroke.lastPoint().x+offset.x,
@ -402,7 +402,7 @@ public:
gfx::Point offset = loop->statusBarPositionOffset();
char buf[1024];
sprintf(buf, ":pos: %3d %3d",
sprintf(buf, ":pos: %d %d",
stroke[0].x+offset.x,
stroke[0].y+offset.y);
text = buf;
@ -460,7 +460,7 @@ public:
gfx::Point offset = loop->statusBarPositionOffset();
char buf[1024];
sprintf(buf, ":start: %3d %3d :end: %3d %3d (%3d %3d - %3d %3d)",
sprintf(buf, ":start: %d %d :end: %d %d (%d %d - %d %d)",
stroke[0].x+offset.x, stroke[0].y+offset.y,
stroke[3].x+offset.x, stroke[3].y+offset.y,
stroke[1].x+offset.x, stroke[1].y+offset.y,

View File

@ -2887,6 +2887,7 @@ void Editor::updateAutoCelGuides(ui::Message* msg)
if (m_showGuidesThisCel != oldShowGuidesThisCel ||
m_showAutoCelGuides != oldShowAutoCelGuides) {
invalidate();
updateStatusBar();
}
}

View File

@ -304,6 +304,9 @@ namespace app {
// key is pressed to cancel the active selection.
void cancelSelections();
// Properties to show information in the status bar
bool showAutoCelGuides() const { return m_showAutoCelGuides; }
static void registerCommands();
protected:
@ -374,7 +377,6 @@ namespace app {
gfx::Point calcExtraPadding(const render::Projection& proj);
void invalidateIfActive();
bool showAutoCelGuides();
void updateAutoCelGuides(ui::Message* msg);
// Stack of states. The top element in the stack is the current state (m_state).

View File

@ -97,8 +97,12 @@ MovingCelState::MovingCelState(Editor* editor,
ASSERT(!m_celList.empty());
m_cel = collect.mainCel();
if (m_cel)
m_celMainSize = m_cel->boundsF().size();
if (m_cel) {
if (m_cel->data()->hasBoundsF())
m_celMainSize = m_cel->boundsF().size();
else
m_celMainSize = gfx::SizeF(m_cel->bounds().size());
}
// Record start positions of all cels in selected range
for (Cel* cel : m_celList) {
@ -282,6 +286,11 @@ void MovingCelState::onCommitMouseMove(Editor* editor,
// Redraw the new cel position.
editor->invalidate();
// Redraw status bar with the new position of cels (without this the
// previous position before this onCommitMouseMove() is still
// displayed in the screen).
editor->updateStatusBar();
}
bool MovingCelState::onKeyDown(Editor* editor, KeyMessage* msg)
@ -297,37 +306,46 @@ bool MovingCelState::onKeyDown(Editor* editor, KeyMessage* msg)
bool MovingCelState::onUpdateStatusBar(Editor* editor)
{
gfx::PointF pos = m_cursorStart - gfx::PointF(editor->mainTilePosition());
gfx::PointF pos = m_celOffset + m_cursorStart - gfx::PointF(editor->mainTilePosition());
gfx::RectF fullBounds = calcFullBounds();
std::string buf;
if (m_hasReference) {
buf = fmt::format(":pos: {:.2f} {:.2f}", pos.x, pos.y);
if (m_scaled && m_cel) {
StatusBar::instance()->setStatusText(
0,
fmt::format(
":pos: {:.2f} {:.2f} :offset: {:.2f} {:.2f} :size: {:.2f}% {:.2f}%",
pos.x, pos.y,
m_celOffset.x, m_celOffset.y,
100.0*m_celScale.w*m_celMainSize.w/m_cel->image()->width(),
100.0*m_celScale.h*m_celMainSize.h/m_cel->image()->height()));
buf += fmt::format(
" :start: {:.2f} {:.2f}"
" :size: {:.2f} {:.2f} [{:.2f}% {:.2f}%]",
m_cel->boundsF().x,
m_cel->boundsF().y,
m_celScale.w*m_celMainSize.w,
m_celScale.h*m_celMainSize.h,
100.0*m_celScale.w*m_celMainSize.w/m_cel->image()->width(),
100.0*m_celScale.h*m_celMainSize.h/m_cel->image()->height());
}
else {
StatusBar::instance()->setStatusText(
0,
fmt::format(
":pos: {:.2f} {:.2f} :offset: {:.2f} {:.2f}",
pos.x, pos.y,
m_celOffset.x, m_celOffset.y));
buf += fmt::format(
" :start: {:.2f} {:.2f} :size: {:.2f} {:.2f}"
" :delta: {:.2f} {:.2f}",
fullBounds.x, fullBounds.y,
fullBounds.w, fullBounds.h,
m_celOffset.x, m_celOffset.y);
}
}
else {
gfx::Point intOffset = intCelOffset();
StatusBar::instance()->setStatusText(
0,
fmt::format(":pos: {:3d} {:3d} :offset: {:3d} {:3d}",
int(pos.x), int(pos.y),
intOffset.x, intOffset.y));
fullBounds.floor();
buf = fmt::format(
":pos: {} {}"
" :start: {} {} :size: {} {}"
" :delta: {} {}",
int(pos.x), int(pos.y),
int(fullBounds.x), int(fullBounds.y),
int(fullBounds.w), int(fullBounds.h),
intOffset.x, intOffset.y);
}
StatusBar::instance()->setStatusText(0, buf);
return true;
}
@ -337,6 +355,18 @@ gfx::Point MovingCelState::intCelOffset() const
int(std::round(m_celOffset.y)));
}
gfx::RectF MovingCelState::calcFullBounds() const
{
gfx::RectF bounds;
for (Cel* cel : m_celList) {
if (cel->data()->hasBoundsF())
bounds |= cel->boundsF();
else
bounds |= gfx::RectF(cel->bounds()).floor();
}
return bounds;
}
bool MovingCelState::restoreCelStartPosition() const
{
bool modified = false;

View File

@ -57,6 +57,7 @@ namespace app {
private:
gfx::Point intCelOffset() const;
gfx::RectF calcFullBounds() const;
bool restoreCelStartPosition() const;
// ContextObserver
void onBeforeCommandExecution(CommandExecutionEvent& ev);

View File

@ -535,7 +535,11 @@ bool MovingPixelsState::onUpdateStatusBar(Editor* editor)
StatusBar::instance()->setStatusText(
100,
fmt::format(
":pos: {} {} :size: {:3d} {:3d} :selsize: {} {} [{:.02f}% {:.02f}%] :angle: {:.1f} :aspect_ratio: {}:{}",
":pos: {} {}"
" :size: {} {}"
" :selsize: {} {} [{:.02f}% {:.02f}%]"
" :angle: {:.1f}"
" :aspect_ratio: {}:{}",
int(transform.bounds().x),
int(transform.bounds().y),
imageSize.w,

View File

@ -157,7 +157,9 @@ bool MovingSelectionState::onUpdateStatusBar(Editor* editor)
StatusBar::instance()->setStatusText(
100,
fmt::format(
":pos: {} {} :size: {:3d} {:3d} :offset: {} {}",
":pos: {} {}"
" :size: {} {}"
" :delta: {} {}",
bounds.x, bounds.y,
bounds.w, bounds.h,
m_delta.x, m_delta.y));

View File

@ -563,11 +563,27 @@ bool StandbyState::onUpdateStatusBar(Editor* editor)
editor->document()->mask(): NULL);
std::string buf = fmt::format(
":pos: {} {} :size: {} {}",
":pos: {} {}",
int(std::floor(spritePos.x)),
int(std::floor(spritePos.y)),
sprite->width(),
sprite->height());
int(std::floor(spritePos.y)));
Cel* cel = nullptr;
if (editor->showAutoCelGuides()) {
cel = editor->getSite().cel();
}
if (cel) {
buf += fmt::format(
" :start: {} {} :size: {} {}",
cel->bounds().x, cel->bounds().y,
cel->bounds().w, cel->bounds().h);
}
else {
buf += fmt::format(
" :size: {} {}",
sprite->width(),
sprite->height());
}
if (mask)
buf += fmt::format(" :selsize: {} {}",