LibGUI+VisualBuilder: Add move-to-front/back to GCommonActions

Also give them nice little icons. :^)
This commit is contained in:
Andreas Kling 2019-09-14 22:42:02 +02:00
parent 92b17eab23
commit d754ac5bcb
Notes: sideshowbarker 2024-07-19 12:06:28 +09:00
5 changed files with 14 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

View file

@ -27,11 +27,11 @@ VBForm::VBForm(const String& name, GWidget* parent)
set_greedy_for_hits(true);
m_context_menu = make<GMenu>();
m_context_menu->add_action(GAction::create("Move to front", [this](auto&) {
m_context_menu->add_action(GCommonActions::make_move_to_front_action([this](auto&) {
if (auto* widget = single_selected_widget())
widget->gwidget()->move_to_front();
}));
m_context_menu->add_action(GAction::create("Move to back", [this](auto&) {
m_context_menu->add_action(GCommonActions::make_move_to_back_action([this](auto&) {
if (auto* widget = single_selected_widget())
widget->gwidget()->move_to_back();
}));

View file

@ -6,6 +6,16 @@
namespace GCommonActions {
NonnullRefPtr<GAction> make_move_to_front_action(Function<void(GAction&)> callback, GWidget* widget)
{
return GAction::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), widget);
}
NonnullRefPtr<GAction> make_move_to_back_action(Function<void(GAction&)> callback, GWidget* widget)
{
return GAction::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), widget);
}
NonnullRefPtr<GAction> make_undo_action(Function<void(GAction&)> callback, GWidget* widget)
{
return GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), widget);

View file

@ -25,6 +25,8 @@ NonnullRefPtr<GAction> make_cut_action(Function<void(GAction&)>, GWidget* widget
NonnullRefPtr<GAction> make_copy_action(Function<void(GAction&)>, GWidget* widget = nullptr);
NonnullRefPtr<GAction> make_paste_action(Function<void(GAction&)>, GWidget* widget = nullptr);
NonnullRefPtr<GAction> make_delete_action(Function<void(GAction&)>, GWidget* widget = nullptr);
NonnullRefPtr<GAction> make_move_to_front_action(Function<void(GAction&)>, GWidget* widget = nullptr);
NonnullRefPtr<GAction> make_move_to_back_action(Function<void(GAction&)>, GWidget* widget = nullptr);
NonnullRefPtr<GAction> make_quit_action(Function<void(GAction&)>);
};