Bill Skaggs <weskaggs@primate.ucdavis.edu>

* app/tools/gimprectangletool.[ch]: add "constrain" property
	to specify whether to clip at image bounds when computing
	dimensions.

	* app/tools/gimpcroptool.c
	* app/tools/gimpnewrectselecttool.c: set "constrain" to TRUE.

	* app/tools/gimpellipseselecttool.c: set "constrain" to FALSE.

	Hopefully fixes bug #329817.
This commit is contained in:
William Skaggs 2006-05-31 19:45:38 +00:00
parent 2606a93524
commit 8387dd98a4
7 changed files with 90 additions and 10 deletions

View File

@ -1,3 +1,16 @@
2006-05-31 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/tools/gimprectangletool.[ch]: add "constrain" property
to specify whether to clip at image bounds when computing
dimensions.
* app/tools/gimpcroptool.c
* app/tools/gimpnewrectselecttool.c: set "constrain" to TRUE.
* app/tools/gimpellipseselecttool.c: set "constrain" to FALSE.
Hopefully fixes bug #329817.
2006-05-31 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpcolorscale.c: removed #define SHADOW 1, it's

View File

@ -132,8 +132,10 @@ static void
gimp_crop_tool_init (GimpCropTool *crop_tool)
{
GimpTool *tool = GIMP_TOOL (crop_tool);
GimpRectangleTool *rect_tool = GIMP_RECTANGLE_TOOL (crop_tool);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);
gimp_rectangle_tool_set_constrain (rect_tool, TRUE);
}
static void

View File

@ -35,6 +35,7 @@
#include "display/gimpdisplay.h"
#include "gimprectangletool.h"
#include "gimpellipseselecttool.h"
#include "gimpnewrectselectoptions.h"
#include "gimptoolcontrol.h"
@ -96,10 +97,12 @@ gimp_ellipse_select_tool_class_init (GimpEllipseSelectToolClass *klass)
static void
gimp_ellipse_select_tool_init (GimpEllipseSelectTool *ellipse_select)
{
GimpTool *tool = GIMP_TOOL (ellipse_select);
GimpTool *tool = GIMP_TOOL (ellipse_select);
GimpRectangleTool *rect_tool = GIMP_RECTANGLE_TOOL (ellipse_select);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_ELLIPSE_SELECT);
gimp_rectangle_tool_set_constrain (rect_tool, FALSE);
}
static void

View File

@ -156,8 +156,10 @@ static void
gimp_new_rect_select_tool_init (GimpNewRectSelectTool *new_rect_select_tool)
{
GimpTool *tool = GIMP_TOOL (new_rect_select_tool);
GimpRectangleTool *rect_tool = GIMP_RECTANGLE_TOOL (new_rect_select_tool);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_RECT_SELECT);
gimp_rectangle_tool_set_constrain (rect_tool, TRUE);
}
static void

View File

@ -156,8 +156,10 @@ static void
gimp_new_rect_select_tool_init (GimpNewRectSelectTool *new_rect_select_tool)
{
GimpTool *tool = GIMP_TOOL (new_rect_select_tool);
GimpRectangleTool *rect_tool = GIMP_RECTANGLE_TOOL (new_rect_select_tool);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_RECT_SELECT);
gimp_rectangle_tool_set_constrain (rect_tool, TRUE);
}
static void

View File

