mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
PaintBrush: Let's have a tool (pen) checked on startup
This commit is contained in:
parent
1631077b74
commit
2c45076e68
1 changed files with 3 additions and 10 deletions
|
@ -100,24 +100,17 @@ ToolboxWidget::ToolboxWidget()
|
|||
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) -> ToolButton& {
|
||||
auto& button = add<ToolButton>(*this, name, shortcut, move(tool));
|
||||
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
button.set_preferred_size(0, 32);
|
||||
button.set_checkable(true);
|
||||
button.set_exclusive(true);
|
||||
button.set_icon(Gfx::Bitmap::load_from_file(String::format("/res/icons/paintbrush/%s.png", icon_name.to_string().characters())));
|
||||
|
||||
button.on_checked = [this, button = &button](auto checked) {
|
||||
if (checked)
|
||||
on_tool_selection(&button->tool());
|
||||
else
|
||||
on_tool_selection(nullptr);
|
||||
};
|
||||
return button;
|
||||
};
|
||||
|
||||
add_tool("Move", "move", { 0, Key_M }, make<MoveTool>());
|
||||
add_tool("Pen", "pen", { 0, Key_N }, make<PenTool>());
|
||||
add_tool("Pen", "pen", { 0, Key_N }, make<PenTool>()).set_checked(true);
|
||||
add_tool("Bucket Fill", "bucket", { Mod_Shift, Key_B }, make<BucketTool>());
|
||||
add_tool("Spray", "spray", { Mod_Shift, Key_S }, make<SprayTool>());
|
||||
add_tool("Color Picker", "picker", { 0, Key_O }, make<PickerTool>());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue