app: get rid of hardcoding GDK_SHIFT_MASK in tools/

gimp_suggest_modifiers(): change "shift_format" and "control_format"
parameters to "extend_selection_format" and "toggle_behavior_format",
which fixes the longstanding problem that the function did the right
thing only by accident.

tools: use gimp_get_extend_selection_mask() instead of GDK_SHIFT_MASK
which is not 100% semantically correct in all cases, but at least a
step in the right direction to make the tool modifiers easier to
improve.
This commit is contained in:
Michael Natterer 2015-10-17 15:31:08 +02:00
parent 1318015adc
commit 7ec04e4afe
23 changed files with 166 additions and 139 deletions

View File

@ -221,9 +221,8 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
GtkWidget *scale; GtkWidget *scale;
GtkWidget *combo; GtkWidget *combo;
gchar *str; gchar *str;
GdkModifierType toggle_mask; GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
toggle_mask = gimp_get_toggle_behavior_mask ();
/* fill type */ /* fill type */
str = g_strdup_printf (_("Fill Type (%s)"), str = g_strdup_printf (_("Fill Type (%s)"),
@ -242,7 +241,7 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
/* fill selection */ /* fill selection */
str = g_strdup_printf (_("Affected Area (%s)"), str = g_strdup_printf (_("Affected Area (%s)"),
gimp_get_mod_string (GDK_SHIFT_MASK)); gimp_get_mod_string (extend_mask));
frame = gimp_prop_boolean_radio_frame_new (config, "fill-selection", frame = gimp_prop_boolean_radio_frame_new (config, "fill-selection",
str, str,
_("Fill whole selection"), _("Fill whole selection"),

View File

@ -268,7 +268,7 @@ gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
break; break;
} }
} }
else if (key == GDK_SHIFT_MASK) else if (key == gimp_get_extend_selection_mask ())
{ {
g_object_set (options, "fill-selection", ! options->fill_selection, NULL); g_object_set (options, "fill-selection", ! options->fill_selection, NULL);
} }

View File

