mirror of https://github.com/GNOME/gimp.git
Clean up fix for bug #328001:
2007-03-07 Michael Natterer <mitch@gimp.org> Clean up fix for bug #328001: * app/tools/gimpeditselectiontool.[ch] (process_event_queue_keys): made private again. (gimp_edit_selection_tool_translate): new function which has an additional GimpTransformType parameter to determine what transform to perform. Do all the work here, ignoring the key event's modifier state. (gimp_edit_selection_tool_key_press): just determine the transform type from the key event's modifier state and call gimp_edit_selection_tool_translate(). * app/tools/gimpmovetool.c (gimp_move_tool_key_press): removed all code and call gimp_edit_selection_tool_translate() with options->move_type. Moved the function to its proper place in the file. svn path=/trunk/; revision=22063
This commit is contained in:
parent
4d76165127
commit
c2c21a30f2
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2007-03-07 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Clean up fix for bug #328001:
|
||||
|
||||
* app/tools/gimpeditselectiontool.[ch] (process_event_queue_keys):
|
||||
made private again.
|
||||
|
||||
(gimp_edit_selection_tool_translate): new function which has an
|
||||
additional GimpTransformType parameter to determine what transform
|
||||
to perform. Do all the work here, ignoring the key event's
|
||||
modifier state.
|
||||
|
||||
(gimp_edit_selection_tool_key_press): just determine the transform
|
||||
type from the key event's modifier state and call
|
||||
gimp_edit_selection_tool_translate().
|
||||
|
||||
* app/tools/gimpmovetool.c (gimp_move_tool_key_press): removed all
|
||||
code and call gimp_edit_selection_tool_translate() with
|
||||
options->move_type. Moved the function to its proper place in the
|
||||
file.
|
||||
|
||||
2007-03-07 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/base/pixel-surround.c: keep an internal buffer filled with
|
||||
|
|
|
@ -872,7 +872,7 @@ gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool)
|
|||
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
||||
}
|
||||
|
||||
gint
|
||||
static gint
|
||||
process_event_queue_keys (GdkEventKey *kevent,
|
||||
... /* GdkKeyType, GdkModifierType, value ... 0 */)
|
||||
{
|
||||
|
@ -971,6 +971,25 @@ gboolean
|
|||
gimp_edit_selection_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpTransformType translate_type;
|
||||
|
||||
if (kevent->state & GDK_MOD1_MASK)
|
||||
translate_type = GIMP_TRANSFORM_TYPE_SELECTION;
|
||||
else if (kevent->state & GDK_CONTROL_MASK)
|
||||
translate_type = GIMP_TRANSFORM_TYPE_PATH;
|
||||
else
|
||||
translate_type = GIMP_TRANSFORM_TYPE_LAYER;
|
||||
|
||||
return gimp_edit_selection_tool_translate (tool, kevent, translate_type,
|
||||
display);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_edit_selection_tool_translate (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpTransformType translate_type,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
gint inc_x = 0;
|
||||
gint inc_y = 0;
|
||||
|
@ -995,145 +1014,91 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
|
|||
gimp_zoom_model_get_factor (GIMP_DISPLAY_SHELL (display->shell)->zoom));
|
||||
velocity = MAX (1.0, velocity);
|
||||
|
||||
/* check for mask translation first because the translate_layer
|
||||
* modifiers match the translate_mask ones...
|
||||
/* check the event queue for key events with the same modifier mask
|
||||
* as the current event, allowing only GDK_SHIFT_MASK to vary between
|
||||
* them.
|
||||
*/
|
||||
inc_x =
|
||||
process_event_queue_keys (kevent,
|
||||
GDK_Left, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
|
||||
-1 * velocity,
|
||||
inc_x = process_event_queue_keys (kevent,
|
||||
GDK_Left,
|
||||
kevent->state | GDK_SHIFT_MASK,
|
||||
-1 * velocity,
|
||||
|
||||
GDK_Left, GDK_MOD1_MASK,
|
||||
-1,
|
||||
GDK_Left,
|
||||
kevent->state & ~GDK_SHIFT_MASK,
|
||||
-1,
|
||||
|
||||
GDK_Right, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
|
||||
1 * velocity,
|
||||
GDK_Right,
|
||||
kevent->state | GDK_SHIFT_MASK,
|
||||
1 * velocity,
|
||||
|
||||
GDK_Right, GDK_MOD1_MASK,
|
||||
1,
|
||||
GDK_Right,
|
||||
kevent->state & ~GDK_SHIFT_MASK,
|
||||
1,
|
||||
|
||||
0);
|
||||
0);
|
||||
|
||||
inc_y =
|
||||
process_event_queue_keys (kevent,
|
||||
GDK_Up, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
|
||||
-1 * velocity,
|
||||
inc_y = process_event_queue_keys (kevent,
|
||||
GDK_Up,
|
||||
kevent->state | GDK_SHIFT_MASK,
|
||||
-1 * velocity,
|
||||
|
||||
GDK_Up, GDK_MOD1_MASK,
|
||||
-1,
|
||||
GDK_Up,
|
||||
kevent->state & ~GDK_SHIFT_MASK,
|
||||
-1,
|
||||
|
||||
GDK_Down, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
|
||||
1 * velocity,
|
||||
GDK_Down,
|
||||
kevent->state | GDK_SHIFT_MASK,
|
||||
1 * velocity,
|
||||
|
||||
GDK_Down, GDK_MOD1_MASK,
|
||||
1,
|
||||
GDK_Down,
|
||||
kevent->state & ~GDK_SHIFT_MASK,
|
||||
1,
|
||||
|
||||
0);
|
||||
0);
|
||||
|
||||
if (inc_x != 0 || inc_y != 0)
|
||||
{
|
||||
item = GIMP_ITEM (gimp_image_get_mask (display->image));
|
||||
|
||||
edit_mode = GIMP_TRANSLATE_MODE_MASK;
|
||||
undo_type = GIMP_UNDO_GROUP_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
inc_x = process_event_queue_keys (kevent,
|
||||
GDK_Left, (GDK_CONTROL_MASK | GDK_SHIFT_MASK),
|
||||
-1 * velocity,
|
||||
|
||||
GDK_Left, GDK_CONTROL_MASK,
|
||||
-1,
|
||||
|
||||
GDK_Right, (GDK_CONTROL_MASK | GDK_SHIFT_MASK),
|
||||
1 * velocity,
|
||||
|
||||
GDK_Right, GDK_CONTROL_MASK,
|
||||
1,
|
||||
|
||||
0);
|
||||
|
||||
inc_y = process_event_queue_keys (kevent,
|
||||
GDK_Up, (GDK_CONTROL_MASK | GDK_SHIFT_MASK),
|
||||
-1 * velocity,
|
||||
|
||||
GDK_Up, GDK_CONTROL_MASK,
|
||||
-1,
|
||||
|
||||
GDK_Down, (GDK_CONTROL_MASK | GDK_SHIFT_MASK),
|
||||
1 * velocity,
|
||||
|
||||
GDK_Down, GDK_CONTROL_MASK,
|
||||
1,
|
||||
|
||||
0);
|
||||
|
||||
if (inc_x != 0 || inc_y != 0)
|
||||
switch (translate_type)
|
||||
{
|
||||
item = (GimpItem *) gimp_image_get_active_vectors (display->image);
|
||||
case GIMP_TRANSFORM_TYPE_SELECTION:
|
||||
item = GIMP_ITEM (gimp_image_get_mask (display->image));
|
||||
|
||||
edit_mode = GIMP_TRANSLATE_MODE_MASK;
|
||||
undo_type = GIMP_UNDO_GROUP_MASK;
|
||||
break;
|
||||
|
||||
case GIMP_TRANSFORM_TYPE_PATH:
|
||||
item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
|
||||
|
||||
edit_mode = GIMP_TRANSLATE_MODE_VECTORS;
|
||||
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
|
||||
}
|
||||
else
|
||||
{
|
||||
inc_x = process_event_queue_keys (kevent,
|
||||
GDK_Left, GDK_SHIFT_MASK,
|
||||
-1 * velocity,
|
||||
break;
|
||||
|
||||
GDK_Left, 0,
|
||||
-1,
|
||||
case GIMP_TRANSFORM_TYPE_LAYER:
|
||||
item = GIMP_ITEM (gimp_image_active_drawable (display->image));
|
||||
|
||||
GDK_Right, GDK_SHIFT_MASK,
|
||||
1 * velocity,
|
||||
|
||||
GDK_Right, 0,
|
||||
1,
|
||||
|
||||
0);
|
||||
|
||||
inc_y = process_event_queue_keys (kevent,
|
||||
GDK_Up, GDK_SHIFT_MASK,
|
||||
-1 * velocity,
|
||||
|
||||
GDK_Up, 0,
|
||||
-1,
|
||||
|
||||
GDK_Down, GDK_SHIFT_MASK,
|
||||
1 * velocity,
|
||||
|
||||
GDK_Down, 0,
|
||||
1,
|
||||
|
||||
0);
|
||||
|
||||
if (inc_x != 0 || inc_y != 0)
|
||||
if (item)
|
||||
{
|
||||
item = (GimpItem *) gimp_image_active_drawable (display->image);
|
||||
|
||||
if (item)
|
||||
if (GIMP_IS_LAYER_MASK (item))
|
||||
{
|
||||
if (GIMP_IS_LAYER_MASK (item))
|
||||
{
|
||||
edit_mode = GIMP_TRANSLATE_MODE_LAYER_MASK;
|
||||
}
|
||||
else if (GIMP_IS_CHANNEL (item))
|
||||
{
|
||||
edit_mode = GIMP_TRANSLATE_MODE_CHANNEL;
|
||||
}
|
||||
else if (gimp_layer_is_floating_sel (GIMP_LAYER (item)))
|
||||
{
|
||||
edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
edit_mode = GIMP_TRANSLATE_MODE_LAYER;
|
||||
}
|
||||
|
||||
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
|
||||
edit_mode = GIMP_TRANSLATE_MODE_LAYER_MASK;
|
||||
}
|
||||
else if (GIMP_IS_CHANNEL (item))
|
||||
{
|
||||
edit_mode = GIMP_TRANSLATE_MODE_CHANNEL;
|
||||
}
|
||||
else if (gimp_layer_is_floating_sel (GIMP_LAYER (item)))
|
||||
{
|
||||
edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
edit_mode = GIMP_TRANSLATE_MODE_LAYER;
|
||||
}
|
||||
|
||||
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,11 +72,10 @@ void gimp_edit_selection_tool_start (GimpTool *parent_tool,
|
|||
gboolean gimp_edit_selection_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display);
|
||||
gboolean gimp_edit_selection_tool_translate (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpTransformType translate_type,
|
||||
GimpDisplay *display);
|
||||
|
||||
/* could move this function to a more central location
|
||||
* so it can be used by other tools?
|
||||
*/
|
||||
gint process_event_queue_keys (GdkEventKey *kevent,
|
||||
... /* GdkKeyType, GdkModifierType, value ... 0 */);
|
||||
|
||||
#endif /* __GIMP_EDIT_SELECTION_TOOL_H__ */
|
||||
|
|
|
@ -84,6 +84,9 @@ static void gimp_move_tool_motion (GimpTool *tool,
|
|||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static gboolean gimp_move_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display);
|
||||
static void gimp_move_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
|
@ -105,10 +108,6 @@ static void gimp_move_tool_start_guide (GimpMoveTool *move,
|
|||
GimpDisplay *display,
|
||||
GimpOrientationType orientation);
|
||||
|
||||
static gboolean gimp_move_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpMoveTool, gimp_move_tool, GIMP_TYPE_DRAW_TOOL)
|
||||
|
||||
|
@ -561,6 +560,18 @@ gimp_move_tool_motion (GimpTool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_move_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
|
||||
|
||||
return gimp_edit_selection_tool_translate (tool, kevent,
|
||||
options->move_type,
|
||||
display);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_move_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
|
@ -830,132 +841,3 @@ gimp_move_tool_start_guide (GimpMoveTool *move,
|
|||
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (move), display);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_move_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
|
||||
GimpUndo *undo;
|
||||
GimpItem *item;
|
||||
GimpUndoType undo_type;
|
||||
const gchar *undo_desc;
|
||||
gboolean push_undo;
|
||||
gint inc_x;
|
||||
gint inc_y;
|
||||
gint velocity;
|
||||
|
||||
/* bail out early if it is not an arrow key event */
|
||||
if (kevent->keyval != GDK_Left &&
|
||||
kevent->keyval != GDK_Right &&
|
||||
kevent->keyval != GDK_Up &&
|
||||
kevent->keyval != GDK_Down)
|
||||
return FALSE;
|
||||
|
||||
/* Handle cases gimp_edit_selection_tool_key_press can't handle here,
|
||||
otherwise just pass everything on to it. */
|
||||
switch (options->move_type)
|
||||
{
|
||||
/* Fix bug #328001 */
|
||||
case GIMP_TRANSFORM_TYPE_SELECTION:
|
||||
|
||||
if (gimp_channel_is_empty (gimp_image_get_mask (display->image)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
item = GIMP_ITEM (gimp_image_get_mask (display->image));
|
||||
|
||||
/* adapt arrow velocity to the zoom factor when holding <shift> */
|
||||
velocity = (ARROW_VELOCITY /
|
||||
gimp_zoom_model_get_factor (GIMP_DISPLAY_SHELL (display->shell)->zoom));
|
||||
velocity = MAX (1.0, velocity);
|
||||
|
||||
inc_x = process_event_queue_keys (kevent,
|
||||
GDK_Left, GDK_SHIFT_MASK,
|
||||
-1 * velocity,
|
||||
|
||||
GDK_Left, 0,
|
||||
-1,
|
||||
|
||||
GDK_Right, GDK_SHIFT_MASK,
|
||||
1 * velocity,
|
||||
|
||||
GDK_Right, 0,
|
||||
1,
|
||||
|
||||
0);
|
||||
|
||||
inc_y = process_event_queue_keys (kevent,
|
||||
GDK_Up, GDK_SHIFT_MASK,
|
||||
-1 * velocity,
|
||||
|
||||
GDK_Up, 0,
|
||||
-1,
|
||||
|
||||
GDK_Down, GDK_SHIFT_MASK,
|
||||
1 * velocity,
|
||||
|
||||
GDK_Down, 0,
|
||||
1,
|
||||
|
||||
0);
|
||||
|
||||
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
|
||||
undo_desc = GIMP_ITEM_GET_CLASS (item)->translate_desc;
|
||||
|
||||
/* compress undo */
|
||||
undo = gimp_image_undo_can_compress (display->image, GIMP_TYPE_UNDO_STACK,
|
||||
undo_type);
|
||||
|
||||
/* Only push undo if we're not working on the same group of undo:s as in
|
||||
the previous call to this function. */
|
||||
push_undo = ! (undo &&
|
||||
g_object_get_data (G_OBJECT (undo),
|
||||
"move-tool") == (gpointer) tool &&
|
||||
g_object_get_data (G_OBJECT (undo),
|
||||
"move-tool-item") == (gpointer) item &&
|
||||
g_object_get_data (G_OBJECT (undo),
|
||||
"move-tool-type") == GINT_TO_POINTER (options->move_type));
|
||||
|
||||
if (push_undo)
|
||||
{
|
||||
if (gimp_image_undo_group_start (display->image, undo_type, undo_desc))
|
||||
{
|
||||
undo = gimp_image_undo_can_compress (display->image,
|
||||
GIMP_TYPE_UNDO_STACK,
|
||||
undo_type);
|
||||
|
||||
if (undo)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (undo), "move-tool",
|
||||
tool);
|
||||
g_object_set_data (G_OBJECT (undo), "move-tool-item",
|
||||
item);
|
||||
g_object_set_data (G_OBJECT (undo), "move-tool-type",
|
||||
GINT_TO_POINTER (options->move_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gimp_item_translate (item, inc_x, inc_y, push_undo);
|
||||
|
||||
if (push_undo)
|
||||
{
|
||||
gimp_image_undo_group_end (display->image);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_undo_refresh_preview (undo,
|
||||
gimp_get_user_context (display->image->gimp));
|
||||
}
|
||||
|
||||
gimp_image_flush (display->image);
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return gimp_edit_selection_tool_key_press (tool, kevent, display);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue