diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 17193a8f6..2874e8f42 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -99,17 +99,14 @@ class EditorPostRenderImpl : public EditorPostRender { public: EditorPostRenderImpl(Editor* editor, Graphics* g) : m_editor(editor) - , m_g(g) - { + , m_g(g) { } - Editor* getEditor() - { + Editor* getEditor() { return m_editor; } - void drawLine(int x1, int y1, int x2, int y2, gfx::Color screenColor) - { + void drawLine(int x1, int y1, int x2, int y2, gfx::Color screenColor) override { gfx::Point a(x1, y1); gfx::Point b(x2, y2); a = m_editor->editorToScreen(a); @@ -122,6 +119,17 @@ public: m_g->drawLine(screenColor, a, b); } + void drawRectXor(const gfx::Rect& rc) override { + gfx::Rect rc2 = m_editor->editorToScreen(rc); + gfx::Rect bounds = m_editor->getBounds(); + rc2.x -= bounds.x; + rc2.y -= bounds.y; + + m_g->setDrawMode(Graphics::DrawMode::Xor); + m_g->drawRect(gfx::rgba(255, 255, 255), rc2); + m_g->setDrawMode(Graphics::DrawMode::Solid); + } + private: Editor* m_editor; Graphics* m_g; diff --git a/src/app/ui/editor/editor_decorator.h b/src/app/ui/editor/editor_decorator.h index 906d7a035..a8b6b616d 100644 --- a/src/app/ui/editor/editor_decorator.h +++ b/src/app/ui/editor/editor_decorator.h @@ -38,6 +38,7 @@ namespace app { virtual ~EditorPostRender() { } virtual Editor* getEditor() = 0; virtual void drawLine(int x1, int y1, int x2, int y2, gfx::Color screenColor) = 0; + virtual void drawRectXor(const gfx::Rect& rc) = 0; }; // Used by editor's states to pre- and post-render customized diff --git a/src/app/ui/editor/select_box_state.cpp b/src/app/ui/editor/select_box_state.cpp index afc896b54..4eb931782 100644 --- a/src/app/ui/editor/select_box_state.cpp +++ b/src/app/ui/editor/select_box_state.cpp @@ -263,6 +263,10 @@ void SelectBoxState::postRenderDecorator(EditorPostRender* render) } } } + + if (hasFlag(QUICKBOX)) { + render->drawRectXor(getBoxBounds()); + } } bool SelectBoxState::touchRuler(Editor* editor, Ruler& ruler, int x, int y) diff --git a/src/she/alleg4/surface.h b/src/she/alleg4/surface.h index a3898cf32..e1b9c7fd4 100644 --- a/src/she/alleg4/surface.h +++ b/src/she/alleg4/surface.h @@ -161,6 +161,7 @@ namespace she { void setDrawMode(DrawMode mode, int param) { switch (mode) { case DrawMode::Solid: checked_mode(-1); break; + case DrawMode::Xor: xor_mode(TRUE); break; case DrawMode::Checked: checked_mode(param); break; } } diff --git a/src/she/surface.h b/src/she/surface.h index 9e7a2340c..f70ee09b5 100644 --- a/src/she/surface.h +++ b/src/she/surface.h @@ -1,5 +1,5 @@ // SHE library -// Copyright (C) 2012-2013 David Capello +// Copyright (C) 2012-2013, 2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -16,7 +16,8 @@ namespace she { enum class DrawMode { Solid, - Checked + Checked, + Xor }; class Surface { diff --git a/src/ui/graphics.cpp b/src/ui/graphics.cpp index 475679fb4..674125aba 100644 --- a/src/ui/graphics.cpp +++ b/src/ui/graphics.cpp @@ -67,6 +67,9 @@ void Graphics::setDrawMode(DrawMode mode, int param) case DrawMode::Solid: m_surface->setDrawMode(she::DrawMode::Solid); break; + case DrawMode::Xor: + m_surface->setDrawMode(she::DrawMode::Xor); + break; case DrawMode::Checked: m_surface->setDrawMode(she::DrawMode::Checked, param); break; diff --git a/src/ui/graphics.h b/src/ui/graphics.h index 47013fba0..f7e38e26d 100644 --- a/src/ui/graphics.h +++ b/src/ui/graphics.h @@ -33,6 +33,7 @@ namespace ui { public: enum class DrawMode { Solid, + Xor, Checked, };