Skip to content

Commit

Permalink
Fix fill enabling for selections
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Apr 27, 2023
1 parent 695eb5c commit 34cadef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/core/control/Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 8 additions & 3 deletions src/core/control/ToolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
8 changes: 8 additions & 0 deletions src/core/control/ToolHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 34cadef

Please sign in to comment.