From d754ac5bcb1b20f49285909fa31792c8111424d3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 14 Sep 2019 22:42:02 +0200 Subject: [PATCH] LibGUI+VisualBuilder: Add move-to-front/back to GCommonActions Also give them nice little icons. :^) --- Base/res/icons/16x16/move-to-back.png | Bin 0 -> 143 bytes Base/res/icons/16x16/move-to-front.png | Bin 0 -> 143 bytes DevTools/VisualBuilder/VBForm.cpp | 4 ++-- Libraries/LibGUI/GAction.cpp | 10 ++++++++++ Libraries/LibGUI/GAction.h | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Base/res/icons/16x16/move-to-back.png create mode 100644 Base/res/icons/16x16/move-to-front.png diff --git a/Base/res/icons/16x16/move-to-back.png b/Base/res/icons/16x16/move-to-back.png new file mode 100644 index 0000000000000000000000000000000000000000..a7556652f3035dc5b9b27d0e1fe670ca33f70451 GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`VV*9IAr`04PBP>>V8Fp#8#@rulOV9_)GWLMuaf4!3pW%{a9aGT#rh*)IsQP1(IW qP4IvILKTL0KQA%IRc(mu$&GP2A)wWg;lC1S1B0ilpUXO@geCyw=P={| literal 0 HcmV?d00001 diff --git a/Base/res/icons/16x16/move-to-front.png b/Base/res/icons/16x16/move-to-front.png new file mode 100644 index 0000000000000000000000000000000000000000..17e33bbf0c7f72ffca52bd28355d6d86ebc9745e GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`VV*9IAr`04PO|1ZV8G!#f3@7j z<4^ih{8%SyO{;K8_{q$p$Z-3nu1kv_%lVLlGal%w)VoLC%;RJ*dhMYSJEJj+eJ|_n r=%eD-ZY=%Vp0L|)?@w9NzKsmVvchWY9P@tyZD8bP0l+XkK5SB2H literal 0 HcmV?d00001 diff --git a/DevTools/VisualBuilder/VBForm.cpp b/DevTools/VisualBuilder/VBForm.cpp index 94891cfbe33..cb7f140b71c 100644 --- a/DevTools/VisualBuilder/VBForm.cpp +++ b/DevTools/VisualBuilder/VBForm.cpp @@ -27,11 +27,11 @@ VBForm::VBForm(const String& name, GWidget* parent) set_greedy_for_hits(true); m_context_menu = make(); - 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(); })); diff --git a/Libraries/LibGUI/GAction.cpp b/Libraries/LibGUI/GAction.cpp index c5df20869bc..61b9a775eef 100644 --- a/Libraries/LibGUI/GAction.cpp +++ b/Libraries/LibGUI/GAction.cpp @@ -6,6 +6,16 @@ namespace GCommonActions { +NonnullRefPtr make_move_to_front_action(Function 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 make_move_to_back_action(Function 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 make_undo_action(Function callback, GWidget* widget) { return GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), widget); diff --git a/Libraries/LibGUI/GAction.h b/Libraries/LibGUI/GAction.h index f17cd377e28..b3c591098a7 100644 --- a/Libraries/LibGUI/GAction.h +++ b/Libraries/LibGUI/GAction.h @@ -25,6 +25,8 @@ NonnullRefPtr make_cut_action(Function, GWidget* widget NonnullRefPtr make_copy_action(Function, GWidget* widget = nullptr); NonnullRefPtr make_paste_action(Function, GWidget* widget = nullptr); NonnullRefPtr make_delete_action(Function, GWidget* widget = nullptr); +NonnullRefPtr make_move_to_front_action(Function, GWidget* widget = nullptr); +NonnullRefPtr make_move_to_back_action(Function, GWidget* widget = nullptr); NonnullRefPtr make_quit_action(Function); };