mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 06:32:42 +00:00
Fix Alt+1, Alt+2, etc. shortcuts to change the selected tool brush (fix #1195)
This commit is contained in:
parent
87a04f5c03
commit
3333855db3
@ -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 @@ public:
|
||||
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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user