From f686d8a9513dd73c3f084a85116213cb264a5435 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 16 May 2010 14:52:45 +0000 Subject: [PATCH] Issue 257: In the Paintbrush selection screen, outline the current brush git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1478 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/buttons.c | 50 +++++++++++++++++++++++++++++++++++++------------- src/windows.c | 3 ++- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/buttons.c b/src/buttons.c index 7e7ca04b..2c778add 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -2719,6 +2719,26 @@ void Button_Unselect_fill(void) //---------------------------- Menu des pinceaux ----------------------------- +/// Checks if the current brush is identical to a preset one. +byte Is_paintbrush(byte index) +{ + if (Paintbrush_shape!=Gfx->Paintbrush_type[index] || + Paintbrush_width!=Gfx->Preset_paintbrush_width[index] || + Paintbrush_height!=Gfx->Preset_paintbrush_height[index]) + return 0; + + if (Paintbrush_shape==PAINTBRUSH_SHAPE_MISC) + { + // Check all pixels + int x,y; + for(y=0;yPaintbrush_sprite[index][y][x]) + return 0; + } + return 1; +} + void Button_Paintbrush_menu(void) { short clicked_button; @@ -2736,6 +2756,10 @@ void Button_Paintbrush_menu(void) x_pos=13+(index%12)*24; y_pos=27+(index/12)*25; Window_set_normal_button(x_pos ,y_pos ,20,20,"",0,1,SDLK_LAST); + // Highlight selected brush + if (Is_paintbrush(index)) + Window_rectangle(x_pos,y_pos,20,20,MC_White); + Display_paintbrush_in_window(x_pos+2,y_pos+2,index); } for (index=0; index1 && Window_attribute1==LEFT_SIDE) // Standard paintbrushes - { + { Close_window(); - index=clicked_button-2; - Paintbrush_shape=Gfx->Paintbrush_type[index]; - Paintbrush_width=Gfx->Preset_paintbrush_width[index]; - Paintbrush_height=Gfx->Preset_paintbrush_height[index]; - Paintbrush_offset_X=Gfx->Preset_paintbrush_offset_X[index]; - Paintbrush_offset_Y=Gfx->Preset_paintbrush_offset_Y[index]; - for (y_pos=0; y_posPaintbrush_sprite[index][y_pos][x_pos]; - Change_paintbrush_shape(Gfx->Paintbrush_type[index]); + index=clicked_button-2; + Paintbrush_shape=Gfx->Paintbrush_type[index]; + Paintbrush_width=Gfx->Preset_paintbrush_width[index]; + Paintbrush_height=Gfx->Preset_paintbrush_height[index]; + Paintbrush_offset_X=Gfx->Preset_paintbrush_offset_X[index]; + Paintbrush_offset_Y=Gfx->Preset_paintbrush_offset_Y[index]; + for (y_pos=0; y_posPaintbrush_sprite[index][y_pos][x_pos]; + Change_paintbrush_shape(Gfx->Paintbrush_type[index]); break; } diff --git a/src/windows.c b/src/windows.c index a528d327..754ffc2d 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1291,7 +1291,8 @@ void Display_paintbrush_in_window(word x,word y,int number) for (window_y_pos=0,y_pos=0; y_posPreset_paintbrush_height[number]; window_y_pos++,y_pos++) for (window_x_pos=0,x_pos=0; x_posPreset_paintbrush_width[number]; window_x_pos++,x_pos++) - Block(origin_x+window_x_pos*x_size,origin_y+window_y_pos*y_size,x_size,y_size,(Gfx->Paintbrush_sprite[number][y_pos][x_pos])?MC_Black:MC_Light); + if (Gfx->Paintbrush_sprite[number][y_pos][x_pos]) + Block(origin_x+window_x_pos*x_size,origin_y+window_y_pos*y_size,x_size,y_size,MC_Black); // On n'utilise pas Pixel_in_window() car on ne dessine pas // forcément avec la même taille de pixel.