mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
PaintBrush: Put all the tool buttons into an action group
This allows us to easily make them exclusive and uncheckable. :^)
This commit is contained in:
parent
0de3b1c4bf
commit
1631077b74
2 changed files with 9 additions and 0 deletions
|
@ -63,6 +63,7 @@ public:
|
||||||
});
|
});
|
||||||
|
|
||||||
set_action(*m_action);
|
set_action(*m_action);
|
||||||
|
m_toolbox.m_action_group.add_action(*m_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tool& tool() const { return *m_tool; }
|
const Tool& tool() const { return *m_tool; }
|
||||||
|
@ -96,6 +97,9 @@ ToolboxWidget::ToolboxWidget()
|
||||||
set_layout<GUI::VerticalBoxLayout>();
|
set_layout<GUI::VerticalBoxLayout>();
|
||||||
layout()->set_margins({ 4, 4, 4, 4 });
|
layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
|
m_action_group.set_exclusive(true);
|
||||||
|
m_action_group.set_unchecking_allowed(false);
|
||||||
|
|
||||||
auto add_tool = [&](const StringView& name, const StringView& icon_name, const GUI::Shortcut& shortcut, NonnullOwnPtr<Tool> tool) {
|
auto add_tool = [&](const StringView& name, const StringView& icon_name, const GUI::Shortcut& shortcut, NonnullOwnPtr<Tool> tool) {
|
||||||
auto& button = add<ToolButton>(*this, name, shortcut, move(tool));
|
auto& button = add<ToolButton>(*this, name, shortcut, move(tool));
|
||||||
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibGUI/ActionGroup.h>
|
||||||
#include <LibGUI/Frame.h>
|
#include <LibGUI/Frame.h>
|
||||||
|
|
||||||
namespace PaintBrush {
|
namespace PaintBrush {
|
||||||
|
@ -40,7 +41,11 @@ public:
|
||||||
Function<void(Tool*)> on_tool_selection;
|
Function<void(Tool*)> on_tool_selection;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class ToolButton;
|
||||||
|
|
||||||
explicit ToolboxWidget();
|
explicit ToolboxWidget();
|
||||||
|
|
||||||
|
GUI::ActionGroup m_action_group;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue