[gimp] app: add prepare-to-remove-slider signal to GimpToolLine
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add prepare-to-remove-slider signal to GimpToolLine
- Date: Mon, 9 Oct 2017 16:51:52 +0000 (UTC)
commit 50acb6690d9c3927749578b699de88758cc9b001
Author: Ell <ell_se yahoo com>
Date: Fri Oct 6 12:04:01 2017 -0400
app: add prepare-to-remove-slider signal to GimpToolLine
The signal is emitted when a slider is dragged away from the line,
and will be removed when the button is released, and when the
slider is dragged back to the vicinity of the line, and won't be
removed. The last parameter of the signal is a boolean flag
differentiating between the two cases.
Note that a remove-slider signal may be emitted without a preceeding
prepare-to-remove-slider signal, however, is a prepare-to-remove-
slider signal is emitted with a TRUE last parameter, it must be
eventually followed by a remove-slider signal, or by another
prepare-to-remove-slider signal with a FALSE last parameter.
app/core/gimpmarshal.list | 1 +
app/display/gimptoolline.c | 62 ++++++++++++++++++++++++++++++++++----------
app/display/gimptoolline.h | 17 +++++++-----
3 files changed, 59 insertions(+), 21 deletions(-)
---
diff --git a/app/core/gimpmarshal.list b/app/core/gimpmarshal.list
index add1892..f44c1c7 100644
--- a/app/core/gimpmarshal.list
+++ b/app/core/gimpmarshal.list
@@ -47,6 +47,7 @@ VOID: ENUM, OBJECT
VOID: ENUM, POINTER
VOID: FLAGS
VOID: INT
+VOID: INT, BOOLEAN
VOID: INT, INT
VOID: INT, INT, INT, INT
VOID: INT, INT, BOOLEAN, BOOLEAN
diff --git a/app/display/gimptoolline.c b/app/display/gimptoolline.c
index dfa3fba..4c6664e 100644
--- a/app/display/gimptoolline.c
+++ b/app/display/gimptoolline.c
@@ -85,6 +85,7 @@ enum
{
CAN_ADD_SLIDER,
ADD_SLIDER,
+ PREPARE_TO_REMOVE_SLIDER,
REMOVE_SLIDER,
SELECTION_CHANGED,
LAST_SIGNAL
@@ -242,6 +243,17 @@ gimp_tool_line_class_init (GimpToolLineClass *klass)
G_TYPE_INT, 1,
G_TYPE_DOUBLE);
+ line_signals[PREPARE_TO_REMOVE_SLIDER] =
+ g_signal_new ("prepare-to-remove-slider",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GimpToolLineClass, prepare_to_remove_slider),
+ NULL, NULL,
+ gimp_marshal_VOID__INT_BOOLEAN,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ G_TYPE_BOOLEAN);
+
line_signals[REMOVE_SLIDER] =
g_signal_new ("remove-slider",
G_TYPE_FROM_CLASS (klass),
@@ -670,6 +682,14 @@ gimp_tool_line_button_release (GimpToolWidget *widget,
{
gimp_tool_line_get_slider (line, private->selection)->value =
private->saved_slider_value;
+
+ if (private->remove_slider)
+ {
+ private->remove_slider = FALSE;
+
+ g_signal_emit (line, line_signals[PREPARE_TO_REMOVE_SLIDER], 0,
+ private->selection, FALSE);
+ }
}
g_object_set (line,
@@ -682,6 +702,8 @@ gimp_tool_line_button_release (GimpToolWidget *widget,
}
else if (grab == GRAB_SELECTION && private->remove_slider)
{
+ private->remove_slider = FALSE;
+
g_signal_emit (line, line_signals[REMOVE_SLIDER], 0,
private->selection);
}
@@ -1124,6 +1146,7 @@ gimp_tool_line_selection_motion (GimpToolLine *line,
GimpControllerSlider *slider;
gdouble value;
gdouble dist;
+ gboolean remove_slider;
shell = gimp_tool_widget_get_shell (GIMP_TOOL_WIDGET (line));
@@ -1144,25 +1167,36 @@ gimp_tool_line_selection_motion (GimpToolLine *line,
NULL);
/* slider tearing */
- private->remove_slider = dist > SLIDER_TEAR_DISTANCE;
+ remove_slider = dist > SLIDER_TEAR_DISTANCE;
- /* eek! */
- {
- GimpCursorType cursor;
- GimpToolCursorType tool_cursor;
- GimpCursorModifier modifier;
+ if (remove_slider != private->remove_slider)
+ {
+ private->remove_slider = remove_slider;
- cursor = shell->current_cursor;
- tool_cursor = shell->tool_cursor;
- modifier = GIMP_CURSOR_MODIFIER_NONE;
+ g_signal_emit (line, line_signals[PREPARE_TO_REMOVE_SLIDER], 0,
+ private->selection, remove_slider);
- gimp_tool_line_get_cursor (GIMP_TOOL_WIDGET (line), NULL, 0,
- &cursor, &tool_cursor, &modifier);
+ /* set the cursor modifier to a minus by talking to the shell
+ * directly -- eek!
+ */
+ {
+ GimpCursorType cursor;
+ GimpToolCursorType tool_cursor;
+ GimpCursorModifier modifier;
- gimp_display_shell_set_cursor (shell, cursor, tool_cursor, modifier);
- }
+ cursor = shell->current_cursor;
+ tool_cursor = shell->tool_cursor;
+ modifier = GIMP_CURSOR_MODIFIER_NONE;
- gimp_tool_line_update_handles (line);
+ gimp_tool_line_get_cursor (GIMP_TOOL_WIDGET (line), NULL, 0,
+ &cursor, &tool_cursor, &modifier);
+
+ gimp_display_shell_set_cursor (shell, cursor, tool_cursor, modifier);
+ }
+
+ gimp_tool_line_update_handles (line);
+ gimp_tool_line_update_circle (line);
+ }
return TRUE;
}
diff --git a/app/display/gimptoolline.h b/app/display/gimptoolline.h
index d9a557c..8642a35 100644
--- a/app/display/gimptoolline.h
+++ b/app/display/gimptoolline.h
@@ -60,13 +60,16 @@ struct _GimpToolLineClass
GimpToolWidgetClass parent_class;
/* signals */
- gboolean (* can_add_slider) (GimpToolLine *line,
- gdouble value);
- gint (* add_slider) (GimpToolLine *line,
- gdouble value);
- void (* remove_slider) (GimpToolLine *line,
- gint slider);
- void (* selection_changed) (GimpToolLine *line);
+ gboolean (* can_add_slider) (GimpToolLine *line,
+ gdouble value);
+ gint (* add_slider) (GimpToolLine *line,
+ gdouble value);
+ void (* prepare_to_remove_slider) (GimpToolLine *line,
+ gint slider,
+ gboolean remove);
+ void (* remove_slider) (GimpToolLine *line,
+ gint slider);
+ void (* selection_changed) (GimpToolLine *line);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]