Bill Skaggs <weskaggs@primate.ucdavis.edu>

* app/tools/gimprectangletool.c: add "notify" callbacks for changes
	of width, height, or aspect entries in the tool options.
This commit is contained in:
William Skaggs 2005-10-21 20:17:19 +00:00
parent 1792475747
commit 2eed91bfc7
2 changed files with 148 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2005-10-20 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/tools/gimprectangletool.c: add "notify" callbacks for changes
of width, height, or aspect entries in the tool options.
2005-10-20 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/tools/gimprectangletool.c:

View File

@ -106,6 +106,15 @@ static void gimp_rectangle_tool_update_options (GimpRectangleTool *rectan
GimpDisplay *gdisp);
static GtkWidget * gimp_rectangle_controls (GimpRectangleTool *rectangle);
static void gimp_rectangle_tool_zero_controls (GimpRectangleTool *rectangle);
static void gimp_rectangle_tool_notify_width (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle);
static void gimp_rectangle_tool_notify_height (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle);
static void gimp_rectangle_tool_notify_aspect (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle);
GType
@ -1189,6 +1198,16 @@ gimp_rectangle_tool_constructor (GObject *object)
options = G_OBJECT (tool->tool_info->tool_options);
g_signal_connect_object (options, "notify::width",
G_CALLBACK (gimp_rectangle_tool_notify_width),
rectangle, 0);
g_signal_connect_object (options, "notify::height",
G_CALLBACK (gimp_rectangle_tool_notify_height),
rectangle, 0);
g_signal_connect_object (options, "notify::aspect",
G_CALLBACK (gimp_rectangle_tool_notify_aspect),
rectangle, 0);
controls_container = GTK_CONTAINER (g_object_get_data (options,
"controls-container"));
@ -2541,11 +2560,31 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle,
gimp_size_entry_set_refval (entry, 2, x1);
gimp_size_entry_set_refval (entry, 3, y1);
g_object_set (options, "width", width, NULL);
g_signal_handlers_block_by_func (options,
gimp_rectangle_tool_notify_width,
rectangle);
g_signal_handlers_block_by_func (options,
gimp_rectangle_tool_notify_height,
rectangle);
g_signal_handlers_block_by_func (options,
gimp_rectangle_tool_notify_aspect,
rectangle);
g_object_set (options, "height", height, NULL);
g_object_set (options,
"width", width,
"height", height,
"aspect", aspect,
NULL);
g_object_set (options, "aspect", aspect, NULL);
g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_notify_width,
rectangle);
g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_notify_height,
rectangle);
g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_notify_aspect,
rectangle);
g_object_set (options,
"center-x", center_x,
@ -2621,3 +2660,100 @@ gimp_rectangle_tool_zero_controls (GimpRectangleTool *rectangle)
gimp_size_entry_set_refval (entry, 2, 0);
gimp_size_entry_set_refval (entry, 3, 0);
}
/*
* we handle changes in width by treating them as movement of the right edge
*/
static void
gimp_rectangle_tool_notify_width (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle)
{
gint rx1, rx2, ry1, ry2;
GimpCoords coords;
gdouble width = gimp_rectangle_options_get_width (options);
g_object_get (rectangle,
"x1", &rx1,
"y1", &ry1,
"x2", &rx2,
"y2", &ry2,
NULL);
coords.x = rx1 + width;
coords.y = ry2;
g_object_set (rectangle,
"function", RECT_RESIZING_RIGHT,
"startx", rx2,
"starty", ry2,
NULL);
gimp_rectangle_tool_motion (GIMP_TOOL (rectangle), &coords, 0, 0,
GIMP_TOOL (rectangle)->gdisp);
}
/*
* we handle changes in height by treating them as movement of the bottom edge
*/
static void
gimp_rectangle_tool_notify_height (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle)
{
gint rx1, rx2, ry1, ry2;
GimpCoords coords;
gdouble height = gimp_rectangle_options_get_height (options);
g_object_get (rectangle,
"x1", &rx1,
"y1", &ry1,
"x2", &rx2,
"y2", &ry2,
NULL);
coords.x = rx2;
coords.y = ry1 + height;
g_object_set (rectangle,
"function", RECT_RESIZING_BOTTOM,
"startx", rx2,
"starty", ry2,
NULL);
gimp_rectangle_tool_motion (GIMP_TOOL (rectangle), &coords, 0, 0,
GIMP_TOOL (rectangle)->gdisp);
}
/*
* we handle changes in aspect by treating them as movement of the bottom edge
*/
static void
gimp_rectangle_tool_notify_aspect (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle)
{
gint rx1, rx2, ry1, ry2;
GimpCoords coords;
gdouble aspect = gimp_rectangle_options_get_aspect (options);
g_object_get (rectangle,
"x1", &rx1,
"y1", &ry1,
"x2", &rx2,
"y2", &ry2,
NULL);
coords.x = rx2;
coords.y = ry1 + aspect * (rx2 - rx1);
g_object_set (rectangle,
"function", RECT_RESIZING_BOTTOM,
"startx", rx2,
"starty", ry2,
NULL);
gimp_rectangle_tool_motion (GIMP_TOOL (rectangle), &coords, 0, 0,
GIMP_TOOL (rectangle)->gdisp);
}