From 78039ef057b3251b5db9052483a277c0cf6e535a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 16 Mar 2019 23:16:11 +0100 Subject: [PATCH] TextEditor: Add actions for undo and redo. Not hooked up yet. --- Applications/TextEditor/main.cpp | 16 ++++++++++++++++ Base/res/icons/16x16/redo.png | Bin 0 -> 252 bytes Base/res/icons/16x16/redo.rgb | Bin 0 -> 1024 bytes Base/res/icons/16x16/undo.png | Bin 0 -> 252 bytes Base/res/icons/16x16/undo.rgb | Bin 0 -> 1024 bytes 5 files changed, 16 insertions(+) create mode 100644 Base/res/icons/16x16/redo.png create mode 100644 Base/res/icons/16x16/redo.rgb create mode 100644 Base/res/icons/16x16/undo.png create mode 100644 Base/res/icons/16x16/undo.rgb diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp index c7bddbe69d..68e79f6c70 100644 --- a/Applications/TextEditor/main.cpp +++ b/Applications/TextEditor/main.cpp @@ -74,6 +74,14 @@ int main(int argc, char** argv) text_editor->write_to_file(path); }); + auto undo_action = GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/16x16/undo.rgb", { 16, 16 }), [&] (const GAction&) { + // FIXME: Undo + }); + + auto redo_action = GAction::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/16x16/redo.rgb", { 16, 16 }), [&] (const GAction&) { + // FIXME: Redo + }); + auto cut_action = GAction::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/cut16.rgb", { 16, 16 }), [&] (const GAction&) { text_editor->cut(); }); @@ -101,6 +109,9 @@ int main(int argc, char** argv) menubar->add_menu(move(file_menu)); auto edit_menu = make("Edit"); + edit_menu->add_action(undo_action.copy_ref()); + edit_menu->add_action(redo_action.copy_ref()); + edit_menu->add_separator(); edit_menu->add_action(cut_action.copy_ref()); edit_menu->add_action(copy_action.copy_ref()); edit_menu->add_action(paste_action.copy_ref()); @@ -133,6 +144,11 @@ int main(int argc, char** argv) toolbar->add_action(move(copy_action)); toolbar->add_action(move(paste_action)); + toolbar->add_separator(); + + toolbar->add_action(move(undo_action)); + toolbar->add_action(move(redo_action)); + auto* window = new GWindow; window->set_title(String::format("TextEditor: %s", path.characters())); window->set_rect(20, 200, 640, 400); diff --git a/Base/res/icons/16x16/redo.png b/Base/res/icons/16x16/redo.png new file mode 100644 index 0000000000000000000000000000000000000000..57a831010d5af7754de88c75be76c396bd00705d GIT binary patch literal 252 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7BevDDT6R$#Zvn+1_lQ95>H=O_Q%WuV*DJpLYMwwU|^6eag8W(&d<$F%`0JW zE=o--Nlj5G&n(GMaQE~L2yf&QXJBAR@pN$vu{eEn(nVedMGohQr8kxyHtII-|0i?u z=ze^LH>XFfe$!`njxgN@xNA9rak} literal 0 HcmV?d00001 diff --git a/Base/res/icons/16x16/redo.rgb b/Base/res/icons/16x16/redo.rgb new file mode 100644 index 0000000000000000000000000000000000000000..6534f5c346161395a414483d588741ef3904c62f GIT binary patch literal 1024 zcmZP=oIu;p&+k7Bli)R=d2 zoS@wxwJ?1!8YBk7AU=r3he2x4F-$#39L6Sxrc^&MVNb|igTW0je+&}05DGG|JOGYY BL^J>Z literal 0 HcmV?d00001 diff --git a/Base/res/icons/16x16/undo.png b/Base/res/icons/16x16/undo.png new file mode 100644 index 0000000000000000000000000000000000000000..161cf8e04bb520bc5918e745be860bb4a32a7a09 GIT binary patch literal 252 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7BevDDT6R$#Zvn+1_lQ95>H=O_Q%WuVto2(E{fL}7#Ji=Tq8=H^K)}k^GX<; zi&7IyQd1PlGfOfQ+&z5*!W;R-85kH+JY5_^EKVmUNMs!7@V|8a{CoSJy_uKQWZBr- zRqmrHf!m%s{!?v7TTRJbEKmVS~^&oS?VbfN?U!?ix6e>-a>EEyOW7(8A5T-G@yGywp5pi`;< literal 0 HcmV?d00001 diff --git a/Base/res/icons/16x16/undo.rgb b/Base/res/icons/16x16/undo.rgb new file mode 100644 index 0000000000000000000000000000000000000000..c743aff5937c54d9fa8e75a0a2952f62bab85cc6 GIT binary patch literal 1024 zcmZP=#K6zb?>`JPFfeH2awbAO%J*l zNG-A$h>whs<*>0qYLUYO#7D>2^dXCZ)FbmrWe=o&sNE=WK#KdJ`bp6OR}0lkvfUtk TAdDPua6<_&$kj){Sg