Commit d7ed6394 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Step one towards enabling tool cancellation by other means than mouse

2007-02-27  Michael Natterer  <mitch@gimp.org>

	Step one towards enabling tool cancellation by other means than
	mouse button 3 and towards proper "clicked" semantics.

	* app/tools/tools-enums.[ch]: added enum GimpButtonReleaseType
	which can be one of { NORMAL, CANCEL, CLICK } (click is curently
	unused).

	* app/tools/gimptool.[ch] (GimpTool::button_release): added
	"release_type" parameter.

	(gimp_tool_button_release): if the state contains
	GDK_BUTTON3_MASK, call the tool's button_release() with CANCEL,
	use NORMAL otherwise.

	* app/tools/gimpaligntool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpcolortool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpforegroundselecttool.c
	* app/tools/gimpfreeselecttool.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.c
	* app/tools/gimprectangleselecttool.c
	* app/tools/gimprectangletool.[ch]
	* app/tools/gimpregionselecttool.c
	* app/tools/gimptransformtool.c
	* app/tools/gimpvectortool.c (button_release): added
	"release_type" parameters and get rid of own checks for
	GDK_BUTTON3_MASK.


svn path=/trunk/; revision=22015
parent e172a72c
2007-02-27 Michael Natterer <mitch@gimp.org>
Step one towards enabling tool cancellation by other means than
mouse button 3 and towards proper "clicked" semantics.
* app/tools/tools-enums.[ch]: added enum GimpButtonReleaseType
which can be one of { NORMAL, CANCEL, CLICK } (click is curently
unused).
* app/tools/gimptool.[ch] (GimpTool::button_release): added
"release_type" parameter.
(gimp_tool_button_release): if the state contains
GDK_BUTTON3_MASK, call the tool's button_release() with CANCEL,
use NORMAL otherwise.
* app/tools/gimpaligntool.c
* app/tools/gimpblendtool.c
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolortool.c
* app/tools/gimpcroptool.c
* app/tools/gimpcurvestool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpmagnifytool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/tools/gimppainttool.c
* app/tools/gimprectangleselecttool.c
* app/tools/gimprectangletool.[ch]
* app/tools/gimpregionselecttool.c
* app/tools/gimptransformtool.c
* app/tools/gimpvectortool.c (button_release): added
"release_type" parameters and get rid of own checks for
GDK_BUTTON3_MASK.
2007-02-27 Michael Natterer <mitch@gimp.org>
* app/tools/gimpblendoptions.c (gimp_blend_options_gui): set the
......@@ -50,56 +50,57 @@
/* local function prototypes */
static GObject * gimp_align_tool_constructor (GType type,
guint n_params,
static GObject * gimp_align_tool_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static gboolean gimp_align_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static void gimp_align_tool_finalize (GObject *object);
static void gimp_align_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_align_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_align_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_align_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_align_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_align_tool_draw (GimpDrawTool *draw_tool);
static GtkWidget *button_with_stock (GimpAlignmentType action,
GimpAlignTool *align_tool);
static GtkWidget *gimp_align_tool_controls (GimpAlignTool *align_tool);
static void do_alignment (GtkWidget *widget,
gpointer data);
static void clear_selected_object (GObject *object,
GimpAlignTool *align_tool);
static void clear_all_selected_objects (GimpAlignTool *align_tool);
static GimpLayer *select_layer_by_coords (GimpImage *image,
gint x,
gint y);
void gimp_image_arrange_objects (GimpImage *image,
GList *list,
GimpAlignmentType alignment,
GObject *reference,
GimpAlignmentType reference_alignment,
gint offset);
static gboolean gimp_align_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static void gimp_align_tool_finalize (GObject *object);
static void gimp_align_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_align_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_align_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_tyle,
GimpDisplay *display);
static void gimp_align_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_align_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_align_tool_draw (GimpDrawTool *draw_tool);
static GtkWidget *button_with_stock (GimpAlignmentType action,
GimpAlignTool *align_tool);
static GtkWidget *gimp_align_tool_controls (GimpAlignTool *align_tool);
static void do_alignment (GtkWidget *widget,
gpointer data);
static void clear_selected_object (GObject *object,
GimpAlignTool *align_tool);
static void clear_all_selected_objects (GimpAlignTool *align_tool);
static GimpLayer *select_layer_by_coords (GimpImage *image,
gint x,
gint y);
void gimp_image_arrange_objects (GimpImage *image,
GList *list,
GimpAlignmentType alignment,
GObject *reference,
GimpAlignmentType reference_alignment,
gint offset);
G_DEFINE_TYPE (GimpAlignTool, gimp_align_tool, GIMP_TYPE_DRAW_TOOL)
......@@ -287,11 +288,12 @@ gimp_align_tool_button_press (GimpTool *tool,
* be used as reference.
*/
static void
gimp_align_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
gimp_align_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
......@@ -301,7 +303,7 @@ gimp_align_tool_button_release (GimpTool *tool,
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if (state & GDK_BUTTON3_MASK) /* cancel this action */
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
{
align_tool->x1 = align_tool->x0;
align_tool->y1 = align_tool->y0;
......
......@@ -52,42 +52,43 @@
/* local function prototypes */
static gboolean gimp_blend_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static void gimp_blend_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_blend_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_active_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_draw (GimpDrawTool *draw_tool);
static void gimp_blend_tool_push_status (GimpBlendTool *blend_tool,
GdkModifierType state,
GimpDisplay *display);
static gboolean gimp_blend_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static void gimp_blend_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_blend_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display);
static void gimp_blend_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_active_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_blend_tool_draw (GimpDrawTool *draw_tool);
static void gimp_blend_tool_push_status (GimpBlendTool *blend_tool,
GdkModifierType state,
GimpDisplay *display);
G_DEFINE_TYPE (GimpBlendTool, gimp_blend_tool, GIMP_TYPE_DRAW_TOOL)
......@@ -221,11 +222,12 @@ gimp_blend_tool_button_press (GimpTool *tool,
}
static void
gimp_blend_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
gimp_blend_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (tool);
......@@ -239,8 +241,7 @@ gimp_blend_tool_button_release (GimpTool *tool,
gimp_tool_control_halt (tool->control);
/* if the 3rd button isn't pressed, fill the selected region */
if (! (state & GDK_BUTTON3_MASK) &&
if ((release_type != GIMP_BUTTON_RELEASE_CANCEL) &&
((blend_tool->startx != blend_tool->endx) ||
(blend_tool->starty != blend_tool->endy)))
{
......
......@@ -50,37 +50,39 @@
#define ALL (BRIGHTNESS | CONTRAST)
static void gimp_brightness_contrast_tool_finalize (GObject *object);
static gboolean gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static void gimp_brightness_contrast_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_brightness_contrast_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_brightness_contrast_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_brightness_contrast_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_brightness_contrast_tool_reset (GimpImageMapTool *image_map_tool);
static void brightness_contrast_update (GimpBrightnessContrastTool *bc_tool,
gint update);
static void brightness_contrast_brightness_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void brightness_contrast_contrast_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void gimp_brightness_contrast_tool_finalize (GObject *object);
static gboolean gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static void gimp_brightness_contrast_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_brightness_contrast_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display);
static void gimp_brightness_contrast_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_brightness_contrast_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_brightness_contrast_tool_reset (GimpImageMapTool *image_map_tool);
static void brightness_contrast_update (GimpBrightnessContrastTool *bc_tool,
gint update);
static void brightness_contrast_brightness_changed (GtkAdjustment *adj,
GimpBrightnessContrastTool *bc_tool);
static void brightness_contrast_contrast_changed (GtkAdjustment *adj,
GimpBrightnessContrastTool *bc_tool);
G_DEFINE_TYPE (GimpBrightnessContrastTool, gimp_brightness_contrast_tool,
......@@ -212,11 +214,12 @@ gimp_brightness_contrast_tool_button_press (GimpTool *tool,
}
static void
gimp_brightness_contrast_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
gimp_brightness_contrast_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
......@@ -226,7 +229,7 @@ gimp_brightness_contrast_tool_button_release (GimpTool *tool,
if (bc_tool->dx == 0 && bc_tool->dy == 0)
return;
if ((state & GDK_BUTTON3_MASK))
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
gimp_brightness_contrast_tool_reset (im_tool);
gimp_image_map_tool_preview (im_tool);
......@@ -290,7 +293,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
g_signal_connect (data, "value-changed",
G_CALLBACK (brightness_contrast_brightness_adjustment_update),
G_CALLBACK (brightness_contrast_brightness_changed),
bc_tool);
/* Create the contrast scale widget */
......@@ -305,7 +308,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
g_signal_connect (data, "value-changed",
G_CALLBACK (brightness_contrast_contrast_adjustment_update),
G_CALLBACK (brightness_contrast_contrast_changed),
bc_tool);
}
......@@ -332,11 +335,9 @@ brightness_contrast_update (GimpBrightnessContrastTool *bc_tool,
}
static void
brightness_contrast_brightness_adjustment_update (GtkAdjustment *adjustment,
gpointer data)
brightness_contrast_brightness_changed (GtkAdjustment *adjustment,
GimpBrightnessContrastTool *bc_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (data);
if (bc_tool->brightness != adjustment->value)
{
bc_tool->brightness = adjustment->value;
......@@ -346,11 +347,9 @@ brightness_contrast_brightness_adjustment_update (GtkAdjustment *adjustment,
}
static void
brightness_contrast_contrast_adjustment_update (GtkAdjustment *adjustment,
gpointer data)
brightness_contrast_contrast_changed (GtkAdjustment *adjustment,
GimpBrightnessContrastTool *bc_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (data);
if (bc_tool->contrast != adjustment->value)
{
bc_tool->contrast = adjustment->value;
......
......@@ -46,25 +46,26 @@
/* local function prototypes */
static void gimp_bucket_fill_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_bucket_fill_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_bucket_fill_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_bucket_fill_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display);
static void gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
G_DEFINE_TYPE (GimpBucketFillTool, gimp_bucket_fill_tool, GIMP_TYPE_TOOL)
......@@ -147,18 +148,18 @@ gimp_bucket_fill_tool_button_press (GimpTool *tool,
}
static void
gimp_bucket_fill_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
gimp_bucket_fill_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
GimpBucketFillTool *bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
GimpContext *context = GIMP_CONTEXT (options);
/* if the 3rd button isn't pressed, fill the selected region */
if (! (state & GDK_BUTTON3_MASK))
if (release_type != GIMP_BUTTON_RELEASE_CANCEL)
{
gimp_drawable_bucket_fill (gimp_image_active_drawable (display->image),
context,
......
......@@ -65,53 +65,54 @@ enum
/* local function prototypes */
static void gimp_color_tool_finalize (GObject *object);
static void gimp_color_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_color_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_color_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_color_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_color_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_color_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_color_tool_draw (GimpDrawTool *draw_tool);
static gboolean gimp_color_tool_real_pick (GimpColorTool *color_tool,
gint x,
gint y,
GimpImageType *sample_type,
GimpRGB *color,
gint *color_index);
static void gimp_color_tool_pick (GimpColorTool *tool,
GimpColorPickState pick_state,
gint x,
gint y);
static void gimp_color_tool_real_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
static void gimp_color_tool_finalize (GObject *object);
static void gimp_color_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_color_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_color_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display);
static void gimp_color_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_color_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_color_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_color_tool_draw (GimpDrawTool *draw_tool);
static gboolean gimp_color_tool_real_pick (GimpColorTool *color_tool,
gint x,
gint y,
GimpImageType *sample_type,
GimpRGB *color,
gint *color_index);
static void gimp_color_tool_pick (GimpColorTool *tool,
GimpColorPickState pick_state,
gint x,
gint y);
static void gimp_color_tool_real_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
G_DEFINE_TYPE (GimpColorTool, gimp_color_tool, GIMP_TYPE_DRAW_TOOL);
......@@ -274,18 +275,19 @@ gimp_color_tool_button_press (GimpTool *tool,
}
static void
gimp_color_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
gimp_color_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
/* Chain up to halt the tool */
GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state,
display);
release_type, display);
if (! color_tool->enabled)
return;
......@@ -298,7 +300,7 @@ gimp_color_tool_button_release (GimpTool *tool,