From b427969b26d3652c4f73ecad0786f816acaa5d94 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 9 Jan 2019 15:04:25 -0300 Subject: [PATCH] Now we can press Shift+Alt in any order to use subtract mode in selection tools Fixes #1972, related to #1626 --- src/app/ui/context_bar.cpp | 3 --- src/app/ui/editor/editor.cpp | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp index 0126bc086..f3dcbc491 100644 --- a/src/app/ui/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -1472,9 +1472,6 @@ void ContextBar::updateForSelectingBox(const std::string& text) void ContextBar::updateToolLoopModifiersIndicators(tools::ToolLoopModifiers modifiers) { - if (!m_selectionMode->isVisible()) - return; - gen::SelectionMode mode = gen::SelectionMode::DEFAULT; if (int(modifiers) & int(tools::ToolLoopModifiers::kAddSelection)) mode = gen::SelectionMode::ADD; diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index f127eea62..29c657274 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -1448,14 +1448,17 @@ void Editor::updateStatusBar() void Editor::updateQuicktool() { if (m_customizationDelegate && !hasCapture()) { - auto activeToolManager = App::instance()->activeToolManager(); - tools::Tool* selectedTool = activeToolManager->selectedTool(); + auto atm = App::instance()->activeToolManager(); + tools::Tool* selectedTool = atm->selectedTool(); // Don't change quicktools if we are in a selection tool and using // the selection modifiers. if (selectedTool->getInk(0)->isSelection() && - int(m_customizationDelegate->getPressedKeyAction(KeyContext::SelectionTool)) != 0) + int(m_customizationDelegate->getPressedKeyAction(KeyContext::SelectionTool)) != 0) { + if (atm->quickTool()) + atm->newQuickToolSelectedFromEditor(nullptr); return; + } tools::Tool* newQuicktool = m_customizationDelegate->getQuickTool(selectedTool); @@ -1464,8 +1467,7 @@ void Editor::updateQuicktool() if (newQuicktool && !m_state->acceptQuickTool(newQuicktool)) return; - activeToolManager - ->newQuickToolSelectedFromEditor(newQuicktool); + atm->newQuickToolSelectedFromEditor(newQuicktool); } } @@ -1489,6 +1491,8 @@ void Editor::updateToolLoopModifiersIndicators() KeyAction action; if (m_customizationDelegate) { + auto atm = App::instance()->activeToolManager(); + // When the mouse is captured, is when we are scrolling, or // drawing, or moving, or selecting, etc. So several // parameters/tool-loop-modifiers are static. @@ -1500,8 +1504,8 @@ void Editor::updateToolLoopModifiersIndicators() int(tools::ToolLoopModifiers::kIntersectSelection))); tools::Controller* controller = - (App::instance()->activeToolManager()->selectedTool() ? - App::instance()->activeToolManager()->selectedTool()->getController(0): nullptr); + (atm->selectedTool() ? + atm->selectedTool()->getController(0): nullptr); // Shape tools modifiers (line, curves, rectangles, etc.) if (controller && controller->isTwoPoints()) { @@ -1532,8 +1536,8 @@ void Editor::updateToolLoopModifiersIndicators() // Don't use "subtract" mode if the selection was activated // with the "right click mode = a selection-like tool" (m_secondaryButton && - App::instance()->activeToolManager()->selectedTool() && - App::instance()->activeToolManager()->selectedTool()->getInk(0)->isSelection())) { + atm->selectedTool() && + atm->selectedTool()->getInk(0)->isSelection())) { mode = gen::SelectionMode::SUBTRACT; } else if (int(action & KeyAction::IntersectSelection)) {