mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-05 21:57:20 +00:00
Add xor-ed bounding box in SelectBoxState when QUICKBOX style is enabled
This is useful when we want to select a brush in a black image (the DARKOUTSIDE style is not useful in this case).
This commit is contained in:
parent
96769d061e
commit
955383f91a
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -33,6 +33,7 @@ namespace ui {
|
||||
public:
|
||||
enum class DrawMode {
|
||||
Solid,
|
||||
Xor,
|
||||
Checked,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user