diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp index 504560c52..6138694e4 100644 --- a/src/app/ui/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -1751,12 +1751,14 @@ void ContextBar::updateToolLoopModifiersIndicators(tools::ToolLoopModifiers modi void ContextBar::updateAutoSelectLayer(bool state) { - if (!m_autoSelectLayer->isVisible()) - return; - m_autoSelectLayer->setSelected(state); } +bool ContextBar::isAutoSelectLayer() const +{ + return m_autoSelectLayer->isSelected(); +} + void ContextBar::setActiveBrushBySlot(tools::Tool* tool, int slot) { ASSERT(tool); diff --git a/src/app/ui/context_bar.h b/src/app/ui/context_bar.h index 9d9d7aad8..a2432b109 100644 --- a/src/app/ui/context_bar.h +++ b/src/app/ui/context_bar.h @@ -53,6 +53,7 @@ namespace app { void updateForSelectingBox(const std::string& text); void updateToolLoopModifiersIndicators(app::tools::ToolLoopModifiers modifiers); void updateAutoSelectLayer(bool state); + bool isAutoSelectLayer() const; void setActiveBrush(const doc::BrushRef& brush); void setActiveBrushBySlot(tools::Tool* tool, int slot); diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 242fe0ab4..32cb905b6 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -162,7 +162,6 @@ Editor::Editor(Document* document, EditorFlags flags) , m_brushPreview(this) , m_lastDrawingPosition(-1, -1) , m_toolLoopModifiers(tools::ToolLoopModifiers::kNone) - , m_autoSelectLayer(false) , m_padding(0, 0) , m_antsTimer(100, this) , m_antsOffset(0) @@ -1029,6 +1028,11 @@ tools::Ink* Editor::getCurrentEditorInk() return App::instance()->activeToolManager()->activeInk(); } +bool Editor::isAutoSelectLayer() const +{ + return App::instance()->contextBar()->isAutoSelectLayer(); +} + gfx::Point Editor::screenToEditor(const gfx::Point& pt) { View* view = View::getView(this); @@ -1185,7 +1189,8 @@ void Editor::updateToolByTipProximity(ui::PointerType pointerType) void Editor::updateToolLoopModifiersIndicators() { int modifiers = int(tools::ToolLoopModifiers::kNone); - bool autoSelectLayer = Preferences::instance().editor.autoSelectLayer(); + const bool autoSelectLayer = isAutoSelectLayer(); + bool newAutoSelectLayer = autoSelectLayer; KeyAction action; if (m_customizationDelegate) { @@ -1197,7 +1202,6 @@ void Editor::updateToolLoopModifiersIndicators() (int(tools::ToolLoopModifiers::kReplaceSelection) | int(tools::ToolLoopModifiers::kAddSelection) | int(tools::ToolLoopModifiers::kSubtractSelection))); - autoSelectLayer = m_autoSelectLayer; // Shape tools (line, curves, rectangles, etc.) action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool); @@ -1226,7 +1230,9 @@ void Editor::updateToolLoopModifiersIndicators() // For move tool action = m_customizationDelegate->getPressedKeyAction(KeyContext::MoveTool); if (int(action & KeyAction::AutoSelectLayer)) - autoSelectLayer = true; + newAutoSelectLayer = true; + else + newAutoSelectLayer = Preferences::instance().editor.autoSelectLayer(); } } @@ -1243,10 +1249,8 @@ void Editor::updateToolLoopModifiersIndicators() } } - if (m_autoSelectLayer != autoSelectLayer) { - m_autoSelectLayer = autoSelectLayer; - ctxBar->updateAutoSelectLayer(autoSelectLayer); - } + if (autoSelectLayer != newAutoSelectLayer) + ctxBar->updateAutoSelectLayer(newAutoSelectLayer); } app::Color Editor::getColorByPosition(const gfx::Point& mousePos) diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h index e121bd019..60c31fe5b 100644 --- a/src/app/ui/editor/editor.h +++ b/src/app/ui/editor/editor.h @@ -181,7 +181,7 @@ namespace app { tools::Ink* getCurrentEditorInk(); tools::ToolLoopModifiers getToolLoopModifiers() const { return m_toolLoopModifiers; } - bool isAutoSelectLayer() const { return m_autoSelectLayer; } + bool isAutoSelectLayer() const; bool isSecondaryButton() const { return m_secondaryButton; } gfx::Point lastDrawingPosition() const { return m_lastDrawingPosition; } @@ -296,7 +296,6 @@ namespace app { gfx::Point m_lastDrawingPosition; tools::ToolLoopModifiers m_toolLoopModifiers; - bool m_autoSelectLayer; // Extra space around the sprite. gfx::Point m_padding;