mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-27 11:37:39 +00:00
Fix status bar position depending on the tiled mode
This commit is contained in:
parent
392312d687
commit
29c2c0cd90
@ -46,7 +46,7 @@ namespace app {
|
||||
|
||||
// The input and output strokes are relative to sprite coordinates.
|
||||
virtual void getStrokeToInterwine(const Stroke& input, Stroke& output) = 0;
|
||||
virtual void getStatusBarText(const Stroke& stroke, std::string& text) = 0;
|
||||
virtual void getStatusBarText(ToolLoop* loop, const Stroke& stroke, std::string& text) = 0;
|
||||
|
||||
// Last point used by this controller, useful to save the last
|
||||
// point of a freehand tool.
|
||||
|
@ -78,17 +78,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void getStatusBarText(const Stroke& stroke, std::string& text) override {
|
||||
void getStatusBarText(ToolLoop* loop, const Stroke& stroke, std::string& text) override {
|
||||
ASSERT(!stroke.empty());
|
||||
if (stroke.empty())
|
||||
return;
|
||||
|
||||
gfx::Point offset = loop->statusBarPositionOffset();
|
||||
char buf[1024];
|
||||
sprintf(buf, ":start: %3d %3d :end: %3d %3d",
|
||||
stroke.firstPoint().x,
|
||||
stroke.firstPoint().y,
|
||||
stroke.lastPoint().x,
|
||||
stroke.lastPoint().y);
|
||||
stroke.firstPoint().x+offset.x,
|
||||
stroke.firstPoint().y+offset.y,
|
||||
stroke.lastPoint().x+offset.x,
|
||||
stroke.lastPoint().y+offset.y);
|
||||
text = buf;
|
||||
}
|
||||
|
||||
@ -204,7 +205,7 @@ public:
|
||||
output.addPoint(input[1]);
|
||||
}
|
||||
|
||||
void getStatusBarText(const Stroke& stroke, std::string& text) override {
|
||||
void getStatusBarText(ToolLoop* loop, const Stroke& stroke, std::string& text) override {
|
||||
ASSERT(stroke.size() >= 2);
|
||||
if (stroke.size() < 2)
|
||||
return;
|
||||
@ -212,10 +213,11 @@ public:
|
||||
int w = ABS(stroke[1].x-stroke[0].x)+1;
|
||||
int h = ABS(stroke[1].y-stroke[0].y)+1;
|
||||
|
||||
gfx::Point offset = loop->statusBarPositionOffset();
|
||||
char buf[1024];
|
||||
sprintf(buf, ":start: %3d %3d :end: %3d %3d :size: %3d %3d :distance: %.1f :angle: %.1f",
|
||||
stroke[0].x, stroke[0].y,
|
||||
stroke[1].x, stroke[1].y,
|
||||
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),
|
||||
180.0 * std::atan2(static_cast<double>(stroke[0].y-stroke[1].y),
|
||||
@ -269,17 +271,18 @@ public:
|
||||
output = input;
|
||||
}
|
||||
|
||||
void getStatusBarText(const Stroke& stroke, std::string& text) override {
|
||||
void getStatusBarText(ToolLoop* loop, const Stroke& stroke, std::string& text) override {
|
||||
ASSERT(!stroke.empty());
|
||||
if (stroke.empty())
|
||||
return;
|
||||
|
||||
gfx::Point offset = loop->statusBarPositionOffset();
|
||||
char buf[1024];
|
||||
sprintf(buf, ":start: %3d %3d :end: %3d %3d",
|
||||
stroke.firstPoint().x,
|
||||
stroke.firstPoint().y,
|
||||
stroke.lastPoint().x,
|
||||
stroke.lastPoint().y);
|
||||
stroke.firstPoint().x+offset.x,
|
||||
stroke.firstPoint().y+offset.y,
|
||||
stroke.lastPoint().x+offset.x,
|
||||
stroke.lastPoint().y+offset.y);
|
||||
text = buf;
|
||||
}
|
||||
|
||||
@ -308,13 +311,16 @@ public:
|
||||
output = input;
|
||||
}
|
||||
|
||||
void getStatusBarText(const Stroke& stroke, std::string& text) override {
|
||||
void getStatusBarText(ToolLoop* loop, const Stroke& stroke, std::string& text) override {
|
||||
ASSERT(!stroke.empty());
|
||||
if (stroke.empty())
|
||||
return;
|
||||
|
||||
gfx::Point offset = loop->statusBarPositionOffset();
|
||||
char buf[1024];
|
||||
sprintf(buf, ":pos: %3d %3d", stroke[0].x, stroke[0].y);
|
||||
sprintf(buf, ":pos: %3d %3d",
|
||||
stroke[0].x+offset.x,
|
||||
stroke[0].y+offset.y);
|
||||
text = buf;
|
||||
}
|
||||
|
||||
@ -363,17 +369,18 @@ public:
|
||||
output = input;
|
||||
}
|
||||
|
||||
void getStatusBarText(const Stroke& stroke, std::string& text) override {
|
||||
void getStatusBarText(ToolLoop* loop, const Stroke& stroke, std::string& text) override {
|
||||
ASSERT(stroke.size() >= 4);
|
||||
if (stroke.size() < 4)
|
||||
return;
|
||||
|
||||
gfx::Point offset = loop->statusBarPositionOffset();
|
||||
char buf[1024];
|
||||
sprintf(buf, ":start: %3d %3d :end: %3d %3d (%3d %3d - %3d %3d)",
|
||||
stroke[0].x, stroke[0].y,
|
||||
stroke[3].x, stroke[3].y,
|
||||
stroke[1].x, stroke[1].y,
|
||||
stroke[2].x, stroke[2].y);
|
||||
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,
|
||||
stroke[2].x+offset.x, stroke[2].y+offset.y);
|
||||
|
||||
text = buf;
|
||||
}
|
||||
@ -422,8 +429,8 @@ public:
|
||||
m_controller->getStrokeToInterwine(input, output);
|
||||
}
|
||||
|
||||
void getStatusBarText(const Stroke& stroke, std::string& text) override {
|
||||
m_controller->getStatusBarText(stroke, text);
|
||||
void getStatusBarText(ToolLoop* loop, const Stroke& stroke, std::string& text) override {
|
||||
m_controller->getStatusBarText(loop, stroke, text);
|
||||
}
|
||||
|
||||
bool handleTracePolicy() const override {
|
||||
|
@ -228,6 +228,7 @@ namespace app {
|
||||
virtual void updateDirtyArea() = 0;
|
||||
|
||||
virtual void updateStatusBar(const char* text) = 0;
|
||||
virtual gfx::Point statusBarPositionOffset() = 0;
|
||||
|
||||
// For gradients
|
||||
virtual render::DitheringMatrix getDitheringMatrix() = 0;
|
||||
|
@ -93,7 +93,7 @@ void ToolLoopManager::pressButton(const Pointer& pointer)
|
||||
m_toolLoop->getController()->pressButton(m_stroke, spritePoint);
|
||||
|
||||
std::string statusText;
|
||||
m_toolLoop->getController()->getStatusBarText(m_stroke, statusText);
|
||||
m_toolLoop->getController()->getStatusBarText(m_toolLoop, m_stroke, statusText);
|
||||
m_toolLoop->updateStatusBar(statusText.c_str());
|
||||
|
||||
doLoopStep(false);
|
||||
@ -139,7 +139,7 @@ void ToolLoopManager::movement(const Pointer& pointer)
|
||||
m_toolLoop->getController()->movement(m_toolLoop, m_stroke, spritePoint);
|
||||
|
||||
std::string statusText;
|
||||
m_toolLoop->getController()->getStatusBarText(m_stroke, statusText);
|
||||
m_toolLoop->getController()->getStatusBarText(m_toolLoop, m_stroke, statusText);
|
||||
m_toolLoop->updateStatusBar(statusText.c_str());
|
||||
|
||||
doLoopStep(false);
|
||||
|
@ -282,12 +282,14 @@ bool MovingCelState::onKeyDown(Editor* editor, KeyMessage* msg)
|
||||
|
||||
bool MovingCelState::onUpdateStatusBar(Editor* editor)
|
||||
{
|
||||
gfx::PointF pos = m_cursorStart - gfx::PointF(editor->mainTilePosition());
|
||||
|
||||
if (m_hasReference) {
|
||||
if (m_scaled && m_cel) {
|
||||
StatusBar::instance()->setStatusText
|
||||
(0,
|
||||
":pos: %.2f %.2f :offset: %.2f %.2f :size: %.2f%% %.2f%%",
|
||||
m_cursorStart.x, m_cursorStart.y,
|
||||
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());
|
||||
@ -296,7 +298,7 @@ bool MovingCelState::onUpdateStatusBar(Editor* editor)
|
||||
StatusBar::instance()->setStatusText
|
||||
(0,
|
||||
":pos: %.2f %.2f :offset: %.2f %.2f",
|
||||
m_cursorStart.x, m_cursorStart.y,
|
||||
pos.x, pos.y,
|
||||
m_celOffset.x, m_celOffset.y);
|
||||
}
|
||||
}
|
||||
@ -305,7 +307,7 @@ bool MovingCelState::onUpdateStatusBar(Editor* editor)
|
||||
StatusBar::instance()->setStatusText
|
||||
(0,
|
||||
":pos: %3d %3d :offset: %3d %3d",
|
||||
int(m_cursorStart.x), int(m_cursorStart.y),
|
||||
int(pos.x), int(pos.y),
|
||||
intOffset.x, intOffset.y);
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,9 @@ bool StandbyState::onUpdateStatusBar(Editor* editor)
|
||||
{
|
||||
tools::Ink* ink = editor->getCurrentEditorInk();
|
||||
const Sprite* sprite = editor->sprite();
|
||||
gfx::PointF spritePos = editor->screenToEditorF(ui::get_mouse_position());
|
||||
gfx::PointF spritePos =
|
||||
editor->screenToEditorF(ui::get_mouse_position())
|
||||
- gfx::PointF(editor->mainTilePosition());
|
||||
|
||||
if (!sprite) {
|
||||
StatusBar::instance()->clearText();
|
||||
|
@ -279,6 +279,10 @@ public:
|
||||
StatusBar::instance()->setStatusText(0, text);
|
||||
}
|
||||
|
||||
gfx::Point statusBarPositionOffset() override {
|
||||
return -m_editor->mainTilePosition();
|
||||
}
|
||||
|
||||
render::DitheringMatrix getDitheringMatrix() override {
|
||||
return App::instance()->contextBar()->ditheringMatrix();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user