diff --git a/src/tools/inks.h b/src/tools/inks.h index 6abfb2664..f84cdaa62 100644 --- a/src/tools/inks.h +++ b/src/tools/inks.h @@ -246,9 +246,9 @@ public: if (m_modify_selection) { Point offset = loop->getOffset(); - if (loop->getMouseButton() == 0) + if (loop->getMouseButton() == ToolLoop::Left) loop->getMask()->add(x1-offset.x, y-offset.y, x2-x1+1, 1); - else if (loop->getMouseButton() == 1) + else if (loop->getMouseButton() == ToolLoop::Right) mask_subtract(loop->getMask(), x1-offset.x, y-offset.y, x2-x1+1, 1); } else diff --git a/src/tools/tool_loop.h b/src/tools/tool_loop.h index 5ff477819..602e654f3 100644 --- a/src/tools/tool_loop.h +++ b/src/tools/tool_loop.h @@ -48,6 +48,8 @@ class Tool; class ToolLoop { public: + enum Button { Left = 0, Right = 1 }; + virtual ~ToolLoop() { } // Returns the context where we want to draw on (generally UIContext::instance() singleton) @@ -83,11 +85,11 @@ public: // Gets mask X,Y origin coordinates virtual gfx::Point getMaskOrigin() = 0; - // Return the mouse button which start the tool-loop (0 = left - // button, 1 = right button). It can be used by some tools that - // instead of using the primary/secondary color uses the pressed - // button for different behavior (like selection tools) - virtual int getMouseButton() = 0; + // Return the mouse button which start the tool-loop. It can be used + // by some tools that instead of using the primary/secondary color + // uses the pressed button for different behavior (like selection + // tools). + virtual Button getMouseButton() = 0; // Primary color to draw (e.g. foreground if the user start drawing // with the left button, or background color if he used the right diff --git a/src/tools/tool_loop_manager.cpp b/src/tools/tool_loop_manager.cpp index c70100be7..5d93b308f 100644 --- a/src/tools/tool_loop_manager.cpp +++ b/src/tools/tool_loop_manager.cpp @@ -73,8 +73,8 @@ void ToolLoopManager::releaseLoop(const Pointer& pointer) void ToolLoopManager::pressButton(const Pointer& pointer) { // If the user pressed the other mouse button... - if ((m_toolLoop->getMouseButton() == 0 && pointer.getButton() == Pointer::Right) || - (m_toolLoop->getMouseButton() == 1 && pointer.getButton() == Pointer::Left)) { + if ((m_toolLoop->getMouseButton() == ToolLoop::Left && pointer.getButton() == Pointer::Right) || + (m_toolLoop->getMouseButton() == ToolLoop::Right && pointer.getButton() == Pointer::Left)) { // Cancel the tool-loop (the destination image should be completelly discarded) m_toolLoop->cancel(); return; diff --git a/src/widgets/editor/tool_loop_impl.cpp b/src/widgets/editor/tool_loop_impl.cpp index 75b8dfab9..17efb0372 100644 --- a/src/widgets/editor/tool_loop_impl.cpp +++ b/src/widgets/editor/tool_loop_impl.cpp @@ -81,7 +81,7 @@ class ToolLoopImpl : public tools::ToolLoop gfx::Point m_offset; gfx::Point m_speed; bool m_canceled; - int m_button; + tools::ToolLoop::Button m_button; int m_primary_color; int m_secondary_color; @@ -92,7 +92,9 @@ public: Document* document, Sprite* sprite, Layer* layer, - int button, const Color& primary_color, const Color& secondary_color) + tools::ToolLoop::Button button, + const Color& primary_color, + const Color& secondary_color) : m_editor(editor) , m_context(context) , m_tool(tool) @@ -348,7 +350,7 @@ public: bool useMask() { return m_useMask; } Mask* getMask() { return m_mask; } gfx::Point getMaskOrigin() { return m_maskOrigin; } - int getMouseButton() { return m_button; } + ToolLoop::Button getMouseButton() { return m_button; } int getPrimaryColor() { return m_primary_color; } void setPrimaryColor(int color) { m_primary_color = color; } int getSecondaryColor() { return m_secondary_color; } @@ -449,7 +451,8 @@ tools::ToolLoop* create_tool_loop(Editor* editor, Context* context, Message* msg current_tool, editor->getDocument(), sprite, layer, - msg->mouse.left ? 0: 1, + msg->mouse.left ? tools::ToolLoop::Left: + tools::ToolLoop::Right, msg->mouse.left ? fg: bg, msg->mouse.left ? bg: fg); }