Commit 7125fdbc authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

fixed qmask callbacks to check if the toggle is active before performing

2001-11-10  Michael Natterer  <mitch@gimp.org>

	* app/qmask.c: fixed qmask callbacks to check if the toggle is
	active before performing any action.

	* app/core/core-types.h: added the GimpCoords type here because it
	will be used by core functions as soon as the painting stuff is
	separated from the painting tools.

	* app/core/gimpdrawable-bucket-fill.c: fixed g_return_if_fail()s
	to not disable any useful operation :-) Still didn't figure out
	how I broke display color and pattern dropping :-(

	* app/display/gimpdisplayshell.[ch]: added
	gimp_display_shell_[un]transform_coords() which work on two
	GimpCoords pointers.

	* app/display/gimpdisplayshell-callbacks.c: use the new functions
	instead of the gdisplay_* ones.

	* app/gui/image-commands.c: GimpImage emits "disconnect", not
	"destroy".

	* app/tools/tools-types.h
	* app/tools/gimptool.h: removed GimpCoords here.

	* app/tools/gimpconvolvetool.c: fixed modifier_key() implementation.

	* app/tools/gimpcroptool.c: cleanup.

	* app/tools/paint_options.c: don't need a separator in the ink
	tool options.

	* app/tools/gimprectselecttool.c
	* app/tools/selection_options.[ch]: implemented wish #50352:

	Added "Auto Shrink Selection" and "Sample Merged" toggles to
	the rect_select and ellipse_select tools. Put the "Fixed size"
	widgets in a frame. Removed the separators after the common
	selection tool options because I didn't like them any more
	(feel free to comment ;)
parent b70ac761
2001-11-10 Michael Natterer <mitch@gimp.org>
* app/qmask.c: fixed qmask callbacks to check if the toggle is
active before performing any action.
* app/core/core-types.h: added the GimpCoords type here because it
will be used by core functions as soon as the painting stuff is
separated from the painting tools.
* app/core/gimpdrawable-bucket-fill.c: fixed g_return_if_fail()s
to not disable any useful operation :-) Still didn't figure out
how I broke display color and pattern dropping :-(
* app/display/gimpdisplayshell.[ch]: added
gimp_display_shell_[un]transform_coords() which work on two
GimpCoords pointers.
* app/display/gimpdisplayshell-callbacks.c: use the new functions
instead of the gdisplay_* ones.
* app/gui/image-commands.c: GimpImage emits "disconnect", not
"destroy".
* app/tools/tools-types.h
* app/tools/gimptool.h: removed GimpCoords here.
* app/tools/gimpconvolvetool.c: fixed modifier_key() implementation.
* app/tools/gimpcroptool.c: cleanup.
* app/tools/paint_options.c: don't need a separator in the ink
tool options.
* app/tools/gimprectselecttool.c
* app/tools/selection_options.[ch]: implemented wish #50352:
Added "Auto Shrink Selection" and "Sample Merged" toggles to
the rect_select and ellipse_select tools. Put the "Fixed size"
widgets in a frame. Removed the separators after the common
selection tool options because I didn't like them any more
(feel free to comment ;)
2001-11-09 Michael Natterer <mitch@gimp.org>
* app/gui/resize-dialog.c: added a "Center" button to the "Offset"
......
......@@ -204,7 +204,7 @@ image_resize_cmd_callback (GtkWidget *widget,
ResizeWidget,
ResizeImage,
G_OBJECT (gimage),
"destroy",
"disconnect",
gimage->width,
gimage->height,
gimage->xresolution,
......@@ -240,7 +240,7 @@ image_scale_cmd_callback (GtkWidget *widget,
ScaleWidget,
ResizeImage,
G_OBJECT (gimage),
"destroy",
"disconnect",
gimage->width,
gimage->height,
gimage->xresolution,
......
......@@ -177,17 +177,16 @@ qmask_deactivate_callback (GtkWidget *widget,
GimpImage *gimage;
GimpChannel *gmask;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
return; /* if already set do nothing */
if ( (gmask = gimp_image_get_channel_by_name (gimage, "Qmask")) )
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
......@@ -215,20 +214,19 @@ qmask_activate_callback (GtkWidget *widget,
GimpLayer *layer;
GimpRGB color;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (gdisp->gimage->qmask_state)
return; /* If already set, do nothing */
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
if ((gmask = gimp_image_get_channel_by_name (gimage, "Qmask")))
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
gimage->qmask_state = TRUE;
/* if the user was clever and created his own */
......
......@@ -177,17 +177,16 @@ qmask_deactivate_callback (GtkWidget *widget,
GimpImage *gimage;
GimpChannel *gmask;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
return; /* if already set do nothing */
if ( (gmask = gimp_image_get_channel_by_name (gimage, "Qmask")) )
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
......@@ -215,20 +214,19 @@ qmask_activate_callback (GtkWidget *widget,
GimpLayer *layer;
GimpRGB color;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (gdisp->gimage->qmask_state)
return; /* If already set, do nothing */
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
if ((gmask = gimp_image_get_channel_by_name (gimage, "Qmask")))
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
gimage->qmask_state = TRUE;
/* if the user was clever and created his own */
......
......@@ -260,6 +260,8 @@ typedef struct _ImageMap ImageMap; /* temp_hack, will be an object */
/* non-object types */
typedef struct _GimpCoords GimpCoords;
typedef struct _GimpCoreConfig GimpCoreConfig;
typedef struct _GimpGuide GimpGuide;
......@@ -293,4 +295,17 @@ typedef void (* GimpDataFileLoaderFunc) (const gchar *filename,
typedef GimpData * (* GimpDataObjectLoaderFunc) (const gchar *filename);
/* structs */
struct _GimpCoords
{
gdouble x;
gdouble y;
gdouble pressure;
gdouble xtilt;
gdouble ytilt;
gdouble wheel;
};
#endif /* __CORE_TYPES_H__ */
......@@ -155,10 +155,10 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
gboolean new_buf = FALSE;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (fill_mode == PATTERN_BUCKET_FILL &&
g_return_if_fail (fill_mode != PATTERN_BUCKET_FILL ||
GIMP_IS_PATTERN (pattern));
g_return_if_fail ((fill_mode == FG_BUCKET_FILL ||
fill_mode == BG_BUCKET_FILL) && color != NULL);
g_return_if_fail ((fill_mode != FG_BUCKET_FILL &&
fill_mode != BG_BUCKET_FILL) || color != NULL);
gimage = gimp_drawable_gimage (drawable);
......@@ -226,7 +226,7 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
/* If there is no selection mask, the do a seed bucket
* fill...To do this, calculate a new contiguous region
*/
if (do_seed_fill && ! gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2))
if (! gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2) && do_seed_fill)
{
mask = gimp_image_contiguous_region_by_seed (gimage, drawable,
sample_merged,
......
......@@ -177,17 +177,16 @@ qmask_deactivate_callback (GtkWidget *widget,
GimpImage *gimage;
GimpChannel *gmask;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
return; /* if already set do nothing */
if ( (gmask = gimp_image_get_channel_by_name (gimage, "Qmask")) )
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
......@@ -215,20 +214,19 @@ qmask_activate_callback (GtkWidget *widget,
GimpLayer *layer;
GimpRGB color;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (gdisp->gimage->qmask_state)
return; /* If already set, do nothing */
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
if ((gmask = gimp_image_get_channel_by_name (gimage, "Qmask")))
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
gimage->qmask_state = TRUE;
/* if the user was clever and created his own */
......
......@@ -177,17 +177,16 @@ qmask_deactivate_callback (GtkWidget *widget,
GimpImage *gimage;
GimpChannel *gmask;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
return; /* if already set do nothing */
if ( (gmask = gimp_image_get_channel_by_name (gimage, "Qmask")) )
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
......@@ -215,20 +214,19 @@ qmask_activate_callback (GtkWidget *widget,
GimpLayer *layer;
GimpRGB color;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (gdisp->gimage->qmask_state)
return; /* If already set, do nothing */
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
if ((gmask = gimp_image_get_channel_by_name (gimage, "Qmask")))
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
gimage->qmask_state = TRUE;
/* if the user was clever and created his own */
......
......@@ -1197,8 +1197,8 @@ device_status_data_changed (GimpContext *context,
}
static void
device_status_context_connect (GimpContext *context,
GdkDevice *device)
device_status_context_connect (GimpContext *context,
GdkDevice *device)
{
g_signal_connect (G_OBJECT (context), "foreground_changed",
G_CALLBACK (device_status_data_changed),
......
......@@ -322,10 +322,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
image_coords = display_coords;
/* GimpCoords passed to tools are ALWAYS in image coordinates */
gdisplay_untransform_coords_f (gdisp,
display_coords.x, display_coords.y,
&image_coords.x, &image_coords.y,
FALSE);
gimp_display_shell_untransform_coords (shell,
&display_coords,
&image_coords);
switch (event->type)
{
......@@ -452,12 +451,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
&display_coords.x,
&display_coords.y);
gdisplay_untransform_coords_f (gdisp,
display_coords.x,
display_coords.y,
&image_coords.x,
&image_coords.y,
FALSE);
gimp_display_shell_untransform_coords (shell,
&display_coords,
&image_coords);
update_cursor = TRUE;
}
......@@ -559,12 +555,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
&display_coords.x,
&display_coords.y);
gdisplay_untransform_coords_f (gdisp,
display_coords.x,
display_coords.y,
&image_coords.x,
&image_coords.y,
FALSE);
gimp_display_shell_untransform_coords (shell,
&display_coords,
&image_coords);
update_cursor = TRUE;
}
......@@ -625,6 +618,17 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
gtk_adjustment_set_value (adj, value);
}
gimp_display_shell_untransform_coords (shell,
&display_coords,
&image_coords);
if (active_tool)
{
gimp_tool_oper_update (active_tool,
&image_coords, state,
gdisp);
}
return_val = TRUE;
break;
......@@ -717,12 +721,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
&display_coords.x,
&display_coords.y);
gdisplay_untransform_coords_f (gdisp,
display_coords.x,
display_coords.y,
&image_coords.x,
&image_coords.y,
FALSE);
gimp_display_shell_untransform_coords (shell,
&display_coords,
&image_coords);
update_cursor = TRUE;
}
......
......@@ -598,6 +598,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
/* the qmask buttons */
shell->qmaskoff = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (shell->qmaskoff));
gtk_widget_set_usize (GTK_WIDGET (shell->qmaskoff), 16, 16);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (shell->qmaskoff), FALSE);
GTK_WIDGET_UNSET_FLAGS (shell->qmaskoff, GTK_CAN_FOCUS);
......@@ -609,6 +610,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
shell->qmaskon = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (shell->qmaskon));
gtk_widget_set_usize (GTK_WIDGET (shell->qmaskon), 16, 16);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (shell->qmaskon), FALSE);
GTK_WIDGET_UNSET_FLAGS (shell->qmaskon, GTK_CAN_FOCUS);
......@@ -782,6 +784,50 @@ gimp_display_shell_close (GimpDisplayShell *shell,
}
}
void
gimp_display_shell_transform_coords (GimpDisplayShell *shell,
GimpCoords *image_coords,
GimpCoords *display_coords)
{
gdouble scalex;
gdouble scaley;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (image_coords != NULL);
g_return_if_fail (display_coords != NULL);
scalex = SCALEFACTOR_X (shell->gdisp);
scaley = SCALEFACTOR_Y (shell->gdisp);
display_coords->x = scalex * image_coords->x;
display_coords->y = scaley * image_coords->y;
display_coords->x += - shell->offset_x + shell->disp_xoffset;
display_coords->y += - shell->offset_y + shell->disp_yoffset;
}
void
gimp_display_shell_untransform_coords (GimpDisplayShell *shell,
GimpCoords *display_coords,
GimpCoords *image_coords)
{
gdouble scalex;
gdouble scaley;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (display_coords != NULL);
g_return_if_fail (image_coords != NULL);
scalex = SCALEFACTOR_X (shell->gdisp);
scaley = SCALEFACTOR_Y (shell->gdisp);
image_coords->x = display_coords->x - shell->disp_xoffset + shell->offset_x;
image_coords->y = display_coords->y - shell->disp_yoffset + shell->offset_y;
image_coords->x /= scalex;
image_coords->y /= scaley;
}
void
gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
{
......
......@@ -131,6 +131,13 @@ GtkWidget * gimp_display_shell_new (GimpDisplay *gdisp);
void gimp_display_shell_close (GimpDisplayShell *shell,
gboolean kill_it);
void gimp_display_shell_transform_coords (GimpDisplayShell *shell,
GimpCoords *image_coords,
GimpCoords *display_coords);
void gimp_display_shell_untransform_coords (GimpDisplayShell *shell,
GimpCoords *display_coords,
GimpCoords *image_coords);
void gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell);
GimpGuide * gimp_display_shell_find_guide (GimpDisplayShell *shell,
......
......@@ -177,17 +177,16 @@ qmask_deactivate_callback (GtkWidget *widget,
GimpImage *gimage;
GimpChannel *gmask;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
return; /* if already set do nothing */
if ( (gmask = gimp_image_get_channel_by_name (gimage, "Qmask")) )
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
......@@ -215,20 +214,19 @@ qmask_activate_callback (GtkWidget *widget,
GimpLayer *layer;
GimpRGB color;
if (gdisp)
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimage)
return;
if (gdisp->gimage->qmask_state)
return; /* If already set, do nothing */
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
if ((gmask = gimp_image_get_channel_by_name (gimage, "Qmask")))
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
{
gimage->qmask_state = TRUE;
/* if the user was clever and created his own */
......
......@@ -598,6 +598,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
/* the qmask buttons */
shell->qmaskoff = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (shell->qmaskoff));
gtk_widget_set_usize (GTK_WIDGET (shell->qmaskoff), 16, 16);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (shell->qmaskoff), FALSE);
GTK_WIDGET_UNSET_FLAGS (shell->qmaskoff, GTK_CAN_FOCUS);
......@@ -609,6 +610,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
shell->qmaskon = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (shell->qmaskon));
gtk_widget_set_usize (GTK_WIDGET (shell->qmaskon), 16, 16);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (shell->qmaskon), FALSE);
GTK_WIDGET_UNSET_FLAGS (shell->qmaskon, GTK_CAN_FOCUS);
......@@ -782,6 +784,50 @@ gimp_display_shell_close (GimpDisplayShell *shell,
}
}
void
gimp_display_shell_transform_coords (GimpDisplayShell *shell,
GimpCoords *image_coords,
GimpCoords *display_coords)
{
gdouble scalex;
gdouble scaley;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (image_coords != NULL);
g_return_if_fail (display_coords != NULL);
scalex = SCALEFACTOR_X (shell->gdisp);
scaley = SCALEFACTOR_Y (shell->gdisp);
display_coords->x = scalex * image_coords->x;
display_coords->y = scaley * image_coords->y;
display_coords->x += - shell->offset_x + shell->disp_xoffset;
display_coords->y += - shell->offset_y + shell->disp_yoffset;
}
void
gimp_display_shell_untransform_coords (GimpDisplayShell *shell,
GimpCoords *display_coords,
GimpCoords *image_coords)
{
gdouble scalex;
gdouble scaley;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (display_coords != NULL);
g_return_if_fail (image_coords != NULL);
scalex = SCALEFACTOR_X (shell->gdisp);
scaley = SCALEFACTOR_Y (shell->gdisp);
image_coords->x = display_coords->x - shell->disp_xoffset + shell->offset_x;
image_coords->y = display_coords->y - shell->disp_yoffset + shell->offset_y;
image_coords->x /= scalex;
image_coords->y /= scaley;
}
void
gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
{
......
......@@ -131,6 +131,13 @@ GtkWidget * gimp_display_shell_new (GimpDisplay *gdisp);
void gimp_display_shell_close (GimpDisplayShell *shell,
gboolean kill_it);
void gimp_display_shell_transform_coords (GimpDisplayShell *shell,
GimpCoords *image_coords,
GimpCoords *display_coords);
void gimp_display_shell_untransform_coords (GimpDisplayShell *shell,
GimpCoords *display_coords,
GimpCoords *image_coords);
void gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell);
GimpGuide * gimp_display_shell_find_guide (GimpDisplayShell *shell,
......
......@@ -1197,8 +1197,8 @@ device_status_data_changed (GimpContext *context,
}
static void
device_status_context_connect (GimpContext *context,
GdkDevice *device)
device_status_context_connect (GimpContext *context,
GdkDevice *device)
{
g_signal_connect (G_OBJECT (context), "foreground_changed",
G_CALLBACK (device_status_data_changed),
......
......@@ -204,7 +204,7 @@ image_resize_cmd_callback (GtkWidget *widget,
ResizeWidget,
ResizeImage,
G_OBJECT (gimage),
"destroy",
"disconnect",