[gimp/wip/gradient-edit: 195/225] app: add "custom" gradient



commit 1c51468257ff9865fee2fdc4ee3df6dcb7a4e84f
Author: Ell <ell_se yahoo com>
Date:   Wed Jul 26 14:45:24 2017 -0400

    app: add "custom" gradient
    
    An internal gradient object, that will be used by the blend tool
    when editing a gradient.  By default, the active gradient will not
    be edited directly, but rather, upon editing, the active gradient's
    contents will be copied to the custom gradient, which will then
    become the active gradient and be edited.  This allows editing both
    writable and nonwritable gradients without modifying them, and
    without having to duplicate them.

 app/core/gimp-gradients.c |   19 +++++++++++++++++++
 app/core/gimp-gradients.h |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimp-gradients.c b/app/core/gimp-gradients.c
index 1d6a874..8961b43 100644
--- a/app/core/gimp-gradients.c
+++ b/app/core/gimp-gradients.c
@@ -35,6 +35,7 @@
 #include "gimp-intl.h"
 
 
+#define CUSTOM_KEY         "gimp-gradient-custom"
 #define FG_BG_RGB_KEY      "gimp-gradient-fg-bg-rgb"
 #define FG_BG_HARDEDGE_KEY "gimp-gradient-fg-bg-rgb-hardedge"
 #define FG_BG_HSV_CCW_KEY  "gimp-gradient-fg-bg-hsv-ccw"
@@ -58,6 +59,16 @@ gimp_gradients_init (Gimp *gimp)
 
   g_return_if_fail (GIMP_IS_GIMP (gimp));
 
+  /* Custom */
+  gradient = gimp_gradients_add_gradient (gimp,
+                                          _("Custom"),
+                                          CUSTOM_KEY);
+  g_object_set (gradient,
+                "writable", TRUE,
+                NULL);
+  gradient->segments->left_color_type  = GIMP_GRADIENT_COLOR_FOREGROUND;
+  gradient->segments->right_color_type = GIMP_GRADIENT_COLOR_BACKGROUND;
+
   /* FG to BG (RGB) */
   gradient = gimp_gradients_add_gradient (gimp,
                                           _("FG to BG (RGB)"),
@@ -108,6 +119,14 @@ gimp_gradients_init (Gimp *gimp)
 }
 
 GimpGradient *
+gimp_gradients_get_custom (Gimp *gimp)
+{
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
+
+  return g_object_get_data (G_OBJECT (gimp), CUSTOM_KEY);
+}
+
+GimpGradient *
 gimp_gradients_get_fg_bg_rgb (Gimp *gimp)
 {
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
diff --git a/app/core/gimp-gradients.h b/app/core/gimp-gradients.h
index 5afda63..f2a5a68 100644
--- a/app/core/gimp-gradients.h
+++ b/app/core/gimp-gradients.h
@@ -24,6 +24,7 @@
 
 void           gimp_gradients_init               (Gimp *gimp);
 
+GimpGradient * gimp_gradients_get_custom         (Gimp *gimp);
 GimpGradient * gimp_gradients_get_fg_bg_rgb      (Gimp *gimp);
 GimpGradient * gimp_gradients_get_fg_bg_hsv_ccw  (Gimp *gimp);
 GimpGradient * gimp_gradients_get_fg_bg_hsv_cw   (Gimp *gimp);


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