From 34cadef56515b995c0af65e27c14cf042885d5c6 Mon Sep 17 00:00:00 2001 From: rolandlo Date: Wed, 26 Apr 2023 22:22:27 +0200 Subject: [PATCH] Fix fill enabling for selections --- src/core/control/Control.cpp | 7 +------ src/core/control/ToolHandler.cpp | 11 ++++++++--- src/core/control/ToolHandler.h | 8 ++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/core/control/Control.cpp b/src/core/control/Control.cpp index 9016a264c16c..1030ffaabb72 100644 --- a/src/core/control/Control.cpp +++ b/src/core/control/Control.cpp @@ -3139,12 +3139,7 @@ void Control::setFill(bool fill) { undoRedo->addUndoAction(UndoActionPtr( sel->setFill(fill ? toolHandler->getPenFill() : -1, fill ? toolHandler->getHighlighterFill() : -1))); } - - if (toolHandler->getToolType() == TOOL_PEN) { - this->toolHandler->setPenFillEnabled(fill, true); - } else if (toolHandler->getToolType() == TOOL_HIGHLIGHTER) { - this->toolHandler->setHighlighterFillEnabled(fill, true); - } + toolHandler->setFillEnabled(fill, true); } void Control::setLineStyle(const string& style) { diff --git a/src/core/control/ToolHandler.cpp b/src/core/control/ToolHandler.cpp index ba5e8828c9e0..c1e82f0c7d26 100644 --- a/src/core/control/ToolHandler.cpp +++ b/src/core/control/ToolHandler.cpp @@ -347,9 +347,14 @@ auto ToolHandler::getColor() const -> Color { return tool->getColor(); } -/** - * @return -1 if fill is disabled, else the fill alpha value - */ +void ToolHandler::setFillEnabled(bool fill, bool fireEvent) { + Tool* tool = this->toolbarSelectedTool; + tool->setFill(fill); + if (fireEvent) { + this->stateChangeListener->toolFillChanged(); + } +} + auto ToolHandler::getFill() const -> int { Tool* tool = this->activeTool; if (!tool->getFill()) { diff --git a/src/core/control/ToolHandler.h b/src/core/control/ToolHandler.h index 152d503a6fd7..d5b8fecf654e 100644 --- a/src/core/control/ToolHandler.h +++ b/src/core/control/ToolHandler.h @@ -106,6 +106,14 @@ class ToolHandler { */ Color getColor() const; + /** + * @brief Enable/disable fill for the tool selected in the toolbar + * + * @param fill whether fill should be enabled + * @param fireEvent whether a toolFillChanged event should be fired + */ + void setFillEnabled(bool fill, bool fireEvent); + /** * @brief Get the Fill of the active tool *