[gimp/wip/gradient-edit: 28/35] app: add support for removing gradient stops to the blend tool



commit 7c7e395e50233023e1cde3c29409984c42b15189
Author: Ell <ell_se yahoo com>
Date:   Tue Aug 1 17:34:31 2017 -0400

    app: add support for removing gradient stops to the blend tool
    
    ... by responding to the line's remove-slider signal.

 app/tools/gimpblendtool-editor.c |   42 +++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimpblendtool-editor.c b/app/tools/gimpblendtool-editor.c
index 7e57f36..9cdb628 100644
--- a/app/tools/gimpblendtool-editor.c
+++ b/app/tools/gimpblendtool-editor.c
@@ -55,6 +55,9 @@ static gboolean              gimp_blend_tool_editor_line_can_add_slider  (GimpTo
 static gint                  gimp_blend_tool_editor_line_add_slider      (GimpToolLine  *line,
                                                                           gdouble        value,
                                                                           GimpBlendTool *blend_tool);
+static void                  gimp_blend_tool_editor_line_remove_slider   (GimpToolLine  *line,
+                                                                          gint           slider,
+                                                                          GimpBlendTool *blend_tool);
 
 static gboolean              gimp_blend_tool_editor_is_gradient_editable (GimpBlendTool  *blend_tool);
 
@@ -123,6 +126,31 @@ gimp_blend_tool_editor_line_add_slider (GimpToolLine  *line,
   return slider;
 }
 
+static void
+gimp_blend_tool_editor_line_remove_slider (GimpToolLine  *line,
+                                           gint           slider,
+                                           GimpBlendTool *blend_tool)
+{
+  GimpGradientSegment *seg;
+
+  g_assert (! blend_tool->modifying);
+
+  blend_tool->modifying = TRUE;
+
+  gimp_blend_tool_editor_freeze_gradient (blend_tool);
+
+  seg = gimp_blend_tool_editor_handle_get_segment (blend_tool, slider);
+
+  gimp_gradient_segment_range_merge (blend_tool->gradient,
+                                     seg, seg->next, NULL, NULL);
+
+  gimp_blend_tool_editor_thaw_gradient (blend_tool);
+
+  blend_tool->modifying = FALSE;
+
+  gimp_blend_tool_editor_update_sliders (blend_tool);
+}
+
 static gboolean
 gimp_blend_tool_editor_is_gradient_editable (GimpBlendTool *blend_tool)
 {
@@ -240,13 +268,14 @@ gimp_blend_tool_editor_update_sliders (GimpBlendTool *blend_tool)
     {
       *slider = GIMP_CONTROLLER_SLIDER_DEFAULT;
 
-      slider->value   = seg->right;
-      slider->min     = seg->left;
-      slider->max     = seg->next->right;
+      slider->value     = seg->right;
+      slider->min       = seg->left;
+      slider->max       = seg->next->right;
 
-      slider->movable = editable;
+      slider->movable   = editable;
+      slider->removable = editable;
 
-      slider->data    = GINT_TO_POINTER (i);
+      slider->data      = GINT_TO_POINTER (i);
 
       slider++;
     }
@@ -362,6 +391,9 @@ gimp_blend_tool_editor_start (GimpBlendTool *blend_tool)
   g_signal_connect (blend_tool->widget, "add-slider",
                     G_CALLBACK (gimp_blend_tool_editor_line_add_slider),
                     blend_tool);
+  g_signal_connect (blend_tool->widget, "remove-slider",
+                    G_CALLBACK (gimp_blend_tool_editor_line_remove_slider),
+                    blend_tool);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]