Merge pull request #562 from andreasb242/unexpected-color-change

Should fix unexpected color change
presentation
andreasb242 7 years ago committed by GitHub
commit e7ed312a0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .settings/language.settings.xml
  2. 14
      src/control/Control.cpp
  3. 13
      src/control/Control.h
  4. 17
      src/control/ToolHandler.cpp
  5. 13
      src/control/ToolHandler.h
  6. 40
      src/control/settings/ButtonConfig.cpp
  7. 8
      src/gui/toolbarMenubar/ColorToolItem.cpp

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.autotools.core.LibtoolGCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="587125454581862298" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="587297783307056298" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

@ -1687,7 +1687,7 @@ void Control::toolChanged()
// Update color
if (toolHandler->isEnableColor())
{
toolColorChanged();
toolColorChanged(false);
}
ActionType rulerAction = ACTION_NOT_SELECTED;
@ -1833,14 +1833,22 @@ void Control::toolSizeChanged()
}
}
void Control::toolColorChanged()
/**
* Select the color for the tool
*
* @param userSelection
* true if the user selected the color
* false if the color is selected by a tool change
* and therefore should not be applied to a selection
*/
void Control::toolColorChanged(bool userSelection)
{
XOJ_CHECK_TYPE(Control);
fireActionSelected(GROUP_COLOR, ACTION_SELECT_COLOR);
getCursor()->updateCursor();
if (this->win && toolHandler->getColor() != -1)
if (userSelection && this->win && toolHandler->getColor() != -1)
{
EditSelection* sel = this->win->getXournal()->getSelection();
if (sel)

@ -49,7 +49,8 @@ class PageTypeHandler;
class PageTypeMenu;
class BaseExportJob;
class Control : public ActionHandler,
class Control :
public ActionHandler,
public ToolListener,
public DocumentHandler,
public RecentManagerListener,
@ -90,7 +91,15 @@ public:
virtual void actionPerformed(ActionType type, ActionGroup group, GdkEvent* event, GtkMenuItem* menuitem,
GtkToolButton* toolbutton, bool enabled);
virtual void toolColorChanged();
/**
* Select the color for the tool
*
* @param userSelection
* true if the user selected the color
* false if the color is selected by a tool change
* and therefore should not be applied to a selection
*/
virtual void toolColorChanged(bool userSelection);
virtual void setCustomColorSelected();
virtual void toolChanged();
virtual void toolSizeChanged();

@ -339,14 +339,23 @@ void ToolHandler::setSize(ToolSize size)
this->listener->toolSizeChanged();
}
void ToolHandler::setColor(int color)
/**
* Select the color for the tool
*
* @param color Color
* @param userSelection
* true if the user selected the color
* false if the color is selected by a tool change
* and therefore should not be applied to a selection
*/
void ToolHandler::setColor(int color, bool userSelection)
{
XOJ_CHECK_TYPE(ToolHandler);
this->colorFound = false;
this->current->color = color;
this->listener->toolColorChanged();
this->listener->toolColorChanged(userSelection);
if (!colorFound)
{
@ -544,7 +553,7 @@ void ToolHandler::restoreLastConfig()
delete this->lastSelectedTool;
this->lastSelectedTool = NULL;
this->listener->toolColorChanged();
this->listener->toolColorChanged(false);
this->listener->toolSizeChanged();
this->fireToolChanged();
}
@ -574,7 +583,7 @@ void ToolHandler::setSelectionEditTools(bool setColor, bool setSize)
this->current->type == TOOL_SELECT_OBJECT ||
this->current->type == TOOL_PLAY_OBJECT)
{
this->listener->toolColorChanged();
this->listener->toolColorChanged(false);
this->listener->toolSizeChanged();
this->fireToolChanged();
}

@ -22,7 +22,7 @@ class LastSelectedTool;
class ToolListener
{
public:
virtual void toolColorChanged() = 0;
virtual void toolColorChanged(bool userSelection) = 0;
virtual void setCustomColorSelected() = 0;
virtual void toolSizeChanged() = 0;
virtual void toolChanged() = 0;
@ -38,7 +38,16 @@ public:
ToolHandler(ToolListener* listener, ActionHandler* actionHandler, Settings* settings);
virtual ~ToolHandler();
void setColor(int color);
/**
* Select the color for the tool
*
* @param color Color
* @param userSelection
* true if the user selected the color
* false if the color is selected by a tool change
* and therefore should not be applied to a selection
*/
void setColor(int color, bool userSelection);
int getColor();
DrawingType getDrawingType();

@ -44,34 +44,36 @@ void ButtonConfig::acceptActions(ToolHandler* toolHandler)
{
XOJ_CHECK_TYPE(ButtonConfig);
if (this->action != TOOL_NONE)
if (this->action == TOOL_NONE)
{
toolHandler->selectTool(this->action, false);
if (this->action == TOOL_PEN || this->action == TOOL_HILIGHTER)
{
return;
}
if (this->drawingType != DRAWING_TYPE_DONT_CHANGE)
{
toolHandler->setDrawingType(this->drawingType);
}
toolHandler->selectTool(this->action, false);
if (this->size != TOOL_SIZE_NONE)
{
toolHandler->setSize(this->size);
}
}
if (this->action == TOOL_PEN || this->action == TOOL_HILIGHTER)
{
if (this->action == TOOL_PEN || this->action == TOOL_HILIGHTER || this->action == TOOL_TEXT)
if (this->drawingType != DRAWING_TYPE_DONT_CHANGE)
{
toolHandler->setColor(this->color);
toolHandler->setDrawingType(this->drawingType);
}
if (this->action == TOOL_ERASER && this->eraserMode != ERASER_TYPE_NONE)
if (this->size != TOOL_SIZE_NONE)
{
toolHandler->setEraserType(this->eraserMode);
toolHandler->setSize(this->size);
}
}
toolHandler->fireToolChanged();
if (this->action == TOOL_PEN || this->action == TOOL_HILIGHTER || this->action == TOOL_TEXT)
{
toolHandler->setColor(this->color, false);
}
if (this->action == TOOL_ERASER && this->eraserMode != ERASER_TYPE_NONE)
{
toolHandler->setEraserType(this->eraserMode);
}
toolHandler->fireToolChanged();
}

@ -10,8 +10,8 @@
bool ColorToolItem::inUpdate = false;
ColorToolItem::ColorToolItem(ActionHandler* handler, ToolHandler* toolHandler, GtkWindow* parent, int color, bool selektor) :
AbstractToolItem("", handler, selektor ? ACTION_SELECT_COLOR_CUSTOM : ACTION_SELECT_COLOR)
ColorToolItem::ColorToolItem(ActionHandler* handler, ToolHandler* toolHandler, GtkWindow* parent, int color, bool selektor)
: AbstractToolItem("", handler, selektor ? ACTION_SELECT_COLOR_CUSTOM : ACTION_SELECT_COLOR)
{
XOJ_INIT_TYPE(ColorToolItem);
@ -97,7 +97,7 @@ void ColorToolItem::enableColor(int color)
// Only equals more ore less, so we will set it exact to the default color
if (this->color != color)
{
this->toolHandler->setColor(this->color);
this->toolHandler->setColor(this->color, true);
}
}
@ -185,7 +185,7 @@ void ColorToolItem::activated(GdkEvent* event, GtkMenuItem* menuitem, GtkToolBut
showColorchooser();
}
toolHandler->setColor(this->color);
toolHandler->setColor(this->color, true);
inUpdate = false;
}

Loading…
Cancel
Save