Fix part of Issue 168: Mouse3 shortcuts are no longer allowed at wrong moments during drawing.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@839 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-06-06 19:30:39 +00:00
parent 106912a5a0
commit fb4d2fdb43

72
input.c
View File

@ -167,6 +167,40 @@ 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)
@ -225,16 +259,16 @@ int Handle_mouse_click(SDL_MouseButtonEvent event)
break;
case SDL_BUTTON_MIDDLE:
Key = KEY_MOUSEMIDDLE|Key_modifiers(SDL_GetModState());
// TODO: systeme de répétition
Key = Inhibit_shortcut(KEY_MOUSEMIDDLE|Key_modifiers(SDL_GetModState()));
// TODO: repeat system maybe?
return 0;
case SDL_BUTTON_WHEELUP:
Key = KEY_MOUSEWHEELUP|Key_modifiers(SDL_GetModState());
Key = Inhibit_shortcut(KEY_MOUSEWHEELUP|Key_modifiers(SDL_GetModState()));
return 0;
case SDL_BUTTON_WHEELDOWN:
Key = KEY_MOUSEWHEELDOWN|Key_modifiers(SDL_GetModState());
Key = Inhibit_shortcut(KEY_MOUSEWHEELDOWN|Key_modifiers(SDL_GetModState()));
return 0;
default:
return 0;
@ -296,35 +330,7 @@ int Handle_key_press(SDL_KeyboardEvent event)
return Move_cursor_with_constraints();
}
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;
}
Key = Inhibit_shortcut(Key);
return 0;
}