app: use the new modifier API instead of constants in all tools

There are still many uses of literal SHIFT and MOD1 left, but all uses
of CONTROL are gone. Should work exactly as before on Win/X11, and
still has some glitches on OSX.
This commit is contained in:
Michael Natterer 2011-10-06 21:59:07 +02:00
parent 59f4396c7b
commit 38b8f0596d
30 changed files with 269 additions and 191 deletions

View File

@ -247,8 +247,11 @@ gimp_align_tool_button_release (GimpTool *tool,
GimpDisplayShell *shell = gimp_display_get_shell (display);
GObject *object = NULL;
GimpImage *image = gimp_display_get_image (display);
GdkModifierType extend_mask;
gint i;
extend_mask = gimp_get_extend_selection_mask ();
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
gimp_tool_control_halt (tool->control);
@ -262,7 +265,7 @@ gimp_align_tool_button_release (GimpTool *tool,
return;
}
if (! (state & GDK_SHIFT_MASK)) /* start a new list */
if (! (state & extend_mask)) /* start a new list */
{
gimp_align_tool_clear_selected (align_tool);
align_tool->set_reference = FALSE;
@ -317,7 +320,7 @@ gimp_align_tool_button_release (GimpTool *tool,
/* if an object has been selected using unmodified click,
* it should be used as the reference
*/
if (! (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)))
if (! (state & extend_mask))
align_tool->set_reference = TRUE;
}
}
@ -426,7 +429,8 @@ gimp_align_tool_oper_update (GimpTool *tool,
gint snap_distance = display->config->snap_distance;
gboolean add;
add = (state & GDK_SHIFT_MASK) && align_tool->selected_objects;
add = ((state & gimp_get_extend_selection_mask ()) &&
align_tool->selected_objects);
if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), display,
coords, snap_distance, snap_distance,
@ -481,7 +485,7 @@ gimp_align_tool_cursor_update (GimpTool *tool,
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
/* always add '+' when Shift is pressed, even if nothing is selected */
if (state & GDK_SHIFT_MASK)
if (state & gimp_get_extend_selection_mask ())
modifier = GIMP_CURSOR_MODIFIER_PLUS;
switch (align_tool->function)
@ -522,7 +526,10 @@ gimp_align_tool_status_update (GimpTool *tool,
GdkModifierType state,
gboolean proximity)
{
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
GdkModifierType extend_mask;
extend_mask = gimp_get_extend_selection_mask ();
gimp_tool_pop_status (tool, display);
@ -533,7 +540,7 @@ gimp_align_tool_status_update (GimpTool *tool,
if (! align_tool->selected_objects)
{
/* no need to suggest Shift if nothing is selected */
state |= GDK_SHIFT_MASK;
state |= extend_mask;
}
switch (align_tool->function)
@ -542,14 +549,14 @@ gimp_align_tool_status_update (GimpTool *tool,
status = gimp_suggest_modifiers (_("Click on a layer, path or guide, "
"or Click-Drag to pick several "
"layers"),
GDK_SHIFT_MASK & ~state,
extend_mask & ~state,
NULL, NULL, NULL);
break;
case ALIGN_TOOL_PICK_LAYER:
status = gimp_suggest_modifiers (_("Click to pick this layer as "
"first item"),
GDK_SHIFT_MASK & ~state,
extend_mask & ~state,
NULL, NULL, NULL);
break;
@ -560,7 +567,7 @@ gimp_align_tool_status_update (GimpTool *tool,
case ALIGN_TOOL_PICK_GUIDE:
status = gimp_suggest_modifiers (_("Click to pick this guide as "
"first item"),
GDK_SHIFT_MASK & ~state,
extend_mask & ~state,
NULL, NULL, NULL);
break;
@ -571,7 +578,7 @@ gimp_align_tool_status_update (GimpTool *tool,
case ALIGN_TOOL_PICK_PATH:
status = gimp_suggest_modifiers (_("Click to pick this path as "
"first item"),
GDK_SHIFT_MASK & ~state,
extend_mask & ~state,
NULL, NULL, NULL);
break;

View File

@ -309,7 +309,7 @@ gimp_blend_tool_motion (GimpTool *tool,
blend_tool->end_y = coords->y;
}
if (state & GDK_CONTROL_MASK)
if (state & gimp_get_constrain_behavior_mask ())
{
gimp_constrain_line (blend_tool->start_x, blend_tool->start_y,
&blend_tool->end_x, &blend_tool->end_y,
@ -334,7 +334,7 @@ gimp_blend_tool_active_modifier_key (GimpTool *tool,
{
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
if (key == GDK_CONTROL_MASK)
if (key == gimp_get_constrain_behavior_mask ())
{
blend_tool->end_x = blend_tool->mouse_x;
blend_tool->end_y = blend_tool->mouse_y;
@ -440,8 +440,9 @@ gimp_blend_tool_push_status (GimpBlendTool *blend_tool,
gchar *status_help;
status_help = gimp_suggest_modifiers ("",
((GDK_CONTROL_MASK | GDK_MOD1_MASK)
& ~state),
(gimp_get_constrain_behavior_mask () |
GDK_MOD1_MASK) &
~state,
NULL,
_("%s for constrained angles"),
_("%s to move the whole line"));

View File

@ -211,20 +211,23 @@ gimp_bucket_fill_options_reset (GimpToolOptions *tool_options)
GtkWidget *
gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
GtkWidget *vbox2;
GtkWidget *table;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *scale;
GtkWidget *combo;
gchar *str;
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
GtkWidget *vbox2;
GtkWidget *table;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *scale;
GtkWidget *combo;
gchar *str;
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
/* fill type */
str = g_strdup_printf (_("Fill Type (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK)),
gimp_get_mod_string (toggle_mask)),
frame = gimp_prop_enum_radio_frame_new (config, "fill-mode", str, 0, 0);
g_free (str);

View File

@ -32,6 +32,7 @@
#include "core/gimppickable.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
@ -218,7 +219,7 @@ gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
{
GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
if (key == GDK_CONTROL_MASK)
if (key == gimp_get_toggle_behavior_mask ())
{
switch (options->fill_mode)
{

View File

@ -144,11 +144,14 @@ gimp_color_picker_options_get_property (GObject *object,
GtkWidget *
gimp_color_picker_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_color_options_gui (tool_options);
GtkWidget *button;
GtkWidget *frame;
gchar *str;
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_color_options_gui (tool_options);
GtkWidget *button;
GtkWidget *frame;
gchar *str;
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
/* the sample merged toggle button */
button = gimp_prop_check_button_new (config, "sample-merged",
@ -158,7 +161,7 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
/* the pick FG/BG frame */
str = g_strdup_printf (_("Pick Mode (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
gimp_get_mod_string (toggle_mask));
frame = gimp_prop_enum_radio_frame_new (config, "pick-mode", str, -1, -1);
g_free (str);

View File

@ -177,7 +177,7 @@ gimp_color_picker_tool_modifier_key (GimpTool *tool,
g_object_set (options, "use-info-window", ! options->use_info_window,
NULL);
}
else if (key == GDK_CONTROL_MASK)
else if (key == gimp_get_toggle_behavior_mask ())
{
switch (options->pick_mode)
{
@ -207,6 +207,9 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
{
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (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;
@ -231,16 +234,16 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
case GIMP_COLOR_PICK_MODE_FOREGROUND:
status_help = gimp_suggest_modifiers (_("Click in any image to pick"
" the foreground color"),
(shift_mod
| GDK_CONTROL_MASK) & ~state,
(shift_mod | toggle_mask) &
~state,
NULL, NULL, NULL);
break;
case GIMP_COLOR_PICK_MODE_BACKGROUND:
status_help = gimp_suggest_modifiers (_("Click in any image to pick"
" the background color"),
(shift_mod
| GDK_CONTROL_MASK) & ~state,
(shift_mod | toggle_mask) &
~state,
NULL, NULL, NULL);
break;

View File

@ -110,8 +110,11 @@ gimp_convolve_tool_modifier_key (GimpTool *tool,
{
GimpConvolveTool *convolve = GIMP_CONVOLVE_TOOL (tool);
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
GdkModifierType toggle_mask;
if (((key == GDK_CONTROL_MASK) &&
toggle_mask = gimp_get_toggle_behavior_mask ();
if (((key == toggle_mask) &&
! (state & GDK_SHIFT_MASK) && /* leave stuff untouched in line draw mode */
press != convolve->toggled)
@ -120,7 +123,7 @@ gimp_convolve_tool_modifier_key (GimpTool *tool,
(key == GDK_SHIFT_MASK && /* toggle back after keypresses CTRL(hold)-> */
! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
convolve->toggled &&
! (state & GDK_CONTROL_MASK)))
! (state & toggle_mask)))
{
convolve->toggled = press;
@ -200,15 +203,18 @@ gimp_convolve_tool_status_update (GimpTool *tool,
static GtkWidget *
gimp_convolve_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
GtkWidget *frame;
GtkWidget *scale;
gchar *str;
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
GtkWidget *frame;
GtkWidget *scale;
gchar *str;
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
/* the type radio box */
str = g_strdup_printf (_("Convolve Type (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
gimp_get_mod_string (toggle_mask));
frame = gimp_prop_enum_radio_frame_new (config, "type",
str, 0, 0);

View File

@ -48,6 +48,7 @@
#include "widgets/gimpcolorbar.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpcurveview.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
@ -280,7 +281,7 @@ gimp_curves_tool_button_release (GimpTool *tool,
gimp_curve_set_point (curve, closest,
value, gimp_curve_map_value (curve, value));
}
else if (state & GDK_CONTROL_MASK)
else if (state & gimp_get_toggle_behavior_mask ())
{
gint i;
@ -338,7 +339,7 @@ gimp_curves_tool_oper_update (GimpTool *tool,
mode = GIMP_COLOR_PICK_MODE_PALETTE;
status = _("Click to add a control point");
}
else if (state & GDK_CONTROL_MASK)
else if (state & gimp_get_toggle_behavior_mask ())
{
mode = GIMP_COLOR_PICK_MODE_PALETTE;
status = _("Click to add control points to all channels");

View File

@ -110,8 +110,11 @@ gimp_dodge_burn_tool_modifier_key (GimpTool *tool,
{
GimpDodgeBurnTool *dodgeburn = GIMP_DODGE_BURN_TOOL (tool);
GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
GdkModifierType toggle_mask;
if ((key == GDK_CONTROL_MASK &&
toggle_mask = gimp_get_toggle_behavior_mask ();
if ((key == toggle_mask &&
! (state & GDK_SHIFT_MASK) && /* leave stuff untouched in line draw mode */
press != dodgeburn->toggled)
@ -120,7 +123,7 @@ gimp_dodge_burn_tool_modifier_key (GimpTool *tool,
(key == GDK_SHIFT_MASK && /* toggle back after keypresses CTRL(hold)-> */
! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
dodgeburn->toggled &&
! (state & GDK_CONTROL_MASK)))
! (state & toggle_mask)))
{
dodgeburn->toggled = press;
@ -203,15 +206,18 @@ gimp_dodge_burn_tool_status_update (GimpTool *tool,
static GtkWidget *
gimp_dodge_burn_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
GtkWidget *frame;
GtkWidget *scale;
gchar *str;
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
GtkWidget *frame;
GtkWidget *scale;
gchar *str;
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
/* the type (dodge or burn) */
str = g_strdup_printf (_("Type (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
gimp_get_mod_string (toggle_mask));
frame = gimp_prop_enum_radio_frame_new (config, "type",
str, 0, 0);

View File

@ -46,6 +46,8 @@
#include "vectors/gimpvectors.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-appearance.h"
@ -765,7 +767,8 @@ gimp_edit_selection_tool_active_modifier_key (GimpTool *tool,
{
GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
edit_select->constrain = state & GDK_CONTROL_MASK ? TRUE : FALSE;
edit_select->constrain = (state & gimp_get_constrain_behavior_mask () ?
TRUE : FALSE);
/* If we didn't came here due to a mouse release, immediately update
* the position of the thing we move.
@ -1104,7 +1107,7 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
if (kevent->state & GDK_MOD1_MASK)
translate_type = GIMP_TRANSFORM_TYPE_SELECTION;
else if (kevent->state & GDK_CONTROL_MASK)
else if (kevent->state & gimp_get_toggle_behavior_mask ())
translate_type = GIMP_TRANSFORM_TYPE_PATH;
else
translate_type = GIMP_TRANSFORM_TYPE_LAYER;

View File

@ -115,13 +115,16 @@ gimp_flip_options_get_property (GObject *object,
GtkWidget *
gimp_flip_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
GtkWidget *hbox;
GtkWidget *box;
GtkWidget *label;
GtkWidget *frame;
gchar *str;
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
GtkWidget *hbox;
GtkWidget *box;
GtkWidget *label;
GtkWidget *frame;
gchar *str;
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
@ -137,7 +140,7 @@ gimp_flip_options_gui (GimpToolOptions *tool_options)
/* tool toggle */
str = g_strdup_printf (_("Flip Type (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
gimp_get_mod_string (toggle_mask));
frame = gimp_prop_enum_radio_frame_new (config, "flip-type",
str,

View File

@ -34,6 +34,7 @@
#include "core/gimppickable.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
@ -127,7 +128,7 @@ gimp_flip_tool_modifier_key (GimpTool *tool,
{
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (tool);
if (key == GDK_CONTROL_MASK)
if (key == gimp_get_toggle_behavior_mask ())
{
switch (options->flip_type)
{

View File

@ -258,18 +258,21 @@ gimp_foreground_select_options_get_property (GObject *object,
GtkWidget *
gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_selection_options_gui (tool_options);
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scale;
GtkWidget *label;
GtkWidget *menu;
GtkWidget *inner_frame;
GtkWidget *table;
gchar *title;
gint row = 0;
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_selection_options_gui (tool_options);
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scale;
GtkWidget *label;
GtkWidget *menu;
GtkWidget *inner_frame;
GtkWidget *table;
gchar *title;
gint row = 0;
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
gtk_widget_set_sensitive (GIMP_SELECTION_OPTIONS (tool_options)->antialias_toggle,
FALSE);
@ -281,7 +284,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
/* foreground / background */
title = g_strdup_printf (_("Interactive refinement (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
gimp_get_mod_string (toggle_mask));
frame = gimp_prop_boolean_radio_frame_new (config, "background", title,
_("Mark background"),

View File

@ -41,6 +41,7 @@
#include "core/gimpscanconvert.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@ -319,7 +320,7 @@ gimp_foreground_select_tool_modifier_key (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
if (key == GDK_CONTROL_MASK)
if (key == gimp_get_toggle_behavior_mask ())
{
GimpForegroundSelectOptions *options;

View File

@ -38,6 +38,7 @@
#include "core/gimplayer-floating-sel.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpcanvasgroup.h"
#include "display/gimpdisplay.h"
@ -1385,9 +1386,10 @@ gimp_free_select_tool_modifier_key (GimpTool *tool,
{
gimp_draw_tool_pause (draw_tool);
priv->constrain_angle = state & GDK_CONTROL_MASK ? TRUE : FALSE;
priv->constrain_angle = state & (gimp_get_constrain_behavior_mask () ?
TRUE : FALSE);
priv->supress_handles = state & GDK_SHIFT_MASK ? TRUE : FALSE;
priv->supress_handles = state & GDK_SHIFT_MASK ? TRUE : FALSE;
gimp_draw_tool_resume (draw_tool);
}
@ -1414,7 +1416,8 @@ gimp_free_select_tool_active_modifier_key (GimpTool *tool,
gimp_draw_tool_pause (draw_tool);
priv->constrain_angle = state & GDK_CONTROL_MASK ? TRUE : FALSE;
priv->constrain_angle = state & (gimp_get_constrain_behavior_mask () ?
TRUE : FALSE);
/* If we didn't came here due to a mouse release, immediately update
* the position of the thing we move.

View File

@ -158,11 +158,14 @@ gimp_magnify_options_reset (GimpToolOptions *tool_options)
GtkWidget *
gimp_magnify_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
GtkWidget *frame;
GtkWidget *button;
gchar *str;
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
GtkWidget *frame;
GtkWidget *button;
gchar *str;
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
/* the auto_resize toggle button */
button = gimp_prop_check_button_new (config, "auto-resize",
@ -172,7 +175,7 @@ gimp_magnify_options_gui (GimpToolOptions *tool_options)
/* tool toggle */
str = g_strdup_printf (_("Direction (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
gimp_get_mod_string (toggle_mask));
frame = gimp_prop_enum_radio_frame_new (config, "zoom-type",
str, 0, 0);

View File

@ -28,6 +28,7 @@
#include "core/gimpimage.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpcanvasrectangle.h"
#include "display/gimpdisplay.h"
@ -324,7 +325,7 @@ gimp_magnify_tool_modifier_key (GimpTool *tool,
{
GimpMagnifyOptions *options = GIMP_MAGNIFY_TOOL_GET_OPTIONS (tool);
if (key == GDK_CONTROL_MASK)
if (key == gimp_get_toggle_behavior_mask ())
{
switch (options->zoom_type)
{

View File

@ -220,12 +220,14 @@ gimp_measure_tool_button_press (GimpTool *tool,
*/
if (measure->point != -1)
{
if (state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if (state & (toggle_mask | GDK_MOD1_MASK))
{
gboolean create_hguide;
gboolean create_vguide;
create_hguide = ((state & GDK_CONTROL_MASK) &&
create_hguide = ((state & toggle_mask) &&
(measure->y[measure->point] ==
CLAMP (measure->y[measure->point],
0,
@ -435,7 +437,7 @@ gimp_measure_tool_motion (GimpTool *tool,
measure->x[measure->point] = ROUND (coords->x);
measure->y[measure->point] = ROUND (coords->y);
if (state & GDK_CONTROL_MASK)
if (state & gimp_get_constrain_behavior_mask ())
{
gdouble x = measure->x[measure->point];
gdouble y = measure->y[measure->point];
@ -503,7 +505,8 @@ gimp_measure_tool_active_modifier_key (GimpTool *tool,
{
GimpMeasureTool *measure = GIMP_MEASURE_TOOL (tool);
if (key == GDK_CONTROL_MASK && measure->function == MOVING)
if (key == gimp_get_constrain_behavior_mask () &&
measure->function == MOVING)
{
gdouble x, y;
@ -546,9 +549,11 @@ gimp_measure_tool_oper_update (GimpTool *tool,
if (gimp_canvas_item_hit (measure->handles[i],
coords->x, coords->y))
{
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
point = i;
if (state & GDK_CONTROL_MASK)
if (state & toggle_mask)
{
if (state & GDK_MOD1_MASK)
{
@ -576,7 +581,7 @@ gimp_measure_tool_oper_update (GimpTool *tool,
{
status = gimp_suggest_modifiers (_("Click to place a "
"vertical guide"),
GDK_CONTROL_MASK & ~state,
toggle_mask & ~state,
NULL, NULL, NULL);
gimp_tool_replace_status (tool, display, "%s", status);
g_free (status);
@ -589,8 +594,8 @@ gimp_measure_tool_oper_update (GimpTool *tool,
{
status = gimp_suggest_modifiers (_("Click-Drag to add a "
"new point"),
(GDK_CONTROL_MASK
| GDK_MOD1_MASK) & ~state,
(toggle_mask |
GDK_MOD1_MASK) & ~state,
NULL, NULL, NULL);
}
else
@ -599,9 +604,9 @@ gimp_measure_tool_oper_update (GimpTool *tool,
state |= GDK_SHIFT_MASK;
status = gimp_suggest_modifiers (_("Click-Drag to move this "
"point"),
(GDK_SHIFT_MASK
| GDK_CONTROL_MASK
| GDK_MOD1_MASK) & ~state,
(GDK_SHIFT_MASK |
toggle_mask |
GDK_MOD1_MASK) & ~state,
NULL, NULL, NULL);
}
@ -667,7 +672,9 @@ gimp_measure_tool_cursor_update (GimpTool *tool,
{
if (measure->point != -1)
{
if (state & GDK_CONTROL_MASK)
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if (state & toggle_mask)
{
if (state & GDK_MOD1_MASK)
cursor = GIMP_CURSOR_CORNER_BOTTOM_RIGHT;

View File

@ -42,6 +42,7 @@
#include "core/gimpundostack.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpcanvasitem.h"
#include "display/gimpdisplay.h"
@ -582,7 +583,8 @@ gimp_move_tool_modifier_key (GimpTool *tool,
{
g_object_set (options, "move-current", ! options->move_current, NULL);
}
else if (key == GDK_MOD1_MASK || key == GDK_CONTROL_MASK)
else if (key == GDK_MOD1_MASK ||
key == gimp_get_toggle_behavior_mask ())
{
GimpTransformType button_type;
@ -590,7 +592,8 @@ gimp_move_tool_modifier_key (GimpTool *tool,
if (press)
{
if (key == (state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)))
if (key == (state & (GDK_MOD1_MASK |
gimp_get_toggle_behavior_mask ())))
{
/* first modifier pressed */
@ -599,7 +602,8 @@ gimp_move_tool_modifier_key (GimpTool *tool,
}
else
{
if (! (state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)))
if (! (state & (GDK_MOD1_MASK |
gimp_get_toggle_behavior_mask ())))
{
/* last modifier released */
@ -611,7 +615,7 @@ gimp_move_tool_modifier_key (GimpTool *tool,
{
button_type = GIMP_TRANSFORM_TYPE_SELECTION;
}
else if (state & GDK_CONTROL_MASK)
else if (state & gimp_get_toggle_behavior_mask ())
{
button_type = GIMP_TRANSFORM_TYPE_PATH;
}

View File

@ -310,13 +310,14 @@ gimp_paint_tool_button_press (GimpTool *tool,
}
else if (paint_tool->draw_line)
{
gboolean constrain = (state & gimp_get_constrain_behavior_mask ()) != 0;
/* If shift is down and this is not the first paint
* stroke, then draw a line from the last coords to the pointer
*/
core->start_coords = core->last_coords;
gimp_paint_core_round_line (core, paint_options,
(state & GDK_CONTROL_MASK) != 0);
gimp_paint_core_round_line (core, paint_options, constrain);
}
/* chain up to activate the tool */
@ -451,7 +452,7 @@ gimp_paint_tool_modifier_key (GimpTool *tool,
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
if (key != GDK_CONTROL_MASK)
if (key != gimp_get_constrain_behavior_mask ())
return;
if (paint_tool->pick_colors && ! paint_tool->draw_line)
@ -591,15 +592,17 @@ gimp_paint_tool_oper_update (GimpTool *tool,
if (drawable && proximity)
{
gboolean constrain_mask = gimp_get_constrain_behavior_mask ();
if (display == tool->display && (state & GDK_SHIFT_MASK))
{
/* If shift is down and this is not the first paint stroke,
* draw a line.
*/
gchar *status_help;
gdouble dx, dy, dist;
gint off_x, off_y;
gchar *status_help;
gdouble dx, dy, dist;
gint off_x, off_y;
core->cur_coords = *coords;
@ -609,13 +612,13 @@ gimp_paint_tool_oper_update (GimpTool *tool,
core->cur_coords.y -= off_y;
gimp_paint_core_round_line (core, paint_options,
(state & GDK_CONTROL_MASK) != 0);
(state & constrain_mask) != 0);
dx = core->cur_coords.x - core->last_coords.x;
dy = core->cur_coords.y - core->last_coords.y;
status_help = gimp_suggest_modifiers (paint_tool->status_line,
GDK_CONTROL_MASK & ~state,
constrain_mask & ~state,
NULL,
_("%s for constrained angles"),
NULL);
@ -663,7 +666,7 @@ gimp_paint_tool_oper_update (GimpTool *tool,
* gimp_suggest_modifiers() would interpret this parameter.
*/
if (paint_tool->status_ctrl != NULL)
modifiers |= GDK_CONTROL_MASK;
modifiers |= constrain_mask;
/* suggest drawing lines only after the first point is set
*/

View File

@ -340,11 +340,12 @@ gimp_perspective_clone_tool_button_press (GimpTool *tool,
case GIMP_PERSPECTIVE_CLONE_MODE_PAINT:
{
gdouble nnx, nny;
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
gdouble nnx, nny;
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask)
{
source_core->set_source = TRUE;
@ -568,7 +569,9 @@ gimp_perspective_clone_tool_cursor_update (GimpTool *tool,
{
if (GIMP_CLONE_OPTIONS (options)->clone_type == GIMP_IMAGE_CLONE)
{
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask)
{
cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
}

View File

@ -388,8 +388,12 @@ gimp_rectangle_select_tool_button_press (GimpTool *tool,
/* if the shift or ctrl keys are down, we don't want to adjust, we
* want to create a new rectangle, regardless of pointer loc */
if (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))
gimp_rectangle_tool_set_function (rectangle, GIMP_RECTANGLE_TOOL_CREATING);
if (state & (gimp_get_extend_selection_mask () |
gimp_get_modify_selection_mask ()))
{
gimp_rectangle_tool_set_function (rectangle,
GIMP_RECTANGLE_TOOL_CREATING);
}
gimp_rectangle_tool_button_press (tool, coords, time, state, display);
@ -549,8 +553,12 @@ gimp_rectangle_select_tool_cursor_update (GimpTool *tool,
gimp_rectangle_tool_cursor_update (tool, coords, state, display);
/* override the previous if shift or ctrl are down */
if (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))
gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_CROSSHAIR_SMALL);
if (state & (gimp_get_extend_selection_mask () |
gimp_get_modify_selection_mask ()))
{
gimp_tool_control_set_cursor (tool->control,
GIMP_CURSOR_CROSSHAIR_SMALL);
}
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}

View File

@ -40,6 +40,8 @@
#include "core/gimppickable.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpcanvasgroup.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@ -1278,7 +1280,7 @@ gimp_rectangle_tool_active_modifier_key (GimpTool *tool,
}
}
if (key == GDK_CONTROL_MASK)
if (key == gimp_get_toggle_behavior_mask ())
{
g_object_set (options,
"fixed-center", ! options_private->fixed_center,

View File

@ -162,30 +162,35 @@ gimp_selection_options_get_property (GObject *object,
}
static const gchar *
gimp_selection_options_get_modifier (GimpChannelOps operation)
gimp_selection_options_get_modifiers (GimpChannelOps operation)
{
GdkModifierType mod = 0;
GdkModifierType extend_mask;
GdkModifierType modify_mask;
GdkModifierType modifiers = 0;
extend_mask = gimp_get_extend_selection_mask ();
modify_mask = gimp_get_modify_selection_mask ();
switch (operation)
{
case GIMP_CHANNEL_OP_ADD:
mod = GDK_SHIFT_MASK;
modifiers = extend_mask;
break;
case GIMP_CHANNEL_OP_SUBTRACT:
mod = GDK_CONTROL_MASK;
modifiers = modify_mask;
break;
case GIMP_CHANNEL_OP_REPLACE:
mod = 0;
modifiers = 0;
break;
case GIMP_CHANNEL_OP_INTERSECT:
mod = GDK_CONTROL_MASK | GDK_SHIFT_MASK;
modifiers = extend_mask | modify_mask;
break;
}
return gimp_get_mod_string (mod);
return gimp_get_mod_string (gimp_replace_virtual_modifiers (modifiers));
}
GtkWidget *
@ -224,7 +229,7 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
for (list = children, i = 0; list; list = list->next, i++)
{
GtkWidget *button = list->data;
const gchar *modifier = gimp_selection_options_get_modifier (i);
const gchar *modifier = gimp_selection_options_get_modifiers (i);
gchar *tooltip;
if (! modifier)

View File

@ -90,20 +90,23 @@ gimp_selection_tool_modifier_key (GimpTool *tool,
GimpDisplay *display)
{
GimpSelectionTool *selection_tool = GIMP_SELECTION_TOOL (tool);
GimpSelectionOptions *options;
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GdkModifierType extend_mask;
GdkModifierType modify_mask;
options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
extend_mask = gimp_get_extend_selection_mask ();
modify_mask = gimp_get_modify_selection_mask ();
if (key == GDK_SHIFT_MASK ||
key == GDK_CONTROL_MASK ||
if (key == extend_mask ||
key == modify_mask ||
key == GDK_MOD1_MASK)
{
GimpChannelOps button_op = options->operation;
if (press)
{
if (key == (state & (GDK_SHIFT_MASK |
GDK_CONTROL_MASK |
if (key == (state & (extend_mask |
modify_mask |
GDK_MOD1_MASK)))
{
/* first modifier pressed */
@ -113,8 +116,8 @@ gimp_selection_tool_modifier_key (GimpTool *tool,
}
else
{
if (! (state & (GDK_SHIFT_MASK |
GDK_CONTROL_MASK |
if (! (state & (extend_mask |
modify_mask |
GDK_MOD1_MASK)))
{
/* last modifier released */
@ -130,17 +133,9 @@ gimp_selection_tool_modifier_key (GimpTool *tool,
*/
button_op = selection_tool->saved_operation;
}
else if ((state & GDK_CONTROL_MASK) && (state & GDK_SHIFT_MASK))
else
{
button_op = GIMP_CHANNEL_OP_INTERSECT;
}
else if (state & GDK_SHIFT_MASK)
{
button_op = GIMP_CHANNEL_OP_ADD;
}
else if (state & GDK_CONTROL_MASK)
{
button_op = GIMP_CHANNEL_OP_SUBTRACT;
button_op = gimp_modifiers_to_channel_op (state);
}
if (button_op != options->operation)
@ -158,24 +153,27 @@ gimp_selection_tool_oper_update (GimpTool *tool,
GimpDisplay *display)
{
GimpSelectionTool *selection_tool = GIMP_SELECTION_TOOL (tool);
GimpSelectionOptions *options;
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpImage *image;
GimpChannel *selection;
GimpDrawable *drawable;
GimpLayer *layer;
GimpLayer *floating_sel;
GdkModifierType extend_mask;
GdkModifierType modify_mask;
gboolean move_layer = FALSE;
gboolean move_floating_sel = FALSE;
gboolean selection_empty;
options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
image = gimp_display_get_image (display);
selection = gimp_image_get_mask (image);
drawable = gimp_image_get_active_drawable (image);
layer = gimp_image_pick_layer (image, coords->x, coords->y);
floating_sel = gimp_image_get_floating_selection (image);
extend_mask = gimp_get_extend_selection_mask ();
modify_mask = gimp_get_modify_selection_mask ();
if (drawable)
{
if (floating_sel)
@ -195,13 +193,13 @@ gimp_selection_tool_oper_update (GimpTool *tool,
selection_tool->function = SELECTION_SELECT;
if (selection_tool->allow_move &&
(state & GDK_MOD1_MASK) && (state & GDK_CONTROL_MASK) && move_layer)
(state & GDK_MOD1_MASK) && (state & modify_mask) && move_layer)
{
/* move the selection */
selection_tool->function = SELECTION_MOVE;
}
else if (selection_tool->allow_move &&
(state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK) && move_layer)
(state & GDK_MOD1_MASK) && (state & extend_mask) && move_layer)
{
/* move a copy of the selection */
selection_tool->function = SELECTION_MOVE_COPY;
@ -213,13 +211,13 @@ gimp_selection_tool_oper_update (GimpTool *tool,
selection_tool->function = SELECTION_MOVE_MASK;
}
else if (selection_tool->allow_move &&
! (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
! (state & (extend_mask | modify_mask)) &&
move_floating_sel)
{
/* move the selection */
selection_tool->function = SELECTION_MOVE;
}
else if ((state & GDK_CONTROL_MASK) || (state & GDK_SHIFT_MASK))
else if ((state & modify_mask) || (state & extend_mask))
{
/* select */
selection_tool->function = SELECTION_SELECT;
@ -236,7 +234,7 @@ gimp_selection_tool_oper_update (GimpTool *tool,
{
const gchar *status = NULL;
gboolean free_status = FALSE;
GdkModifierType modifiers = (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
GdkModifierType modifiers = (extend_mask | modify_mask);
if (! selection_empty)
modifiers |= GDK_MOD1_MASK;
@ -265,7 +263,7 @@ gimp_selection_tool_oper_update (GimpTool *tool,
status = gimp_suggest_modifiers (_("Click-Drag to add to the "
"current selection"),
modifiers
& ~(state | GDK_SHIFT_MASK),
& ~(state | extend_mask),
NULL, NULL, NULL);
free_status = TRUE;
break;
@ -274,7 +272,7 @@ gimp_selection_tool_oper_update (GimpTool *tool,
status = gimp_suggest_modifiers (_("Click-Drag to subtract from the "
"current selection"),
modifiers
& ~(state | GDK_CONTROL_MASK),
& ~(state | modify_mask),
NULL, NULL, NULL);
free_status = TRUE;
break;

View File

@ -176,10 +176,11 @@ gimp_source_tool_button_press (GimpTool *tool,
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask)
{
source->set_source = TRUE;
@ -231,7 +232,7 @@ gimp_source_tool_modifier_key (GimpTool *tool,
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpSourceOptions *options = GIMP_SOURCE_TOOL_GET_OPTIONS (tool);
if (options->use_source && key == GDK_CONTROL_MASK)
if (options->use_source && key == gimp_get_toggle_behavior_mask ())
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
@ -267,7 +268,9 @@ gimp_source_tool_cursor_update (GimpTool *tool,
if (options->use_source)
{
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask)
{
cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
}
@ -312,7 +315,9 @@ gimp_source_tool_oper_update (GimpTool *tool,
if (source->src_drawable == NULL)
{
if (state & GDK_CONTROL_MASK)
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if (state & toggle_mask)
{
gimp_tool_replace_status (tool, display, "%s",
source_tool->status_set_source);
@ -320,7 +325,7 @@ gimp_source_tool_oper_update (GimpTool *tool,
else
{
gimp_tool_replace_status (tool, display, "%s%s%s",
gimp_get_mod_string (GDK_CONTROL_MASK),
gimp_get_mod_string (toggle_mask),
gimp_get_mod_separator (),
source_tool->status_set_source);
}

View File

@ -351,11 +351,14 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
if (constrain)
{
GtkWidget *button;
gchar *label;
GtkWidget *button;
gchar *label;
GdkModifierType constrain_mask;
constrain_mask = gimp_get_constrain_behavior_mask ();
label = g_strdup_printf (constrain,
gimp_get_mod_string (GDK_CONTROL_MASK));
gimp_get_mod_string (constrain_mask));
button = gimp_prop_check_button_new (config, "constrain", label);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

View File

@ -51,6 +51,7 @@
#include "vectors/gimpstroke.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpcanvasgroup.h"
#include "display/gimpdisplay.h"
@ -456,7 +457,7 @@ gimp_transform_tool_modifier_key (GimpTool *tool,
{
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
if (key == GDK_CONTROL_MASK)
if (key == gimp_get_constrain_behavior_mask ())
g_object_set (options,
"constrain", ! options->constrain,
NULL);

View File

@ -166,7 +166,8 @@ gimp_vector_options_gui (GimpToolOptions *tool_options)
button_append_modifier (list->data, GDK_MOD1_MASK);
if (list->next) /* GIMP_VECTOR_MODE_EDIT */
button_append_modifier (list->next->data, GDK_CONTROL_MASK);
button_append_modifier (list->next->data,
gimp_get_toggle_behavior_mask ());
}
button = gimp_prop_check_button_new (config, "vectors-polygonal",
@ -178,10 +179,10 @@ gimp_vector_options_gui (GimpToolOptions *tool_options)
"%s Add\n"
"%s Subtract\n"
"%s Intersect"),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_string (GDK_CONTROL_MASK),
gimp_get_mod_string (GDK_SHIFT_MASK |
GDK_CONTROL_MASK));
gimp_get_mod_string (gimp_get_extend_selection_mask ()),
gimp_get_mod_string (gimp_get_modify_selection_mask ()),
gimp_get_mod_string (gimp_get_extend_selection_mask () |
gimp_get_modify_selection_mask ()));
button = gimp_button_new ();
/* Create a selection from the current path */

View File

@ -63,7 +63,7 @@
#define TOGGLE_MASK GDK_SHIFT_MASK
#define MOVE_MASK GDK_MOD1_MASK
#define INSDEL_MASK GDK_CONTROL_MASK
#define INSDEL_MASK gimp_get_toggle_behavior_mask ()
/* local function prototypes */
@ -813,7 +813,7 @@ gimp_vector_tool_key_press (GimpTool *tool,
if (kevent->state & GDK_SHIFT_MASK)
pixels = 10.0;
if (kevent->state & GDK_CONTROL_MASK)
if (kevent->state & gimp_get_toggle_behavior_mask ())
pixels = 50.0;
switch (kevent->keyval)
@ -1221,9 +1221,11 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_MOVE_ANCHOR:
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 "
"anchor around"),
GDK_CONTROL_MASK & ~state,
toggle_mask & ~state,
NULL, NULL, NULL);
free_status = TRUE;
}
@ -1926,28 +1928,15 @@ static void
gimp_vector_tool_to_selection_extended (GimpVectorTool *vector_tool,
gint state)
{
GimpImage *image;
GimpChannelOps operation = GIMP_CHANNEL_OP_REPLACE;
GimpImage *image;
if (! vector_tool->vectors)
return;
image = gimp_item_get_image (GIMP_ITEM (vector_tool->vectors));
if (state & GDK_SHIFT_MASK)
{
if (state & GDK_CONTROL_MASK)
operation = GIMP_CHANNEL_OP_INTERSECT;
else
operation = GIMP_CHANNEL_OP_ADD;
}
else if (state & GDK_CONTROL_MASK)
{
operation = GIMP_CHANNEL_OP_SUBTRACT;
}
gimp_item_to_selection (GIMP_ITEM (vector_tool->vectors),
operation,
gimp_modifiers_to_channel_op (state),
TRUE, FALSE, 0, 0);
gimp_image_flush (image);
}