1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:17:34 +00:00

PaintBrush: Let's have a tool (pen) checked on startup

This commit is contained in:
Andreas Kling 2020-05-13 15:06:11 +02:00
parent 1631077b74
commit 2c45076e68

View file

@ -100,24 +100,17 @@ ToolboxWidget::ToolboxWidget()
m_action_group.set_exclusive(true); m_action_group.set_exclusive(true);
m_action_group.set_unchecking_allowed(false); 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)); 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);
button.set_preferred_size(0, 32); button.set_preferred_size(0, 32);
button.set_checkable(true); 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.set_icon(Gfx::Bitmap::load_from_file(String::format("/res/icons/paintbrush/%s.png", icon_name.to_string().characters())));
return button;
button.on_checked = [this, button = &button](auto checked) {
if (checked)
on_tool_selection(&button->tool());
else
on_tool_selection(nullptr);
};
}; };
add_tool("Move", "move", { 0, Key_M }, make<MoveTool>()); 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("Bucket Fill", "bucket", { Mod_Shift, Key_B }, make<BucketTool>());
add_tool("Spray", "spray", { Mod_Shift, Key_S }, make<SprayTool>()); add_tool("Spray", "spray", { Mod_Shift, Key_S }, make<SprayTool>());
add_tool("Color Picker", "picker", { 0, Key_O }, make<PickerTool>()); add_tool("Color Picker", "picker", { 0, Key_O }, make<PickerTool>());