Commit 84e1f757 authored by Michael Natterer's avatar Michael Natterer 😴

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().
parent d089aa62
...@@ -61,6 +61,7 @@ VOID: POINTER, FLAGS, BOOLEAN ...@@ -61,6 +61,7 @@ VOID: POINTER, FLAGS, BOOLEAN
VOID: POINTER, UINT, FLAGS VOID: POINTER, UINT, FLAGS
VOID: STRING VOID: STRING
VOID: STRING, BOOLEAN, UINT, FLAGS VOID: STRING, BOOLEAN, UINT, FLAGS
VOID: STRING, DOUBLE, STRING, DOUBLE, STRING
VOID: STRING, FLAGS VOID: STRING, FLAGS
VOID: STRING, STRING, STRING VOID: STRING, STRING, STRING
VOID: VOID VOID: VOID
...@@ -820,7 +820,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget, ...@@ -820,7 +820,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
NULL, NULL, NULL); NULL, NULL, NULL);
} }
gimp_tool_widget_status (widget, status); gimp_tool_widget_set_status (widget, status);
g_free (status); g_free (status);
break; break;
} }
...@@ -831,7 +831,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget, ...@@ -831,7 +831,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
"vertical guide"), "vertical guide"),
toggle_mask & ~state, toggle_mask & ~state,
NULL, NULL, NULL); NULL, NULL, NULL);
gimp_tool_widget_status (widget, status); gimp_tool_widget_set_status (widget, status);
g_free (status); g_free (status);
break; break;
} }
...@@ -857,7 +857,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget, ...@@ -857,7 +857,7 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
NULL, NULL, NULL); NULL, NULL, NULL);
} }
gimp_tool_widget_status (widget, status); gimp_tool_widget_set_status (widget, status);
g_free (status); g_free (status);
break; break;
} }
...@@ -867,11 +867,12 @@ gimp_tool_compass_hover (GimpToolWidget *widget, ...@@ -867,11 +867,12 @@ gimp_tool_compass_hover (GimpToolWidget *widget,
{ {
if ((private->n_points > 1) && (state & GDK_MOD1_MASK)) 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 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, ...@@ -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); g_free (status);
gimp_tool_handle_grid_update_hilight (grid); gimp_tool_handle_grid_update_hilight (grid);
......
...@@ -488,8 +488,8 @@ gimp_tool_path_check_writable (GimpToolPath *path) ...@@ -488,8 +488,8 @@ gimp_tool_path_check_writable (GimpToolPath *path)
if (gimp_item_is_content_locked (GIMP_ITEM (private->vectors)) || if (gimp_item_is_content_locked (GIMP_ITEM (private->vectors)) ||
gimp_item_is_position_locked (GIMP_ITEM (private->vectors))) gimp_item_is_position_locked (GIMP_ITEM (private->vectors)))
{ {
gimp_tool_widget_status (GIMP_TOOL_WIDGET (path), gimp_tool_widget_set_status (GIMP_TOOL_WIDGET (path),
_("The active path is locked.")); _("The active path is locked."));
private->function = VECTORS_FINISHED; private->function = VECTORS_FINISHED;
...@@ -1430,7 +1430,7 @@ gimp_tool_path_update_status (GimpToolPath *path, ...@@ -1430,7 +1430,7 @@ gimp_tool_path_update_status (GimpToolPath *path,
if (! proximity) if (! proximity)
{ {
gimp_tool_widget_status (GIMP_TOOL_WIDGET (path), NULL); gimp_tool_widget_set_status (GIMP_TOOL_WIDGET (path), NULL);
return; return;
} }
...@@ -1547,7 +1547,7 @@ gimp_tool_path_update_status (GimpToolPath *path, ...@@ -1547,7 +1547,7 @@ gimp_tool_path_update_status (GimpToolPath *path,
break; break;
} }
gimp_tool_widget_status (GIMP_TOOL_WIDGET (path), status); gimp_tool_widget_set_status (GIMP_TOOL_WIDGET (path), status);
if (free_status) if (free_status)
g_free ((gchar *) status); g_free ((gchar *) status);
......
...@@ -963,12 +963,12 @@ gimp_tool_polygon_status_update (GimpToolPolygon *polygon, ...@@ -963,12 +963,12 @@ gimp_tool_polygon_status_update (GimpToolPolygon *polygon,
if (status_text) if (status_text)
{ {
gimp_tool_widget_status (widget, status_text); gimp_tool_widget_set_status (widget, status_text);
} }
} }
else 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, ...@@ -1152,14 +1152,14 @@ gimp_tool_transform_grid_button_press (GimpToolWidget *widget,
gimp_canvas_handle_get_position (handle, &x, &y); gimp_canvas_handle_get_position (handle, &x, &y);
gimp_tool_widget_snap_offsets (widget, gimp_tool_widget_set_snap_offsets (widget,
SIGNED_ROUND (x - coords->x), SIGNED_ROUND (x - coords->x),
SIGNED_ROUND (y - coords->y), SIGNED_ROUND (y - coords->y),
0, 0); 0, 0);
} }
else 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; private->prev_tx1 = private->tx1;
...@@ -1178,7 +1178,7 @@ gimp_tool_transform_grid_button_press (GimpToolWidget *widget, ...@@ -1178,7 +1178,7 @@ gimp_tool_transform_grid_button_press (GimpToolWidget *widget,
return private->handle; 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; return 0;
} }
...@@ -1891,11 +1891,12 @@ gimp_tool_transform_grid_hover (GimpToolWidget *widget, ...@@ -1891,11 +1891,12 @@ gimp_tool_transform_grid_hover (GimpToolWidget *widget,
if (handle != GIMP_TRANSFORM_HANDLE_NONE && proximity) 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 else
{ {
gimp_tool_widget_status (widget, NULL); gimp_tool_widget_set_status (widget, NULL);
} }
private->handle = handle; private->handle = handle;
......
...@@ -49,6 +49,7 @@ enum ...@@ -49,6 +49,7 @@ enum
CHANGED, CHANGED,
SNAP_OFFSETS, SNAP_OFFSETS,
STATUS, STATUS,
STATUS_COORDS,
LAST_SIGNAL LAST_SIGNAL
}; };
...@@ -57,6 +58,11 @@ struct _GimpToolWidgetPrivate ...@@ -57,6 +58,11 @@ struct _GimpToolWidgetPrivate
GimpDisplayShell *shell; GimpDisplayShell *shell;
GimpCanvasItem *item; GimpCanvasItem *item;
GList *group_stack; 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) ...@@ -127,6 +133,20 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_STRING); 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_object_class_install_property (object_class, PROP_SHELL,
g_param_spec_object ("shell", g_param_spec_object ("shell",
NULL, NULL, NULL, NULL,
...@@ -253,21 +273,55 @@ gimp_tool_widget_get_item (GimpToolWidget *widget) ...@@ -253,21 +273,55 @@ gimp_tool_widget_get_item (GimpToolWidget *widget)
} }
void void
gimp_tool_widget_snap_offsets (GimpToolWidget *widget, gimp_tool_widget_set_snap_offsets (GimpToolWidget *widget,
gint offset_x, gint offset_x,
gint offset_y, gint offset_y,
gint width, gint width,
gint height) gint height)
{ {
GimpToolWidgetPrivate *private;
g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget)); 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); offset_x, offset_y, width, height);
}
} }
void void
gimp_tool_widget_status (GimpToolWidget *widget, gimp_tool_widget_get_snap_offsets (GimpToolWidget *widget,
const gchar *status) 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)); g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
...@@ -275,6 +329,20 @@ gimp_tool_widget_status (GimpToolWidget *widget, ...@@ -275,6 +329,20 @@ gimp_tool_widget_status (GimpToolWidget *widget,
status); 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 void
gimp_tool_widget_add_item (GimpToolWidget *widget, gimp_tool_widget_add_item (GimpToolWidget *widget,
GimpCanvasItem *item) GimpCanvasItem *item)
......
...@@ -56,6 +56,12 @@ struct _GimpToolWidgetClass ...@@ -56,6 +56,12 @@ struct _GimpToolWidgetClass
gint height); gint height);
void (* status) (GimpToolWidget *widget, void (* status) (GimpToolWidget *widget,
const gchar *status); const gchar *status);
void (* status_coords) (GimpToolWidget *widget,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y,
const gchar *help);
/* virtual functions */ /* virtual functions */
gint (* button_press) (GimpToolWidget *widget, gint (* button_press) (GimpToolWidget *widget,
...@@ -101,20 +107,32 @@ struct _GimpToolWidgetClass ...@@ -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); GimpDisplayShell * gimp_tool_widget_get_shell (GimpToolWidget *widget);
GimpCanvasItem * gimp_tool_widget_get_item (GimpToolWidget *widget); GimpCanvasItem * gimp_tool_widget_get_item (GimpToolWidget *widget);
/* for subclasses, to notify the handling tool /* for subclasses, to notify the handling tool
*/ */
void gimp_tool_widget_snap_offsets (GimpToolWidget *widget, void gimp_tool_widget_set_snap_offsets (GimpToolWidget *widget,
gint offset_x, gint offset_x,
gint offset_y, gint offset_y,
gint width, gint width,
gint height); gint height);
void gimp_tool_widget_status (GimpToolWidget *widget, void gimp_tool_widget_get_snap_offsets (GimpToolWidget *widget,
const gchar *status); 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 /* for subclasses, to add and manage their items
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment