From 562106c6f0263468d6a427a7b2a614145c61cb2b Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 7 Dec 2015 15:25:10 -0300 Subject: [PATCH] Add EditorDecorator::getInvalidDecoratoredRegion() needed in #873 --- src/app/ui/editor/editor.cpp | 10 ++++++++++ src/app/ui/editor/editor_decorator.h | 5 +++++ src/app/ui/editor/select_box_state.cpp | 5 +++++ src/app/ui/editor/select_box_state.h | 1 + src/app/ui/editor/standby_state.cpp | 9 +++++++++ src/app/ui/editor/standby_state.h | 1 + 6 files changed, 31 insertions(+) diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 1b10cb26f..2bfffed9e 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -362,10 +362,20 @@ void Editor::setEditorScroll(const gfx::Point& scroll, bool blitValidRegion) View* view = View::getView(this); Point oldScroll; Region region; + Region invalidRegion; if (blitValidRegion) { getDrawableRegion(region, kCutTopWindows); oldScroll = view->viewScroll(); + + // Remove decorated region that cannot be just moved because it + // must be redrawn in another position when the Editor's scroll + // changes (e.g. symmetry handles). + if ((m_flags & kShowDecorators) && m_decorator) { + m_decorator->getInvalidDecoratoredRegion(this, invalidRegion); + if (!invalidRegion.isEmpty()) + region.createSubtraction(region, invalidRegion); + } } view->setViewScroll(scroll); diff --git a/src/app/ui/editor/editor_decorator.h b/src/app/ui/editor/editor_decorator.h index a8b6b616d..20b17850b 100644 --- a/src/app/ui/editor/editor_decorator.h +++ b/src/app/ui/editor/editor_decorator.h @@ -12,6 +12,10 @@ #include "gfx/color.h" #include "gfx/rect.h" +namespace gfx { + class Region; +} + namespace doc { class Image; } @@ -49,6 +53,7 @@ namespace app { virtual ~EditorDecorator() { } virtual void preRenderDecorator(EditorPreRender* render) = 0; virtual void postRenderDecorator(EditorPostRender* render) = 0; + virtual void getInvalidDecoratoredRegion(Editor* editor, gfx::Region& region) = 0; }; } // namespace app diff --git a/src/app/ui/editor/select_box_state.cpp b/src/app/ui/editor/select_box_state.cpp index 025f0fa57..1f42c35eb 100644 --- a/src/app/ui/editor/select_box_state.cpp +++ b/src/app/ui/editor/select_box_state.cpp @@ -321,6 +321,11 @@ void SelectBoxState::postRenderDecorator(EditorPostRender* render) } } +void SelectBoxState::getInvalidDecoratoredRegion(Editor* editor, gfx::Region& region) +{ + // Do nothing +} + void SelectBoxState::updateContextBar() { ContextBar* contextBar = App::instance()->getMainWindow()->getContextBar(); diff --git a/src/app/ui/editor/select_box_state.h b/src/app/ui/editor/select_box_state.h index 15bb0f4f1..4355c5a6d 100644 --- a/src/app/ui/editor/select_box_state.h +++ b/src/app/ui/editor/select_box_state.h @@ -86,6 +86,7 @@ namespace app { // EditorDecorator overrides virtual void preRenderDecorator(EditorPreRender* render) override; virtual void postRenderDecorator(EditorPostRender* render) override; + virtual void getInvalidDecoratoredRegion(Editor* editor, gfx::Region& region) override; private: typedef std::vector Rulers; diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp index b7f322664..f3cf67146 100644 --- a/src/app/ui/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -671,6 +671,15 @@ void StandbyState::Decorator::postRenderDecorator(EditorPostRender* render) } } +void StandbyState::Decorator::getInvalidDecoratoredRegion(Editor* editor, gfx::Region& region) +{ + gfx::Rect box1, box2; + if (getSymmetryHandles(editor, box1, box2)) { + region.createUnion(region, gfx::Region(box1)); + region.createUnion(region, gfx::Region(box2)); + } +} + bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, gfx::Rect& box1, gfx::Rect& box2) { // Draw transformation handles (if the mask is visible and isn't frozen). diff --git a/src/app/ui/editor/standby_state.h b/src/app/ui/editor/standby_state.h index f95734245..edbfc9065 100644 --- a/src/app/ui/editor/standby_state.h +++ b/src/app/ui/editor/standby_state.h @@ -65,6 +65,7 @@ namespace app { // EditorDecorator overrides void preRenderDecorator(EditorPreRender* render) override; void postRenderDecorator(EditorPostRender* render) override; + void getInvalidDecoratoredRegion(Editor* editor, gfx::Region& region) override; private: TransformHandles* m_transfHandles;