summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-14 22:42:02 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-14 22:42:39 +0200
commitd754ac5bcb1b20f49285909fa31792c8111424d3 (patch)
tree73fd5adbee0267d3d4b0d38c0fdf2a3a6d7aaf54
parent92b17eab23b5789714bdc6255566d53b16ce626f (diff)
downloadserenity-d754ac5bcb1b20f49285909fa31792c8111424d3.zip
LibGUI+VisualBuilder: Add move-to-front/back to GCommonActions
Also give them nice little icons. :^)
-rw-r--r--Base/res/icons/16x16/move-to-back.pngbin0 -> 143 bytes
-rw-r--r--Base/res/icons/16x16/move-to-front.pngbin0 -> 143 bytes
-rw-r--r--DevTools/VisualBuilder/VBForm.cpp4
-rw-r--r--Libraries/LibGUI/GAction.cpp10
-rw-r--r--Libraries/LibGUI/GAction.h2
5 files changed, 14 insertions, 2 deletions
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 0000000000..a7556652f3
--- /dev/null
+++ b/Base/res/icons/16x16/move-to-back.png
Binary files differ
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 0000000000..17e33bbf0c
--- /dev/null
+++ b/Base/res/icons/16x16/move-to-front.png
Binary files differ
diff --git a/DevTools/VisualBuilder/VBForm.cpp b/DevTools/VisualBuilder/VBForm.cpp
index 94891cfbe3..cb7f140b71 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<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();
}));
diff --git a/Libraries/LibGUI/GAction.cpp b/Libraries/LibGUI/GAction.cpp
index c5df20869b..61b9a775ee 100644
--- a/Libraries/LibGUI/GAction.cpp
+++ b/Libraries/LibGUI/GAction.cpp
@@ -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);
diff --git a/Libraries/LibGUI/GAction.h b/Libraries/LibGUI/GAction.h
index f17cd377e2..b3c591098a 100644
--- a/Libraries/LibGUI/GAction.h
+++ b/Libraries/LibGUI/GAction.h
@@ -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&)>);
};