app: store the snap offsets in GimpToolWidget
Rename gimp_tool_widget_snap_offsets() to set_snap_offsets(), and add gimp_tool_widget_get_snap_offsets(). Also rename gimp_tool_widget_status() to set_status(), and add new function and signal set_status_coords().
This commit is contained in:
@ -61,6 +61,7 @@ VOID: POINTER, FLAGS, BOOLEAN
|
||||
VOID: POINTER, UINT, FLAGS
|
||||
VOID: STRING
|
||||
VOID: STRING, BOOLEAN, UINT, FLAGS
|
||||
VOID: STRING, DOUBLE, STRING, DOUBLE, STRING
|
||||
VOID: STRING, FLAGS
|
||||
VOID: STRING, STRING, STRING
|
||||
VOID: VOID
|
||||
|
@ -820,7 +820,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
gimp_tool_widget_status (widget, status);
|
||||
gimp_tool_widget_set_status (widget, status);
|
||||
g_free (status);
|
||||
break;
|
||||
}
|
||||
@ -831,7 +831,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
|
||||
"vertical guide"),
|
||||
toggle_mask & ~state,
|
||||
NULL, NULL, NULL);
|
||||
gimp_tool_widget_status (widget, status);
|
||||
gimp_tool_widget_set_status (widget, status);
|
||||
g_free (status);
|
||||
break;
|
||||
}
|
||||
@ -857,7 +857,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
gimp_tool_widget_status (widget, status);
|
||||
gimp_tool_widget_set_status (widget, status);
|
||||
g_free (status);
|
||||
break;
|
||||
}
|
||||
@ -867,11 +867,12 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
|
||||
{
|
||||
if ((private->n_points > 1) && (state & GDK_MOD1_MASK))
|
||||
{
|
||||
gimp_tool_widget_status (widget, _("Click-Drag to move all points"));
|
||||
gimp_tool_widget_set_status (widget,
|
||||
_("Click-Drag to move all points"));
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_tool_widget_status (widget, NULL);
|
||||
gimp_tool_widget_set_status (widget, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -882,7 +882,7 @@ gimp_tool_handle_grid_hover (GimpToolWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
gimp_tool_widget_status (widget, status);
|
||||
gimp_tool_widget_set_status (widget, status);
|
||||
g_free (status);
|
||||
|
||||
gimp_tool_handle_grid_update_hilight (grid);
|
||||
|
@ -488,8 +488,8 @@ gimp_tool_path_check_writable (GimpToolPath *path)
|
||||
if (gimp_item_is_content_locked (GIMP_ITEM (private->vectors)) ||
|
||||
gimp_item_is_position_locked (GIMP_ITEM (private->vectors)))
|
||||
{
|
||||
gimp_tool_widget_status (GIMP_TOOL_WIDGET (path),
|
||||
_("The active path is locked."));
|
||||
gimp_tool_widget_set_status (GIMP_TOOL_WIDGET (path),
|
||||
_("The active path is locked."));
|
||||
|
||||
private->function = VECTORS_FINISHED;
|
||||
|
||||
@ -1430,7 +1430,7 @@ gimp_tool_path_update_status (GimpToolPath *path,
|
||||
|
||||
if (! proximity)
|
||||
{
|
||||
gimp_tool_widget_status (GIMP_TOOL_WIDGET (path), NULL);
|
||||
gimp_tool_widget_set_status (GIMP_TOOL_WIDGET (path), NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1547,7 +1547,7 @@ gimp_tool_path_update_status (GimpToolPath *path,
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_tool_widget_status (GIMP_TOOL_WIDGET (path), status);
|
||||
gimp_tool_widget_set_status (GIMP_TOOL_WIDGET (path), status);
|
||||
|
||||
if (free_status)
|
||||
g_free ((gchar *) status);
|
||||
|
@ -963,12 +963,12 @@ gimp_tool_polygon_status_update (GimpToolPolygon *polygon,
|
||||
|
||||
if (status_text)
|
||||
{
|
||||
gimp_tool_widget_status (widget, status_text);
|
||||
gimp_tool_widget_set_status (widget, status_text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_tool_widget_status (widget, NULL);
|
||||
gimp_tool_widget_set_status (widget, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1152,14 +1152,14 @@ gimp_tool_transform_grid_button_press (GimpToolWidget *widget,
|
||||
|
||||
gimp_canvas_handle_get_position (handle, &x, &y);
|
||||
|
||||
gimp_tool_widget_snap_offsets (widget,
|
||||
SIGNED_ROUND (x - coords->x),
|
||||
SIGNED_ROUND (y - coords->y),
|
||||
0, 0);
|
||||
gimp_tool_widget_set_snap_offsets (widget,
|
||||
SIGNED_ROUND (x - coords->x),
|
||||
SIGNED_ROUND (y - coords->y),
|
||||
0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_tool_widget_snap_offsets (widget, 0, 0, 0, 0);
|
||||
gimp_tool_widget_set_snap_offsets (widget, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
private->prev_tx1 = private->tx1;
|
||||
@ -1178,7 +1178,7 @@ gimp_tool_transform_grid_button_press (GimpToolWidget *widget,
|
||||
return private->handle;
|
||||
}
|
||||
|
||||
gimp_tool_widget_snap_offsets (widget, 0, 0, 0, 0);
|
||||
gimp_tool_widget_set_snap_offsets (widget, 0, 0, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1891,11 +1891,12 @@ gimp_tool_transform_grid_hover (GimpToolWidget *widget,
|
||||
|
||||
if (handle != GIMP_TRANSFORM_HANDLE_NONE && proximity)
|
||||
{
|
||||
gimp_tool_widget_status (widget, get_friendly_operation_name (handle));
|
||||
gimp_tool_widget_set_status (widget,
|
||||
get_friendly_operation_name (handle));
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_tool_widget_status (widget, NULL);
|
||||
gimp_tool_widget_set_status (widget, NULL);
|
||||
}
|
||||
|
||||
private->handle = handle;
|
||||
|
@ -49,6 +49,7 @@ enum
|
||||
CHANGED,
|
||||
SNAP_OFFSETS,
|
||||
STATUS,
|
||||
STATUS_COORDS,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@ -57,6 +58,11 @@ struct _GimpToolWidgetPrivate
|
||||
GimpDisplayShell *shell;
|
||||
GimpCanvasItem *item;
|
||||
GList *group_stack;
|
||||
|
||||
gint snap_offset_x;
|
||||
gint snap_offset_y;
|
||||
gint snap_width;
|
||||
gint snap_height;
|
||||
};
|
||||
|
||||
|
||||
@ -127,6 +133,20 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
widget_signals[STATUS_COORDS] =
|
||||
g_signal_new ("status-coords",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpToolWidgetClass, status_coords),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__STRING_DOUBLE_STRING_DOUBLE_STRING,
|
||||
G_TYPE_NONE, 5,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_DOUBLE,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_DOUBLE,
|
||||
G_TYPE_STRING);
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SHELL,
|
||||
g_param_spec_object ("shell",
|
||||
NULL, NULL,
|
||||
@ -253,21 +273,55 @@ gimp_tool_widget_get_item (GimpToolWidget *widget)
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tool_widget_snap_offsets (GimpToolWidget *widget,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gint width,
|
||||
gint height)
|
||||
gimp_tool_widget_set_snap_offsets (GimpToolWidget *widget,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GimpToolWidgetPrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
|
||||
|
||||
g_signal_emit (widget, widget_signals[SNAP_OFFSETS], 0,
|
||||
private = widget->private;
|
||||
|
||||
if (offset_x != private->snap_offset_x ||
|
||||
offset_y != private->snap_offset_y ||
|
||||
width != private->snap_width ||
|
||||
height != private->snap_height)
|
||||
{
|
||||
private->snap_offset_x = offset_x;
|
||||
private->snap_offset_y = offset_y;
|
||||
private->snap_width = width;
|
||||
private->snap_height = height;
|
||||
|
||||
g_signal_emit (widget, widget_signals[SNAP_OFFSETS], 0,
|
||||
offset_x, offset_y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tool_widget_status (GimpToolWidget *widget,
|
||||
const gchar *status)
|
||||
gimp_tool_widget_get_snap_offsets (GimpToolWidget *widget,
|
||||
gint *offset_x,
|
||||
gint *offset_y,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GimpToolWidgetPrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
|
||||
|
||||
private = widget->private;
|
||||
|
||||
if (offset_x) *offset_x = private->snap_offset_x;
|
||||
if (offset_y) *offset_y = private->snap_offset_y;
|
||||
if (width) *width = private->snap_width;
|
||||
if (height) *height = private->snap_height;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tool_widget_set_status (GimpToolWidget *widget,
|
||||
const gchar *status)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
|
||||
|
||||
@ -275,6 +329,20 @@ gimp_tool_widget_status (GimpToolWidget *widget,
|
||||
status);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tool_widget_set_status_coords (GimpToolWidget *widget,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y,
|
||||
const gchar *help)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
|
||||
|
||||
g_signal_emit (widget, widget_signals[STATUS_COORDS], 0,
|
||||
title, x, separator, y, help);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tool_widget_add_item (GimpToolWidget *widget,
|
||||
GimpCanvasItem *item)
|
||||
|
@ -56,6 +56,12 @@ struct _GimpToolWidgetClass
|
||||
gint height);
|
||||
void (* status) (GimpToolWidget *widget,
|
||||
const gchar *status);
|
||||
void (* status_coords) (GimpToolWidget *widget,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y,
|
||||
const gchar *help);
|
||||
|
||||
/* virtual functions */
|
||||
gint (* button_press) (GimpToolWidget *widget,
|
||||
@ -101,20 +107,32 @@ struct _GimpToolWidgetClass
|
||||
};
|
||||
|
||||
|
||||
GType gimp_tool_widget_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_tool_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpDisplayShell * gimp_tool_widget_get_shell (GimpToolWidget *widget);
|
||||
GimpCanvasItem * gimp_tool_widget_get_item (GimpToolWidget *widget);
|
||||
GimpDisplayShell * gimp_tool_widget_get_shell (GimpToolWidget *widget);
|
||||
GimpCanvasItem * gimp_tool_widget_get_item (GimpToolWidget *widget);
|
||||
|
||||
/* for subclasses, to notify the handling tool
|
||||
*/
|
||||
void gimp_tool_widget_snap_offsets (GimpToolWidget *widget,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gimp_tool_widget_status (GimpToolWidget *widget,
|
||||
const gchar *status);
|
||||
void gimp_tool_widget_set_snap_offsets (GimpToolWidget *widget,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gimp_tool_widget_get_snap_offsets (GimpToolWidget *widget,
|
||||
gint *offset_x,
|
||||
gint *offset_y,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
void gimp_tool_widget_set_status (GimpToolWidget *widget,
|
||||
const gchar *status);
|
||||
void gimp_tool_widget_set_status_coords (GimpToolWidget *widget,
|
||||
const gchar *title,
|
||||
gdouble x,
|
||||
const gchar *separator,
|
||||
gdouble y,
|
||||
const gchar *help);
|
||||
|
||||
/* for subclasses, to add and manage their items
|
||||
*/
|
||||
|
Reference in New Issue
Block a user