From e5edfda5ccb80346d4b208fe99923bb6716e943f Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 30 May 2010 17:59:32 +0000 Subject: [PATCH] Skins with flat buttons (Issue 352). Sample skins: Clax2, Clax3 git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1494 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/Makefile | 2 +- src/const.h | 2 + src/engine.c | 118 +++++++++++++++++++++++++++++++++++++++------------ src/init.c | 5 +++ src/struct.h | 2 + 5 files changed, 100 insertions(+), 29 deletions(-) diff --git a/src/Makefile b/src/Makefile index f7b7ee6a..9e29fb40 100644 --- a/src/Makefile +++ b/src/Makefile @@ -305,7 +305,7 @@ endif # This is the list of the objects we want to build. Dependancies are built by "make depend" automatically. OBJ = $(OBJDIR)/main.o $(OBJDIR)/init.o $(OBJDIR)/graph.o $(OBJDIR)/sdlscreen.o $(OBJDIR)/misc.o $(OBJDIR)/special.o $(OBJDIR)/buttons.o $(OBJDIR)/palette.o $(OBJDIR)/help.o $(OBJDIR)/operatio.o $(OBJDIR)/pages.o $(OBJDIR)/loadsave.o $(OBJDIR)/readline.o $(OBJDIR)/engine.o $(OBJDIR)/filesel.o $(OBJDIR)/op_c.o $(OBJDIR)/readini.o $(OBJDIR)/saveini.o $(OBJDIR)/shade.o $(OBJDIR)/keyboard.o $(OBJDIR)/io.o $(OBJDIR)/version.o $(OBJDIR)/text.o $(OBJDIR)/SFont.o $(OBJDIR)/setup.o $(OBJDIR)/pxsimple.o $(OBJDIR)/pxtall.o $(OBJDIR)/pxwide.o $(OBJDIR)/pxdouble.o $(OBJDIR)/pxtriple.o $(OBJDIR)/pxtall2.o $(OBJDIR)/pxwide2.o $(OBJDIR)/pxquad.o $(OBJDIR)/windows.o $(OBJDIR)/brush.o $(OBJDIR)/realpath.o $(OBJDIR)/mountlist.o $(OBJDIR)/input.o $(OBJDIR)/hotkeys.o $(OBJDIR)/transform.o $(OBJDIR)/pversion.o $(OBJDIR)/factory.o $(PLATFORMOBJ) $(OBJDIR)/fileformats.o $(OBJDIR)/miscfileformats.o $(OBJDIR)/libraw2crtc.o $(OBJDIR)/brush_ops.o $(OBJDIR)/buttons_effects.o $(OBJDIR)/layers.o -SKIN_FILES = ../share/grafx2/skins/skin_classic.png ../share/grafx2/skins/skin_modern.png ../share/grafx2/skins/skin_DPaint.png ../share/grafx2/skins/font_Classic.png ../share/grafx2/skins/font_Fun.png ../share/grafx2/skins/font_Fairlight.png ../share/grafx2/skins/font_Melon.png ../share/grafx2/skins/font_DPaint.png ../share/grafx2/skins/skin_scenish.png ../share/grafx2/skins/font_Seen.png ../share/grafx2/skins/skin_Aurora.png +SKIN_FILES = ../share/grafx2/skins/skin_classic.png ../share/grafx2/skins/skin_modern.png ../share/grafx2/skins/skin_DPaint.png ../share/grafx2/skins/font_Classic.png ../share/grafx2/skins/font_Fun.png ../share/grafx2/skins/font_Fairlight.png ../share/grafx2/skins/font_Melon.png ../share/grafx2/skins/font_DPaint.png ../share/grafx2/skins/skin_scenish.png ../share/grafx2/skins/font_Seen.png ../share/grafx2/skins/skin_Aurora.png ../share/grafx2/skins/skin_Clax3.gif ../share/grafx2/skins/skin_Clax2.gif SCRIPT_FILES1 = ../share/grafx2/scripts/bru_db_Amigaball.lua ../share/grafx2/scripts/bru_db_ColorSphere.lua ../share/grafx2/scripts/bru_db_FindAA.lua ../share/grafx2/scripts/bru_db_Fisheye.lua ../share/grafx2/scripts/bru_db_GrayscaleAvg.lua ../share/grafx2/scripts/bru_db_GrayscaleDesat.lua ../share/grafx2/scripts/bru_db_Halfsmooth.lua ../share/grafx2/scripts/bru_db_Mandelbrot.lua ../share/grafx2/scripts/bru_db_Waves.lua ../share/grafx2/scripts/pal_db_Desaturate.lua ../share/grafx2/scripts/pal_db_ExpandColors.lua ../share/grafx2/scripts/pal_db_FillColorCube.lua ../share/grafx2/scripts/pal_db_InvertedRGB.lua ../share/grafx2/scripts/pal_db_Set3bit.lua ../share/grafx2/scripts/pal_db_Set6bit.lua ../share/grafx2/scripts/pal_db_SetC64Palette.lua ../share/grafx2/scripts/pal_db_ShiftHue.lua ../share/grafx2/scripts/pic_db_Pic2isometric.lua ../share/grafx2/scripts/pic_db_Rainbow-Dark2Bright.lua ../share/grafx2/scripts/pic_db_SierpinskyCarpet.lua SCRIPT_FILES2 = ../share/grafx2/scripts/pic_db_SierpinskyTriangle.lua ../share/grafx2/scripts/pic_ni_Colorspace12bit.lua ../share/grafx2/scripts/pic_ni_Colorspace15bit.lua ../share/grafx2/scripts/pic_ni_Colorspace18bit.lua ../share/grafx2/scripts/pic_ni_GlassGridFilter.lua ../share/grafx2/scripts/pic_ni_Grid8.lua ../share/grafx2/scripts/pic_ni_Grid8red.lua ../share/grafx2/scripts/pic_ni_GridIso.lua ../share/grafx2/scripts/pic_ni_PaletteX1.lua ../share/grafx2/scripts/pic_ni_PaletteX8.lua ../share/grafx2/scripts/scn_db_RemapImage2RGB.lua ../share/grafx2/scripts/scn_db_RemapImage2RGB_ed.lua ../share/grafx2/scripts/scn_db_RemapImageTo3bitPal.lua diff --git a/src/const.h b/src/const.h index 1264338c..7d8d3a54 100644 --- a/src/const.h +++ b/src/const.h @@ -230,6 +230,8 @@ enum PAINTBRUSH_SHAPES #define BUTTON_RELEASED 0 /// State of a menu button that is being pressed. #define BUTTON_PRESSED 1 +/// State of a button temporarily highligted +#define BUTTON_HIGHLIGHTED 2 /// The different modes of the Shade enum SHADE_MODES diff --git a/src/engine.c b/src/engine.c index 7a4dcea7..99c91d38 100644 --- a/src/engine.c +++ b/src/engine.c @@ -240,17 +240,44 @@ void Draw_menu_button_frame(byte btn_number,byte pressed) end_x =start_x+Buttons_Pool[btn_number].Width; end_y =start_y+Buttons_Pool[btn_number].Height; - if (!pressed) + switch (pressed) { + default: + case BUTTON_RELEASED: + if (Gfx->No_outline) + { + color_top_left=MC_Light; + color_bottom_right=MC_Light; + color_diagonal=MC_Light; + } + else + { + color_top_left=MC_White; + color_bottom_right=MC_Dark; + color_diagonal=MC_Light; + } + break; + + case BUTTON_PRESSED: + if (Gfx->No_outline) + { + color_top_left=MC_Dark; + color_bottom_right=MC_White; + color_diagonal=MC_White; + } + else + { + color_top_left=MC_Dark; + color_bottom_right=MC_Black; + color_diagonal=MC_Dark; + } + break; + + case BUTTON_HIGHLIGHTED: color_top_left=MC_White; color_bottom_right=MC_Dark; color_diagonal=MC_Light; - } - else - { - color_top_left=MC_Dark; - color_bottom_right=MC_Black; - color_diagonal=MC_Dark; + break; } switch(Buttons_Pool[btn_number].Shape) @@ -282,9 +309,9 @@ void Draw_menu_button_frame(byte btn_number,byte pressed) break; case BUTTON_SHAPE_TRIANGLE_TOP_LEFT: // On colorie le point haut droit - Pixel_in_menu_and_skin(current_menu, end_x, start_y, color_diagonal); + Pixel_in_menu_and_skin(current_menu, end_x, start_y, color_top_left); // On colorie le point bas gauche - Pixel_in_menu_and_skin(current_menu, start_x, end_y, color_diagonal); + Pixel_in_menu_and_skin(current_menu, start_x, end_y, color_top_left); // On colorie le coin haut gauche for (x_pos=0;x_posNo_outline) { - Pixel_in_menu_and_skin(current_menu, start_x+x_pos, end_y-x_pos, color_bottom_right); + if (! Buttons_Pool[btn_number+1].Pressed) + for (x_pos=0;x_posNo_outline) { - Pixel_in_menu_and_skin(current_menu, start_x+x_pos, end_y-x_pos, color_top_left); + if (! Buttons_Pool[btn_number-1].Pressed) + for (x_pos=1;x_pos<=Buttons_Pool[btn_number].Width;x_pos++) + { + Pixel_in_menu_and_skin(current_menu, start_x+x_pos-1, end_y-x_pos, color_top_left); + } } + else + for (x_pos=1;x_posNo_outline && prev_button_number > -1 && !Buttons_Pool[prev_button_number].Pressed) + Draw_menu_button_frame(prev_button_number, BUTTON_RELEASED); + Block(18*Menu_factor_X,Menu_status_Y,192*Menu_factor_X,Menu_factor_Y<<3,MC_Light); Update_rect(18*Menu_factor_X,Menu_status_Y,192*Menu_factor_X,Menu_factor_Y<<3); Display_cursor(); @@ -1186,7 +1235,15 @@ void Main_handler(void) if (button_index!=BUTTON_CHOOSE_COL) { Hide_cursor(); + + if (Gfx->No_outline && prev_button_number > -1 && !Buttons_Pool[prev_button_number].Pressed) + Draw_menu_button_frame(prev_button_number, BUTTON_RELEASED); + Print_in_menu(Menu_tooltip[button_index],0); + + if (Gfx->No_outline && !Buttons_Pool[button_index].Pressed) + Draw_menu_button_frame(button_index, 2 /* BUTTON_HIGHLIGHTED */); + Display_cursor(); } else @@ -1241,21 +1298,26 @@ void Main_handler(void) // Le curseur se trouve dans l'image if ( (!Cursor_in_menu) && (Menu_is_visible) && (Old_MY != Mouse_Y || Old_MX != Mouse_X || Key || Mouse_K)) // On ne met les coordonnées à jour que si l'utilisateur a fait un truc { - if ( (Current_operation!=OPERATION_COLORPICK) && (Current_operation!=OPERATION_REPLACE) ) - { - if(Cursor_in_menu_previous) - { - Print_in_menu("X: Y: ",0); - } - } - else - { - if(Cursor_in_menu_previous) - { - Print_in_menu("X: Y: ( )",0); - } - } - Cursor_in_menu_previous = 0; + if(Cursor_in_menu_previous) + { + Hide_cursor(); + + if (Gfx->No_outline && prev_button_number > -1 && !Buttons_Pool[prev_button_number].Pressed) + Draw_menu_button_frame(prev_button_number, BUTTON_RELEASED); + + if ( (Current_operation!=OPERATION_COLORPICK) && (Current_operation!=OPERATION_REPLACE) ) + { + Print_in_menu("X: Y: ",0); + } + else + { + Print_in_menu("X: Y: ( )",0); + } + + Display_cursor(); + + Cursor_in_menu_previous = 0; + } } if(Cursor_in_menu) diff --git a/src/init.c b/src/init.c index 176fd14b..13e88e63 100644 --- a/src/init.c +++ b/src/init.c @@ -277,6 +277,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx) sprintf(Gui_loading_error_message, "Not a 256-color palette"); return 1; } + // Read the default palette Get_SDL_Palette(SDLPal, gfx->Default_palette); @@ -357,6 +358,10 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Menu_block, Menu_bars[MENUBAR_TOOLS].Skin_width, Menu_bars[MENUBAR_TOOLS].Height,"menu",0)) return 1; + // Check the skin as "No outline" if the first button + // has a grey pixel at top left angle. + gfx->No_outline=gfx->Menu_block[1][0]==gfx->Color[2]; + // Preview cursor_x += Menu_bars[MENUBAR_TOOLS].Skin_width; if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "preview")) diff --git a/src/struct.h b/src/struct.h index b8f8ed24..3073f039 100644 --- a/src/struct.h +++ b/src/struct.h @@ -448,6 +448,8 @@ typedef struct /// Transparent GUI color index in skin file byte Color_trans; + /// Boolean, true if the buttons have normally no outline + byte No_outline; } T_Gui_skin;