mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibCore: Make Core::Object::add<ChildType> return a ChildType&
Since the returned object is now owned by the callee object, we can simply vend a ChildType&. This allows us to use "." instead of "->" at the call site, which is quite nice. :^)
This commit is contained in:
parent
fb09b6a8ce
commit
028c011760
46 changed files with 1035 additions and 1039 deletions
|
@ -74,15 +74,15 @@ ToolboxWidget::ToolboxWidget()
|
|||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr<Tool>&& tool) {
|
||||
auto button = add<ToolButton>(name, 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);
|
||||
auto& button = add<ToolButton>(name, 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", String(icon_name).characters())));
|
||||
button.set_icon(Gfx::Bitmap::load_from_file(String::format("/res/icons/paintbrush/%s.png", String(icon_name).characters())));
|
||||
|
||||
button->on_checked = [button = button.ptr()](auto checked) {
|
||||
button.on_checked = [button = &button](auto checked) {
|
||||
if (checked)
|
||||
PaintableWidget::the().set_tool(&button->tool());
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue