Add EditorDecorator::getInvalidDecoratoredRegion() needed in #873

This commit is contained in:
David Capello 2015-12-07 15:25:10 -03:00
parent df6e97d98d
commit 562106c6f0
6 changed files with 31 additions and 0 deletions

View File

@ -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);

View File

@ -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

View File

@ -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();

View File

@ -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<Ruler> Rulers;

View File

@ -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).

View File

@ -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;