app: add GimpToolPolygon::change-complete signal
... which is emitted when finishing a change to the polygon,
similarly to GimpToolRectangle::change-complete.
(cherry picked from commit 134ff92fe0
)
This commit is contained in:
@ -37,6 +37,7 @@
|
|||||||
#include "display-types.h"
|
#include "display-types.h"
|
||||||
|
|
||||||
#include "core/gimp-utils.h"
|
#include "core/gimp-utils.h"
|
||||||
|
#include "core/gimpmarshal.h"
|
||||||
|
|
||||||
#include "widgets/gimpwidgets-utils.h"
|
#include "widgets/gimpwidgets-utils.h"
|
||||||
|
|
||||||
@ -57,6 +58,13 @@
|
|||||||
#define NO_CLICK_TIME_AVAILABLE 0
|
#define NO_CLICK_TIME_AVAILABLE 0
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CHANGE_COMPLETE,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct _GimpToolPolygonPrivate
|
struct _GimpToolPolygonPrivate
|
||||||
{
|
{
|
||||||
/* Index of grabbed segment index. */
|
/* Index of grabbed segment index. */
|
||||||
@ -185,6 +193,8 @@ static gboolean gimp_tool_polygon_get_cursor (GimpToolWidget *widget
|
|||||||
GimpToolCursorType *tool_cursor,
|
GimpToolCursorType *tool_cursor,
|
||||||
GimpCursorModifier *modifier);
|
GimpCursorModifier *modifier);
|
||||||
|
|
||||||
|
static void gimp_tool_polygon_change_complete (GimpToolPolygon *polygon);
|
||||||
|
|
||||||
static gint gimp_tool_polygon_get_segment_index (GimpToolPolygon *polygon,
|
static gint gimp_tool_polygon_get_segment_index (GimpToolPolygon *polygon,
|
||||||
const GimpCoords *coords);
|
const GimpCoords *coords);
|
||||||
|
|
||||||
@ -194,6 +204,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (GimpToolPolygon, gimp_tool_polygon,
|
|||||||
|
|
||||||
#define parent_class gimp_tool_polygon_parent_class
|
#define parent_class gimp_tool_polygon_parent_class
|
||||||
|
|
||||||
|
static guint polygon_signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
static const GimpVector2 vector2_zero = { 0.0, 0.0 };
|
static const GimpVector2 vector2_zero = { 0.0, 0.0 };
|
||||||
|
|
||||||
|
|
||||||
@ -219,6 +231,15 @@ gimp_tool_polygon_class_init (GimpToolPolygonClass *klass)
|
|||||||
widget_class->motion_modifier = gimp_tool_polygon_motion_modifier;
|
widget_class->motion_modifier = gimp_tool_polygon_motion_modifier;
|
||||||
widget_class->hover_modifier = gimp_tool_polygon_hover_modifier;
|
widget_class->hover_modifier = gimp_tool_polygon_hover_modifier;
|
||||||
widget_class->get_cursor = gimp_tool_polygon_get_cursor;
|
widget_class->get_cursor = gimp_tool_polygon_get_cursor;
|
||||||
|
|
||||||
|
polygon_signals[CHANGE_COMPLETE] =
|
||||||
|
g_signal_new ("change-complete",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
G_STRUCT_OFFSET (GimpToolPolygonClass, change_complete),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1131,6 +1152,8 @@ gimp_tool_polygon_button_release (GimpToolWidget *widget,
|
|||||||
gimp_tool_polygon_revert_to_saved_state (polygon);
|
gimp_tool_polygon_revert_to_saved_state (polygon);
|
||||||
|
|
||||||
priv->polygon_closed = TRUE;
|
priv->polygon_closed = TRUE;
|
||||||
|
|
||||||
|
gimp_tool_polygon_change_complete (polygon);
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->last_click_time = time;
|
priv->last_click_time = time;
|
||||||
@ -1152,6 +1175,8 @@ gimp_tool_polygon_button_release (GimpToolWidget *widget,
|
|||||||
{
|
{
|
||||||
priv->polygon_closed = TRUE;
|
priv->polygon_closed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gimp_tool_polygon_change_complete (polygon);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_BUTTON_RELEASE_CANCEL:
|
case GIMP_BUTTON_RELEASE_CANCEL:
|
||||||
@ -1302,11 +1327,15 @@ gimp_tool_polygon_key_press (GimpToolWidget *widget,
|
|||||||
GdkEventKey *kevent)
|
GdkEventKey *kevent)
|
||||||
{
|
{
|
||||||
GimpToolPolygon *polygon = GIMP_TOOL_POLYGON (widget);
|
GimpToolPolygon *polygon = GIMP_TOOL_POLYGON (widget);
|
||||||
|
GimpToolPolygonPrivate *priv = polygon->private;
|
||||||
|
|
||||||
switch (kevent->keyval)
|
switch (kevent->keyval)
|
||||||
{
|
{
|
||||||
case GDK_KEY_BackSpace:
|
case GDK_KEY_BackSpace:
|
||||||
gimp_tool_polygon_remove_last_segment (polygon);
|
gimp_tool_polygon_remove_last_segment (polygon);
|
||||||
|
|
||||||
|
if (priv->n_segment_indices > 0)
|
||||||
|
gimp_tool_polygon_change_complete (polygon);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1382,6 +1411,12 @@ gimp_tool_polygon_get_cursor (GimpToolWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_tool_polygon_change_complete (GimpToolPolygon *polygon)
|
||||||
|
{
|
||||||
|
g_signal_emit (polygon, polygon_signals[CHANGE_COMPLETE], 0);
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gimp_tool_polygon_get_segment_index (GimpToolPolygon *polygon,
|
gimp_tool_polygon_get_segment_index (GimpToolPolygon *polygon,
|
||||||
const GimpCoords *coords)
|
const GimpCoords *coords)
|
||||||
|
@ -47,6 +47,9 @@ struct _GimpToolPolygon
|
|||||||
struct _GimpToolPolygonClass
|
struct _GimpToolPolygonClass
|
||||||
{
|
{
|
||||||
GimpToolWidgetClass parent_class;
|
GimpToolWidgetClass parent_class;
|
||||||
|
|
||||||
|
/* signals */
|
||||||
|
void (* change_complete) (GimpToolPolygon *polygon);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user