@ -46,6 +46,7 @@
#include "core/gimpprojection.h" #include "core/gimpprojection.h"
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h" #include "display/gimpdisplay.h"
@ -551,7 +552,7 @@ gimp_cage_tool_button_press (GimpTool *tool,
{ {
/* User clicked on a handle, so we move it */ /* User clicked on a handle, so we move it */
if (state & GDK_SHIFT_MASK) if (state & gimp_get_extend_selection_mask ())
{ {
/* Multiple selection */ /* Multiple selection */
@ -595,7 +596,7 @@ gimp_cage_tool_button_press (GimpTool *tool,
{ {
/* User clicked on a handle, so we move it */ /* User clicked on a handle, so we move it */
if (state & GDK_SHIFT_MASK) if (state & gimp_get_extend_selection_mask ())
{ {
/* Multiple selection */ /* Multiple selection */
@ -690,7 +691,7 @@ gimp_cage_tool_button_release (GimpTool *tool,
abs (ct->selection_start_x - coords->x), abs (ct->selection_start_x - coords->x),
abs (ct->selection_start_y - coords->y) }; abs (ct->selection_start_y - coords->y) };
if (state & GDK_SHIFT_MASK) if (state & gimp_get_extend_selection_mask ())
{ {
gimp_cage_config_select_add_area (ct->config, gimp_cage_config_select_add_area (ct->config,
GIMP_CAGE_MODE_CAGE_CHANGE, GIMP_CAGE_MODE_CAGE_CHANGE,
@ -720,7 +721,7 @@ gimp_cage_tool_button_release (GimpTool *tool,
abs (ct->selection_start_x - coords->x), abs (ct->selection_start_x - coords->x),
abs (ct->selection_start_y - coords->y) }; abs (ct->selection_start_y - coords->y) };
if (state & GDK_SHIFT_MASK) if (state & gimp_get_extend_selection_mask ())
{ {
gimp_cage_config_select_add_area (ct->config, gimp_cage_config_select_add_area (ct->config,
GIMP_CAGE_MODE_DEFORM, area); GIMP_CAGE_MODE_DEFORM, area);

View File

@ -150,9 +150,8 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
GtkWidget *button; GtkWidget *button;
GtkWidget *frame; GtkWidget *frame;
gchar *str; gchar *str;
GdkModifierType toggle_mask; GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
toggle_mask = gimp_get_toggle_behavior_mask ();
/* the sample merged toggle button */ /* the sample merged toggle button */
button = gimp_prop_check_button_new (config, "sample-merged", button = gimp_prop_check_button_new (config, "sample-merged",
@ -171,7 +170,7 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
/* the use_info_window toggle button */ /* the use_info_window toggle button */
str = g_strdup_printf (_("Use info window (%s)"), str = g_strdup_printf (_("Use info window (%s)"),
gimp_get_mod_string (GDK_SHIFT_MASK)); gimp_get_mod_string (extend_mask));
button = gimp_prop_check_button_new (config, "use-info-window", str); button = gimp_prop_check_button_new (config, "use-info-window", str);
g_free (str); g_free (str);

View File

@ -191,7 +191,7 @@ gimp_color_picker_tool_modifier_key (GimpTool *tool,
{ {
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool); GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool);
if (key == GDK_SHIFT_MASK) if (key == gimp_get_extend_selection_mask ())
{ {
g_object_set (options, "use-info-window", ! options->use_info_window, g_object_set (options, "use-info-window", ! options->use_info_window,
NULL); NULL);
@ -226,9 +226,6 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
{ {
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (tool); GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (tool);
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool); GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool);
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
GIMP_COLOR_TOOL (tool)->pick_mode = options->pick_mode; GIMP_COLOR_TOOL (tool)->pick_mode = options->pick_mode;
@ -237,24 +234,27 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
if (proximity) if (proximity)
{ {
gchar *status_help = NULL; gchar *status_help = NULL;
GdkModifierType shift_mod = 0; GdkModifierType extend_mask = 0;
GdkModifierType toggle_mask;
if (! picker_tool->gui) if (! picker_tool->gui)
shift_mod = GDK_SHIFT_MASK; extend_mask = gimp_get_extend_selection_mask ();
toggle_mask = gimp_get_toggle_behavior_mask ();
switch (options->pick_mode) switch (options->pick_mode)
{ {
case GIMP_COLOR_PICK_MODE_NONE: case GIMP_COLOR_PICK_MODE_NONE:
status_help = gimp_suggest_modifiers (_("Click in any image to view" status_help = gimp_suggest_modifiers (_("Click in any image to view"
" its color"), " its color"),
shift_mod & ~state, extend_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
break; break;
case GIMP_COLOR_PICK_MODE_FOREGROUND: case GIMP_COLOR_PICK_MODE_FOREGROUND:
status_help = gimp_suggest_modifiers (_("Click in any image to pick" status_help = gimp_suggest_modifiers (_("Click in any image to pick"
" the foreground color"), " the foreground color"),
(shift_mod | toggle_mask) & (extend_mask | toggle_mask) &
~state, ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
break; break;
@ -262,7 +262,7 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
case GIMP_COLOR_PICK_MODE_BACKGROUND: case GIMP_COLOR_PICK_MODE_BACKGROUND:
status_help = gimp_suggest_modifiers (_("Click in any image to pick" status_help = gimp_suggest_modifiers (_("Click in any image to pick"
" the background color"), " the background color"),
(shift_mod | toggle_mask) & (extend_mask | toggle_mask) &
~state, ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
break; break;
@ -270,7 +270,7 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
case GIMP_COLOR_PICK_MODE_PALETTE: case GIMP_COLOR_PICK_MODE_PALETTE:
status_help = gimp_suggest_modifiers (_("Click in any image to add" status_help = gimp_suggest_modifiers (_("Click in any image to add"
" the color to the palette"), " the color to the palette"),
shift_mod & ~state, extend_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
break; break;
} }

View File

@ -109,21 +109,20 @@ gimp_convolve_tool_modifier_key (GimpTool *tool,
GdkModifierType state, GdkModifierType state,
GimpDisplay *display) GimpDisplay *display)
{ {
GimpConvolveTool *convolve = GIMP_CONVOLVE_TOOL (tool); GimpConvolveTool *convolve = GIMP_CONVOLVE_TOOL (tool);
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool); GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
GdkModifierType toggle_mask; GdkModifierType line_mask = GIMP_PAINT_TOOL_LINE_MASK;
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
toggle_mask = gimp_get_toggle_behavior_mask (); if (((key == toggle_mask) &&
! (state & line_mask) && /* leave stuff untouched in line draw mode */
if (((key == toggle_mask) &&
! (state & GDK_SHIFT_MASK) && /* leave stuff untouched in line draw mode */
press != convolve->toggled) press != convolve->toggled)
|| ||
(key == GDK_SHIFT_MASK && /* toggle back after keypresses CTRL(hold)-> */ (key == line_mask && /* toggle back after keypresses CTRL(hold)-> */
! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */ ! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
convolve->toggled && convolve->toggled &&
! (state & toggle_mask))) ! (state & toggle_mask)))
{ {
convolve->toggled = press; convolve->toggled = press;

View File

@ -237,7 +237,7 @@ gimp_curves_tool_button_release (GimpTool *tool,
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool); GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
GimpCurvesConfig *config = c_tool->config; GimpCurvesConfig *config = c_tool->config;
if (state & GDK_SHIFT_MASK) if (state & gimp_get_extend_selection_mask ())
{ {
GimpCurve *curve = config->curve[config->channel]; GimpCurve *curve = config->curve[config->channel];
gdouble value = c_tool->picked_color[config->channel]; gdouble value = c_tool->picked_color[config->channel];
@ -300,33 +300,41 @@ gimp_curves_tool_oper_update (GimpTool *tool,
GimpDisplay *display) GimpDisplay *display)
{ {
GimpColorPickMode mode; GimpColorPickMode mode;
const gchar *status; gchar *status = NULL;
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity, GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
display); display);
gimp_tool_pop_status (tool, display); gimp_tool_pop_status (tool, display);
if (state & GDK_SHIFT_MASK) if (state & extend_mask)
{ {
mode = GIMP_COLOR_PICK_MODE_PALETTE; mode = GIMP_COLOR_PICK_MODE_PALETTE;
status = _("Click to add a control point"); status = g_strdup (_("Click to add a control point"));
} }
else if (state & gimp_get_toggle_behavior_mask ()) else if (state & toggle_mask)
{ {
mode = GIMP_COLOR_PICK_MODE_PALETTE; mode = GIMP_COLOR_PICK_MODE_PALETTE;
status = _("Click to add control points to all channels"); status = g_strdup (_("Click to add control points to all channels"));
} }
else else
{ {
mode = GIMP_COLOR_PICK_MODE_NONE; mode = GIMP_COLOR_PICK_MODE_NONE;
status = _("Click to locate on curve (try Shift, Ctrl)"); status = gimp_suggest_modifiers (_("Click to locate on curve"),
(extend_mask | toggle_mask) & ~state,
_("%s: add control point"),
_("%s: add control points to all channels"),
NULL);
} }
GIMP_COLOR_TOOL (tool)->pick_mode = mode; GIMP_COLOR_TOOL (tool)->pick_mode = mode;
if (proximity) if (proximity)
gimp_tool_push_status (tool, display, "%s", status); gimp_tool_push_status (tool, display, "%s", status);
g_free (status);
} }
static void static void

View File

@ -109,21 +109,20 @@ gimp_dodge_burn_tool_modifier_key (GimpTool *tool,
GdkModifierType state, GdkModifierType state,
GimpDisplay *display) GimpDisplay *display)
{ {
GimpDodgeBurnTool *dodgeburn = GIMP_DODGE_BURN_TOOL (tool); GimpDodgeBurnTool *dodgeburn = GIMP_DODGE_BURN_TOOL (tool);
GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool); GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
GdkModifierType toggle_mask; GdkModifierType line_mask = GIMP_PAINT_TOOL_LINE_MASK;
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
toggle_mask = gimp_get_toggle_behavior_mask (); if ((key == toggle_mask &&
! (state & line_mask) && /* leave stuff untouched in line draw mode */
if ((key == toggle_mask &&
! (state & GDK_SHIFT_MASK) && /* leave stuff untouched in line draw mode */
press != dodgeburn->toggled) press != dodgeburn->toggled)
|| ||
(key == GDK_SHIFT_MASK && /* toggle back after keypresses CTRL(hold)-> */ (key == line_mask && /* toggle back after keypresses CTRL(hold)-> */
! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */ ! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
dodgeburn->toggled && dodgeburn->toggled &&
! (state & toggle_mask))) ! (state & toggle_mask)))
{ {
dodgeburn->toggled = press; dodgeburn->toggled = press;

View File

@ -964,11 +964,17 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
GimpTransformType translate_type; GimpTransformType translate_type;
if (kevent->state & GDK_MOD1_MASK) if (kevent->state & GDK_MOD1_MASK)
translate_type = GIMP_TRANSFORM_TYPE_SELECTION; {
translate_type = GIMP_TRANSFORM_TYPE_SELECTION;
}
else if (kevent->state & gimp_get_toggle_behavior_mask ()) else if (kevent->state & gimp_get_toggle_behavior_mask ())
translate_type = GIMP_TRANSFORM_TYPE_PATH; {
translate_type = GIMP_TRANSFORM_TYPE_PATH;
}
else else
translate_type = GIMP_TRANSFORM_TYPE_LAYER; {
translate_type = GIMP_TRANSFORM_TYPE_LAYER;
}
return gimp_edit_selection_tool_translate (tool, kevent, translate_type, return gimp_edit_selection_tool_translate (tool, kevent, translate_type,
display); display);
@ -980,15 +986,16 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
GimpTransformType translate_type, GimpTransformType translate_type,
GimpDisplay *display) GimpDisplay *display)
{ {
gint inc_x = 0; gint inc_x = 0;
gint inc_y = 0; gint inc_y = 0;
GimpUndo *undo; GimpUndo *undo;
gboolean push_undo = TRUE; gboolean push_undo = TRUE;
GimpImage *image = gimp_display_get_image (display); GimpImage *image = gimp_display_get_image (display);
GimpItem *item = NULL; GimpItem *item = NULL;
GimpTranslateMode edit_mode = GIMP_TRANSLATE_MODE_MASK; GimpTranslateMode edit_mode = GIMP_TRANSLATE_MODE_MASK;
GimpUndoType undo_type = GIMP_UNDO_GROUP_MASK; GimpUndoType undo_type = GIMP_UNDO_GROUP_MASK;
const gchar *undo_desc = NULL; const gchar *undo_desc = NULL;
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
gint velocity; gint velocity;
/* bail out early if it is not an arrow key event */ /* bail out early if it is not an arrow key event */
@ -1005,43 +1012,43 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
velocity = MAX (1.0, velocity); velocity = MAX (1.0, velocity);
/* check the event queue for key events with the same modifier mask /* check the event queue for key events with the same modifier mask
* as the current event, allowing only GDK_SHIFT_MASK to vary between * as the current event, allowing only extend_mask to vary between
* them. * them.
*/ */
inc_x = process_event_queue_keys (kevent, inc_x = process_event_queue_keys (kevent,
GDK_KEY_Left, GDK_KEY_Left,
kevent->state | GDK_SHIFT_MASK, kevent->state | extend_mask,
-1 * velocity, -1 * velocity,
GDK_KEY_Left, GDK_KEY_Left,
kevent->state & ~GDK_SHIFT_MASK, kevent->state & ~extend_mask,
-1, -1,
GDK_KEY_Right, GDK_KEY_Right,
kevent->state | GDK_SHIFT_MASK, kevent->state | extend_mask,
1 * velocity, 1 * velocity,
GDK_KEY_Right, GDK_KEY_Right,
kevent->state & ~GDK_SHIFT_MASK, kevent->state & ~extend_mask,
1, 1,
0); 0);
inc_y = process_event_queue_keys (kevent, inc_y = process_event_queue_keys (kevent,
GDK_KEY_Up, GDK_KEY_Up,
kevent->state | GDK_SHIFT_MASK, kevent->state | extend_mask,
-1 * velocity, -1 * velocity,
GDK_KEY_Up, GDK_KEY_Up,
kevent->state & ~GDK_SHIFT_MASK, kevent->state & ~extend_mask,
-1, -1,
GDK_KEY_Down, GDK_KEY_Down,
kevent->state | GDK_SHIFT_MASK, kevent->state | extend_mask,
1 * velocity, 1 * velocity,
GDK_KEY_Down, GDK_KEY_Down,
kevent->state & ~GDK_SHIFT_MASK, kevent->state & ~extend_mask,
1, 1,
0); 0);

View File

@ -1393,7 +1393,8 @@ gimp_free_select_tool_modifier_key (GimpTool *tool,
priv->constrain_angle = ((state & gimp_get_constrain_behavior_mask ()) ? priv->constrain_angle = ((state & gimp_get_constrain_behavior_mask ()) ?
TRUE : FALSE); TRUE : FALSE);
priv->supress_handles = state & GDK_SHIFT_MASK ? TRUE : FALSE; priv->supress_handles = ((state & gimp_get_extend_selection_mask ()) ?
TRUE : FALSE);
gimp_draw_tool_resume (draw_tool); gimp_draw_tool_resume (draw_tool);
} }

View File

@ -417,7 +417,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool,
case NO_ACTION: case NO_ACTION:
iscissors->state = SEED_PLACEMENT; iscissors->state = SEED_PLACEMENT;
if (! (state & GDK_SHIFT_MASK)) if (! (state & gimp_get_extend_selection_mask ()))
find_max_gradient (iscissors, image, find_max_gradient (iscissors, image,
&iscissors->x, &iscissors->y); &iscissors->x, &iscissors->y);
@ -742,7 +742,7 @@ gimp_iscissors_tool_motion (GimpTool *tool,
iscissors->y = RINT (coords->y); iscissors->y = RINT (coords->y);
/* Hold the shift key down to disable the auto-edge snap feature */ /* Hold the shift key down to disable the auto-edge snap feature */
if (! (state & GDK_SHIFT_MASK)) if (! (state & gimp_get_extend_selection_mask ()))
find_max_gradient (iscissors, image, find_max_gradient (iscissors, image,
&iscissors->x, &iscissors->y); &iscissors->x, &iscissors->y);
@ -927,6 +927,7 @@ gimp_iscissors_tool_oper_update (GimpTool *tool,
if (mouse_over_vertex (iscissors, coords->x, coords->y) > 1) if (mouse_over_vertex (iscissors, coords->x, coords->y) > 1)
{ {
GdkModifierType snap_mask = gimp_get_extend_selection_mask ();
GdkModifierType remove_mask = gimp_get_modify_selection_mask (); GdkModifierType remove_mask = gimp_get_modify_selection_mask ();
if (state & remove_mask) if (state & remove_mask)
@ -939,7 +940,7 @@ gimp_iscissors_tool_oper_update (GimpTool *tool,
{ {
gchar *status = gchar *status =
gimp_suggest_modifiers (_("Click-Drag to move this point"), gimp_suggest_modifiers (_("Click-Drag to move this point"),
(GDK_SHIFT_MASK | remove_mask) & ~state, (snap_mask | remove_mask) & ~state,
_("%s: disable auto-snap"), _("%s: disable auto-snap"),
_("%s: remove this point"), _("%s: remove this point"),
NULL); NULL);
@ -1003,11 +1004,12 @@ gimp_iscissors_tool_oper_update (GimpTool *tool,
case WAITING: case WAITING:
if (proximity) if (proximity)
{ {
gchar *status; GdkModifierType snap_mask = gimp_get_extend_selection_mask ();
gchar *status;
status = gimp_suggest_modifiers (_("Click or Click-Drag to add a" status = gimp_suggest_modifiers (_("Click or Click-Drag to add a"
" point"), " point"),
GDK_SHIFT_MASK & ~state, snap_mask & ~state,
_("%s: disable auto-snap"), _("%s: disable auto-snap"),
NULL, NULL); NULL, NULL);
gimp_tool_replace_status (tool, display, "%s", status); gimp_tool_replace_status (tool, display, "%s", status);

View File

@ -223,6 +223,7 @@ gimp_measure_tool_button_press (GimpTool *tool,
*/ */
if (measure->point != -1) if (measure->point != -1)
{ {
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask (); GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if (state & (toggle_mask | GDK_MOD1_MASK)) if (state & (toggle_mask | GDK_MOD1_MASK))
@ -267,7 +268,7 @@ gimp_measure_tool_button_press (GimpTool *tool,
} }
else else
{ {
if (state & GDK_SHIFT_MASK) if (state & extend_mask)
measure->function = ADDING; measure->function = ADDING;
else else
measure->function = MOVING; measure->function = MOVING;
@ -550,6 +551,7 @@ gimp_measure_tool_oper_update (GimpTool *tool,
if (gimp_canvas_item_hit (measure->handles[i], if (gimp_canvas_item_hit (measure->handles[i],
coords->x, coords->y)) coords->x, coords->y))
{ {
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask (); GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
point = i; point = i;
@ -590,7 +592,7 @@ gimp_measure_tool_oper_update (GimpTool *tool,
break; break;
} }
if ((state & GDK_SHIFT_MASK) if ((state & extend_mask)
&& ! ((i == 0) && (measure->num_points == 3))) && ! ((i == 0) && (measure->num_points == 3)))
{ {
status = gimp_suggest_modifiers (_("Click-Drag to add a " status = gimp_suggest_modifiers (_("Click-Drag to add a "
@ -602,11 +604,11 @@ gimp_measure_tool_oper_update (GimpTool *tool,
else else
{ {
if ((i == 0) && (measure->num_points == 3)) if ((i == 0) && (measure->num_points == 3))
state |= GDK_SHIFT_MASK; state |= extend_mask;
status = gimp_suggest_modifiers (_("Click-Drag to move this " status = gimp_suggest_modifiers (_("Click-Drag to move this "
"point"), "point"),
(GDK_SHIFT_MASK | (extend_mask |
toggle_mask | toggle_mask |
GDK_MOD1_MASK) & ~state, GDK_MOD1_MASK) & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
} }
@ -673,6 +675,7 @@ gimp_measure_tool_cursor_update (GimpTool *tool,
{ {
if (measure->point != -1) if (measure->point != -1)
{ {
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask (); GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if (state & toggle_mask) if (state & toggle_mask)
@ -686,7 +689,7 @@ gimp_measure_tool_cursor_update (GimpTool *tool,
{ {
cursor = GIMP_CURSOR_SIDE_RIGHT; cursor = GIMP_CURSOR_SIDE_RIGHT;
} }
else if ((state & GDK_SHIFT_MASK) && else if ((state & extend_mask) &&
! ((measure->point == 0) && ! ((measure->point == 0) &&
(measure->num_points == 3))) (measure->num_points == 3)))
{ {

View File

@ -185,8 +185,9 @@ gimp_move_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (box); gtk_widget_show (box);
/* tool toggle */ /* tool toggle */
title = g_strdup_printf (_("Tool Toggle (%s)"), title =
gimp_get_mod_string (GDK_SHIFT_MASK)); g_strdup_printf (_("Tool Toggle (%s)"),
gimp_get_mod_string (gimp_get_extend_selection_mask ()));
frame = gimp_prop_boolean_radio_frame_new (config, "move-current", frame = gimp_prop_boolean_radio_frame_new (config, "move-current",
title, "true", "false"); title, "true", "false");

View File

@ -635,7 +635,7 @@ gimp_move_tool_modifier_key (GimpTool *tool,
GimpMoveTool *move = GIMP_MOVE_TOOL (tool); GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool); GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
if (key == GDK_SHIFT_MASK) if (key == gimp_get_extend_selection_mask ())
{ {
g_object_set (options, "move-current", ! options->move_current, NULL); g_object_set (options, "move-current", ! options->move_current, NULL);
} }

View File

@ -578,7 +578,7 @@ gimp_n_point_deformation_tool_button_press (GimpTool *tool,
* list of selected control points * list of selected control points
*/ */
if (! (state & GDK_SHIFT_MASK)) if (! (state & gimp_get_extend_selection_mask ()))
{ {
/* <SHIFT> isn't pressed, so this isn't a /* <SHIFT> isn't pressed, so this isn't a
* multiselection - clear the list of selected * multiselection - clear the list of selected
@ -589,7 +589,7 @@ gimp_n_point_deformation_tool_button_press (GimpTool *tool,
gimp_n_point_deformation_tool_add_cp_to_selection (npd_tool, cp); gimp_n_point_deformation_tool_add_cp_to_selection (npd_tool, cp);
} }
else if (state & GDK_SHIFT_MASK) else if (state & gimp_get_extend_selection_mask ())
{ {
/* control point is selected and <SHIFT> is pressed - /* control point is selected and <SHIFT> is pressed -
* remove control point from selected points * remove control point from selected points
@ -666,7 +666,7 @@ gimp_n_point_deformation_tool_button_release (GimpTool *tool,
gint y1 = MAX (npd_tool->start_y, npd_tool->cursor_y); gint y1 = MAX (npd_tool->start_y, npd_tool->cursor_y);
gint i; gint i;
if (! (state & GDK_SHIFT_MASK)) if (! (state & gimp_get_extend_selection_mask ()))
{ {
/* <SHIFT> isn't pressed, so we want a clear selection */ /* <SHIFT> isn't pressed, so we want a clear selection */
gimp_n_point_deformation_tool_clear_selected_points_list (npd_tool); gimp_n_point_deformation_tool_clear_selected_points_list (npd_tool);

View File

@ -634,7 +634,7 @@ gimp_paint_tool_oper_update (GimpTool *tool,
core->cur_coords.x -= off_x; core->cur_coords.x -= off_x;
core->cur_coords.y -= off_y; core->cur_coords.y -= off_y;
if (display == tool->display && (state & GDK_SHIFT_MASK)) if (display == tool->display && (state & GIMP_PAINT_TOOL_LINE_MASK))
{ {
/* If shift is down and this is not the first paint stroke, /* If shift is down and this is not the first paint stroke,
* draw a line. * draw a line.
@ -703,7 +703,7 @@ gimp_paint_tool_oper_update (GimpTool *tool,
/* suggest drawing lines only after the first point is set /* suggest drawing lines only after the first point is set
*/ */
if (display == tool->display) if (display == tool->display)
modifiers |= GDK_SHIFT_MASK; modifiers |= GIMP_PAINT_TOOL_LINE_MASK;
status = gimp_suggest_modifiers (paint_tool->status, status = gimp_suggest_modifiers (paint_tool->status,
modifiers & ~state, modifiers & ~state,

View File

@ -22,6 +22,9 @@
#include "gimpcolortool.h" #include "gimpcolortool.h"
#define GIMP_PAINT_TOOL_LINE_MASK (gimp_get_extend_selection_mask ())
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ()) #define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
#define GIMP_PAINT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PAINT_TOOL, GimpPaintTool)) #define GIMP_PAINT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PAINT_TOOL, GimpPaintTool))
#define GIMP_PAINT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PAINT_TOOL, GimpPaintToolClass)) #define GIMP_PAINT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PAINT_TOOL, GimpPaintToolClass))

View File

@ -342,12 +342,13 @@ gimp_perspective_clone_tool_button_press (GimpTool *tool,
case GIMP_PERSPECTIVE_CLONE_MODE_PAINT: case GIMP_PERSPECTIVE_CLONE_MODE_PAINT:
{ {
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask (); GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
gdouble nnx, nny; gdouble nnx, nny;
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask) if ((state & (toggle_mask | extend_mask)) == toggle_mask)
{ {
source_core->set_source = TRUE; source_core->set_source = TRUE;
@ -569,9 +570,10 @@ gimp_perspective_clone_tool_cursor_update (GimpTool *tool,
} }
else else
{ {
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask (); GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask) if ((state & (toggle_mask | extend_mask)) == toggle_mask)
{ {
cursor = GIMP_CURSOR_CROSSHAIR_SMALL; cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
} }

View File

@ -1242,7 +1242,7 @@ gimp_rectangle_tool_active_modifier_key (GimpTool *tool,
gimp_draw_tool_pause (draw_tool); gimp_draw_tool_pause (draw_tool);
if (key == GDK_SHIFT_MASK) if (key == gimp_get_extend_selection_mask ())
{ {
/* Here we want to handle manualy when to update the rectangle, so we /* Here we want to handle manualy when to update the rectangle, so we
* don't want gimp_rectangle_tool_options_notify to do anything. * don't want gimp_rectangle_tool_options_notify to do anything.
@ -1462,7 +1462,7 @@ gimp_rectangle_tool_key_press (GimpTool *tool,
} }
/* If the shift key is down, move by an accelerated increment */ /* If the shift key is down, move by an accelerated increment */
if (kevent->state & GDK_SHIFT_MASK) if (kevent->state & gimp_get_extend_selection_mask ())
{ {
dx *= ARROW_VELOCITY; dx *= ARROW_VELOCITY;
dy *= ARROW_VELOCITY; dy *= ARROW_VELOCITY;

View File

@ -179,11 +179,12 @@ gimp_source_tool_button_press (GimpTool *tool,
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool); GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core); GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask (); GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask) if ((state & (toggle_mask | extend_mask)) == toggle_mask)
{ {
source->set_source = TRUE; source->set_source = TRUE;
@ -275,9 +276,10 @@ gimp_source_tool_cursor_update (GimpTool *tool,
if (gimp_source_core_use_source (GIMP_SOURCE_CORE (paint_tool->core), if (gimp_source_core_use_source (GIMP_SOURCE_CORE (paint_tool->core),
options)) options))
{ {
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask (); GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask) if ((state & (toggle_mask | extend_mask)) == toggle_mask)
{ {
cursor = GIMP_CURSOR_CROSSHAIR_SMALL; cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
} }

View File

@ -61,7 +61,7 @@
#include "gimp-intl.h" #include "gimp-intl.h"
#define TOGGLE_MASK GDK_SHIFT_MASK #define TOGGLE_MASK gimp_get_extend_selection_mask ()
#define MOVE_MASK GDK_MOD1_MASK #define MOVE_MASK GDK_MOD1_MASK
#define INSDEL_MASK gimp_get_toggle_behavior_mask () #define INSDEL_MASK gimp_get_toggle_behavior_mask ()
@ -815,7 +815,7 @@ gimp_vector_tool_key_press (GimpTool *tool,
shell = gimp_display_get_shell (draw_tool->display); shell = gimp_display_get_shell (draw_tool->display);
if (kevent->state & GDK_SHIFT_MASK) if (kevent->state & gimp_get_extend_selection_mask ())
pixels = 10.0; pixels = 10.0;
if (kevent->state & gimp_get_toggle_behavior_mask ()) if (kevent->state & gimp_get_toggle_behavior_mask ())
@ -1198,8 +1198,10 @@ gimp_vector_tool_status_update (GimpTool *tool,
if (proximity) if (proximity)
{ {
const gchar *status = NULL; GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
gboolean free_status = FALSE; GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
const gchar *status = NULL;
gboolean free_status = FALSE;
switch (vector_tool->function) switch (vector_tool->function)
{ {
@ -1218,7 +1220,7 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_ADD_ANCHOR: case VECTORS_ADD_ANCHOR:
status = gimp_suggest_modifiers (_("Click or Click-Drag to create " status = gimp_suggest_modifiers (_("Click or Click-Drag to create "
"a new anchor"), "a new anchor"),
GDK_SHIFT_MASK & ~state, extend_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
free_status = TRUE; free_status = TRUE;
break; break;
@ -1226,8 +1228,6 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_MOVE_ANCHOR: case VECTORS_MOVE_ANCHOR:
if (options->edit_mode != GIMP_VECTOR_MODE_EDIT) if (options->edit_mode != GIMP_VECTOR_MODE_EDIT)
{ {
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
status = gimp_suggest_modifiers (_("Click-Drag to move the " status = gimp_suggest_modifiers (_("Click-Drag to move the "
"anchor around"), "anchor around"),
toggle_mask & ~state, toggle_mask & ~state,
@ -1247,14 +1247,14 @@ gimp_vector_tool_status_update (GimpTool *tool,
{ {
status = gimp_suggest_modifiers (_("Click-Drag to move the " status = gimp_suggest_modifiers (_("Click-Drag to move the "
"handle around"), "handle around"),
GDK_SHIFT_MASK & ~state, extend_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
} }
else else
{ {
status = gimp_suggest_modifiers (_("Click-Drag to move the " status = gimp_suggest_modifiers (_("Click-Drag to move the "
"handles around symmetrically"), "handles around symmetrically"),
GDK_SHIFT_MASK & ~state, extend_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
} }
free_status = TRUE; free_status = TRUE;
@ -1264,12 +1264,12 @@ gimp_vector_tool_status_update (GimpTool *tool,
if (GIMP_VECTOR_TOOL_GET_OPTIONS (tool)->polygonal) if (GIMP_VECTOR_TOOL_GET_OPTIONS (tool)->polygonal)
status = gimp_suggest_modifiers (_("Click-Drag to move the " status = gimp_suggest_modifiers (_("Click-Drag to move the "
"anchors around"), "anchors around"),
GDK_SHIFT_MASK & ~state, extend_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
else else
status = gimp_suggest_modifiers (_("Click-Drag to change the " status = gimp_suggest_modifiers (_("Click-Drag to change the "
"shape of the curve"), "shape of the curve"),
GDK_SHIFT_MASK & ~state, extend_mask & ~state,
_("%s: symmetrical"), NULL, NULL); _("%s: symmetrical"), NULL, NULL);
free_status = TRUE; free_status = TRUE;
break; break;
@ -1277,7 +1277,7 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_MOVE_STROKE: case VECTORS_MOVE_STROKE:
status = gimp_suggest_modifiers (_("Click-Drag to move the " status = gimp_suggest_modifiers (_("Click-Drag to move the "
"component around"), "component around"),
GDK_SHIFT_MASK & ~state, extend_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
free_status = TRUE; free_status = TRUE;
break; break;
@ -1289,7 +1289,7 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_INSERT_ANCHOR: case VECTORS_INSERT_ANCHOR:
status = gimp_suggest_modifiers (_("Click-Drag to insert an anchor " status = gimp_suggest_modifiers (_("Click-Drag to insert an anchor "
"on the path"), "on the path"),
GDK_SHIFT_MASK & ~state, extend_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
free_status = TRUE; free_status = TRUE;
break; break;

View File

@ -552,66 +552,67 @@ gimp_get_mod_string (GdkModifierType modifiers)
#define BUF_SIZE 100 #define BUF_SIZE 100
/** /**
* gimp_suggest_modifiers: * gimp_suggest_modifiers:
* @message: initial text for the message * @message: initial text for the message
* @modifiers: bit mask of modifiers that should be suggested * @modifiers: bit mask of modifiers that should be suggested
* @shift_format: optional format string for the Shift modifier * @extend_selection_format: optional format string for the
* @control_format: optional format string for the Ctrl modifier * "Extend selection" modifier
* @alt_format: optional format string for the Alt modifier * @toggle_behavior_format: optional format string for the
* "Toggle behavior" modifier
* @alt_format: optional format string for the Alt modifier
* *
* Utility function to build a message suggesting to use some * Utility function to build a message suggesting to use some
* modifiers for performing different actions (only Shift, Ctrl and * modifiers for performing different actions (only Shift, Ctrl and
* Alt are currently supported). If some of these modifiers are * Alt are currently supported). If some of these modifiers are
* already active, they will not be suggested. The optional format * already active, they will not be suggested. The optional format
* strings #shift_format, #control_format and #alt_format may be used * strings #extend_selection_format, #toggle_behavior_format and
* to describe what the modifier will do. They must contain a single * #alt_format may be used to describe what the modifier will do.
* '%%s' which will be replaced by the name of the modifier. They * They must contain a single '%%s' which will be replaced by the name
* can also be %NULL if the modifier name should be left alone. * of the modifier. They can also be %NULL if the modifier name
* should be left alone.
* *
* Return value: a newly allocated string containing the message. * Return value: a newly allocated string containing the message.
**/ **/
gchar * gchar *
gimp_suggest_modifiers (const gchar *message, gimp_suggest_modifiers (const gchar *message,
GdkModifierType modifiers, GdkModifierType modifiers,
const gchar *shift_format, const gchar *extend_selection_format,
const gchar *control_format, const gchar *toggle_behavior_format,
const gchar *alt_format) const gchar *alt_format)
{ {
gchar msg_buf[3][BUF_SIZE]; GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
gint num_msgs = 0; GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
gboolean try = FALSE; gchar msg_buf[3][BUF_SIZE];
gint num_msgs = 0;
gboolean try = FALSE;
if (modifiers & GDK_SHIFT_MASK) if (modifiers & extend_mask)
{ {
if (shift_format && *shift_format) if (extend_selection_format && *extend_selection_format)
{ {
g_snprintf (msg_buf[num_msgs], BUF_SIZE, shift_format, g_snprintf (msg_buf[num_msgs], BUF_SIZE, extend_selection_format,
gimp_get_mod_string (GDK_SHIFT_MASK)); gimp_get_mod_string (extend_mask));
} }
else else
{ {
g_strlcpy (msg_buf[num_msgs], g_strlcpy (msg_buf[num_msgs],
gimp_get_mod_string (GDK_SHIFT_MASK), BUF_SIZE); gimp_get_mod_string (extend_mask), BUF_SIZE);
try = TRUE; try = TRUE;
} }
num_msgs++; num_msgs++;
} }
/* FIXME: using toggle_behavior_mask is such a hack. The fact that if (modifiers & toggle_mask)
* it happens to do the right thing on all platforms doesn't make it
* any better.
*/
if (modifiers & gimp_get_toggle_behavior_mask ())
{ {
if (control_format && *control_format) if (toggle_behavior_format && *toggle_behavior_format)
{ {
g_snprintf (msg_buf[num_msgs], BUF_SIZE, control_format, g_snprintf (msg_buf[num_msgs], BUF_SIZE, toggle_behavior_format,
gimp_get_mod_string (gimp_get_toggle_behavior_mask ())); gimp_get_mod_string (toggle_mask));
} }
else else
{ {
g_strlcpy (msg_buf[num_msgs], g_strlcpy (msg_buf[num_msgs],
gimp_get_mod_string (gimp_get_toggle_behavior_mask ()), BUF_SIZE); gimp_get_mod_string (toggle_mask), BUF_SIZE);
try = TRUE; try = TRUE;
} }

View File

@ -57,8 +57,8 @@ GimpTabStyle gimp_preview_tab_style_to_icon (GimpTabStyle tab_st
const gchar * gimp_get_mod_string (GdkModifierType modifiers); const gchar * gimp_get_mod_string (GdkModifierType modifiers);
gchar * gimp_suggest_modifiers (const gchar *message, gchar * gimp_suggest_modifiers (const gchar *message,
GdkModifierType modifiers, GdkModifierType modifiers,
const gchar *shift_format, const gchar *extend_selection_format,
const gchar *control_format, const gchar *toggle_behavior_format,
const gchar *alt_format); const gchar *alt_format);
GimpChannelOps gimp_modifiers_to_channel_op (GdkModifierType modifiers); GimpChannelOps gimp_modifiers_to_channel_op (GdkModifierType modifiers);
GdkModifierType gimp_replace_virtual_modifiers (GdkModifierType modifiers); GdkModifierType gimp_replace_virtual_modifiers (GdkModifierType modifiers);