From 05e05d0d75857829f052577d8538d31373247c75 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 29 Aug 2010 18:11:16 +0000 Subject: [PATCH] Keyboard shortcut for enabling/disabling color cycle. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1595 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/Makefile.dep | 14 ++++++++------ src/const.h | 1 + src/engine.c | 14 +++++++++++++- src/global.h | 2 ++ src/hotkeys.c | 9 +++++++++ src/hotkeys.h | 2 +- src/input.c | 2 +- 7 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/Makefile.dep b/src/Makefile.dep index 82d0e417..7abb642e 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -11,7 +11,7 @@ $(OBJDIR)/buttons_effects.o: buttons_effects.c buttons.h struct.h const.h engine global.h graph.h help.h input.h misc.h readline.h sdlscreen.h windows.h $(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \ buttons.h operatio.h shade.h errors.h sdlscreen.h windows.h brush.h \ - input.h engine.h pages.h layers.h factory.h + input.h engine.h pages.h layers.h factory.h loadsave.h io.h $(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h engine.h errors.h \ filesel.h loadsave.h global.h graph.h io.h misc.h pages.h readline.h \ sdlscreen.h windows.h palette.h input.h help.h @@ -32,7 +32,7 @@ $(OBJDIR)/init.o: init.c buttons.h struct.h const.h errors.h global.h graph.h \ mountlist.h operatio.h palette.h sdlscreen.h setup.h transform.h \ windows.h layers.h $(OBJDIR)/input.o: input.c global.h struct.h const.h keyboard.h sdlscreen.h \ - windows.h errors.h misc.h input.h + windows.h errors.h misc.h input.h loadsave.h $(OBJDIR)/io.o: io.c struct.h const.h io.h realpath.h $(OBJDIR)/keyboard.o: keyboard.c global.h struct.h const.h keyboard.h $(OBJDIR)/layers.o: layers.c const.h struct.h global.h windows.h engine.h pages.h \ @@ -43,7 +43,7 @@ $(OBJDIR)/loadsave.o: loadsave.c buttons.h struct.h const.h errors.h global.h io engine.h $(OBJDIR)/main.o: main.c const.h struct.h global.h graph.h misc.h init.h buttons.h \ engine.h pages.h loadsave.h sdlscreen.h errors.h readini.h saveini.h \ - io.h text.h setup.h windows.h brush.h palette.h realpath.h + io.h text.h setup.h windows.h brush.h palette.h realpath.h input.h $(OBJDIR)/misc.o: misc.c struct.h const.h sdlscreen.h global.h errors.h buttons.h \ engine.h misc.h keyboard.h windows.h palette.h input.h graph.h pages.h $(OBJDIR)/miscfileformats.o: miscfileformats.c engine.h struct.h const.h errors.h \ @@ -51,7 +51,8 @@ $(OBJDIR)/miscfileformats.o: miscfileformats.c engine.h struct.h const.h errors. $(OBJDIR)/mountlist.o: mountlist.c $(OBJDIR)/op_c.o: op_c.c op_c.h struct.h const.h errors.h $(OBJDIR)/operatio.o: operatio.c const.h struct.h global.h misc.h engine.h graph.h \ - operatio.h buttons.h pages.h errors.h sdlscreen.h brush.h windows.h + operatio.h buttons.h pages.h errors.h sdlscreen.h brush.h windows.h \ + input.h $(OBJDIR)/pages.o: pages.c global.h struct.h const.h pages.h errors.h loadsave.h \ misc.h windows.h $(OBJDIR)/palette.o: palette.c const.h struct.h global.h misc.h engine.h readline.h \ @@ -88,9 +89,10 @@ $(OBJDIR)/shade.o: shade.c global.h struct.h const.h graph.h engine.h errors.h \ $(OBJDIR)/special.o: special.c const.h struct.h global.h graph.h engine.h windows.h \ special.h pages.h misc.h buttons.h $(OBJDIR)/text.o: text.c SFont.h struct.h const.h global.h sdlscreen.h io.h \ - errors.h + errors.h windows.h +$(OBJDIR)/tiles.o: tiles.c $(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.h \ sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h pages.h $(OBJDIR)/version.o: version.c $(OBJDIR)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \ - global.h graph.h input.h misc.h readline.h sdlscreen.h + global.h graph.h input.h misc.h op_c.h readline.h sdlscreen.h palette.h diff --git a/src/const.h b/src/const.h index 49fd163b..c3581791 100644 --- a/src/const.h +++ b/src/const.h @@ -481,6 +481,7 @@ enum SPECIAL_ACTIONS SPECIAL_RUN_SCRIPT_8, SPECIAL_RUN_SCRIPT_9, SPECIAL_RUN_SCRIPT_10, + SPECIAL_CYCLE_MODE, NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts }; diff --git a/src/engine.c b/src/engine.c index 961ca2f4..aa930678 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1307,6 +1307,13 @@ void Main_handler(void) action++; #endif break; + case SPECIAL_CYCLE_MODE: + Cycling_mode= !Cycling_mode; + // Restore palette + if (!Cycling_mode) + Set_palette(Main_palette); + action++; + break; } } } // End of special keys @@ -1579,7 +1586,12 @@ void Open_window(word width,word height, const char * title) Cursor_shape=CURSOR_SHAPE_ARROW; Paintbrush_hidden_before_window=Paintbrush_hidden; Paintbrush_hidden=1; - Allow_colorcycling=0; + if (Allow_colorcycling) + { + Allow_colorcycling=0; + // Restore palette + Set_palette(Main_palette); + } } // Initialisation des listes de boutons de la fenêtre diff --git a/src/global.h b/src/global.h index 060f4f3a..82faa890 100644 --- a/src/global.h +++ b/src/global.h @@ -785,6 +785,8 @@ GFX2_GLOBAL Func_pixel Gradient_pixel; GFX2_GLOBAL T_Gradient_array Gradient_array[16]; /// Index in ::Gradient_array of the currently selected gradient. GFX2_GLOBAL byte Current_gradient; +/// Boolean, true when the color cycling is active. +GFX2_GLOBAL byte Cycling_mode; // -- Airbrush data diff --git a/src/hotkeys.c b/src/hotkeys.c index 7b23caf9..a82cad80 100644 --- a/src/hotkeys.c +++ b/src/hotkeys.c @@ -1605,6 +1605,14 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { true, 0, // No shortcut 0}, + {197, + "Toggle color cycling", + "Activates or desactivates color", + "cycling, if the current image has", + "cycling colors. (See gradient menu)", + true, + SDLK_BACKQUOTE|MOD_CTRL, // Ctrl + `~ + 0}, }; word Ordering[NB_SHORTCUTS]= @@ -1806,4 +1814,5 @@ word Ordering[NB_SHORTCUTS]= SPECIAL_RUN_SCRIPT_8, SPECIAL_RUN_SCRIPT_9, SPECIAL_RUN_SCRIPT_10, + SPECIAL_CYCLE_MODE, }; diff --git a/src/hotkeys.h b/src/hotkeys.h index 14d8ba60..38006841 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -33,7 +33,7 @@ #endif #include -#define NB_SHORTCUTS 197 ///< Number of actions that can have a key combination associated to it. +#define NB_SHORTCUTS 198 ///< Number of actions that can have a key combination associated to it. /*** Types definitions and structs ***/ diff --git a/src/input.c b/src/input.c index 13c20b90..1fb6218e 100644 --- a/src/input.c +++ b/src/input.c @@ -923,7 +923,7 @@ int Color_cycling(__attribute__((unused)) void* useless) start = SDL_GetTicks(); return 1; } - if (!Allow_colorcycling) + if (!Allow_colorcycling || !Cycling_mode) return 1;