Added new draw_color() action that greys colors w/o disabling them.

Fixed bug where colors would be unavailable after returning from slideshow.
This commit is contained in:
William Kendrick 2006-10-10 07:22:19 +00:00
parent 1a8d15aa7a
commit b49e484403

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - September 9, 2006 June 14, 2002 - October 9, 2006
$Id$ $Id$
*/ */
@ -109,6 +109,7 @@
#define COLORSEL_ENABLE 1 // enable and draw the colors #define COLORSEL_ENABLE 1 // enable and draw the colors
#define COLORSEL_CLOBBER 2 // colors get scribbled over #define COLORSEL_CLOBBER 2 // colors get scribbled over
#define COLORSEL_REFRESH 4 // redraw the colors, either on or off #define COLORSEL_REFRESH 4 // redraw the colors, either on or off
#define COLORSEL_CLOBBER_WIPE 8 // draw the (greyed out) colors, but don't disable
static unsigned draw_colors(unsigned action); static unsigned draw_colors(unsigned action);
@ -1168,7 +1169,7 @@ static int do_png_save(FILE * fi, const char *const fname,
static void get_new_file_id(void); static void get_new_file_id(void);
static int do_quit(void); static int do_quit(void);
void do_open(void); void do_open(void);
void do_slideshow(void); int do_slideshow(void);
void play_slideshow(int * selected, int num_selected, char * dirname, void play_slideshow(int * selected, int num_selected, char * dirname,
char **d_names, char **d_exts, int speed); char **d_names, char **d_exts, int speed);
void draw_selection_digits(int right, int bottom, int n); void draw_selection_digits(int right, int bottom, int n);
@ -1668,7 +1669,7 @@ static void mainloop(void)
disable_avail_tools(); disable_avail_tools();
draw_toolbar(); draw_toolbar();
draw_colors(COLORSEL_CLOBBER); draw_colors(COLORSEL_CLOBBER_WIPE);
draw_none(); draw_none();
do_open(); do_open();
@ -2050,7 +2051,7 @@ static void mainloop(void)
{ {
disable_avail_tools(); disable_avail_tools();
draw_toolbar(); draw_toolbar();
draw_colors(COLORSEL_CLOBBER); draw_colors(COLORSEL_CLOBBER_WIPE);
draw_none(); draw_none();
do_open(); do_open();
@ -7625,23 +7626,27 @@ static unsigned draw_colors(unsigned action)
unsigned i; unsigned i;
SDL_Rect dest; SDL_Rect dest;
static unsigned old_color; static unsigned old_color;
unsigned old_colors_state;
unsigned old_colors_state = colors_state; old_colors_state = colors_state;
if (action == COLORSEL_CLOBBER)
if (action == COLORSEL_CLOBBER || action == COLORSEL_CLOBBER_WIPE)
colors_state |= COLORSEL_CLOBBER; colors_state |= COLORSEL_CLOBBER;
if (action == COLORSEL_REFRESH) else if (action == COLORSEL_REFRESH)
colors_state &= ~COLORSEL_CLOBBER; colors_state &= ~COLORSEL_CLOBBER;
if (action == COLORSEL_DISABLE) else if (action == COLORSEL_DISABLE)
colors_state = COLORSEL_DISABLE; colors_state = COLORSEL_DISABLE;
if (action == COLORSEL_ENABLE) else if (action == COLORSEL_ENABLE)
colors_state = COLORSEL_ENABLE; colors_state = COLORSEL_ENABLE;
colors_are_selectable = colors_state == COLORSEL_ENABLE; colors_are_selectable = (colors_state == COLORSEL_ENABLE);
if (colors_state & COLORSEL_CLOBBER) if (colors_state & COLORSEL_CLOBBER && action != COLORSEL_CLOBBER_WIPE)
return old_colors_state; return old_colors_state;
if (cur_color == old_color && colors_state == old_colors_state) if (cur_color == old_color && colors_state == old_colors_state &&
action != COLORSEL_CLOBBER_WIPE)
return old_colors_state; return old_colors_state;
old_color = cur_color; old_color = cur_color;
for (i = 0; i < (unsigned int) NUM_COLORS; i++) for (i = 0; i < (unsigned int) NUM_COLORS; i++)
@ -7663,6 +7668,7 @@ static unsigned draw_colors(unsigned action)
color_hexes[i][1], color_hexes[i][2])); color_hexes[i][1], color_hexes[i][2]));
else else
SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 240, 240, 240)); SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 240, 240, 240));
if (i == cur_color && colors_state == COLORSEL_ENABLE) if (i == cur_color && colors_state == COLORSEL_ENABLE)
{ {
dest.y += 4; dest.y += 4;
@ -7693,6 +7699,7 @@ static unsigned draw_colors(unsigned action)
} }
update_screen_rect(&r_tcolors); update_screen_rect(&r_tcolors);
return old_colors_state; return old_colors_state;
} }
@ -11866,6 +11873,8 @@ void do_open(void)
int last_click_which, last_click_button; int last_click_which, last_click_button;
int places_to_look; int places_to_look;
do
{
do_setcursor(cursor_watch); do_setcursor(cursor_watch);
/* Allocate some space: */ /* Allocate some space: */
@ -12957,16 +12966,18 @@ void do_open(void)
if (slideshow) if (slideshow)
{ {
do_slideshow(); slideshow = do_slideshow();
} }
} }
while (slideshow);
}
/* FIXME: This, and do_open(), should be combined and modularized! */ /* FIXME: This, and do_open(), should be combined and modularized! */
/* Slide Show Selection Screen: */ /* Slide Show Selection Screen: */
void do_slideshow(void) int do_slideshow(void)
{ {
SDL_Surface *img, *img1, *img2; SDL_Surface *img, *img1, *img2;
int things_alloced; int things_alloced;
@ -13572,9 +13583,7 @@ void do_slideshow(void)
SDL_FillRect(screen, NULL, SDL_MapRGB(canvas->format, 255, 255, 255)); SDL_FillRect(screen, NULL, SDL_MapRGB(canvas->format, 255, 255, 255));
draw_toolbar(); draw_toolbar();
draw_colors(COLORSEL_CLOBBER); draw_colors(COLORSEL_CLOBBER_WIPE);
draw_colors(COLORSEL_REFRESH);
draw_colors(COLORSEL_DISABLE);
draw_none(); draw_none();
freeme = textdir(gettext_noop("Choose the pictures you want, " freeme = textdir(gettext_noop("Choose the pictures you want, "
@ -13730,8 +13739,7 @@ void do_slideshow(void)
free(selected); free(selected);
if (go_back == 1) return go_back;
do_open();
} }