Skip to content
Permalink
Browse files

Fix Alt+1, Alt+2, etc. shortcuts to change the selected tool brush (fix

  • Loading branch information...
dacap committed Sep 12, 2016
1 parent 87a04f5 commit 3333855db3d4506d70a913ae88dff46e9e819044
Showing with 14 additions and 8 deletions.
  1. +5 −2 src/app/commands/cmd_change_brush.cpp
  2. +2 −2 src/app/ui/brush_popup.cpp
  3. +6 −3 src/app/ui/context_bar.cpp
  4. +1 −1 src/app/ui/context_bar.h
@@ -15,6 +15,7 @@
#include "app/commands/params.h"
#include "app/context.h"
#include "app/pref/preferences.h"
#include "app/tools/active_tool.h"
#include "app/tools/tool.h"
#include "app/ui/context_bar.h"
#include "base/convert_to.h"
@@ -71,7 +72,9 @@ void ChangeBrushCommand::onLoadParams(const Params& params)

void ChangeBrushCommand::onExecute(Context* context)
{
tools::Tool* tool = App::instance()->activeTool();
// Change the brush of the selected tool in the toolbar (not the
// active tool which might be different, e.g. the quick tool)
tools::Tool* tool = App::instance()->activeToolManager()->selectedTool();
ToolPreferences::Brush& brush =
Preferences::instance().tool(tool).brush;

@@ -97,7 +100,7 @@ void ChangeBrushCommand::onExecute(Context* context)
break;
case CustomBrush:
App::instance()->contextBar()
->setActiveBrushBySlot(m_slot);
->setActiveBrushBySlot(tool, m_slot);
break;
}
}
@@ -91,11 +91,11 @@ class SelectBrushItem : public ButtonSet::Item {
private:
void onClick() override {
ContextBar* contextBar = App::instance()->contextBar();
tools::Tool* tool = App::instance()->activeTool();

if (m_slot >= 0)
contextBar->setActiveBrushBySlot(m_slot);
contextBar->setActiveBrushBySlot(tool, m_slot);
else if (m_brush.hasBrush()) {
tools::Tool* tool = App::instance()->activeTool();
auto& brushPref = Preferences::instance().tool(tool).brush;
BrushRef brush;

@@ -1700,14 +1700,17 @@ void ContextBar::updateAutoSelectLayer(bool state)
m_autoSelectLayer->setSelected(state);
}

void ContextBar::setActiveBrushBySlot(int slot)
void ContextBar::setActiveBrushBySlot(tools::Tool* tool, int slot)
{
ASSERT(tool);
if (!tool)
return;

AppBrushes& brushes = App::instance()->brushes();
BrushSlot brush = brushes.getBrushSlot(slot);
if (!brush.isEmpty()) {
brushes.lockBrushSlot(slot);

Tool* tool = App::instance()->activeTool();
Preferences& pref = Preferences::instance();
ToolPreferences& toolPref = pref.tool(tool);
ToolPreferences::Brush& brushPref = toolPref.brush;
@@ -1752,7 +1755,7 @@ void ContextBar::setActiveBrushBySlot(int slot)
tools::FreehandAlgorithm::REGULAR));
}
else {
updateForTool(App::instance()->activeTool());
updateForTool(tool);
m_brushType->showPopupAndHighlightSlot(slot);
}
}
@@ -54,7 +54,7 @@ namespace app {
void updateAutoSelectLayer(bool state);

void setActiveBrush(const doc::BrushRef& brush);
void setActiveBrushBySlot(int slot);
void setActiveBrushBySlot(tools::Tool* tool, int slot);
doc::BrushRef activeBrush(tools::Tool* tool = nullptr) const;
void discardActiveBrush();

0 comments on commit 3333855

Please sign in to comment.
You can’t perform that action at this time.