trunk: Continued the handling of multiple effect on single shortcuts. Multiple window-open work (one after an other), and the restriction on shortcuts that are disabled while drawing is now applied correctly.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1063 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-10-06 23:24:00 +00:00
parent 5fd28bdd3b
commit 6f8223b09b
5 changed files with 82 additions and 94 deletions

View File

@ -1488,7 +1488,7 @@ void Button_Copy_page(void)
Copy_image_only();
if (clicked_button==5)
Remap_picture();
Remap_spare();
if (clicked_button!=2) // copie de la palette
memcpy(Spare_palette,Main_palette,sizeof(T_Palette));

128
engine.c
View File

@ -481,6 +481,7 @@ void Main_handler(void)
byte temp;
byte effect_modified;
byte action;
dword key_pressed;
do
{
@ -500,6 +501,12 @@ void Main_handler(void)
{
action = 0;
// Inhibit all keys if a drawing operation is in progress.
// We make an exception for the freehand operations, but these will
// only accept a very limited number of shortcuts.
if (Operation_stack_size!=0 && !Allow_color_change_during_operation)
Key=0;
// Evenement de fermeture
if (Quit_is_required)
{
@ -507,7 +514,6 @@ void Main_handler(void)
Button_Quit();
}
// Gestion des touches
if (Key)
{
effect_modified = 0;
@ -518,6 +524,54 @@ void Main_handler(void)
{
// Special keys (functions not hooked to a UI button)
switch(key_index)
{
case SPECIAL_NEXT_FORECOLOR : // Next foreground color
Special_next_forecolor();
action++;
break;
case SPECIAL_PREVIOUS_FORECOLOR : // Previous foreground color
Special_previous_forecolor();
action++;
break;
case SPECIAL_NEXT_BACKCOLOR : // Next background color
Special_next_backcolor();
action++;
break;
case SPECIAL_PREVIOUS_BACKCOLOR : // Previous background color
Special_previous_backcolor();
action++;
break;
case SPECIAL_SMALLER_PAINTBRUSH: // Rétrécir le pinceau
Smaller_paintbrush();
action++;
break;
case SPECIAL_BIGGER_PAINTBRUSH: // Grossir le pinceau
Bigger_paintbrush();
action++;
break;
case SPECIAL_NEXT_USER_FORECOLOR : // Next user-defined foreground color
Special_next_user_forecolor();
action++;
break;
case SPECIAL_PREVIOUS_USER_FORECOLOR : // Previous user-defined foreground color
Special_previous_user_forecolor();
action++;
break;
case SPECIAL_NEXT_USER_BACKCOLOR : // Next user-defined background color
Special_next_user_backcolor();
action++;
break;
case SPECIAL_PREVIOUS_USER_BACKCOLOR : // Previous user-defined background color
Special_previous_user_backcolor();
action++;
break;
}
// Other shortcuts are forbidden while an operation is in progress
if (Operation_stack_size!=0)
continue;
switch (key_index)
{
case SPECIAL_SCROLL_UP : // Scroll up
if (Main_magnifier_mode)
@ -603,46 +657,6 @@ void Main_handler(void)
Scroll_screen(1,0);
action++;
break;
case SPECIAL_NEXT_FORECOLOR : // Next foreground color
Special_next_forecolor();
action++;
break;
case SPECIAL_PREVIOUS_FORECOLOR : // Previous foreground color
Special_previous_forecolor();
action++;
break;
case SPECIAL_NEXT_BACKCOLOR : // Next background color
Special_next_backcolor();
action++;
break;
case SPECIAL_PREVIOUS_BACKCOLOR : // Previous background color
Special_previous_backcolor();
action++;
break;
case SPECIAL_SMALLER_PAINTBRUSH: // Rétrécir le pinceau
Smaller_paintbrush();
action++;
break;
case SPECIAL_BIGGER_PAINTBRUSH: // Grossir le pinceau
Bigger_paintbrush();
action++;
break;
case SPECIAL_NEXT_USER_FORECOLOR : // Next user-defined foreground color
Special_next_user_forecolor();
action++;
break;
case SPECIAL_PREVIOUS_USER_FORECOLOR : // Previous user-defined foreground color
Special_previous_user_forecolor();
action++;
break;
case SPECIAL_NEXT_USER_BACKCOLOR : // Next user-defined background color
Special_next_user_backcolor();
action++;
break;
case SPECIAL_PREVIOUS_USER_BACKCOLOR : // Previous user-defined background color
Special_previous_user_backcolor();
action++;
break;
case SPECIAL_SHOW_HIDE_CURSOR : // Show / Hide cursor
Hide_cursor();
Cursor_hidden=!Cursor_hidden;
@ -1000,20 +1014,28 @@ void Main_handler(void)
}
} // End of special keys
// Shortcut for functions of Menu buttons
for (button_index=0;button_index<NB_BUTTONS;button_index++)
// Shortcut for clicks of Menu buttons.
// Disable all of them when an operation is in progress
if (Operation_stack_size==0)
{
if (Is_shortcut(Key,0x100+button_index))
// Some functions open windows that clear the Key variable,
// so we need to use a temporary replacement.
key_pressed = Key;
for (button_index=0;button_index<NB_BUTTONS;button_index++)
{
Select_button(button_index,LEFT_SIDE);
prev_button_number=-1;
action++;
}
else if (Is_shortcut(Key,0x200+button_index))
{
Select_button(button_index,RIGHT_SIDE);
prev_button_number=-1;
action++;
if (Is_shortcut(key_pressed,0x100+button_index))
{
Select_button(button_index,LEFT_SIDE);
prev_button_number=-1;
action++;
}
else if (Is_shortcut(key_pressed,0x200+button_index))
{
Select_button(button_index,RIGHT_SIDE);
prev_button_number=-1;
action++;
}
}
}

View File

@ -617,7 +617,7 @@ void Resize_image(word chosen_width,word chosen_height)
void Remap_picture(void)
void Remap_spare(void)
{
short x_pos; // Variable de balayage de la brosse
short y_pos; // Variable de balayage de la brosse

View File

@ -95,7 +95,8 @@ void Draw_grad_rectangle(short rax,short ray,short rbx,short rby,short vax,short
void Polyfill_general(int vertices, short * points, int color);
void Polyfill(int vertices, short * points, int color);
void Remap_picture(void);
/// Remap the spare page according to the main page's palette
void Remap_spare(void);
///
/// All the figure-drawing functions work by calling this function for each

41
input.c
View File

@ -202,40 +202,6 @@ int Move_cursor_with_constraints()
return feedback;
}
// Inhibits a key shortcut if it's disallowed during an operation.
dword Inhibit_shortcut(dword key)
{
if (Operation_stack_size!=0 && key != 0)
{
//Enfin, on inhibe les touches (sauf si c'est un changement de couleur
//ou de taille de pinceau lors d'une des operations suivantes:
//OPERATION_CONTINUOUS_DRAW, OPERATION_DISCONTINUOUS_DRAW, OPERATION_AIRBRUSH)
if(Allow_color_change_during_operation)
{
//A ce stade là, on sait qu'on est dans une des 3 opérations
//supportant le changement de couleur ou de taille de pinceau.
if(
(!Is_shortcut(key,SPECIAL_NEXT_FORECOLOR)) &&
(!Is_shortcut(key,SPECIAL_PREVIOUS_FORECOLOR)) &&
(!Is_shortcut(key,SPECIAL_NEXT_BACKCOLOR)) &&
(!Is_shortcut(key,SPECIAL_PREVIOUS_BACKCOLOR)) &&
(!Is_shortcut(key,SPECIAL_SMALLER_PAINTBRUSH)) &&
(!Is_shortcut(key,SPECIAL_BIGGER_PAINTBRUSH)) &&
(!Is_shortcut(key,SPECIAL_NEXT_USER_FORECOLOR)) &&
(!Is_shortcut(key,SPECIAL_PREVIOUS_USER_FORECOLOR)) &&
(!Is_shortcut(key,SPECIAL_NEXT_USER_BACKCOLOR)) &&
(!Is_shortcut(key,SPECIAL_PREVIOUS_USER_BACKCOLOR))
)
{
key=0;
}
}
else key = 0;
}
return key;
}
// WM events management
void Handle_window_resize(SDL_ResizeEvent event)
@ -294,16 +260,16 @@ int Handle_mouse_click(SDL_MouseButtonEvent event)
break;
case SDL_BUTTON_MIDDLE:
Key = Inhibit_shortcut(KEY_MOUSEMIDDLE|Key_modifiers(SDL_GetModState()));
Key = KEY_MOUSEMIDDLE|Key_modifiers(SDL_GetModState());
// TODO: repeat system maybe?
return 0;
case SDL_BUTTON_WHEELUP:
Key = Inhibit_shortcut(KEY_MOUSEWHEELUP|Key_modifiers(SDL_GetModState()));
Key = KEY_MOUSEWHEELUP|Key_modifiers(SDL_GetModState());
return 0;
case SDL_BUTTON_WHEELDOWN:
Key = Inhibit_shortcut(KEY_MOUSEWHEELDOWN|Key_modifiers(SDL_GetModState()));
Key = KEY_MOUSEWHEELDOWN|Key_modifiers(SDL_GetModState());
return 0;
default:
return 0;
@ -368,7 +334,6 @@ int Handle_key_press(SDL_KeyboardEvent event)
return Move_cursor_with_constraints();
}
Key = Inhibit_shortcut(Key);
return 0;
}