Quick shortcuts for numeric transparency levels (Issue 154) (defaults 1-9 and 0). Shortcut for all effects off (default shift-E)

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@864 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-06-14 19:48:03 +00:00
parent fb05f785bd
commit 8478d29373
7 changed files with 283 additions and 48 deletions

View File

@ -3544,7 +3544,6 @@ void Button_Smear_mode(void)
Smear_mode=!Smear_mode;
}
// -- Mode Colorize ---------------------------------------------------------
void Compute_colorize_table(void)
{
@ -3792,6 +3791,76 @@ void Button_Tiling_menu(void)
Display_cursor();
}
// -- All modes off ---------------------------------------------------------
void Effects_off(void)
{
Effect_function=No_effect;
Shade_mode=0;
Quick_shade_mode=0;
Colorize_mode=0;
Smooth_mode=0;
Tiling_mode=0;
Smear_mode=0;
Stencil_mode=0;
Mask_mode=0;
Sieve_mode=0;
Snap_mode=0;
if (! Windows_open)
{
}
}
void Transparency_set(byte amount)
{
const int doubleclick_delay = 500;
static long time_click = 0;
long time_previous;
if (!Colorize_mode)
{
// Activate mode
switch(Colorize_current_mode)
{
case 0 :
Effect_function=Effect_interpolated_colorize;
break;
case 1 :
Effect_function=Effect_additive_colorize;
break;
case 2 :
Effect_function=Effect_substractive_colorize;
}
Shade_mode=0;
Quick_shade_mode=0;
Smooth_mode=0;
Tiling_mode=0;
Colorize_mode=1;
}
time_previous = time_click;
time_click = SDL_GetTicks();
// Check if it's a quick re-press
if (time_click - time_previous < doubleclick_delay)
{
// Use the typed amount as units, keep the tens.
Colorize_opacity = ((Colorize_opacity%100) /10 *10) + amount;
if (Colorize_opacity == 0)
Colorize_opacity = 100;
}
else
{
// Use 10% units: "1"=10%, ... "0"=100%
if (amount == 0)
Colorize_opacity = 100;
else
Colorize_opacity = amount*10;
}
Compute_colorize_table();
}
//---------------------------- Courbes de Bézier ----------------------------
@ -4970,17 +5039,7 @@ void Button_Effects(void)
exit_by_close_button=1;
break;
case 12 : // All off
Effect_function=No_effect;
Shade_mode=0;
Quick_shade_mode=0;
Colorize_mode=0;
Smooth_mode=0;
Tiling_mode=0;
Smear_mode=0;
Stencil_mode=0;
Mask_mode=0;
Sieve_mode=0;
Snap_mode=0;
Effects_off();
Hide_cursor();
Display_effect_states();
Display_cursor();

View File

@ -425,6 +425,17 @@ void Button_Tiling_mode(void);
Displays the tiling setup menu.
*/
void Button_Tiling_menu(void);
/*!
Callback for the command that turns off all drawaing effects.
*/
void Effects_off(void);
/*!
Command that sets the transparency level.
*/
void Transparency_set(byte amount);
// Menu des effets
/*!

13
const.h
View File

@ -33,7 +33,7 @@
#define BETA1 98 ///< Version number for gfx2.cfg (3/4)
#define BETA2 0 ///< Version number for gfx2.cfg (4/4)
#define MAX_VIDEO_MODES 100 ///< Maximum number of video modes Grafx2 can propose.
#define NB_SHORTCUTS 134 ///< Number of actions that can have a key combination associated to it.
#define NB_SHORTCUTS 145 ///< Number of actions that can have a key combination associated to it.
#define NB_ZOOM_FACTORS 12 ///< Number of zoom levels available in the magnifier.
#define MENU_WIDTH 254 ///< Width of the menu (not counting the palette)
#define MENU_HEIGHT 44 ///< Height of the menu.
@ -374,7 +374,18 @@ enum SPECIAL_ACTIONS
SPECIAL_SMOOTH_MODE,
SPECIAL_SMOOTH_MENU,
SPECIAL_SMEAR_MODE,
SPECIAL_EFFECTS_OFF,
SPECIAL_TILING_MODE,
SPECIAL_TRANSPARENCY_1,
SPECIAL_TRANSPARENCY_2,
SPECIAL_TRANSPARENCY_3,
SPECIAL_TRANSPARENCY_4,
SPECIAL_TRANSPARENCY_5,
SPECIAL_TRANSPARENCY_6,
SPECIAL_TRANSPARENCY_7,
SPECIAL_TRANSPARENCY_8,
SPECIAL_TRANSPARENCY_9,
SPECIAL_TRANSPARENCY_0,
SPECIAL_TILING_MENU, ///< This must be the last of the "effects" family
NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts
};

View File

@ -857,6 +857,50 @@ void Main_handler(void)
Button_Tiling_menu();
Key=0;
break;
case SPECIAL_EFFECTS_OFF :
Effects_off();
Key=0;
break;
case SPECIAL_TRANSPARENCY_1 :
Transparency_set(1);
Key=0;
break;
case SPECIAL_TRANSPARENCY_2 :
Transparency_set(2);
Key=0;
break;
case SPECIAL_TRANSPARENCY_3 :
Transparency_set(3);
Key=0;
break;
case SPECIAL_TRANSPARENCY_4 :
Transparency_set(4);
Key=0;
break;
case SPECIAL_TRANSPARENCY_5 :
Transparency_set(5);
Key=0;
break;
case SPECIAL_TRANSPARENCY_6 :
Transparency_set(6);
Key=0;
break;
case SPECIAL_TRANSPARENCY_7 :
Transparency_set(7);
Key=0;
break;
case SPECIAL_TRANSPARENCY_8 :
Transparency_set(8);
Key=0;
break;
case SPECIAL_TRANSPARENCY_9 :
Transparency_set(9);
Key=0;
break;
case SPECIAL_TRANSPARENCY_0 :
Transparency_set(0);
Key=0;
break;
default : // Gestion des touches de raccourci de bouton:
// Pour chaque bouton
shortcut_button=-1;

4
help.c
View File

@ -119,7 +119,7 @@ void Window_set_shortcut(int action_id)
while (Ordering[order_index]!=action_id)
{
order_index++;
if (order_index>=134)
if (order_index>=NB_SHORTCUTS)
{
Error(0);
return;
@ -130,7 +130,7 @@ void Window_set_shortcut(int action_id)
while (ConfigKey[config_index].Number!=order_index)
{
config_index++;
if (config_index>=134)
if (config_index>=NB_SHORTCUTS)
{
Error(0);
return;

View File

@ -159,6 +159,7 @@ static const T_Help_table helptable_help[] =
HELP_LINK ("Adjust picture: %s", 0x100+BUTTON_ADJUST)
HELP_LINK ("Flip picture menu: %s", 0x200+BUTTON_ADJUST)
HELP_LINK ("Effects menu: %s", 0x100+BUTTON_EFFECTS)
HELP_LINK ("Effects all off %s", SPECIAL_EFFECTS_OFF)
HELP_LINK ("Shade mode: %s", SPECIAL_SHADE_MODE)
HELP_LINK ("Shade menu: %s", SPECIAL_SHADE_MENU)
HELP_LINK ("Quick-shade mode: %s", SPECIAL_QUICK_SHADE_MODE)
@ -173,6 +174,16 @@ static const T_Help_table helptable_help[] =
HELP_LINK ("Sieve menu: %s", SPECIAL_SIEVE_MENU)
HELP_LINK ("Invert Sieve: %s", SPECIAL_INVERT_SIEVE)
HELP_LINK ("Colorize mode: %s", SPECIAL_COLORIZE_MODE)
HELP_LINK (" At opacity 10%%: %s", SPECIAL_TRANSPARENCY_1)
HELP_LINK (" At opacity 20%%: %s", SPECIAL_TRANSPARENCY_2)
HELP_LINK (" At opacity 30%%: %s", SPECIAL_TRANSPARENCY_3)
HELP_LINK (" At opacity 40%%: %s", SPECIAL_TRANSPARENCY_4)
HELP_LINK (" At opacity 50%%: %s", SPECIAL_TRANSPARENCY_5)
HELP_LINK (" At opacity 60%%: %s", SPECIAL_TRANSPARENCY_6)
HELP_LINK (" At opacity 70%%: %s", SPECIAL_TRANSPARENCY_7)
HELP_LINK (" At opacity 80%%: %s", SPECIAL_TRANSPARENCY_8)
HELP_LINK (" At opacity 90%%: %s", SPECIAL_TRANSPARENCY_9)
HELP_LINK (" At opacity 100%%: %s", SPECIAL_TRANSPARENCY_0)
HELP_LINK ("Colorize menu: %s", SPECIAL_COLORIZE_MENU)
HELP_LINK ("Smooth mode: %s", SPECIAL_SMOOTH_MODE)
HELP_LINK ("Smooth menu: %s", SPECIAL_SMOOTH_MENU)

103
hotkeys.c
View File

@ -1094,6 +1094,94 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = {
true,
SDLK_PERIOD, // .> (:/ en AZERTY)
0},
{134,
"Effects off",
"Turns off all drawing effects. This",
"is the same as the 'All off' button",
"in the Effects screen",
true,
SDLK_e|MOD_SHIFT, // Shift-E
0},
{135,
"Transparency 10%",
"Turns transparency on and sets its",
"opacity at 10%.",
"",
true,
SDLK_1, // 1
0},
{136,
"Transparency 20%",
"Turns transparency on and sets its",
"opacity at 20%.",
"",
true,
SDLK_1, // 1
0},
{137,
"Transparency 30%",
"Turns transparency on and sets its",
"opacity at 30%.",
"",
true,
SDLK_1, // 1
0},
{138,
"Transparency 40%",
"Turns transparency on and sets its",
"opacity at 40%.",
"",
true,
SDLK_1, // 1
0},
{139,
"Transparency 50%",
"Turns transparency on and sets its",
"opacity at 50%.",
"",
true,
SDLK_1, // 1
0},
{140,
"Transparency 60%",
"Turns transparency on and sets its",
"opacity at 60%.",
"",
true,
SDLK_1, // 1
0},
{141,
"Transparency 70%",
"Turns transparency on and sets its",
"opacity at 70%.",
"",
true,
SDLK_1, // 1
0},
{142,
"Transparency 80%",
"Turns transparency on and sets its",
"opacity at 80%.",
"",
true,
SDLK_1, // 1
0},
{143,
"Transparency 90%",
"Turns transparency on and sets its",
"opacity at 90%.",
"",
true,
SDLK_1, // 1
0},
{144,
"Transparency 0%",
"Turns transparency on and sets its",
"opacity at 0%.",
"",
true,
SDLK_1, // 1
0},
};
word Ordering[NB_SHORTCUTS]=
@ -1230,6 +1318,17 @@ word Ordering[NB_SHORTCUTS]=
SPECIAL_PREVIOUS_USER_FORECOLOR, // Previous user-defined foreground color
SPECIAL_NEXT_USER_BACKCOLOR, // Next user-defined background color
SPECIAL_PREVIOUS_USER_BACKCOLOR, // Previous user-defined background color
SPECIAL_SMALLER_PAINTBRUSH, // Rétrécir le pinceau
SPECIAL_BIGGER_PAINTBRUSH // Grossir le pinceau
SPECIAL_SMALLER_PAINTBRUSH, // Sets paintbrush size: smaller
SPECIAL_BIGGER_PAINTBRUSH, // Sets paintbrush size: bigger
SPECIAL_EFFECTS_OFF, // Turns off all effects
SPECIAL_TRANSPARENCY_1, // Sets transparency level 10%
SPECIAL_TRANSPARENCY_2, // Sets transparency level 20%
SPECIAL_TRANSPARENCY_3, // Sets transparency level 30%
SPECIAL_TRANSPARENCY_4, // Sets transparency level 40%
SPECIAL_TRANSPARENCY_5, // Sets transparency level 50%
SPECIAL_TRANSPARENCY_6, // Sets transparency level 60%
SPECIAL_TRANSPARENCY_7, // Sets transparency level 70%
SPECIAL_TRANSPARENCY_8, // Sets transparency level 80%
SPECIAL_TRANSPARENCY_9, // Sets transparency level 90%
SPECIAL_TRANSPARENCY_0, // Sets transparency level 00%
};