Commit 02b91f66 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/tools/gimptool.[ch] added boolean return value to

2004-06-24  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimptool.[ch]
	* app/tools/tool_manager.[ch]: added boolean return value to
	GimpTool::key_press() which indicates if the event was handled.

	* app/tools/gimpcroptool.c
	* app/tools/gimpeditselectiontool.[ch]
	* app/tools/gimptransformtool.c
	* app/tools/gimpvectortool.c: return TRUE if the key event was handled.

	* app/tools/gimppainttool.c: removed key_press() implementation.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpcontrollerkeyboard.[ch]: new controller class
	which takes GdkEventKey and emits controller events for all
	combinations of modifiers and cursor keys.

	* app/widgets/gimpcontrollers.[ch]: added new function
	gimp_controllers_get_keyboard().

	* app/display/gimpdisplayshell-callbacks.c: if a key event was not
	handled by the active tool, dispatch it to the keyboard controller.

	* etc/controllerrc: add a keyboard controller which is configured
	to do the same as the removed gimp_paint_tool_key_press().
parent ffe9ac07
2004-06-24 Michael Natterer <mitch@gimp.org>
* app/tools/gimptool.[ch]
* app/tools/tool_manager.[ch]: added boolean return value to
GimpTool::key_press() which indicates if the event was handled.
* app/tools/gimpcroptool.c
* app/tools/gimpeditselectiontool.[ch]
* app/tools/gimptransformtool.c
* app/tools/gimpvectortool.c: return TRUE if the key event was handled.
* app/tools/gimppainttool.c: removed key_press() implementation.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpcontrollerkeyboard.[ch]: new controller class
which takes GdkEventKey and emits controller events for all
combinations of modifiers and cursor keys.
* app/widgets/gimpcontrollers.[ch]: added new function
gimp_controllers_get_keyboard().
* app/display/gimpdisplayshell-callbacks.c: if a key event was not
handled by the active tool, dispatch it to the keyboard controller.
* etc/controllerrc: add a keyboard controller which is configured
to do the same as the removed gimp_paint_tool_key_press().
2004-06-23 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* libgimp/gimpdrawable.c: added some documentation for
......
......@@ -46,6 +46,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpcontrollers.h"
#include "widgets/gimpcontrollerkeyboard.h"
#include "widgets/gimpcontrollerwheel.h"
#include "widgets/gimpcursor.h"
#include "widgets/gimpdevices.h"
......@@ -1129,11 +1130,18 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_Right:
case GDK_Up:
case GDK_Down:
if (! gimp_image_is_empty (gimage))
if (gimp_image_is_empty (gimage) ||
! tool_manager_key_press_active (gimp,
kevent,
gdisp))
{
tool_manager_key_press_active (gimp,
kevent,
gdisp);
GimpController *keyboard;
keyboard = gimp_controllers_get_keyboard (gimp);
if (keyboard)
gimp_controller_keyboard_key_press (GIMP_CONTROLLER_KEYBOARD (keyboard),
kevent);
}
return_val = TRUE;
......
......@@ -86,9 +86,6 @@ static void gimp_paint_tool_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_paint_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_paint_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
......@@ -169,7 +166,6 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
tool_class->button_press = gimp_paint_tool_button_press;
tool_class->button_release = gimp_paint_tool_button_release;
tool_class->motion = gimp_paint_tool_motion;
tool_class->key_press = gimp_paint_tool_key_press;
tool_class->modifier_key = gimp_paint_tool_modifier_key;
tool_class->oper_update = gimp_paint_tool_oper_update;
tool_class->cursor_update = gimp_paint_tool_cursor_update;
......@@ -548,40 +544,6 @@ gimp_paint_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
static void
gimp_paint_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
{
if (tool->gdisp)
{
GimpContext *context = GIMP_CONTEXT (tool->tool_info->tool_options);
gdouble opacity;
opacity = gimp_context_get_opacity (context);
switch (kevent->keyval)
{
case GDK_Left:
opacity = CLAMP (opacity - 0.01, 0, 1);
break;
case GDK_Right:
opacity = CLAMP (opacity + 0.01, 0, 1);
break;
case GDK_Up:
opacity = CLAMP (opacity + 0.1, 0, 1);
break;
case GDK_Down:
opacity = CLAMP (opacity - 0.1, 0, 1);
break;
default:
break;
}
gimp_context_set_opacity (context, opacity);
}
}
static void
gimp_paint_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
......
......@@ -70,79 +70,79 @@ enum
};
static void gimp_crop_tool_class_init (GimpCropToolClass *klass);
static void gimp_crop_tool_init (GimpCropTool *crop_tool);
static void gimp_crop_tool_finalize (GObject *object);
static void gimp_crop_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void gimp_crop_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_crop_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_draw (GimpDrawTool *draw_tool);
static void gimp_crop_tool_class_init (GimpCropToolClass *klass);
static void gimp_crop_tool_init (GimpCropTool *crop_tool);
static void gimp_crop_tool_finalize (GObject *object);
static void gimp_crop_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void gimp_crop_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static gboolean gimp_crop_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_crop_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_draw (GimpDrawTool *draw_tool);
/* Crop helper functions */
static void crop_tool_crop_image (GimpImage *gimage,
GimpContext *context,
gint x1,
gint y1,
gint x2,
gint y2,
gboolean layer_only,
GimpCropMode crop_mode);
static void crop_recalc (GimpCropTool *crop);
static void crop_start (GimpCropTool *crop);
static void crop_tool_crop_image (GimpImage *gimage,
GimpContext *context,
gint x1,
gint y1,
gint x2,
gint y2,
gboolean layer_only,
GimpCropMode crop_mode);
static void crop_recalc (GimpCropTool *crop);
static void crop_start (GimpCropTool *crop);
/* Crop dialog functions */
static void crop_info_update (GimpCropTool *crop);
static void crop_info_create (GimpCropTool *crop);
static void crop_response (GtkWidget *widget,
gint response_id,
GimpCropTool *crop);
static void crop_info_update (GimpCropTool *crop);
static void crop_info_create (GimpCropTool *crop);
static void crop_response (GtkWidget *widget,
gint response_id,
GimpCropTool *crop);
static void crop_selection_callback (GtkWidget *widget,
GimpCropTool *crop);
static void crop_automatic_callback (GtkWidget *widget,
GimpCropTool *crop);
static void crop_selection_callback (GtkWidget *widget,
GimpCropTool *crop);
static void crop_automatic_callback (GtkWidget *widget,
GimpCropTool *crop);
static void crop_origin_changed (GtkWidget *widget,
GimpCropTool *crop);
static void crop_size_changed (GtkWidget *widget,
GimpCropTool *crop);
static void crop_aspect_changed (GtkWidget *widget,
GimpCropTool *crop);
static void crop_origin_changed (GtkWidget *widget,
GimpCropTool *crop);
static void crop_size_changed (GtkWidget *widget,
GimpCropTool *crop);
static void crop_aspect_changed (GtkWidget *widget,
GimpCropTool *crop);
static GimpDrawToolClass *parent_class = NULL;
......@@ -514,7 +514,7 @@ gimp_crop_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
static void
static gboolean
gimp_crop_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
......@@ -527,7 +527,7 @@ gimp_crop_tool_key_press (GimpTool *tool,
gint max_x, max_y;
if (gdisp != tool->gdisp)
return;
return FALSE;
inc_x = inc_y = 0;
......@@ -545,12 +545,14 @@ gimp_crop_tool_key_press (GimpTool *tool,
case GDK_Down:
inc_y = 1;
break;
case GDK_KP_Enter:
case GDK_Return:
crop_response (NULL, options->crop_mode, crop);
return;
return TRUE;
default:
return;
return FALSE;
}
/* If the shift key is down, move by an accelerated increment */
......@@ -606,6 +608,8 @@ gimp_crop_tool_key_press (GimpTool *tool,
crop_recalc (crop);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
return TRUE;
}
static void
......
......@@ -113,9 +113,6 @@ static void gimp_edit_selection_tool_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_edit_selection_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_edit_selection_tool_draw (GimpDrawTool *tool);
......@@ -1051,7 +1048,7 @@ process_event_queue_keys (GdkEventKey *kevent,
#undef FILTER_MAX_KEYS
}
void
gboolean
gimp_edit_selection_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
......@@ -1071,7 +1068,7 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
kevent->keyval != GDK_Right &&
kevent->keyval != GDK_Up &&
kevent->keyval != GDK_Down)
return;
return FALSE;
/* check for mask translation first because the translate_layer
* modifiers match the translate_mask ones...
......@@ -1216,7 +1213,7 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
}
if (! item)
return;
return TRUE;
switch (edit_type)
{
......@@ -1297,4 +1294,6 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
gimp_undo_refresh_preview (undo);
gimp_image_flush (gdisp->gimage);
return TRUE;
}
......@@ -33,15 +33,15 @@ typedef enum
} EditType;
void init_edit_selection (GimpTool *tool,
GimpDisplay *gdisp,
GimpCoords *coords,
EditType edit_type);
void init_edit_selection (GimpTool *tool,
GimpDisplay *gdisp,
GimpCoords *coords,
EditType edit_type);
void gimp_edit_selection_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
gboolean gimp_edit_selection_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
#endif /* __GIMP_EDIT_SELECTION_TOOL_H__ */
......@@ -86,9 +86,6 @@ static void gimp_paint_tool_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_paint_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_paint_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
......@@ -169,7 +166,6 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
tool_class->button_press = gimp_paint_tool_button_press;
tool_class->button_release = gimp_paint_tool_button_release;
tool_class->motion = gimp_paint_tool_motion;
tool_class->key_press = gimp_paint_tool_key_press;
tool_class->modifier_key = gimp_paint_tool_modifier_key;
tool_class->oper_update = gimp_paint_tool_oper_update;
tool_class->cursor_update = gimp_paint_tool_cursor_update;
......@@ -548,40 +544,6 @@ gimp_paint_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
static void
gimp_paint_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
{
if (tool->gdisp)
{
GimpContext *context = GIMP_CONTEXT (tool->tool_info->tool_options);
gdouble opacity;
opacity = gimp_context_get_opacity (context);
switch (kevent->keyval)
{
case GDK_Left:
opacity = CLAMP (opacity - 0.01, 0, 1);
break;
case GDK_Right:
opacity = CLAMP (opacity + 0.01, 0, 1);
break;
case GDK_Up:
opacity = CLAMP (opacity + 0.1, 0, 1);
break;
case GDK_Down:
opacity = CLAMP (opacity - 0.1, 0, 1);
break;
default:
break;
}
gimp_context_set_opacity (context, opacity);
}
}
static void
gimp_paint_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
......
......@@ -74,7 +74,7 @@ static void gimp_tool_real_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_tool_real_key_press (GimpTool *tool,
static gboolean gimp_tool_real_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_tool_real_modifier_key (GimpTool *tool,
......@@ -276,11 +276,12 @@ gimp_tool_real_motion (GimpTool *tool,
{
}
static void
static gboolean
gimp_tool_real_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
{
return FALSE;
}
static void
......@@ -442,16 +443,16 @@ gimp_tool_set_focus_display (GimpTool *tool,
}
}
void
gboolean
gimp_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_return_if_fail (gdisp == tool->focus_display);
g_return_val_if_fail (GIMP_IS_TOOL (tool), FALSE);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), FALSE);
g_return_val_if_fail (gdisp == tool->focus_display, FALSE);
GIMP_TOOL_GET_CLASS (tool)->key_press (tool, kevent, gdisp);
return GIMP_TOOL_GET_CLASS (tool)->key_press (tool, kevent, gdisp);
}
static void
......
......@@ -82,7 +82,7 @@ struct _GimpToolClass
GdkModifierType state,
GimpDisplay *gdisp);
void (* key_press) (GimpTool *tool,
gboolean (* key_press) (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
void (* modifier_key) (GimpTool *tool,
......@@ -126,7 +126,7 @@ void gimp_tool_motion (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_tool_key_press (GimpTool *tool,
gboolean gimp_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
......
......@@ -100,7 +100,7 @@ static void gimp_transform_tool_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_transform_tool_key_press (GimpTool *tool,
static gboolean gimp_transform_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_transform_tool_modifier_key (GimpTool *tool,
......@@ -184,13 +184,9 @@ gimp_transform_tool_get_type (void)
static void
gimp_transform_tool_class_init (GimpTransformToolClass *klass)
{
GObjectClass *object_class;
GimpToolClass *tool_class;
GimpDrawToolClass *draw_class;
object_class = G_OBJECT_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
draw_class = GIMP_DRAW_TOOL_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_class = GIMP_DRAW_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -519,7 +515,7 @@ gimp_transform_tool_motion (GimpTool *tool,
#define RESPONSE_RESET 1
static void
static gboolean
gimp_transform_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
......@@ -534,17 +530,16 @@ gimp_transform_tool_key_press (GimpTool *tool,
case GDK_KP_Enter:
case GDK_Return:
gimp_transform_tool_response (NULL, GTK_RESPONSE_OK, trans_tool);
break;
return TRUE;
case GDK_Delete:
case GDK_BackSpace:
gimp_transform_tool_response (NULL, RESPONSE_RESET, trans_tool);
break;
default:
break;
return TRUE;
}
}
return FALSE;
}
static void
......
......@@ -71,78 +71,78 @@
/* local function prototypes */
static void gimp_vector_tool_class_init (GimpVectorToolClass *klass);
static void gimp_vector_tool_init (GimpVectorTool *tool);
static void gimp_vector_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void gimp_vector_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_vector_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_vector_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_vector_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_vector_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_vector_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_vector_tool_status_update (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_vector_tool_status_set (GimpTool *tool,
GimpDisplay *gdisp,
const gchar *message);
static void gimp_vector_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);