[gimp] app: add support for removing gradient stops to the blend tool



commit 9ae09fb03a22dcfb8a2e5f6d9e0a3653b1e75c3c
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 |   34 +++++++++++++++++++++++++++++-----
 1 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimpblendtool-editor.c b/app/tools/gimpblendtool-editor.c
index 3d3ec46..c373cb0 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);
 
@@ -119,6 +122,23 @@ 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;
+
+  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);
+}
+
 static gboolean
 gimp_blend_tool_editor_is_gradient_editable (GimpBlendTool *blend_tool)
 {
@@ -258,13 +278,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++;
     }
@@ -383,6 +404,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]