Don't use the `display' member of GimpTool for keeping track of what
2007-12-13 Martin Nordholts <martinn@svn.gnome.org> * app/tools/gimprectangletool.[ch]: Don't use the `display' member of GimpTool for keeping track of what display the rectangle is active on. Instead store the active display in GimpRectangleToolPrivate. This change is based on a patch by Bill Skaggs. (gimp_rectangle_tool_is_active) (gimp_rectangle_tool_is_active_at) (gimp_rectangle_tool_get_active_display): New public functions for GimpRectangleTool active-display interaction. * app/tools/gimpellipseselecttool.c (gimp_ellipse_select_tool_select): Use the active display of GimpRectangleTool instead of tool->display. * app/tools/gimprectangleselecttool.c (gimp_rect_select_tool_rectangle_changed): Use the active display of GimpRectangleTool instead of tool->display. * app/tools/gimpcroptool.c (gimp_crop_tool_button_press): Use the active display of GimpRectangleTool instead of tool->display. svn path=/trunk/; revision=24358
This commit is contained in:

committed by
Martin Nordholts

parent
4bab078cbe
commit
f643d5545c
24
ChangeLog
24
ChangeLog
@ -1,3 +1,27 @@
|
||||
2007-12-13 Martin Nordholts <martinn@svn.gnome.org>
|
||||
|
||||
* app/tools/gimprectangletool.[ch]: Don't use the `display' member
|
||||
of GimpTool for keeping track of what display the rectangle is
|
||||
active on. Instead store the active display in
|
||||
GimpRectangleToolPrivate. This change is based on a patch by Bill
|
||||
Skaggs.
|
||||
(gimp_rectangle_tool_is_active)
|
||||
(gimp_rectangle_tool_is_active_at)
|
||||
(gimp_rectangle_tool_get_active_display): New public functions for
|
||||
GimpRectangleTool active-display interaction.
|
||||
|
||||
* app/tools/gimpellipseselecttool.c
|
||||
(gimp_ellipse_select_tool_select): Use the active display of
|
||||
GimpRectangleTool instead of tool->display.
|
||||
|
||||
* app/tools/gimprectangleselecttool.c
|
||||
(gimp_rect_select_tool_rectangle_changed): Use the active display
|
||||
of GimpRectangleTool instead of tool->display.
|
||||
|
||||
* app/tools/gimpcroptool.c
|
||||
(gimp_crop_tool_button_press): Use the active display of
|
||||
GimpRectangleTool instead of tool->display.
|
||||
|
||||
2007-12-13 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
|
||||
* app/widgets/gimpfiledialog.c (gimp_file_dialog_new): add
|
||||
|
@ -227,7 +227,12 @@ gimp_crop_tool_button_press (GimpTool *tool,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
if (tool->display && display != tool->display)
|
||||
GimpRectangleTool *rect_tool;
|
||||
|
||||
rect_tool = GIMP_RECTANGLE_TOOL (tool);
|
||||
|
||||
if (gimp_rectangle_tool_is_active (rect_tool) &&
|
||||
! gimp_rectangle_tool_is_active_at (rect_tool, display))
|
||||
gimp_rectangle_tool_cancel (GIMP_RECTANGLE_TOOL (tool));
|
||||
|
||||
gimp_rectangle_tool_button_press (tool, coords, time, state, display);
|
||||
@ -289,13 +294,15 @@ gimp_crop_tool_execute (GimpRectangleTool *rectangle,
|
||||
GimpTool *tool;
|
||||
GimpCropOptions *options;
|
||||
GimpImage *image;
|
||||
GimpDisplay *display;
|
||||
|
||||
tool = GIMP_TOOL (rectangle);
|
||||
options = GIMP_CROP_TOOL_GET_OPTIONS (tool);
|
||||
display = gimp_rectangle_tool_get_active_display (rectangle);
|
||||
|
||||
gimp_tool_pop_status (tool, tool->display);
|
||||
gimp_tool_pop_status (tool, display);
|
||||
|
||||
image = tool->display->image;
|
||||
image = display->image;
|
||||
|
||||
/* if rectangle exists, crop it */
|
||||
if (w > 0 && h > 0)
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include "gimpellipseselecttool.h"
|
||||
#include "gimprectangleselectoptions.h"
|
||||
#include "gimprectangletool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
@ -128,8 +129,11 @@ gimp_ellipse_select_tool_select (GimpRectSelectTool *rect_tool,
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (rect_tool);
|
||||
GimpDisplay *display;
|
||||
|
||||
gimp_channel_select_ellipse (gimp_image_get_mask (tool->display->image),
|
||||
display = gimp_rectangle_tool_get_active_display (GIMP_RECTANGLE_TOOL (tool));
|
||||
|
||||
gimp_channel_select_ellipse (gimp_image_get_mask (display->image),
|
||||
x, y, w, h,
|
||||
operation,
|
||||
options->antialias,
|
||||
|
@ -349,7 +349,8 @@ gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
shell = GIMP_DISPLAY_SHELL (display->shell);
|
||||
priv = GIMP_RECT_SELECT_TOOL_GET_PRIVATE(rect_sel_tool);
|
||||
|
||||
if (tool->display && display != tool->display)
|
||||
if (gimp_rectangle_tool_is_active (rectangle) &&
|
||||
! gimp_rectangle_tool_is_active_at (rectangle, display))
|
||||
gimp_rectangle_tool_cancel (GIMP_RECTANGLE_TOOL (tool));
|
||||
|
||||
function = gimp_rectangle_tool_get_function (rectangle);
|
||||
@ -358,9 +359,11 @@ gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
|
||||
if (function == GIMP_RECTANGLE_TOOL_INACTIVE)
|
||||
{
|
||||
GimpDisplay *old_display = tool->display;
|
||||
GimpDisplay *old_display;
|
||||
gboolean edit_started;
|
||||
|
||||
old_display = gimp_rectangle_tool_get_active_display (rectangle);
|
||||
|
||||
tool->display = display;
|
||||
gimp_tool_control_activate (tool->control);
|
||||
|
||||
@ -399,7 +402,7 @@ gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
else
|
||||
{
|
||||
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpImage *image = display->image;
|
||||
GimpUndo *undo;
|
||||
GimpChannelOps operation;
|
||||
|
||||
@ -440,9 +443,11 @@ gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpButtonReleaseType release_type,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpRectangleTool *rect_tool;
|
||||
GimpRectSelectTool *rect_sel_tool;
|
||||
GimpRectSelectToolPrivate *priv;
|
||||
|
||||
rect_tool = GIMP_RECTANGLE_TOOL (tool);
|
||||
rect_sel_tool = GIMP_RECT_SELECT_TOOL (tool);
|
||||
priv = GIMP_RECT_SELECT_TOOL_GET_PRIVATE(rect_sel_tool);
|
||||
|
||||
@ -456,7 +461,7 @@ gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
*/
|
||||
if (release_type == GIMP_BUTTON_RELEASE_CLICK)
|
||||
{
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpImage *image = display->image;
|
||||
GimpUndo *redo = gimp_undo_stack_peek (image->redo_stack);
|
||||
|
||||
if (redo && priv->redo == redo)
|
||||
@ -478,10 +483,14 @@ gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
{
|
||||
if (priv->redo)
|
||||
{
|
||||
GimpDisplay *display;
|
||||
|
||||
/* prevent this from halting the tool */
|
||||
gimp_tool_control_set_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_redo (tool->display->image);
|
||||
display = gimp_rectangle_tool_get_active_display (rect_tool);
|
||||
|
||||
gimp_image_redo (display->image);
|
||||
|
||||
gimp_tool_control_set_preserve (tool->control, FALSE);
|
||||
}
|
||||
@ -563,21 +572,24 @@ gimp_rect_select_tool_select (GimpRectangleTool *rectangle,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpRectangleTool *rect_tool;
|
||||
GimpRectSelectTool *rect_sel_tool;
|
||||
GimpSelectionOptions *options;
|
||||
GimpDisplay *display;
|
||||
GimpImage *image;
|
||||
GimpRectSelectToolPrivate *priv;
|
||||
gboolean rectangle_exists;
|
||||
GimpChannelOps operation;
|
||||
|
||||
tool = GIMP_TOOL (rectangle);
|
||||
rect_tool = GIMP_RECTANGLE_TOOL (rectangle);
|
||||
rect_sel_tool = GIMP_RECT_SELECT_TOOL (rectangle);
|
||||
options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
||||
priv = GIMP_RECT_SELECT_TOOL_GET_PRIVATE(rect_sel_tool);
|
||||
display = gimp_rectangle_tool_get_active_display (rect_tool);
|
||||
image = display->image;
|
||||
|
||||
image = tool->display->image;
|
||||
|
||||
gimp_tool_pop_status (tool, tool->display);
|
||||
gimp_tool_pop_status (tool, display);
|
||||
|
||||
rectangle_exists = (x <= image->width && y <= image->height &&
|
||||
x + w >= 0 && y + h >= 0 &&
|
||||
@ -605,14 +617,17 @@ gimp_rect_select_tool_real_select (GimpRectSelectTool *rect_sel_tool,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_sel_tool);
|
||||
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
||||
GimpTool *tool = GIMP_TOOL (rect_sel_tool);
|
||||
GimpRectangleTool *rect_tool = GIMP_RECTANGLE_TOOL (tool);
|
||||
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
||||
GimpRectSelectOptions *rect_select_options;
|
||||
GimpChannel *channel;
|
||||
GimpDisplay *display;
|
||||
|
||||
rect_select_options = GIMP_RECT_SELECT_TOOL_GET_OPTIONS (tool);
|
||||
display = gimp_rectangle_tool_get_active_display (rect_tool);
|
||||
|
||||
channel = gimp_image_get_mask (tool->display->image);
|
||||
channel = gimp_image_get_mask (display->image);
|
||||
|
||||
if (rect_select_options->round_corners)
|
||||
{
|
||||
@ -664,7 +679,7 @@ gimp_rect_select_tool_update_option_defaults (GimpRectSelectTool *rect_sel_tool,
|
||||
rectangle_tool = GIMP_RECTANGLE_TOOL (tool);
|
||||
rectangle_options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (rectangle_tool);
|
||||
|
||||
if (tool->display != NULL && !ignore_pending)
|
||||
if (gimp_rectangle_tool_is_active (rectangle_tool) && !ignore_pending)
|
||||
{
|
||||
/* There is a pending rectangle and we should not ignore it, so
|
||||
* set default Fixed: Size to the same as the current pending
|
||||
@ -723,11 +738,16 @@ gimp_rect_select_tool_execute (GimpRectangleTool *rectangle,
|
||||
|
||||
if (w == 0 && h == 0)
|
||||
{
|
||||
GimpImage *image = GIMP_TOOL (rectangle)->display->image;
|
||||
GimpChannel *selection = gimp_image_get_mask (image);
|
||||
GimpDisplay *display;
|
||||
GimpImage *image;
|
||||
GimpChannel *selection;
|
||||
gint pressx;
|
||||
gint pressy;
|
||||
|
||||
display = gimp_rectangle_tool_get_active_display (rectangle);
|
||||
image = display->image;
|
||||
selection = gimp_image_get_mask (image);
|
||||
|
||||
if (gimp_image_floating_sel (image))
|
||||
{
|
||||
floating_sel_anchor (gimp_image_floating_sel (image));
|
||||
@ -790,11 +810,13 @@ gimp_rect_select_tool_cancel (GimpRectangleTool *rectangle)
|
||||
rect_sel_tool = GIMP_RECT_SELECT_TOOL (rectangle);
|
||||
priv = GIMP_RECT_SELECT_TOOL_GET_PRIVATE(rect_sel_tool);
|
||||
|
||||
if (tool->display)
|
||||
if (gimp_rectangle_tool_is_active (rectangle))
|
||||
{
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpImage *image;
|
||||
GimpUndo *undo;
|
||||
|
||||
image = gimp_rectangle_tool_get_active_display (rectangle)->image;
|
||||
|
||||
/* if we have an existing rectangle in the current display, then
|
||||
* we have already "executed", and need to undo at this point,
|
||||
* unless the user has done something in the meantime
|
||||
@ -831,12 +853,15 @@ gimp_rect_select_tool_rectangle_changed (GimpRectangleTool *rectangle)
|
||||
/* prevent change in selection from halting the tool */
|
||||
gimp_tool_control_set_preserve (tool->control, TRUE);
|
||||
|
||||
if (tool->display && ! gimp_tool_control_is_active (tool->control))
|
||||
if (gimp_rectangle_tool_is_active (rectangle) &&
|
||||
! gimp_tool_control_is_active (tool->control))
|
||||
{
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpImage *image;
|
||||
GimpUndo *undo;
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
image = gimp_rectangle_tool_get_active_display (rectangle)->image;
|
||||
|
||||
/* if we got here via button release, we have already undone the
|
||||
* previous operation. But if we got here by some other means,
|
||||
* we need to undo it now.
|
||||
|
@ -129,6 +129,12 @@ struct _GimpRectangleToolPrivate
|
||||
* sure these variables are in consistent states.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The display the rectangele is active on, or NULL if there is no
|
||||
* active rectangle.
|
||||
*/
|
||||
GimpDisplay *active_display;
|
||||
|
||||
/* Coordinates of upper left and lower right rectangle corners. */
|
||||
gdouble x1, y1;
|
||||
gdouble x2, y2;
|
||||
@ -220,10 +226,12 @@ static void gimp_rectangle_tool_rectangle_changed (GimpRectangleTool
|
||||
static void gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool);
|
||||
|
||||
static gboolean gimp_rectangle_tool_coord_outside (GimpRectangleTool *rect_tool,
|
||||
GimpCoords *coords);
|
||||
GimpCoords *coords,
|
||||
GimpDisplay *display);
|
||||
|
||||
static gboolean gimp_rectangle_tool_coord_on_handle (GimpRectangleTool *rect_tool,
|
||||
GimpCoords *coords,
|
||||
GimpDisplay *display,
|
||||
GtkAnchorType anchor);
|
||||
|
||||
static GtkAnchorType gimp_rectangle_tool_get_anchor (GimpRectangleToolPrivate *private);
|
||||
@ -234,7 +242,8 @@ static gboolean gimp_rectangle_tool_rect_rubber_banding_func
|
||||
(GimpRectangleTool *rect_tool);
|
||||
static gboolean gimp_rectangle_tool_rect_adjusting_func (GimpRectangleTool *rect_tool);
|
||||
|
||||
static void gimp_rectangle_tool_update_handle_sizes (GimpRectangleTool *rect_tool);
|
||||
static void gimp_rectangle_tool_update_handle_sizes (GimpRectangleTool *rect_tool,
|
||||
GimpDisplay *display);
|
||||
|
||||
static gboolean gimp_rectangle_tool_scale_has_changed (GimpRectangleTool *rect_tool);
|
||||
|
||||
@ -446,7 +455,11 @@ gimp_rectangle_tool_get_private (GimpRectangleTool *tool)
|
||||
void
|
||||
gimp_rectangle_tool_init (GimpRectangleTool *rect_tool)
|
||||
{
|
||||
/* No need to initialize anything yet. */
|
||||
GimpRectangleToolPrivate *private;
|
||||
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
|
||||
|
||||
private->active_display = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -495,19 +508,23 @@ gimp_rectangle_tool_set_constraint (GimpRectangleTool *tool,
|
||||
|
||||
private->constraint = constraint;
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
if (gimp_rectangle_tool_is_active (tool))
|
||||
{
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
gimp_rectangle_tool_clamp (tool,
|
||||
NULL,
|
||||
constraint,
|
||||
FALSE);
|
||||
gimp_rectangle_tool_clamp (tool,
|
||||
NULL,
|
||||
constraint,
|
||||
FALSE);
|
||||
|
||||
gimp_rectangle_tool_update_highlight (tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (tool);
|
||||
gimp_rectangle_tool_update_highlight (tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (tool,
|
||||
private->active_display);
|
||||
|
||||
gimp_rectangle_tool_rectangle_changed (tool);
|
||||
gimp_rectangle_tool_rectangle_changed (tool);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (tool), "constraint");
|
||||
}
|
||||
@ -671,6 +688,45 @@ gimp_rectangle_tool_point_in_rectangle (GimpRectangleTool *rect_tool,
|
||||
return inside;
|
||||
}
|
||||
|
||||
GimpDisplay *
|
||||
gimp_rectangle_tool_get_active_display (GimpRectangleTool *rect_tool)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (rect_tool), NULL);
|
||||
|
||||
return GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool)->active_display;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rectangle_tool_is_active_at:
|
||||
* @rect_tool:
|
||||
* @display: The #GimpDisplay to test for.
|
||||
*
|
||||
* Returns: %TRUE if there is a rectangle active on %display, %FALSE
|
||||
* otherwise.
|
||||
**/
|
||||
gboolean
|
||||
gimp_rectangle_tool_is_active_at (GimpRectangleTool *rect_tool,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (rect_tool), FALSE);
|
||||
|
||||
return GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool)->active_display == display;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rectangle_tool_is_active:
|
||||
* @rect_tool:
|
||||
*
|
||||
* Returns: %TRUE if a rectangle is active on any display.
|
||||
**/
|
||||
gboolean
|
||||
gimp_rectangle_tool_is_active (GimpRectangleTool *rect_tool)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (rect_tool), FALSE);
|
||||
|
||||
return GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool)->active_display != NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rectangle_tool_set_property (GObject *object,
|
||||
guint property_id,
|
||||
@ -788,7 +844,8 @@ gimp_rectangle_tool_control (GimpTool *tool,
|
||||
* zoom has changed.
|
||||
*/
|
||||
if (gimp_rectangle_tool_scale_has_changed (rect_tool))
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool,
|
||||
display);
|
||||
|
||||
break;
|
||||
|
||||
@ -826,7 +883,7 @@ gimp_rectangle_tool_button_press (GimpTool *tool,
|
||||
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
|
||||
if (display != tool->display)
|
||||
if (! gimp_rectangle_tool_is_active_at (rect_tool, display))
|
||||
{
|
||||
if (gimp_draw_tool_is_active (draw_tool))
|
||||
{
|
||||
@ -869,7 +926,8 @@ gimp_rectangle_tool_button_press (GimpTool *tool,
|
||||
private->x1 = private->x2 = snapped_x;
|
||||
private->y1 = private->y2 = snapped_y;
|
||||
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool,
|
||||
display);
|
||||
|
||||
/* Created rectangles should not be started in narrow-mode */
|
||||
private->narrow_mode = FALSE;
|
||||
@ -910,7 +968,8 @@ gimp_rectangle_tool_button_press (GimpTool *tool,
|
||||
|
||||
gimp_rectangle_tool_update_highlight (rect_tool);
|
||||
|
||||
gimp_tool_control_activate (tool->control);
|
||||
if (! gimp_tool_control_is_active (tool->control))
|
||||
gimp_tool_control_activate (tool->control);
|
||||
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
@ -933,6 +992,9 @@ gimp_rectangle_tool_button_release (GimpTool *tool,
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
|
||||
options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (tool);
|
||||
|
||||
if (! gimp_rectangle_tool_is_active_at (rect_tool, display))
|
||||
return;
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
gimp_tool_control_halt (tool->control);
|
||||
@ -963,11 +1025,13 @@ gimp_rectangle_tool_button_release (GimpTool *tool,
|
||||
case GIMP_BUTTON_RELEASE_CLICK:
|
||||
|
||||
/* When a dead area is clicked, don't execute. */
|
||||
if (private->function == GIMP_RECTANGLE_TOOL_DEAD)
|
||||
break;
|
||||
|
||||
if (gimp_rectangle_tool_execute (rect_tool))
|
||||
gimp_rectangle_tool_halt (rect_tool);
|
||||
if (private->function != GIMP_RECTANGLE_TOOL_DEAD)
|
||||
{
|
||||
if (gimp_rectangle_tool_execute (rect_tool))
|
||||
{
|
||||
gimp_rectangle_tool_halt (rect_tool);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_BUTTON_RELEASE_NO_MOTION:
|
||||
@ -984,7 +1048,8 @@ gimp_rectangle_tool_button_release (GimpTool *tool,
|
||||
private->rect_adjusting = FALSE;
|
||||
|
||||
gimp_rectangle_tool_update_highlight (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool,
|
||||
display);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
@ -1226,7 +1291,7 @@ gimp_rectangle_tool_active_modifier_key (GimpTool *tool,
|
||||
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
|
||||
gimp_rectangle_tool_update_options (rect_tool, tool->display);
|
||||
gimp_rectangle_tool_update_options (rect_tool, display);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1329,12 +1394,12 @@ gimp_rectangle_tool_key_press (GimpTool *tool,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (tool), FALSE);
|
||||
|
||||
if (display != tool->display)
|
||||
return FALSE;
|
||||
|
||||
rect_tool = GIMP_RECTANGLE_TOOL (tool);
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
|
||||
|
||||
if (! gimp_rectangle_tool_is_active_at (rect_tool, display))
|
||||
return FALSE;
|
||||
|
||||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Up:
|
||||
@ -1434,9 +1499,10 @@ gimp_rectangle_tool_key_press (GimpTool *tool,
|
||||
private->center_y_on_fixed_center = (private->y1 + private->y2) / 2;
|
||||
|
||||
gimp_rectangle_tool_update_highlight (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool,
|
||||
display);
|
||||
|
||||
gimp_rectangle_tool_update_options (rect_tool, tool->display);
|
||||
gimp_rectangle_tool_update_options (rect_tool, display);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
@ -1467,7 +1533,7 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
|
||||
rect_tool = GIMP_RECTANGLE_TOOL (tool);
|
||||
|
||||
if (tool->display != display)
|
||||
if (! gimp_rectangle_tool_is_active_at (rect_tool, display))
|
||||
return;
|
||||
|
||||
if (private->suppress_updates)
|
||||
@ -1476,7 +1542,7 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
|
||||
return;
|
||||
}
|
||||
|
||||
if (gimp_rectangle_tool_coord_outside (rect_tool, coords))
|
||||
if (gimp_rectangle_tool_coord_outside (rect_tool, coords, display))
|
||||
{
|
||||
/* The cursor is outside of the rectangle, clicking should
|
||||
* create a new rectangle.
|
||||
@ -1485,54 +1551,63 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_NORTH_WEST))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_RESIZING_UPPER_LEFT;
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_SOUTH_EAST))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_RESIZING_LOWER_RIGHT;
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_NORTH_EAST))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_RESIZING_UPPER_RIGHT;
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_SOUTH_WEST))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_RESIZING_LOWER_LEFT;
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_WEST))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_RESIZING_LEFT;
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_EAST))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_RESIZING_RIGHT;
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_NORTH))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_RESIZING_TOP;
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_SOUTH))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_RESIZING_BOTTOM;
|
||||
}
|
||||
else if (gimp_rectangle_tool_coord_on_handle (rect_tool,
|
||||
coords,
|
||||
display,
|
||||
GTK_ANCHOR_CENTER))
|
||||
{
|
||||
function = GIMP_RECTANGLE_TOOL_MOVING;
|
||||
@ -1560,7 +1635,7 @@ gimp_rectangle_tool_cursor_update (GimpTool *tool,
|
||||
rect_tool = GIMP_RECTANGLE_TOOL (tool);
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
|
||||
|
||||
if (tool->display == display)
|
||||
if (gimp_rectangle_tool_is_active_at (rect_tool, display))
|
||||
{
|
||||
switch (private->function)
|
||||
{
|
||||
@ -1772,7 +1847,8 @@ gimp_rectangle_tool_draw_guides (GimpDrawTool *draw_tool)
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rectangle_tool_update_handle_sizes (GimpRectangleTool *rect_tool)
|
||||
gimp_rectangle_tool_update_handle_sizes (GimpRectangleTool *rect_tool,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpRectangleToolPrivate *private;
|
||||
@ -1786,10 +1862,10 @@ gimp_rectangle_tool_update_handle_sizes (GimpRectangleTool *rect_tool)
|
||||
tool = GIMP_TOOL (rect_tool);
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
|
||||
|
||||
if (! (tool && tool->display))
|
||||
if (! gimp_rectangle_tool_is_active_at (rect_tool, display))
|
||||
return;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (tool->display->shell);
|
||||
shell = GIMP_DISPLAY_SHELL (display->shell);
|
||||
|
||||
gimp_rectangle_tool_get_public_rect (rect_tool,
|
||||
&pub_x1, &pub_y1, &pub_x2, &pub_y2);
|
||||
@ -1893,10 +1969,10 @@ gimp_rectangle_tool_scale_has_changed (GimpRectangleTool *rect_tool)
|
||||
GimpRectangleToolPrivate *private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
if (! tool->display)
|
||||
if (! gimp_rectangle_tool_is_active (rect_tool))
|
||||
return TRUE;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (tool->display->shell);
|
||||
shell = GIMP_DISPLAY_SHELL (private->active_display->shell);
|
||||
|
||||
return shell->scale_x != private->scale_x_used_for_handle_size_calculations ||
|
||||
shell->scale_y != private->scale_y_used_for_handle_size_calculations;
|
||||
@ -1915,20 +1991,21 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
|
||||
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
|
||||
|
||||
tool->display = display;
|
||||
private->active_display = display;
|
||||
|
||||
g_signal_connect_object (tool->display->shell, "scrolled",
|
||||
g_signal_connect_object (display->shell, "scrolled",
|
||||
G_CALLBACK (gimp_rectangle_tool_shell_scrolled),
|
||||
rect_tool, 0);
|
||||
|
||||
gimp_rectangle_tool_update_highlight (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool,
|
||||
display);
|
||||
|
||||
/* initialize the statusbar display */
|
||||
gimp_tool_push_status_coords (tool, tool->display,
|
||||
gimp_tool_push_status_coords (tool, display,
|
||||
_("Rectangle: "), 0, " x ", 0, NULL);
|
||||
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), tool->display);
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
|
||||
|
||||
if (options_private->fixed_width_entry)
|
||||
{
|
||||
@ -1993,16 +2070,19 @@ gimp_rectangle_tool_halt (GimpRectangleTool *rect_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpRectangleOptionsPrivate *options_private;
|
||||
GimpRectangleToolPrivate *private;
|
||||
|
||||
options_private =
|
||||
GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (gimp_tool_get_options (tool));
|
||||
|
||||
if (tool->display)
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
|
||||
|
||||
if (gimp_rectangle_tool_is_active (rect_tool))
|
||||
{
|
||||
gimp_display_shell_set_highlight (GIMP_DISPLAY_SHELL (tool->display->shell),
|
||||
gimp_display_shell_set_highlight (GIMP_DISPLAY_SHELL (private->active_display->shell),
|
||||
NULL);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (GIMP_DISPLAY_SHELL (tool->display->shell),
|
||||
g_signal_handlers_disconnect_by_func (private->active_display->shell,
|
||||
gimp_rectangle_tool_shell_scrolled,
|
||||
rect_tool);
|
||||
}
|
||||
@ -2013,8 +2093,7 @@ gimp_rectangle_tool_halt (GimpRectangleTool *rect_tool)
|
||||
if (gimp_tool_control_is_active (tool->control))
|
||||
gimp_tool_control_halt (tool->control);
|
||||
|
||||
tool->display = NULL;
|
||||
tool->drawable = NULL;
|
||||
private->active_display = NULL;
|
||||
|
||||
gimp_rectangle_tool_set_function (rect_tool, GIMP_RECTANGLE_TOOL_INACTIVE);
|
||||
|
||||
@ -2125,6 +2204,8 @@ gimp_rectangle_tool_synthesize_motion (GimpRectangleTool *rect_tool,
|
||||
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
|
||||
|
||||
g_return_if_fail (private->active_display);
|
||||
|
||||
old_function = private->function;
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (rect_tool));
|
||||
@ -2140,12 +2221,13 @@ gimp_rectangle_tool_synthesize_motion (GimpRectangleTool *rect_tool,
|
||||
private->center_y_on_fixed_center = (private->y1 + private->y2) / 2;
|
||||
|
||||
gimp_rectangle_tool_update_options (rect_tool,
|
||||
GIMP_TOOL (rect_tool)->display);
|
||||
private->active_display);
|
||||
|
||||
gimp_rectangle_tool_set_function (rect_tool, old_function);
|
||||
|
||||
gimp_rectangle_tool_update_highlight (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool,
|
||||
private->active_display);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (rect_tool));
|
||||
|
||||
@ -2174,7 +2256,7 @@ gimp_rectangle_tool_options_notify (GimpRectangleOptions *options,
|
||||
return;
|
||||
}
|
||||
|
||||
if (! tool->display)
|
||||
if (! gimp_rectangle_tool_is_active (rect_tool))
|
||||
return;
|
||||
|
||||
if (! strcmp (pspec->name, "x"))
|
||||
@ -2257,7 +2339,7 @@ gimp_rectangle_tool_options_notify (GimpRectangleOptions *options,
|
||||
* rectangle.
|
||||
*/
|
||||
if (options_private->fixed_rule_active &&
|
||||
tool->display != NULL &&
|
||||
gimp_rectangle_tool_is_active (rect_tool) &&
|
||||
tool->button_press_state == 0 &&
|
||||
tool->active_modifier_state == 0 &&
|
||||
options_private->desired_fixed_size_width == height &&
|
||||
@ -2315,7 +2397,7 @@ gimp_rectangle_tool_options_notify (GimpRectangleOptions *options,
|
||||
* rectangle.
|
||||
*/
|
||||
if (options_private->fixed_rule_active &&
|
||||
tool->display != NULL &&
|
||||
gimp_rectangle_tool_is_active (rect_tool) &&
|
||||
tool->button_press_state == 0 &&
|
||||
tool->active_modifier_state == 0 &&
|
||||
lower_ratio < new_inverse_ratio &&
|
||||
@ -2344,7 +2426,8 @@ gimp_rectangle_tool_shell_scrolled (GimpDisplayShell *shell,
|
||||
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool,
|
||||
shell->display);
|
||||
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
@ -2393,7 +2476,7 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpRectangleToolPrivate *private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
|
||||
GimpDisplay *display = tool->display;
|
||||
GimpDisplay *display = private->active_display;
|
||||
gint width;
|
||||
gint height;
|
||||
gint offset_x = 0;
|
||||
@ -2440,13 +2523,15 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool)
|
||||
|
||||
gimp_rectangle_tool_rectangle_changed (rect_tool);
|
||||
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool);
|
||||
gimp_rectangle_tool_update_handle_sizes (rect_tool,
|
||||
display);
|
||||
gimp_rectangle_tool_update_highlight (rect_tool);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (rect_tool));
|
||||
}
|
||||
|
||||
gimp_rectangle_tool_update_options (rect_tool, tool->display);
|
||||
gimp_rectangle_tool_update_options (rect_tool,
|
||||
private->active_display);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2457,7 +2542,8 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool)
|
||||
*/
|
||||
static gboolean
|
||||
gimp_rectangle_tool_coord_outside (GimpRectangleTool *rect_tool,
|
||||
GimpCoords *coord)
|
||||
GimpCoords *coord,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpRectangleToolPrivate *private;
|
||||
GimpDisplayShell *shell;
|
||||
@ -2467,7 +2553,7 @@ gimp_rectangle_tool_coord_outside (GimpRectangleTool *rect_tool,
|
||||
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
|
||||
narrow_mode = private->narrow_mode;
|
||||
shell = GIMP_DISPLAY_SHELL (GIMP_TOOL (rect_tool)->display->shell);
|
||||
shell = GIMP_DISPLAY_SHELL (display->shell);
|
||||
|
||||
gimp_rectangle_tool_get_public_rect (rect_tool,
|
||||
&pub_x1, &pub_y1, &pub_x2, &pub_y2);
|
||||
@ -2492,6 +2578,7 @@ gimp_rectangle_tool_coord_outside (GimpRectangleTool *rect_tool,
|
||||
static gboolean
|
||||
gimp_rectangle_tool_coord_on_handle (GimpRectangleTool *rect_tool,
|
||||
GimpCoords *coords,
|
||||
GimpDisplay *display,
|
||||
GtkAnchorType anchor)
|
||||
{
|
||||
GimpRectangleToolPrivate *private;
|
||||
@ -2509,7 +2596,7 @@ gimp_rectangle_tool_coord_on_handle (GimpRectangleTool *rect_tool,
|
||||
|
||||
tool = GIMP_TOOL (rect_tool);
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
shell = GIMP_DISPLAY_SHELL (tool->display->shell);
|
||||
shell = GIMP_DISPLAY_SHELL (display->shell);
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
|
||||
|
||||
gimp_rectangle_tool_get_public_rect (rect_tool,
|
||||
@ -2626,7 +2713,7 @@ gimp_rectangle_tool_coord_on_handle (GimpRectangleTool *rect_tool,
|
||||
handle_y += narrow_mode_y_dir * handle_height / shell->scale_y;
|
||||
}
|
||||
|
||||
return gimp_draw_tool_on_handle (draw_tool, shell->display,
|
||||
return gimp_draw_tool_on_handle (draw_tool, display,
|
||||
coords->x, coords->y,
|
||||
GIMP_HANDLE_SQUARE,
|
||||
handle_x, handle_y,
|
||||
@ -2683,10 +2770,10 @@ gimp_rectangle_tool_update_highlight (GimpRectangleTool *rect_tool)
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
|
||||
highlight = FALSE;
|
||||
|
||||
if (! tool->display)
|
||||
if (! gimp_rectangle_tool_is_active (rect_tool))
|
||||
return;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (tool->display->shell);
|
||||
shell = GIMP_DISPLAY_SHELL (private->active_display->shell);
|
||||
|
||||
g_object_get (options, "highlight", &highlight, NULL);
|
||||
|
||||
@ -3815,8 +3902,8 @@ gimp_rectangle_tool_apply_fixed_rule (GimpRectangleTool *rect_tool)
|
||||
|
||||
aspect = CLAMP (options_private->aspect_numerator /
|
||||
options_private->aspect_denominator,
|
||||
1.0 / tool->display->image->height,
|
||||
tool->display->image->width);
|
||||
1.0 / private->active_display->image->height,
|
||||
private->active_display->image->width);
|
||||
|
||||
if (constraint_to_use == GIMP_RECTANGLE_CONSTRAIN_NONE)
|
||||
{
|
||||
@ -3905,6 +3992,7 @@ gimp_rectangle_tool_get_constraints (GimpRectangleTool *rect_tool,
|
||||
GimpRectangleConstraint constraint)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpRectangleToolPrivate *private;
|
||||
gint min_x_dummy;
|
||||
gint min_y_dummy;
|
||||
gint max_x_dummy;
|
||||
@ -3920,16 +4008,18 @@ gimp_rectangle_tool_get_constraints (GimpRectangleTool *rect_tool,
|
||||
*max_x = 0;
|
||||
*max_y = 0;
|
||||
|
||||
if (! tool->display)
|
||||
if (! gimp_rectangle_tool_is_active (rect_tool))
|
||||
return;
|
||||
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
|
||||
|
||||
switch (constraint)
|
||||
{
|
||||
case GIMP_RECTANGLE_CONSTRAIN_IMAGE:
|
||||
*min_x = 0;
|
||||
*min_y = 0;
|
||||
*max_x = tool->display->image->width;
|
||||
*max_y = tool->display->image->height;
|
||||
*max_x = private->active_display->image->width;
|
||||
*max_y = private->active_display->image->height;
|
||||
break;
|
||||
|
||||
case GIMP_RECTANGLE_CONSTRAIN_DRAWABLE:
|
||||
|
@ -142,6 +142,10 @@ gboolean gimp_rectangle_tool_rectangle_is_new (GimpRectangleTool *re
|
||||
gboolean gimp_rectangle_tool_point_in_rectangle (GimpRectangleTool *rect_tool,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
GimpDisplay*gimp_rectangle_tool_get_active_display (GimpRectangleTool *rect_tool);
|
||||
gboolean gimp_rectangle_tool_is_active_at (GimpRectangleTool *rect_tool,
|
||||
GimpDisplay *display);
|
||||
gboolean gimp_rectangle_tool_is_active (GimpRectangleTool *rect_tool);
|
||||
|
||||
|
||||
/* convenience functions */
|
||||
|
Reference in New Issue
Block a user