mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +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
Notes:
sideshowbarker
2024-07-19 06:40:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/1631077b74c
2 changed files with 9 additions and 0 deletions
|
@ -63,6 +63,7 @@ public:
|
|||
});
|
||||
|
||||
set_action(*m_action);
|
||||
m_toolbox.m_action_group.add_action(*m_action);
|
||||
}
|
||||
|
||||
const Tool& tool() const { return *m_tool; }
|
||||
|
@ -96,6 +97,9 @@ ToolboxWidget::ToolboxWidget()
|
|||
set_layout<GUI::VerticalBoxLayout>();
|
||||
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& button = add<ToolButton>(*this, name, shortcut, move(tool));
|
||||
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Frame.h>
|
||||
|
||||
namespace PaintBrush {
|
||||
|
@ -40,7 +41,11 @@ public:
|
|||
Function<void(Tool*)> on_tool_selection;
|
||||
|
||||
private:
|
||||
friend class ToolButton;
|
||||
|
||||
explicit ToolboxWidget();
|
||||
|
||||
GUI::ActionGroup m_action_group;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue