Implemented 'Right click colorpick' option (Issue 300)
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1491 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
e102282dca
commit
acd31e1a3a
100
src/brush_ops.c
100
src/brush_ops.c
@ -251,6 +251,106 @@ void Colorpicker_0_1(void)
|
||||
Unselect_button(BUTTON_COLORPICKER);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////// OPERATION_RMB_COLORPICK
|
||||
|
||||
|
||||
byte Rightclick_colorpick(byte cursor_visible)
|
||||
{
|
||||
// Check if the rightclick colorpick should take over:
|
||||
if (!Config.Right_click_colorpick)
|
||||
return 0;
|
||||
if (Mouse_K!=RIGHT_SIDE)
|
||||
return 0;
|
||||
// In these modes, the Foreground color is ignored,
|
||||
// so the RMB should act as normal.
|
||||
if (Shade_mode||Quick_shade_mode||Tiling_mode)
|
||||
return 0;
|
||||
|
||||
Colorpicker_color=-1;
|
||||
Colorpicker_X=-1;
|
||||
Colorpicker_Y=-1;
|
||||
|
||||
if (cursor_visible)
|
||||
Hide_cursor();
|
||||
Start_operation_stack(OPERATION_RMB_COLORPICK);
|
||||
|
||||
Init_start_operation();
|
||||
|
||||
// Just an indicator to go to next step
|
||||
Operation_push(1);
|
||||
Rightclick_colorpick_2_1();
|
||||
|
||||
if (cursor_visible)
|
||||
Display_cursor();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Rightclick_colorpick_2_1(void)
|
||||
//
|
||||
// Opération : OPERATION_RMB_COLORPICK
|
||||
// Click Souris: 2
|
||||
// Taille_Pile : 1
|
||||
//
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
char str[4];
|
||||
|
||||
if ( (Colorpicker_X!=Paintbrush_X)
|
||||
|| (Colorpicker_Y!=Paintbrush_Y) )
|
||||
{
|
||||
if ( (Paintbrush_X>=0) && (Paintbrush_Y>=0)
|
||||
&& (Paintbrush_X<Main_image_width)
|
||||
&& (Paintbrush_Y<Main_image_height) )
|
||||
Colorpicker_color=Read_pixel_from_current_screen(Paintbrush_X,Paintbrush_Y);
|
||||
else
|
||||
Colorpicker_color=0;
|
||||
|
||||
Colorpicker_X=Paintbrush_X;
|
||||
Colorpicker_Y=Paintbrush_Y;
|
||||
|
||||
if (Menu_is_visible)
|
||||
{
|
||||
Print_coordinates();
|
||||
Num2str(Colorpicker_color,str,3);
|
||||
Print_in_menu(str,20);
|
||||
Print_general(170*Menu_factor_X,Menu_status_Y," ",0,Colorpicker_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Rightclick_colorpick_0_1(void)
|
||||
//
|
||||
// Opération : OPERATION_RMB_COLORPICK
|
||||
// Click Souris: 0
|
||||
// Taille_Pile : 1
|
||||
//
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
short dummy;
|
||||
|
||||
Hide_cursor();
|
||||
|
||||
Operation_pop(&dummy);
|
||||
Set_fore_color(Colorpicker_color);
|
||||
|
||||
// Restore previous operation
|
||||
Start_operation_stack(Operation_before_interrupt);
|
||||
|
||||
// Erase the color block which shows the picked color
|
||||
if (Operation_before_interrupt!=OPERATION_REPLACE)
|
||||
if ( (Mouse_Y<Menu_Y) && (Menu_is_visible) &&
|
||||
( (!Main_magnifier_mode) || (Mouse_X<Main_separator_position) || (Mouse_X>=Main_X_zoom) ) )
|
||||
Print_in_menu("X: Y: ",0);
|
||||
|
||||
Print_coordinates();
|
||||
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////// OPERATION_GRAB_BRUSH
|
||||
|
||||
|
||||
@ -920,7 +920,7 @@ void Button_Settings(void)
|
||||
|
||||
T_Setting setting[SETTING_PER_PAGE*SETTING_PAGES] = {
|
||||
|
||||
{" --- GUI ---",0,NULL,0,0,0,NULL},
|
||||
{" --- GUI ---",0,NULL,0,0,0,NULL},
|
||||
{"",0,NULL,0,0,0,NULL},
|
||||
{"Opening message:",1,&(selected_config.Opening_message),0,1,0,Lookup_YesNo},
|
||||
{"Menu ratio adapt:",1,&(selected_config.Ratio),0,1,0,Lookup_MenuRatio},
|
||||
@ -953,7 +953,7 @@ void Button_Settings(void)
|
||||
{"Clear with stencil:",1,&(selected_config.Clear_with_stencil),0,1,0,Lookup_YesNo},
|
||||
{"Auto discontinuous:",1,&(selected_config.Auto_discontinuous),0,1,0,Lookup_YesNo},
|
||||
{"Auto count colors:",1,&(selected_config.Auto_nb_used),0,1,0,Lookup_YesNo},
|
||||
{"",0,NULL,0,0,0,NULL},
|
||||
{"Right click colorpick:",1,&(selected_config.Right_click_colorpick),0,1,0,Lookup_YesNo},
|
||||
{"",0,NULL,0,0,0,NULL},
|
||||
|
||||
{" --- File selector ---",0,NULL,0,0,0,NULL},
|
||||
@ -3532,6 +3532,7 @@ void Button_Colorpicker(void)
|
||||
|
||||
void Button_Unselect_colorpicker(void)
|
||||
{
|
||||
// Erase the color block which shows the picked color
|
||||
if (Operation_before_interrupt!=OPERATION_REPLACE)
|
||||
if ( (Mouse_Y<Menu_Y) && (Menu_is_visible) &&
|
||||
( (!Main_magnifier_mode) || (Mouse_X<Main_separator_position) || (Mouse_X>=Main_X_zoom) ) )
|
||||
|
||||
@ -483,6 +483,7 @@ enum OPERATIONS
|
||||
OPERATION_STRETCH_BRUSH, ///< Stretch brush
|
||||
OPERATION_DISTORT_BRUSH, ///< Distort brush
|
||||
OPERATION_GRAD_RECTANGLE, ///< Gradient-filled rectangle
|
||||
OPERATION_RMB_COLORPICK, ///< Colorpick on right mouse button
|
||||
NB_OPERATIONS ///< Number of operations handled by the engine
|
||||
};
|
||||
|
||||
|
||||
@ -897,6 +897,7 @@ GFX2_GLOBAL T_Brush_template Brush_container[BRUSH_CONTAINER_COLUMNS*BRUSH_CONTA
|
||||
CURSOR_SHAPE_XOR_TARGET , // Stretch brush
|
||||
CURSOR_SHAPE_TARGET , // Distort brush
|
||||
CURSOR_SHAPE_XOR_TARGET , // Gradient-filled rectangle
|
||||
CURSOR_SHAPE_COLORPICKER , // Colorpick on right mouse button
|
||||
};
|
||||
#else
|
||||
/// ::Cursor_shape to use for each operation.
|
||||
|
||||
@ -2353,7 +2353,14 @@ static const T_Help_table helptable_settings_details[] =
|
||||
HELP_TEXT ("window. (Set it to 'no' if you have a slow")
|
||||
HELP_TEXT ("computer or if you edit huge pictures)")
|
||||
HELP_TEXT ("")
|
||||
HELP_TEXT ("")
|
||||
HELP_BOLD (" Right click colorpick")
|
||||
HELP_TEXT ("This enables a mode where the right mouse")
|
||||
HELP_TEXT ("buttons acts as a color picker until")
|
||||
HELP_TEXT ("it's released, and selects Foreground color.")
|
||||
HELP_TEXT ("This mode prevents you from painting with")
|
||||
HELP_TEXT ("Background color.")
|
||||
HELP_TEXT ("This option is ignored when the Shade,")
|
||||
HELP_TEXT ("Quick-shade, or Tiling mode is used.")
|
||||
};
|
||||
|
||||
static const T_Help_table helptable_clear[] =
|
||||
|
||||
@ -1602,6 +1602,10 @@ void Init_operations(void)
|
||||
Centered_lines_12_7,0,FAST_MOUSE);
|
||||
Init_operation(OPERATION_CENTERED_LINES,0,7,
|
||||
Centered_lines_0_7,0,FAST_MOUSE);
|
||||
|
||||
Init_operation(OPERATION_RMB_COLORPICK,0,1,
|
||||
Rightclick_colorpick_0_1,0,FAST_MOUSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -53,11 +53,12 @@ void Start_operation_stack(word new_operation)
|
||||
// On mémorise l'opération précédente si on démarre une interruption
|
||||
switch(new_operation)
|
||||
{
|
||||
case OPERATION_MAGNIFY :
|
||||
case OPERATION_COLORPICK :
|
||||
case OPERATION_GRAB_BRUSH :
|
||||
case OPERATION_POLYBRUSH :
|
||||
case OPERATION_STRETCH_BRUSH :
|
||||
case OPERATION_MAGNIFY:
|
||||
case OPERATION_COLORPICK:
|
||||
case OPERATION_RMB_COLORPICK:
|
||||
case OPERATION_GRAB_BRUSH:
|
||||
case OPERATION_POLYBRUSH:
|
||||
case OPERATION_STRETCH_BRUSH:
|
||||
case OPERATION_ROTATE_BRUSH:
|
||||
Operation_before_interrupt=Current_operation;
|
||||
// On passe à l'operation demandée
|
||||
@ -226,6 +227,9 @@ void Freehand_mode1_2_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@ -322,6 +326,9 @@ void Freehand_mode2_2_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@ -390,6 +397,9 @@ void Freehand_Mode3_2_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@ -422,6 +432,9 @@ void Line_12_0(void)
|
||||
|
||||
// Début du tracé d'une ligne (premier clic)
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Paintbrush_shape_before_operation=Paintbrush_shape;
|
||||
@ -569,6 +582,9 @@ void K_line_12_0(void)
|
||||
{
|
||||
byte color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
@ -745,6 +761,9 @@ void Rectangle_12_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
|
||||
if ((Config.Coords_rel) && (Menu_is_visible))
|
||||
@ -916,6 +935,9 @@ void Circle_12_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
|
||||
@ -1090,6 +1112,9 @@ void Ellipse_12_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
|
||||
@ -1284,9 +1309,12 @@ void Fill_2_0(void)
|
||||
// Click Souris: 2
|
||||
// Taille_Pile : 0
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
if (Rightclick_colorpick(1))
|
||||
return;
|
||||
|
||||
Hide_cursor();
|
||||
// Pas besoin d'initialiser le début d'opération car le Smear n'affecte pas
|
||||
// le Fill, et on se fout de savoir si on est dans la partie gauche ou
|
||||
@ -1309,7 +1337,7 @@ void Replace_1_0(void)
|
||||
// Click Souris: 1
|
||||
// Taille_Pile : 0
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
Hide_cursor();
|
||||
@ -1331,9 +1359,12 @@ void Replace_2_0(void)
|
||||
// Click Souris: 2
|
||||
// Taille_Pile : 0
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
if (Rightclick_colorpick(1))
|
||||
return;
|
||||
|
||||
Hide_cursor();
|
||||
// Pas besoin d'initialiser le début d'opération car le Smear n'affecte pas
|
||||
// le Replace, et on se fout de savoir si on est dans la partie gauche ou
|
||||
@ -1433,6 +1464,9 @@ void Curve_34_points_2_0(void)
|
||||
// Souris effacée: Oui
|
||||
//
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@ -1889,6 +1923,9 @@ void Airbrush_2_0(void)
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
if (Rightclick_colorpick(1))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@ -1956,6 +1993,9 @@ void Polygon_12_0(void)
|
||||
{
|
||||
byte color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
@ -2057,6 +2097,9 @@ void Polyfill_12_0(void)
|
||||
{
|
||||
byte color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
@ -2255,6 +2298,9 @@ void Polyform_12_0(void)
|
||||
{
|
||||
short color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
@ -2413,6 +2459,9 @@ void Filled_polyform_12_0(void)
|
||||
{
|
||||
short color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
|
||||
// Cette opération étant également utilisée pour le lasso, on ne fait pas de
|
||||
@ -3712,6 +3761,9 @@ void Centered_lines_12_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
|
||||
@ -225,3 +225,8 @@ void Centered_lines_0_3(void);
|
||||
void Centered_lines_12_7(void);
|
||||
void Centered_lines_0_7(void);
|
||||
|
||||
/////////////////////////////////////////////////// OPERATION_RMB_COLORPICK
|
||||
|
||||
byte Rightclick_colorpick(byte cursor_visible);
|
||||
void Rightclick_colorpick_2_1(void);
|
||||
void Rightclick_colorpick_0_1(void);
|
||||
|
||||
@ -894,6 +894,13 @@ int Load_INI(T_Config * conf)
|
||||
Menu_bars[index].Visible = (values[0] & (1<<index)) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
conf->Right_click_colorpick=0;
|
||||
// Optional, right mouse button to pick colors (>=2.3)
|
||||
if (!Load_INI_get_values (file,buffer,"Right_click_colorpick",1,values))
|
||||
{
|
||||
conf->Right_click_colorpick=(values[0]!=0);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
|
||||
@ -673,7 +673,10 @@ int Save_INI(T_Config * conf)
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Menubars_visible",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
|
||||
values[0]=(conf->Right_click_colorpick);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Right_click_colorpick",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
Save_INI_flush(Ancien_fichier,Nouveau_fichier,buffer);
|
||||
|
||||
fclose(Nouveau_fichier);
|
||||
|
||||
@ -321,6 +321,7 @@ typedef struct
|
||||
word Double_click_speed; ///< Maximum delay for double-click, in ms.
|
||||
word Double_key_speed; ///< Maximum delay for double-keypress, in ms.
|
||||
byte Grid_XOR_color; ///< XOR value to apply for grid color.
|
||||
byte Right_click_colorpick; ///< Boolean, true to enable a "tablet" mode, where RMB acts as instant colorpicker
|
||||
} T_Config;
|
||||
|
||||
// Structures utilisées pour les descriptions de pages et de liste de pages.
|
||||
|
||||
@ -706,6 +706,7 @@ void Print_coordinates(void)
|
||||
if (Menu_is_visible && !Cursor_in_menu)
|
||||
{
|
||||
if ( (Current_operation==OPERATION_COLORPICK)
|
||||
|| (Current_operation==OPERATION_RMB_COLORPICK)
|
||||
|| (Current_operation==OPERATION_REPLACE) )
|
||||
{
|
||||
if ( (Paintbrush_X>=0) && (Paintbrush_Y>=0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user