[gimp] app: add new enum GimpLayerModeGroup { LINEAR, PERCEPTUAL, LEGACY }



commit 5dbf9cd4f4524fed7e396c6b5d94f8fa7a3848c4
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jan 24 17:10:59 2017 +0100

    app: add new enum GimpLayerModeGroup { LINEAR, PERCEPTUAL, LEGACY }
    
    and a new function gimp_layer_mode_get_group() which will be used for
    the soon-to-appear GimpLayerModeComboBox.

 app/core/core-enums.c       |   31 +++++++++++++++++++++++++++++++
 app/core/core-enums.h       |   12 ++++++++++++
 app/core/gimp-layer-modes.c |   25 +++++++++++++++++--------
 app/core/gimp-layer-modes.h |    2 ++
 4 files changed, 62 insertions(+), 8 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index eea0160..70e147f 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -462,6 +462,37 @@ gimp_layer_mode_get_type (void)
 }
 
 GType
+gimp_layer_mode_group_get_type (void)
+{
+  static const GEnumValue values[] =
+  {
+    { GIMP_LAYER_MODE_GROUP_LINEAR, "GIMP_LAYER_MODE_GROUP_LINEAR", "linear" },
+    { GIMP_LAYER_MODE_GROUP_PERCEPTUAL, "GIMP_LAYER_MODE_GROUP_PERCEPTUAL", "perceptual" },
+    { GIMP_LAYER_MODE_GROUP_LEGACY, "GIMP_LAYER_MODE_GROUP_LEGACY", "legacy" },
+    { 0, NULL, NULL }
+  };
+
+  static const GimpEnumDesc descs[] =
+  {
+    { GIMP_LAYER_MODE_GROUP_LINEAR, NC_("layer-mode-group", "Linear light"), NULL },
+    { GIMP_LAYER_MODE_GROUP_PERCEPTUAL, NC_("layer-mode-group", "Perceptual"), NULL },
+    { GIMP_LAYER_MODE_GROUP_LEGACY, NC_("layer-mode-group", "Legacy"), NULL },
+    { 0, NULL, NULL }
+  };
+
+  static GType type = 0;
+
+  if (G_UNLIKELY (! type))
+    {
+      type = g_enum_register_static ("GimpLayerModeGroup", values);
+      gimp_type_set_translation_context (type, "layer-mode-group");
+      gimp_enum_set_value_descriptions (type, descs);
+    }
+
+  return type;
+}
+
+GType
 gimp_matting_engine_get_type (void)
 {
   static const GEnumValue values[] =
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index ff537dd..db70cf8 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -240,6 +240,18 @@ typedef enum
 } GimpLayerMode;
 
 
+#define GIMP_TYPE_LAYER_MODE_GROUP (gimp_layer_mode_group_get_type ())
+
+GType gimp_layer_mode_group_get_type (void) G_GNUC_CONST;
+
+typedef enum  /*< pdb-skip >*/
+{
+  GIMP_LAYER_MODE_GROUP_LINEAR,      /*< desc="Linear light" >*/
+  GIMP_LAYER_MODE_GROUP_PERCEPTUAL,  /*< desc="Perceptual"   >*/
+  GIMP_LAYER_MODE_GROUP_LEGACY,      /*< desc="Legacy"       >*/
+} GimpLayerModeGroup;
+
+
 #define GIMP_TYPE_MATTING_ENGINE (gimp_matting_engine_get_type ())
 
 GType gimp_matting_engine_get_type (void) G_GNUC_CONST;
diff --git a/app/core/gimp-layer-modes.c b/app/core/gimp-layer-modes.c
index 13b08b3..b893828 100644
--- a/app/core/gimp-layer-modes.c
+++ b/app/core/gimp-layer-modes.c
@@ -98,6 +98,7 @@ gimp_layer_mode_is_linear (GimpLayerMode  mode)
 
     case GIMP_LAYER_MODE_COLOR_ERASE:
       return FALSE;
+
     case GIMP_LAYER_MODE_OVERLAY:
       return TRUE;
 
@@ -159,11 +160,7 @@ gimp_layer_mode_is_linear (GimpLayerMode  mode)
       return TRUE;
 
     case GIMP_LAYER_MODE_ERASE:
-      return TRUE;
-
     case GIMP_LAYER_MODE_REPLACE:
-      return TRUE;
-
     case GIMP_LAYER_MODE_ANTI_ERASE:
       return TRUE;
   }
@@ -171,6 +168,22 @@ gimp_layer_mode_is_linear (GimpLayerMode  mode)
   return TRUE;
 }
 
+GimpLayerModeGroup
+gimp_layer_mode_get_group (GimpLayerMode  mode)
+{
+  if (gimp_layer_mode_is_legacy (mode))
+    {
+      return GIMP_LAYER_MODE_GROUP_LEGACY;
+    }
+  else if (gimp_layer_mode_get_blend_space (mode) ==
+           GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL)
+    {
+      return GIMP_LAYER_MODE_GROUP_PERCEPTUAL;
+    }
+
+  return GIMP_LAYER_MODE_GROUP_LINEAR;
+}
+
 GimpLayerColorSpace
 gimp_layer_mode_get_blend_space (GimpLayerMode  mode)
 {
@@ -270,11 +283,7 @@ gimp_layer_mode_get_blend_space (GimpLayerMode  mode)
       return GIMP_LAYER_COLOR_SPACE_RGB_LINEAR;
 
     case GIMP_LAYER_MODE_ERASE:
-      return GIMP_LAYER_COLOR_SPACE_RGB_LINEAR;
-
     case GIMP_LAYER_MODE_REPLACE:
-      return GIMP_LAYER_COLOR_SPACE_RGB_LINEAR;
-
     case GIMP_LAYER_MODE_ANTI_ERASE:
       return GIMP_LAYER_COLOR_SPACE_RGB_LINEAR;
   }
diff --git a/app/core/gimp-layer-modes.h b/app/core/gimp-layer-modes.h
index 3d9e0d7..978676f 100644
--- a/app/core/gimp-layer-modes.h
+++ b/app/core/gimp-layer-modes.h
@@ -26,6 +26,8 @@
 gboolean                 gimp_layer_mode_is_legacy           (GimpLayerMode  mode);
 gboolean                 gimp_layer_mode_is_linear           (GimpLayerMode  mode);
 
+GimpLayerModeGroup       gimp_layer_mode_get_group           (GimpLayerMode  mode);
+
 GimpLayerColorSpace      gimp_layer_mode_get_blend_space     (GimpLayerMode  mode);
 GimpLayerColorSpace      gimp_layer_mode_get_composite_space (GimpLayerMode  mode);
 GimpLayerCompositeMode   gimp_layer_mode_get_composite_mode  (GimpLayerMode  mode);


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