mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:37:42 +00:00
PixelPaint: Have ToolboxWidget
keep track of active tool
Since there's only one global toolbox, it makes sense to store the active tool in here, since we don't really have control over the deletion of an editor.
This commit is contained in:
parent
ee25e2adc2
commit
ecf8f243a6
2 changed files with 7 additions and 2 deletions
|
@ -53,10 +53,12 @@ void ToolboxWidget::setup_tools()
|
|||
auto add_tool = [&](String name, StringView const& icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr<Tool> tool) {
|
||||
auto action = GUI::Action::create_checkable(move(name), shortcut, Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name)),
|
||||
[this, tool = tool.ptr()](auto& action) {
|
||||
if (action.is_checked())
|
||||
if (action.is_checked()) {
|
||||
on_tool_selection(tool);
|
||||
else
|
||||
m_active_tool = tool;
|
||||
} else {
|
||||
on_tool_selection(nullptr);
|
||||
}
|
||||
});
|
||||
m_action_group.add_action(action);
|
||||
auto& button = m_toolbar->add_action(action);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue