diff --git a/src/app/commands/cmd_new_brush.cpp b/src/app/commands/cmd_new_brush.cpp index 21c685f67..4f1811e5d 100644 --- a/src/app/commands/cmd_new_brush.cpp +++ b/src/app/commands/cmd_new_brush.cpp @@ -43,15 +43,15 @@ protected: void onExecute(Context* context) override; // SelectBoxDelegate impl - void onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) override; - void onQuickboxCancel() override; + void onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::MouseButtons buttons) override; + void onQuickboxCancel(Editor* editor) override; std::string onGetContextBarHelp() override { return "Select brush bounds | Right-click to cut"; } private: - void createBrush(const Mask* mask); + void createBrush(const Site& site, const Mask* mask); void selectPencilTool(); }; @@ -92,7 +92,8 @@ void NewBrushCommand::onExecute(Context* context) } // Create a brush from the active selection else { - createBrush(context->activeDocument()->mask()); + createBrush(context->activeSite(), + context->activeDocument()->mask()); selectPencilTool(); // Deselect mask @@ -102,11 +103,11 @@ void NewBrushCommand::onExecute(Context* context) } } -void NewBrushCommand::onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) +void NewBrushCommand::onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::MouseButtons buttons) { Mask mask; mask.replace(rect); - createBrush(&mask); + createBrush(editor->getSite(), &mask); selectPencilTool(); // If the right-button was used, we clear the selected area. @@ -128,18 +129,17 @@ void NewBrushCommand::onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons butt App::instance()->getMainWindow()->getContextBar() ->updateForCurrentTool(); - current_editor->backToPreviousState(); + editor->backToPreviousState(); } -void NewBrushCommand::onQuickboxCancel() +void NewBrushCommand::onQuickboxCancel(Editor* editor) { - current_editor->backToPreviousState(); + editor->backToPreviousState(); } -void NewBrushCommand::createBrush(const Mask* mask) +void NewBrushCommand::createBrush(const Site& site, const Mask* mask) { - doc::ImageRef image(new_image_from_mask( - UIContext::instance()->activeSite(), mask)); + doc::ImageRef image(new_image_from_mask(site, mask)); if (!image) return; diff --git a/src/app/ui/editor/select_box_state.cpp b/src/app/ui/editor/select_box_state.cpp index 96ad8486f..286568306 100644 --- a/src/app/ui/editor/select_box_state.cpp +++ b/src/app/ui/editor/select_box_state.cpp @@ -110,9 +110,9 @@ bool SelectBoxState::onMouseUp(Editor* editor, MouseMessage* msg) if (m_delegate) { if (m_selectingButtons == msg->buttons()) - m_delegate->onQuickboxEnd(getBoxBounds(), msg->buttons()); + m_delegate->onQuickboxEnd(editor, getBoxBounds(), msg->buttons()); else - m_delegate->onQuickboxCancel(); + m_delegate->onQuickboxCancel(editor); } } diff --git a/src/app/ui/editor/select_box_state.h b/src/app/ui/editor/select_box_state.h index a7a27f39b..c632dd4eb 100644 --- a/src/app/ui/editor/select_box_state.h +++ b/src/app/ui/editor/select_box_state.h @@ -29,8 +29,8 @@ namespace app { // Called only in QUICKBOX mode, when the user released the mouse // button. - virtual void onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) { } - virtual void onQuickboxCancel() { } + virtual void onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::MouseButtons buttons) { } + virtual void onQuickboxCancel(Editor* editor) { } // Help text to be shown in the ContextBar virtual std::string onGetContextBarHelp() { return ""; }