diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 6a3d19206..ef78be78e 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -93,6 +93,10 @@ public: return m_editor; } + Graphics* getGraphics() override { + return m_g; + } + void drawLine(gfx::Color color, int x1, int y1, int x2, int y2) override { gfx::Point a(x1, y1); gfx::Point b(x2, y2); diff --git a/src/app/ui/editor/editor_decorator.h b/src/app/ui/editor/editor_decorator.h index 8645db175..352bd6a52 100644 --- a/src/app/ui/editor/editor_decorator.h +++ b/src/app/ui/editor/editor_decorator.h @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -36,6 +37,7 @@ namespace app { public: virtual ~EditorPostRender() { } virtual Editor* getEditor() = 0; + virtual ui::Graphics* getGraphics() = 0; virtual void drawLine(gfx::Color color, int x1, int y1, int x2, int y2) = 0; virtual void drawRectXor(const gfx::Rect& rc) = 0; virtual void fillRect(gfx::Color color, const gfx::Rect& rc) = 0; diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp index dc442ddc3..4b7431964 100644 --- a/src/app/ui/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -990,8 +990,9 @@ void StandbyState::Decorator::postRenderDecorator(EditorPostRender* render) tools::Ink* ink = editor->getCurrentEditorInk(); if (ink->isSelection()) { - getTransformHandles(editor)->drawHandles(editor, - m_standbyState->getTransformation(editor)); + getTransformHandles(editor) + ->drawHandles(editor, render->getGraphics(), + m_standbyState->getTransformation(editor)); m_standbyState->m_transformSelectionHandlesAreVisible = true; } diff --git a/src/app/ui/editor/transform_handles.cpp b/src/app/ui/editor/transform_handles.cpp index 9ba8fc15b..5d73cdad9 100644 --- a/src/app/ui/editor/transform_handles.cpp +++ b/src/app/ui/editor/transform_handles.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -84,9 +85,9 @@ HandleType TransformHandles::getHandleAtPoint(Editor* editor, const gfx::Point& return NoHandle; } -void TransformHandles::drawHandles(Editor* editor, const Transformation& transform) +void TransformHandles::drawHandles(Editor* editor, ui::Graphics* g, + const Transformation& transform) { - ScreenGraphics g; fixmath::fixed angle = fixmath::ftofix(128.0 * transform.angle() / PI); Transformation::Corners corners; @@ -95,29 +96,31 @@ void TransformHandles::drawHandles(Editor* editor, const Transformation& transfo std::vector screenPoints; getScreenPoints(editor, corners, screenPoints); - // TODO DO NOT COMMIT + const gfx::Point origin = editor->bounds().origin(); + #if 0 // Uncomment this if you want to see the bounds in red (only for debugging purposes) // ----------------------------------------------- { gfx::Point a(transform.bounds().origin()), b(transform.bounds().point2()); - a = editor->editorToScreen(a); - b = editor->editorToScreen(b); - g.drawRect(gfx::rgba(255, 0, 0), gfx::Rect(a, b)); + a = editor->editorToScreen(a) - origin; + b = editor->editorToScreen(b) - origin; + g->drawRect(gfx::rgba(255, 0, 0), gfx::Rect(a, b)); a = transform.pivot(); - a = editor->editorToScreen(a); - g.drawRect(gfx::rgba(255, 0, 0), gfx::Rect(a.x-2, a.y-2, 5, 5)); + a = editor->editorToScreen(a) - origin; + g->drawRect(gfx::rgba(255, 0, 0), gfx::Rect(a.x-2, a.y-2, 5, 5)); } // ----------------------------------------------- #endif // Draw corner handle for (size_t c=0; cparts.pivotHandle()->bitmap(0); - g.drawRgbaSurface(part, pivotBounds.x, pivotBounds.y); + g->drawRgbaSurface(part, + pivotBounds.x - origin.x, + pivotBounds.y - origin.y); } } diff --git a/src/app/ui/editor/transform_handles.h b/src/app/ui/editor/transform_handles.h index 39336d291..bc65064d0 100644 --- a/src/app/ui/editor/transform_handles.h +++ b/src/app/ui/editor/transform_handles.h @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -30,7 +31,8 @@ namespace app { // has applied the given transformation to the selection. HandleType getHandleAtPoint(Editor* editor, const gfx::Point& pt, const Transformation& transform); - void drawHandles(Editor* editor, const Transformation& transform); + void drawHandles(Editor* editor, ui::Graphics* g, + const Transformation& transform); void invalidateHandles(Editor* editor, const Transformation& transform); private: