[gimp/wip/gradient-edit: 22/42] app: use get_{left, right}_flat_color() in gradient editor



commit e0b678029885454334550ba15c649e622438a91a
Author: Ell <ell_se yahoo com>
Date:   Tue Aug 1 07:39:23 2017 -0400

    app: use get_{left,right}_flat_color() in gradient editor
    
    Use gimp_gradient_get_{left,right}_flat_color(), instead of
    gimp_gradient_get_color_at(), to get the selection endpoints'
    colors in the gradient editor, so that the correct colors are used
    under any condition (in particular, if there are 0-length
    segments.)

 app/actions/gradient-editor-actions.c  |   30 ++++++++++++++++--------------
 app/actions/gradient-editor-commands.c |   16 ++++++----------
 2 files changed, 22 insertions(+), 24 deletions(-)
---
diff --git a/app/actions/gradient-editor-actions.c b/app/actions/gradient-editor-actions.c
index 30f9f78..371e544 100644
--- a/app/actions/gradient-editor-actions.c
+++ b/app/actions/gradient-editor-actions.c
@@ -491,33 +491,35 @@ gradient_editor_actions_update (GimpActionGroup *group,
       if (data_editor->data_editable)
         editable = TRUE;
 
-      gimp_gradient_get_color_at (gradient, data_editor->context,
-                                  editor->control_sel_l,
-                                  editor->control_sel_l->left, FALSE,
-                                  &left_color);
+      gimp_gradient_segment_get_left_flat_color (gradient,
+                                                 data_editor->context,
+                                                 editor->control_sel_l,
+                                                 &left_color);
 
       if (editor->control_sel_l->prev)
         left_seg = editor->control_sel_l->prev;
       else
         left_seg = gimp_gradient_segment_get_last (editor->control_sel_l);
 
-      gimp_gradient_get_color_at (gradient, data_editor->context,
-                                  left_seg, left_seg->right, FALSE,
-                                  &left_seg_color);
+      gimp_gradient_segment_get_right_flat_color (gradient,
+                                                  data_editor->context,
+                                                  left_seg,
+                                                  &left_seg_color);
 
-      gimp_gradient_get_color_at (gradient, data_editor->context,
-                                  editor->control_sel_r,
-                                  editor->control_sel_r->right, FALSE,
-                                  &right_color);
+      gimp_gradient_segment_get_right_flat_color (gradient,
+                                                  data_editor->context,
+                                                  editor->control_sel_r,
+                                                  &right_color);
 
       if (editor->control_sel_r->next)
         right_seg = editor->control_sel_r->next;
       else
         right_seg = gimp_gradient_segment_get_first (editor->control_sel_r);
 
-      gimp_gradient_get_color_at (gradient, data_editor->context,
-                                  right_seg, right_seg->left, FALSE,
-                                  &right_seg_color);
+      gimp_gradient_segment_get_left_flat_color (gradient,
+                                                 data_editor->context,
+                                                 right_seg,
+                                                 &right_seg_color);
 
       left_editable  = (editor->control_sel_l->left_color_type ==
                         GIMP_GRADIENT_COLOR_FIXED);
diff --git a/app/actions/gradient-editor-commands.c b/app/actions/gradient-editor-commands.c
index 746e47a..1e7e06f 100644
--- a/app/actions/gradient-editor-commands.c
+++ b/app/actions/gradient-editor-commands.c
@@ -127,11 +127,9 @@ gradient_editor_left_color_type_cmd_callback (GtkAction *action,
     {
       GimpRGB color;
 
-      gimp_gradient_get_color_at (gradient,
-                                  GIMP_DATA_EDITOR (editor)->context,
-                                  editor->control_sel_l,
-                                  editor->control_sel_l->left, FALSE,
-                                  &color);
+      gimp_gradient_segment_get_left_flat_color (
+        gradient, GIMP_DATA_EDITOR (editor)->context, editor->control_sel_l,
+        &color);
 
       gimp_data_freeze (GIMP_DATA (gradient));
 
@@ -281,11 +279,9 @@ gradient_editor_right_color_type_cmd_callback (GtkAction *action,
     {
       GimpRGB color;
 
-      gimp_gradient_get_color_at (gradient,
-                                  GIMP_DATA_EDITOR (editor)->context,
-                                  editor->control_sel_r,
-                                  editor->control_sel_r->right, FALSE,
-                                  &color);
+      gimp_gradient_segment_get_right_flat_color (
+        gradient, GIMP_DATA_EDITOR (editor)->context, editor->control_sel_r,
+        &color);
 
       gimp_data_freeze (GIMP_DATA (gradient));
 


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