@ -62,6 +62,8 @@ struct _GimpRectangleToolPrivate
gint x2, y2; /* lower right hand coords */
guint function; /* moving or resizing */
gboolean constrain; /* constrain to image bounds */
};
@ -93,6 +95,7 @@ gint gimp_rectangle_tool_get_y2 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_function (GimpRectangleTool *tool,
guint function);
guint gimp_rectangle_tool_get_function (GimpRectangleTool *tool);
gboolean gimp_rectangle_tool_get_constrain (GimpRectangleTool *tool);
/* Rectangle helper functions */
static void rectangle_tool_start (GimpRectangleTool *rectangle);
@ -135,7 +138,6 @@ static gint dx2, dy2; /* */
static gint dcw, dch; /* width and height of edges */
GType
gimp_rectangle_tool_interface_get_type (void)
{
@ -222,6 +224,12 @@ gimp_rectangle_tool_iface_base_init (GimpRectangleToolInterface *iface)
0,
GIMP_PARAM_READWRITE));
g_object_interface_install_property (iface,
g_param_spec_boolean ("constrain",
NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
initialized = TRUE;
}
}
@ -292,6 +300,9 @@ gimp_rectangle_tool_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_TOOL_PROP_FUNCTION,
"function");
g_object_class_override_property (klass,
GIMP_RECTANGLE_TOOL_PROP_CONSTRAIN,
"constrain");
}
void
@ -476,6 +487,32 @@ gimp_rectangle_tool_get_function (GimpRectangleTool *tool)
return private->function;
}
void
gimp_rectangle_tool_set_constrain (GimpRectangleTool *tool,
gboolean constrain)
{
GimpRectangleToolPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool));
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->constrain = constrain? TRUE : FALSE;
g_object_notify (G_OBJECT (tool), "constrain");
}
gboolean
gimp_rectangle_tool_get_constrain (GimpRectangleTool *tool)
{
GimpRectangleToolPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (tool), 0);
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
return private->constrain;
}
void
gimp_rectangle_tool_set_property (GObject *object,
guint property_id,
@ -507,6 +544,9 @@ gimp_rectangle_tool_set_property (GObject *object,
case GIMP_RECTANGLE_TOOL_PROP_FUNCTION:
gimp_rectangle_tool_set_function (tool, g_value_get_uint (value));
break;
case GIMP_RECTANGLE_TOOL_PROP_CONSTRAIN:
gimp_rectangle_tool_set_constrain (tool, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -544,6 +584,9 @@ gimp_rectangle_tool_get_property (GObject *object,
case GIMP_RECTANGLE_TOOL_PROP_FUNCTION:
g_value_set_uint (value, gimp_rectangle_tool_get_function (tool));
break;
case GIMP_RECTANGLE_TOOL_PROP_CONSTRAIN:
g_value_set_boolean (value, gimp_rectangle_tool_get_constrain (tool));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -1201,14 +1244,27 @@ gimp_rectangle_tool_motion (GimpTool *tool,
if (function != RECT_MOVING &&
function != RECT_EXECUTING)
{
gboolean constrain = gimp_rectangle_tool_get_constrain (rectangle);
gimp_tool_pop_status (tool, display);
gimp_tool_push_status_coords (tool, display,
_("Rectangle: "),
(rx2 > max_x ? max_x : rx2) -
(rx1 < min_x ? min_x : rx1),
" × ",
(ry2 > max_y ? max_y : ry2) -
(ry1 < min_y ? min_y : ry1));
if (constrain)
{
gimp_tool_push_status_coords (tool, display,
_("Rectangle: "),
(rx2 > max_x ? max_x : rx2) -
(rx1 < min_x ? min_x : rx1),
" × ",
(ry2 > max_y ? max_y : ry2) -
(ry1 < min_y ? min_y : ry1));
}
else
{
gimp_tool_push_status_coords (tool, display,
_("Rectangle: "),
rx2 - rx1,
" × ",
ry2 - ry1);
}
}
if (function == RECT_CREATING)

View File

@ -34,6 +34,7 @@ typedef enum
GIMP_RECTANGLE_TOOL_PROP_X2,
GIMP_RECTANGLE_TOOL_PROP_Y2,
GIMP_RECTANGLE_TOOL_PROP_FUNCTION,
GIMP_RECTANGLE_TOOL_PROP_CONSTRAIN,
GIMP_RECTANGLE_TOOL_PROP_LAST = GIMP_RECTANGLE_TOOL_PROP_FUNCTION
} GimpRectangleToolProp;
@ -127,7 +128,8 @@ void gimp_rectangle_tool_response (GtkWidget *widget,
gint response_id,
GimpRectangleTool *rectangle);
void gimp_rectangle_tool_configure (GimpRectangleTool *rectangle);
void gimp_rectangle_tool_set_constrain (GimpRectangleTool *rectangle,
gboolean constrain);
/* convenience functions */