Base color selection behaviour on capabilities

master
idotobi 6 years ago
parent df6f4bb62a
commit 8faa96a062
  1. 10
      src/control/ToolHandler.cpp
  2. 2
      src/control/ToolHandler.h
  3. 6
      src/gui/toolbarMenubar/ColorToolItem.cpp

@ -161,7 +161,13 @@ auto ToolHandler::getTool(ToolType type) -> Tool& { return *(this->tools[type -
auto ToolHandler::getToolType() -> ToolType { return this->currentTool->type; }
auto ToolHandler::hasCapability(ToolCapabilities cap) -> bool { return (currentTool->capabilities & cap) != 0; }
auto ToolHandler::hasCapability(ToolCapabilities cap, bool mainTool) -> bool {
if (mainTool == false) {
return (currentTool->capabilities & cap) != 0;
} else {
return (toolbarSelectedTool->capabilities & cap) != 0;
}
}
auto ToolHandler::getSize() -> ToolSize { return this->currentTool->getSize(); }
@ -261,7 +267,7 @@ void ToolHandler::setLineStyle(const LineStyle& style) {
* and therefore should not be applied to a selection
*/
void ToolHandler::setColor(Color color, bool userSelection) {
if (this->buttonSelectedTool->type == TOOL_ERASER) {
if ((this->buttonSelectedTool->capabilities & TOOL_CAP_COLOR) == 0) {
this->toolbarSelectedTool->setColor(color);
}
this->currentTool->setColor(color);

@ -98,7 +98,7 @@ public:
EraserType getEraserType();
void eraserTypeChanged();
bool hasCapability(ToolCapabilities cap);
bool hasCapability(ToolCapabilities cap, bool mainTool = false);
void saveSettings();
void loadSettings();

@ -2,6 +2,7 @@
#include <config.h>
#include "control/ToolEnums.h"
#include "gui/toolbarMenubar/icon/ColorSelectImage.h"
#include "model/ToolbarColorNames.h"
@ -105,9 +106,10 @@ void ColorToolItem::showColorchooser() {
* Enable / Disable the tool item
*/
void ColorToolItem::enable(bool enabled) {
if (!enabled && toolHandler->getToolType() == TOOL_ERASER) {
if (!enabled && !toolHandler->hasCapability(TOOL_CAP_COLOR) && toolHandler->hasCapability(TOOL_CAP_COLOR, true)) {
if (this->icon && toolHandler->triggeredByButton) {
// allow changes in color if eraser only set via stylus
// allow changes if currentTool has no colour capability
// and mainTool has Colour capability
icon->setState(COLOR_ICON_STATE_PEN);
AbstractToolItem::enable(true);
} else {

Loading…
Cancel
Save