summaryrefslogtreecommitdiff
path: root/Applications/PaintBrush/EllipseTool.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-01-21 13:47:57 +0100
committerAndreas Kling <kling@serenityos.org>2020-01-21 13:47:57 +0100
commit1060d59ddd39c75b2fbbb4e2baa17dfaa223695b (patch)
tree83960a99807de0d7a4c4a2aaff1533c01fe036ed /Applications/PaintBrush/EllipseTool.cpp
parent07075cd0014b04660ac0d9d44267bdce72eefb5e (diff)
downloadserenity-1060d59ddd39c75b2fbbb4e2baa17dfaa223695b.zip
PaintBrush: Show which line thickness is selected in the tool menus
Put each tool's thickness altering actions into a GActionGroup and make them mutually exclusive so we get that nice radio button appearance. This all feel very clunky and we should move towards having something like a "tool settings" pane that gets populated by the currently active tool instead.
Diffstat (limited to 'Applications/PaintBrush/EllipseTool.cpp')
-rw-r--r--Applications/PaintBrush/EllipseTool.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/Applications/PaintBrush/EllipseTool.cpp b/Applications/PaintBrush/EllipseTool.cpp
index cbed5ebba6..1517c7065e 100644
--- a/Applications/PaintBrush/EllipseTool.cpp
+++ b/Applications/PaintBrush/EllipseTool.cpp
@@ -115,18 +115,21 @@ void EllipseTool::on_contextmenu(GContextMenuEvent& event)
m_mode = Mode::Outline;
}));
m_context_menu->add_separator();
- m_context_menu->add_action(GAction::create("1", [this](auto&) {
- m_thickness = 1;
- }));
- m_context_menu->add_action(GAction::create("2", [this](auto&) {
- m_thickness = 2;
- }));
- m_context_menu->add_action(GAction::create("3", [this](auto&) {
- m_thickness = 3;
- }));
- m_context_menu->add_action(GAction::create("4", [this](auto&) {
- m_thickness = 4;
- }));
+ m_thickness_actions.set_exclusive(true);
+ auto insert_action = [&](int size, bool checked = false) {
+ auto action = GAction::create(String::number(size), [this, size](auto& action) {
+ m_thickness = size;
+ action.set_checked(true);
+ });
+ action->set_checkable(true);
+ action->set_checked(checked);
+ m_thickness_actions.add_action(*action);
+ m_context_menu->add_action(move(action));
+ };
+ insert_action(1, true);
+ insert_action(2);
+ insert_action(3);
+ insert_action(4);
}
m_context_menu->popup(event.screen_position());
}