[gimp] app: in prop gui & co., allow picking outside drawable bounds



commit bc4589968cdee02a7d4c35c59271be52f48c9ccc
Author: Ell <ell_se yahoo com>
Date:   Wed May 3 10:41:12 2017 -0400

    app: in prop gui & co., allow picking outside drawable bounds
    
    Add a boolean 'pick_abyss' parameter to GimpCreatePickerFunc.  When
    this parameter is TRUE, the picker should pick outside the bounds
    of the drawable.  Use FALSE for color pickers, and TRUE for position
    pickers.

 app/tools/gimpcolorizetool.c           |    3 +-
 app/tools/gimpfiltertool.c             |   38 +++++++++++++++++++++++++------
 app/tools/gimpfiltertool.h             |    3 +-
 app/tools/gimplevelstool.c             |    3 +-
 app/widgets/gimppropgui-constructors.c |    3 +-
 app/widgets/gimppropgui.c              |    3 +-
 app/widgets/gimppropgui.h              |    3 +-
 7 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/app/tools/gimpcolorizetool.c b/app/tools/gimpcolorizetool.c
index 6a2817a..ef48c15 100644
--- a/app/tools/gimpcolorizetool.c
+++ b/app/tools/gimpcolorizetool.c
@@ -216,7 +216,8 @@ gimp_colorize_tool_dialog (GimpFilterTool *filter_tool)
   button = gimp_filter_tool_add_color_picker (filter_tool,
                                               "colorize",
                                               GIMP_ICON_COLOR_PICKER_GRAY,
-                                              _("Pick color from image"));
+                                              _("Pick color from image"),
+                                              /* pick_abyss = */ FALSE);
   gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
   gtk_widget_show (button);
 }
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index b200d2d..bad49a0 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -800,18 +800,36 @@ gimp_filter_tool_pick_color (GimpColorTool  *color_tool,
                              GimpRGB        *color)
 {
   GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (color_tool);
+  gboolean        pick_abyss;
   gint            off_x, off_y;
+  gboolean        picked;
+
+  pick_abyss =
+    GPOINTER_TO_INT (g_object_get_data (G_OBJECT (filter_tool->active_picker),
+                     "picker-pick-abyss"));
 
   gimp_item_get_offset (GIMP_ITEM (filter_tool->drawable), &off_x, &off_y);
 
   *sample_format = gimp_drawable_get_format (filter_tool->drawable);
 
-  return gimp_pickable_pick_color (GIMP_PICKABLE (filter_tool->drawable),
-                                   x - off_x,
-                                   y - off_y,
-                                   color_tool->options->sample_average,
-                                   color_tool->options->average_radius,
-                                   pixel, color);
+  picked = gimp_pickable_pick_color (GIMP_PICKABLE (filter_tool->drawable),
+                                     x - off_x,
+                                     y - off_y,
+                                     color_tool->options->sample_average,
+                                     color_tool->options->average_radius,
+                                     pixel, color);
+
+  if (! picked && pick_abyss)
+    {
+      color->r = 0.0;
+      color->g = 0.0;
+      color->b = 0.0;
+      color->a = 0.0;
+
+      picked = TRUE;
+    }
+
+  return picked;
 }
 
 static void
@@ -1555,7 +1573,8 @@ GtkWidget *
 gimp_filter_tool_add_color_picker (GimpFilterTool *filter_tool,
                                    gpointer        identifier,
                                    const gchar    *icon_name,
-                                   const gchar    *tooltip)
+                                   const gchar    *tooltip,
+                                   gboolean        pick_abyss)
 {
   GtkWidget *button;
   GtkWidget *image;
@@ -1575,7 +1594,10 @@ gimp_filter_tool_add_color_picker (GimpFilterTool *filter_tool,
   if (tooltip)
     gimp_help_set_help_data (button, tooltip, NULL);
 
-  g_object_set_data (G_OBJECT (button), "picker-identifier", identifier);
+  g_object_set_data (G_OBJECT (button),
+                     "picker-identifier", identifier);
+  g_object_set_data (G_OBJECT (button),
+                     "picker-pick-abyss", GINT_TO_POINTER (pick_abyss));
 
   g_signal_connect (button, "toggled",
                     G_CALLBACK (gimp_filter_tool_color_picker_toggled),
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index a1b6eb0..cb75ee5 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -127,7 +127,8 @@ GtkWidget * gimp_filter_tool_dialog_get_vbox  (GimpFilterTool   *filter_tool);
 GtkWidget * gimp_filter_tool_add_color_picker (GimpFilterTool   *filter_tool,
                                                gpointer          identifier,
                                                const gchar      *icon_name,
-                                               const gchar      *tooltip);
+                                               const gchar      *tooltip,
+                                               gboolean          pick_abyss);
 
 
 #endif /* __GIMP_FILTER_TOOL_H__ */
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index e1be971..79d2807 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -323,7 +323,8 @@ gimp_levels_tool_color_picker_new (GimpLevelsTool *tool,
   return gimp_filter_tool_add_color_picker (GIMP_FILTER_TOOL (tool),
                                             GUINT_TO_POINTER (value),
                                             icon_name,
-                                            help);
+                                            help,
+                                            /* pick_abyss = */ FALSE);
 }
 
 static void
diff --git a/app/widgets/gimppropgui-constructors.c b/app/widgets/gimppropgui-constructors.c
index 6f786b6..d4e8a7a 100644
--- a/app/widgets/gimppropgui-constructors.c
+++ b/app/widgets/gimppropgui-constructors.c
@@ -168,7 +168,8 @@ _gimp_prop_gui_new_generic (GObject              *config,
               button = create_picker_func (picker_creator,
                                            pspec_name,
                                            GIMP_ICON_CURSOR,
-                                           _("Pick coordinates from the image"));
+                                           _("Pick coordinates from the image"),
+                                           /* pick_abyss = */ TRUE);
               gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
               gtk_widget_show (button);
 
diff --git a/app/widgets/gimppropgui.c b/app/widgets/gimppropgui.c
index e147e16..4ce8168 100644
--- a/app/widgets/gimppropgui.c
+++ b/app/widgets/gimppropgui.c
@@ -343,7 +343,8 @@ gimp_prop_widget_new_from_pspec (GObject               *config,
           button = create_picker_func (picker_creator,
                                        pspec->name,
                                        GIMP_ICON_COLOR_PICKER_GRAY,
-                                       _("Pick color from the image"));
+                                       _("Pick color from the image"),
+                                       /* pick_abyss = */ FALSE);
           gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
           gtk_widget_show (button);
         }
diff --git a/app/widgets/gimppropgui.h b/app/widgets/gimppropgui.h
index 7aebeac..167708c 100644
--- a/app/widgets/gimppropgui.h
+++ b/app/widgets/gimppropgui.h
@@ -27,7 +27,8 @@
 typedef GtkWidget * (* GimpCreatePickerFunc) (gpointer     creator,
                                               const gchar *property_name,
                                               const gchar *icon_name,
-                                              const gchar *tooltip);
+                                              const gchar *tooltip,
+                                              gboolean     pick_abyss);
 
 GtkWidget * gimp_prop_widget_new            (GObject              *config,
                                              const gchar          *property_name,


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