Keyboard shortcuts that open a window now also close it (Issue 88). Fixed a recent bug that made contextual help in FX window only work once.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1004 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-08-23 00:41:40 +00:00
parent 8ac66726f2
commit 7bfdb28936
9 changed files with 85 additions and 30 deletions

View File

@ -429,6 +429,8 @@ byte Button_Quit_local_function(void)
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_QUIT, NULL); Window_help(BUTTON_QUIT, NULL);
else if (Is_shortcut(Key,0x100+BUTTON_QUIT))
clicked_button=1;
} }
while (clicked_button<=0); while (clicked_button<=0);
@ -526,7 +528,7 @@ void Button_Clear_with_backcolor(void)
} }
//---------- Menu dans lequel on tagge des couleurs (genre Stencil) ---------- //---------- Menu dans lequel on tagge des couleurs (genre Stencil) ----------
void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section) void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section, word close_shortcut)
{ {
short clicked_button; short clicked_button;
byte backup_table[256]; byte backup_table[256];
@ -626,6 +628,10 @@ void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_ca
Key=0; Key=0;
break; break;
} }
else if (Is_shortcut(Key,close_shortcut))
{
clicked_button=4;
}
} }
} }
while (clicked_button<4); while (clicked_button<4);
@ -664,7 +670,7 @@ void Stencil_update_color(byte color)
void Button_Stencil_menu(void) void Button_Stencil_menu(void)
{ {
Menu_tag_colors("Stencil",Stencil,&Stencil_mode,1, "STENCIL"); Menu_tag_colors("Stencil",Stencil,&Stencil_mode,1, "STENCIL", SPECIAL_STENCIL_MENU);
} }
@ -677,7 +683,7 @@ void Button_Mask_mode(void)
void Button_Mask_menu(void) void Button_Mask_menu(void)
{ {
Menu_tag_colors("Mask",Mask_table,&Mask_mode,1, "MASK"); Menu_tag_colors("Mask",Mask_table,&Mask_mode,1, "MASK", SPECIAL_MASK_MENU);
} }
@ -805,7 +811,7 @@ void Button_Settings(void)
// Button Show/Hide dans le fileselect // Button Show/Hide dans le fileselect
Window_set_normal_button(167, 28,131,14,"Hidden files: ",0,1,SDLK_LAST); // 1 Window_set_normal_button(167, 28,131,14,"Hidden files: ",0,1,SDLK_LAST); // 1
Window_set_normal_button(167, 43,131,14,"Hidden dir. : ",0,1,SDLK_LAST); // 2 Window_set_normal_button(167, 43,131,14,"Hidden dir. : ",0,1,SDLK_LAST); // 2
// Window_set_normal_button(167, 58,131,14,"System dir. : ",0,1,SDLK_LAST); // 3 // Window_set_normal_button(167, 58,131,14,"System dir. : ",0,1,SDLK_LAST);
// Button Show/Hide Picture limits // Button Show/Hide Picture limits
Window_set_normal_button( 9, 81,107,14,"Limits : ",0,1,SDLK_LAST); // 3 Window_set_normal_button( 9, 81,107,14,"Limits : ",0,1,SDLK_LAST); // 3
@ -817,31 +823,31 @@ void Button_Settings(void)
Window_set_normal_button( 9,126,107,14,"Backup : ",0,1,SDLK_LAST); // 6 Window_set_normal_button( 9,126,107,14,"Backup : ",0,1,SDLK_LAST); // 6
// Button Safety colors // Button Safety colors
Window_set_normal_button(117, 81,131,14,"Safe. colors: ",0,1,SDLK_LAST); // 8 Window_set_normal_button(117, 81,131,14,"Safe. colors: ",0,1,SDLK_LAST); // 7
// Button Adjust Brush Pick // Button Adjust Brush Pick
Window_set_normal_button(117, 96,131,14,"AdjBrushPick: ",0,1,SDLK_LAST); // 9 Window_set_normal_button(117, 96,131,14,"AdjBrushPick: ",0,1,SDLK_LAST); // 8
// Button Separate colors // Button Separate colors
Window_set_normal_button(117,111,131,14,"Separate col: ",0,1,SDLK_LAST); // 10 Window_set_normal_button(117,111,131,14,"Separate col: ",0,1,SDLK_LAST); // 9
// Button Passer dans la résolution appropriée après un chargement // Button Passer dans la résolution appropriée après un chargement
Window_set_normal_button(117,126,131,14,"Auto-set res: ",0,1,SDLK_LAST); // 11 Window_set_normal_button(117,126,131,14,"Auto-set res: ",0,1,SDLK_LAST); // 10
// Button Adapter la palette après un chargement (<=> Shift+BkSpc) // Button Adapter la palette après un chargement (<=> Shift+BkSpc)
Window_set_normal_button(117,141,131,14,"Coords: ",0,1,SDLK_LAST); // 12 Window_set_normal_button(117,141,131,14,"Coords: ",0,1,SDLK_LAST); // 11
// Button Reload // Button Reload
Window_set_normal_button( 6,163, 51,14,"Reload" ,0,1,SDLK_LAST); // 13 Window_set_normal_button( 6,163, 51,14,"Reload" ,0,1,SDLK_LAST); // 12
// Button Auto-save // Button Auto-save
Window_set_normal_button( 73,163,107,14,"Auto-save: ",0,1,SDLK_LAST); // 14 Window_set_normal_button( 73,163,107,14,"Auto-save: ",0,1,SDLK_LAST); // 13
// Button Save // Button Save
Window_set_normal_button(183,163, 51,14,"Save" ,0,1,SDLK_LAST); // 15 Window_set_normal_button(183,163, 51,14,"Save" ,0,1,SDLK_LAST); // 14
// Button Close // Button Close
Window_set_normal_button(250,163, 51,14,"Close" ,0,1,KEY_ESC); // 16 Window_set_normal_button(250,163, 51,14,"Close" ,0,1,KEY_ESC); // 15
// Jauges de sensibilité de la souris (X puis Y) // Jauges de sensibilité de la souris (X puis Y)
Window_set_scroller_button(265,99,56,4,1,0); // 17 Window_set_scroller_button(265,99,56,4,1,0); // 16
Window_set_scroller_button(279,99,56,4,1,0); // 18 Window_set_scroller_button(279,99,56,4,1,0); // 17
// Zone de saisie du nb de pages de Undo // Zone de saisie du nb de pages de Undo
Window_set_input_button(140,50,2); // 19 Window_set_input_button(140,50,2); // 18
Update_window_area(0,0,Window_width, Window_height); Update_window_area(0,0,Window_width, Window_height);
@ -944,6 +950,8 @@ void Button_Settings(void)
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_SETTINGS, NULL); Window_help(BUTTON_SETTINGS, NULL);
else if (Is_shortcut(Key,0x100+BUTTON_SETTINGS))
clicked_button=15;
} }
while ( (clicked_button!=15) && (Key!=SDLK_RETURN) ); while ( (clicked_button!=15) && (Key!=SDLK_RETURN) );
@ -1418,7 +1426,7 @@ void Copy_some_colors(void)
static byte mask_color_to_copy[256]; // static to use less stack static byte mask_color_to_copy[256]; // static to use less stack
memset(mask_color_to_copy,1,256); memset(mask_color_to_copy,1,256);
Menu_tag_colors("Tag colors to copy",mask_color_to_copy,&confirmation,0, NULL); Menu_tag_colors("Tag colors to copy",mask_color_to_copy,&confirmation,0, NULL, 0xFFFF);
if (confirmation && if (confirmation &&
(!Spare_image_is_modified || Confirmation_box("Spare page was modified. Proceed?"))) (!Spare_image_is_modified || Confirmation_box("Spare page was modified. Proceed?")))
@ -1455,6 +1463,8 @@ void Button_Copy_page(void)
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_PAGE, NULL); Window_help(BUTTON_PAGE, NULL);
else if (Is_shortcut(Key,0x200+BUTTON_PAGE))
clicked_button=6;
} }
while (clicked_button<=0); while (clicked_button<=0);
@ -2374,6 +2384,8 @@ void Button_Gradients(void)
Key=0; Key=0;
break; break;
} }
if (Is_shortcut(Key,0x200+BUTTON_GRADRECT))
clicked_button=6;
} }
} }
while (clicked_button<6); while (clicked_button<6);
@ -2512,7 +2524,6 @@ void Button_Paintbrush_menu(void)
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_PAINTBRUSHES, NULL); Window_help(BUTTON_PAINTBRUSHES, NULL);
// Brush container // Brush container
if (clicked_button>(NB_PAINTBRUSH_SPRITES+1)) if (clicked_button>(NB_PAINTBRUSH_SPRITES+1))
{ {
@ -2559,7 +2570,7 @@ void Button_Paintbrush_menu(void)
break; break;
} }
else if (clicked_button==1) else if (clicked_button==1 || Is_shortcut(Key,0x100+BUTTON_PAINTBRUSHES))
{ {
Close_window(); Close_window();
break; break;
@ -3371,6 +3382,8 @@ void Button_Magnify_menu(void)
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_MAGNIFIER, NULL); Window_help(BUTTON_MAGNIFIER, NULL);
else if (Is_shortcut(Key,0x200+BUTTON_MAGNIFIER))
clicked_button=1;
} }
while (clicked_button<=0); while (clicked_button<=0);
@ -3684,6 +3697,10 @@ void Button_Brush_FX(void)
Key=0; Key=0;
Window_help(BUTTON_BRUSH_EFFECTS, NULL); Window_help(BUTTON_BRUSH_EFFECTS, NULL);
} }
else if (Is_shortcut(Key,0x100+BUTTON_BRUSH_EFFECTS))
{
clicked_button=1;
}
} }
while (clicked_button<=0); while (clicked_button<=0);
@ -3858,6 +3875,8 @@ void Button_Smooth_menu(void)
} }
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_EFFECTS, "SMOOTH"); Window_help(BUTTON_EFFECTS, "SMOOTH");
else if (Is_shortcut(Key,SPECIAL_SMOOTH_MENU))
clicked_button=2;
} }
while ((clicked_button!=1) && (clicked_button!=2)); while ((clicked_button!=1) && (clicked_button!=2));
@ -4023,6 +4042,8 @@ void Button_Colorize_menu(void)
} }
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_EFFECTS, "TRANSPARENCY"); Window_help(BUTTON_EFFECTS, "TRANSPARENCY");
else if (Is_shortcut(Key,SPECIAL_COLORIZE_MENU))
clicked_button=6;
} }
while (clicked_button<5); while (clicked_button<5);
@ -4558,7 +4579,11 @@ void Button_Airbrush_menu(void)
Key=0; Key=0;
break; break;
} }
if (Is_shortcut(Key,0x200+BUTTON_AIRBRUSH))
{
clicked_button=2;
break;
}
} }
} }
while ( (clicked_button!=1) && (clicked_button!=2) ); while ( (clicked_button!=1) && (clicked_button!=2) );
@ -5175,14 +5200,13 @@ void Button_Effects(void)
{ {
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
if (Key==KEY_ESC) if (Key==KEY_ESC || Is_shortcut(Key,0x100+BUTTON_EFFECTS))
{ {
clicked_button=11; clicked_button=11;
Key=0; Key=0;
} }
else if (Is_shortcut(Key,0x100+BUTTON_HELP)) else if (Is_shortcut(Key,0x100+BUTTON_HELP))
{ {
Key=0;
// Aide contextuelle // Aide contextuelle
switch(Window_get_clicked_button()) switch(Window_get_clicked_button())
{ {
@ -5219,7 +5243,9 @@ void Button_Effects(void)
default: default:
Window_help(BUTTON_EFFECTS, NULL); Window_help(BUTTON_EFFECTS, NULL);
} }
continue; // Hack because we have used Window_get_clicked_button()
Input_sticky_control=0;
//
} }
switch (clicked_button) switch (clicked_button)
@ -5540,6 +5566,8 @@ void Button_Text()
{ {
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_TEXT, NULL); Window_help(BUTTON_TEXT, NULL);
else if (Is_shortcut(Key,0x100+BUTTON_TEXT))
clicked_button=12;
} }
switch(clicked_button) switch(clicked_button)
{ {

View File

@ -637,7 +637,7 @@ void Save_picture(byte image);
/*! /*!
Generic color tagging menu, for various effects. Generic color tagging menu, for various effects.
*/ */
void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section); void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section, word close_shortcut );
/*! /*!

View File

@ -778,7 +778,7 @@ void Main_handler(void)
Key=0; Key=0;
break; break;
case SPECIAL_EXCLUDE_COLORS_MENU : // Exclude colors menu case SPECIAL_EXCLUDE_COLORS_MENU : // Exclude colors menu
Menu_tag_colors("Tag colors to exclude",Exclude_color,&temp,1, NULL); Menu_tag_colors("Tag colors to exclude",Exclude_color,&temp,1, NULL, SPECIAL_EXCLUDE_COLORS_MENU);
Key=0; Key=0;
break; break;
case SPECIAL_INVERT_SIEVE : case SPECIAL_INVERT_SIEVE :

View File

@ -1030,6 +1030,12 @@ byte Button_Load_or_Save(byte load, byte image)
char quicksearch_filename[MAX_PATH_CHARACTERS]=""; char quicksearch_filename[MAX_PATH_CHARACTERS]="";
char save_filename[MAX_PATH_CHARACTERS]; char save_filename[MAX_PATH_CHARACTERS];
char * most_matching_filename; char * most_matching_filename;
short window_shortcut;
if (image)
window_shortcut = load?(0x100+BUTTON_LOAD):(0x100+BUTTON_SAVE);
else
window_shortcut = load?SPECIAL_LOAD_BRUSH:SPECIAL_SAVE_BRUSH;
initial_palette=(T_Components *)malloc(sizeof(T_Palette)); initial_palette=(T_Components *)malloc(sizeof(T_Palette));
memcpy(initial_palette,Main_palette,sizeof(T_Palette)); memcpy(initial_palette,Main_palette,sizeof(T_Palette));
@ -1550,7 +1556,7 @@ byte Button_Load_or_Save(byte load, byte image)
} }
Key=0; Key=0;
break; break;
default: // Autre => On se place sur le nom de fichier qui correspond default:
if (clicked_button<=0) if (clicked_button<=0)
{ {
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
@ -1558,6 +1564,12 @@ byte Button_Load_or_Save(byte load, byte image)
Window_help(load?BUTTON_LOAD:BUTTON_SAVE, NULL); Window_help(load?BUTTON_LOAD:BUTTON_SAVE, NULL);
break; break;
} }
if (Is_shortcut(Key,window_shortcut))
{
clicked_button=2;
break;
}
// Autre => On se place sur le nom de fichier qui correspond
temp=strlen(quicksearch_filename); temp=strlen(quicksearch_filename);
if (Key_ANSI>= ' ' && Key_ANSI < 255 && temp<50) if (Key_ANSI>= ' ' && Key_ANSI < 255 && temp<50)
{ {

7
help.c
View File

@ -585,11 +585,12 @@ void Window_help(int section, const char *sub_section)
} }
break; break;
} }
if (Is_shortcut(Key,0x100+BUTTON_HELP))
clicked_button=1;
} }
while ((clicked_button!=1) && (Key!=SDLK_RETURN)); while ((clicked_button!=1) && (Key!=SDLK_RETURN));
if(Key==SDLK_RETURN) Key=0; Key=0;
Close_window(); Close_window();
Unselect_button(BUTTON_HELP); Unselect_button(BUTTON_HELP);
Display_cursor(); Display_cursor();
@ -698,6 +699,8 @@ void Button_Stats(void)
do do
{ {
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
if (Is_shortcut(Key,0x200+BUTTON_HELP))
clicked_button=1;
} }
while ( (clicked_button!=1) && (Key!=SDLK_RETURN) ); while ( (clicked_button!=1) && (Key!=SDLK_RETURN) );

View File

@ -82,7 +82,7 @@ short Joybutton_right_click=0; // Button number that serves as right-click
int Is_shortcut(word Key, word function) int Is_shortcut(word Key, word function)
{ {
if (Key == 0) if (Key == 0 || function == 0xFFFF)
return 0; return 0;
if (function & 0x100) if (function & 0x100)

View File

@ -2097,6 +2097,8 @@ void Button_Palette(void)
Window_help(BUTTON_PALETTE, NULL); Window_help(BUTTON_PALETTE, NULL);
break; break;
} }
else if (Is_shortcut(Key,0x100+BUTTON_PALETTE))
clicked_button=14;
} }
if (need_to_remap) if (need_to_remap)
@ -2221,6 +2223,9 @@ void Button_Secondary_palette(void)
Key=0; Key=0;
Window_help(BUTTON_PALETTE, "PALETTE OPTIONS"); Window_help(BUTTON_PALETTE, "PALETTE OPTIONS");
} }
else if (Is_shortcut(Key,0x200+BUTTON_PALETTE))
clicked_button=3;
switch(clicked_button) switch(clicked_button)
{ {
case 5: case 5:
@ -2298,7 +2303,7 @@ void Button_Secondary_palette(void)
if (clicked_button==1) if (clicked_button==1)
{ {
Menu_tag_colors("Tag colors to exclude",Exclude_color,&dummy,1, NULL); Menu_tag_colors("Tag colors to exclude",Exclude_color,&dummy,1, NULL, SPECIAL_EXCLUDE_COLORS_MENU);
} }
else if (clicked_button==2) else if (clicked_button==2)
{ {

View File

@ -978,6 +978,8 @@ int Menu_shade(void)
Key=0; Key=0;
Window_help(BUTTON_EFFECTS, "SHADE"); Window_help(BUTTON_EFFECTS, "SHADE");
} }
else if (Is_shortcut(Key,SPECIAL_SHADE_MENU))
clicked_button=5;
} }
} }
while ((clicked_button!=4) && (clicked_button!=5)); while ((clicked_button!=4) && (clicked_button!=5));
@ -1097,6 +1099,8 @@ void Button_Quick_shade_menu(void)
} }
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_EFFECTS, "QUICK SHADE"); Window_help(BUTTON_EFFECTS, "QUICK SHADE");
else if (Is_shortcut(Key,SPECIAL_QUICK_SHADE_MENU))
clicked_button=1;
} }
while ((clicked_button!=1) && (clicked_button!=2)); while ((clicked_button!=1) && (clicked_button!=2));

View File

@ -196,6 +196,9 @@ void Button_Transform_menu(void)
Key=0; Key=0;
Window_help(BUTTON_ADJUST, "PICTURE TRANSFORM"); Window_help(BUTTON_ADJUST, "PICTURE TRANSFORM");
} }
else if (Is_shortcut(Key,0x200+BUTTON_ADJUST))
clicked_button=1;
else switch(clicked_button) else switch(clicked_button)
{ {
case 9: // Unit case 9: // Unit