[gimp/wip/gradient-edit: 45/52] app: add tool gui to the blend tool



commit eee707fb53098d6233909e19c5342e0a30d13187
Author: Ell <ell_se yahoo com>
Date:   Wed Aug 2 16:31:10 2017 -0400

    app: add tool gui to the blend tool
    
    To be used by the blend tool gradient editor to edit the gradient
    endpoint/stop/midpoint properties corresponding to the selected
    handle.
    
    The GUI is currently empty; the following commits add its contents.

 app/dialogs/dialogs.c            |    1 +
 app/tools/gimpblendtool-editor.c |   95 ++++++++++++++++++++++++++++++++++++++
 app/tools/gimpblendtool-editor.h |    1 +
 app/tools/gimpblendtool.c        |    2 +
 app/tools/gimpblendtool.h        |    2 +
 5 files changed, 101 insertions(+), 0 deletions(-)
---
diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c
index f9e6a97..8a4ed32 100644
--- a/app/dialogs/dialogs.c
+++ b/app/dialogs/dialogs.c
@@ -223,6 +223,7 @@ static GtkWidget * dialogs_restore_window (GimpDialogFactory *factory,
 static const GimpDialogFactoryEntry entries[] =
 {
   /*  foreign toplevels without constructor  */
+  FOREIGN ("gimp-blend-tool-dialog",               TRUE,  FALSE),
   FOREIGN ("gimp-brightness-contrast-tool-dialog", TRUE,  FALSE),
   FOREIGN ("gimp-color-balance-tool-dialog",       TRUE,  FALSE),
   FOREIGN ("gimp-color-picker-tool-dialog",        TRUE,  TRUE),
diff --git a/app/tools/gimpblendtool-editor.c b/app/tools/gimpblendtool-editor.c
index de47ba1..b97b4ab 100644
--- a/app/tools/gimpblendtool-editor.c
+++ b/app/tools/gimpblendtool-editor.c
@@ -35,6 +35,7 @@
 #include "widgets/gimpwidgets-utils.h"
 
 #include "display/gimpdisplay.h"
+#include "display/gimptoolgui.h"
 #include "display/gimptoolline.h"
 
 #include "gimpblendoptions.h"
@@ -62,12 +63,18 @@ static void                  gimp_blend_tool_editor_line_prepare_to_remove_slide
 static void                  gimp_blend_tool_editor_line_remove_slider            (GimpToolLine        *line,
                                                                                    gint                 
slider,
                                                                                    GimpBlendTool       
*blend_tool);
+static void                  gimp_blend_tool_editor_line_selection_changed        (GimpToolLine        *line,
+                                                                                   GimpBlendTool       
*blend_tool);
 static gboolean              gimp_blend_tool_editor_line_handle_clicked           (GimpToolLine        *line,
                                                                                    gint                 
handle,
                                                                                    GdkModifierType      
state,
                                                                                    GimpButtonPressType  
press_type,
                                                                                    GimpBlendTool       
*blend_tool);
 
+static void                  gimp_blend_tool_editor_gui_response                  (GimpToolGui         *gui,
+                                                                                   gint                 
response_id,
+                                                                                   GimpBlendTool       
*blend_tool);
+
 static gboolean              gimp_blend_tool_editor_is_gradient_editable          (GimpBlendTool       
*blend_tool);
 
 static gboolean              gimp_blend_tool_editor_handle_is_endpoint            (GimpBlendTool       
*blend_tool,
@@ -91,6 +98,8 @@ static gint                  gimp_blend_tool_editor_add_stop
 
 static void                  gimp_blend_tool_editor_update_sliders                (GimpBlendTool       
*blend_tool);
 
+static void                  gimp_blend_tool_editor_update_gui                    (GimpBlendTool       
*blend_tool);
+
 
 /*  private functions  */
 
@@ -177,6 +186,13 @@ gimp_blend_tool_editor_line_remove_slider (GimpToolLine  *line,
   gimp_blend_tool_editor_thaw_gradient (blend_tool);
 }
 
+static void
+gimp_blend_tool_editor_line_selection_changed (GimpToolLine  *line,
+                                               GimpBlendTool *blend_tool)
+{
+  gimp_blend_tool_editor_update_gui (blend_tool);
+}
+
 static gboolean
 gimp_blend_tool_editor_line_handle_clicked (GimpToolLine        *line,
                                             gint                 handle,
@@ -211,6 +227,21 @@ gimp_blend_tool_editor_line_handle_clicked (GimpToolLine        *line,
   return FALSE;
 }
 
+
+static void
+gimp_blend_tool_editor_gui_response (GimpToolGui   *gui,
+                                     gint           response_id,
+                                     GimpBlendTool *blend_tool)
+{
+  switch (response_id)
+    {
+    default:
+      gimp_tool_line_set_selection (GIMP_TOOL_LINE (blend_tool->widget),
+                                    GIMP_TOOL_LINE_HANDLE_NONE);
+      break;
+    }
+}
+
 static gboolean
 gimp_blend_tool_editor_is_gradient_editable (GimpBlendTool *blend_tool)
 {
@@ -339,6 +370,7 @@ gimp_blend_tool_editor_thaw_gradient(GimpBlendTool *blend_tool)
   gimp_data_thaw (GIMP_DATA (blend_tool->gradient));
 
   gimp_blend_tool_editor_update_sliders (blend_tool);
+  gimp_blend_tool_editor_update_gui (blend_tool);
 
   gimp_blend_tool_editor_unblock_handlers (blend_tool);
 }
@@ -474,6 +506,57 @@ gimp_blend_tool_editor_update_sliders (GimpBlendTool *blend_tool)
   g_free (sliders);
 }
 
+static void
+gimp_blend_tool_editor_update_gui (GimpBlendTool *blend_tool)
+{
+  GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
+
+  if (blend_tool->gradient && blend_tool->widget && ! options->instant)
+    {
+      gint selection;
+
+      selection =
+        gimp_tool_line_get_selection (GIMP_TOOL_LINE (blend_tool->widget));
+
+      if (selection != GIMP_TOOL_LINE_HANDLE_NONE)
+        {
+          if (! blend_tool->gui)
+            {
+              GimpDisplayShell *shell;
+
+              shell = gimp_tool_widget_get_shell (blend_tool->widget);
+
+              blend_tool->gui =
+                gimp_tool_gui_new (GIMP_TOOL (blend_tool)->tool_info,
+                                   NULL, NULL, NULL, NULL,
+                                   gtk_widget_get_screen (GTK_WIDGET (shell)),
+                                   gimp_widget_get_monitor (GTK_WIDGET (shell)),
+                                   TRUE,
+
+                                   _("_Close"), GTK_RESPONSE_CLOSE,
+
+                                   NULL);
+
+              gimp_tool_gui_set_shell (blend_tool->gui, shell);
+              gimp_tool_gui_set_viewable (blend_tool->gui,
+                                          GIMP_VIEWABLE (blend_tool->gradient));
+              gimp_tool_gui_set_auto_overlay (blend_tool->gui, TRUE);
+
+              g_signal_connect (blend_tool->gui, "response",
+                                G_CALLBACK (gimp_blend_tool_editor_gui_response),
+                                blend_tool);
+            }
+
+          gimp_tool_gui_show (blend_tool->gui);
+
+          return;
+        }
+    }
+
+  if (blend_tool->gui)
+    gimp_tool_gui_hide (blend_tool->gui);
+}
+
 
 /*  public functions  */
 
@@ -486,6 +569,7 @@ gimp_blend_tool_editor_options_notify (GimpBlendTool    *blend_tool,
   if (! strcmp (pspec->name, "modify-active"))
     {
       gimp_blend_tool_editor_update_sliders (blend_tool);
+      gimp_blend_tool_editor_update_gui (blend_tool);
     }
   else if (! strcmp (pspec->name, "gradient-reverse"))
     {
@@ -535,12 +619,21 @@ gimp_blend_tool_editor_start (GimpBlendTool *blend_tool)
   g_signal_connect (blend_tool->widget, "remove-slider",
                     G_CALLBACK (gimp_blend_tool_editor_line_remove_slider),
                     blend_tool);
+  g_signal_connect (blend_tool->widget, "selection-changed",
+                    G_CALLBACK (gimp_blend_tool_editor_line_selection_changed),
+                    blend_tool);
   g_signal_connect (blend_tool->widget, "handle-clicked",
                     G_CALLBACK (gimp_blend_tool_editor_line_handle_clicked),
                     blend_tool);
 }
 
 void
+gimp_blend_tool_editor_halt (GimpBlendTool *blend_tool)
+{
+  g_clear_object (&blend_tool->gui);
+}
+
+void
 gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
 {
   GimpBlendOptions           *options       = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
@@ -637,6 +730,8 @@ gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
 
   if (changed)
     gimp_blend_tool_editor_thaw_gradient (blend_tool);
+
+  gimp_blend_tool_editor_update_gui (blend_tool);
 }
 
 void
diff --git a/app/tools/gimpblendtool-editor.h b/app/tools/gimpblendtool-editor.h
index 8fdcd5f..fc7bcf2 100644
--- a/app/tools/gimpblendtool-editor.h
+++ b/app/tools/gimpblendtool-editor.h
@@ -24,6 +24,7 @@ void   gimp_blend_tool_editor_options_notify   (GimpBlendTool    *blend_tool,
                                                 const GParamSpec *pspec);
 
 void   gimp_blend_tool_editor_start            (GimpBlendTool    *blend_tool);
+void   gimp_blend_tool_editor_halt             (GimpBlendTool    *blend_tool);
 
 void   gimp_blend_tool_editor_line_changed     (GimpBlendTool    *blend_tool);
 
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index d71573f..3b9e557 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -665,6 +665,8 @@ gimp_blend_tool_halt (GimpBlendTool *blend_tool)
   GimpTool         *tool    = GIMP_TOOL (blend_tool);
   GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
 
+  gimp_blend_tool_editor_halt (blend_tool);
+
   if (blend_tool->graph)
     {
       g_clear_object (&blend_tool->graph);
diff --git a/app/tools/gimpblendtool.h b/app/tools/gimpblendtool.h
index 3a743d2..8221469 100644
--- a/app/tools/gimpblendtool.h
+++ b/app/tools/gimpblendtool.h
@@ -66,6 +66,8 @@ struct _GimpBlendTool
   /*  editor  */
 
   gint                block_handlers_count;
+
+  GimpToolGui        *gui;
 };
 
 struct _GimpBlendToolClass


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