[gimp/wip/gradient-edit: 32/39] app: add tool gui to the blend tool
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/gradient-edit: 32/39] app: add tool gui to the blend tool
- Date: Mon, 14 Aug 2017 19:41:00 +0000 (UTC)
commit d2f2a29131cb2205400adead60a55985a8e647d8
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 | 169 +++++++++++++++++++++++++++++--------
app/tools/gimpblendtool-editor.h | 1 +
app/tools/gimpblendtool.c | 2 +
app/tools/gimpblendtool.h | 2 +
5 files changed, 138 insertions(+), 37 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 bb3af08..2487477 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"
@@ -49,43 +50,51 @@
/* local function prototypes */
-static gboolean gimp_blend_tool_editor_line_can_add_slider (GimpToolLine *line,
- gdouble value,
- GimpBlendTool *blend_tool);
-static gint gimp_blend_tool_editor_line_add_slider (GimpToolLine *line,
- gdouble value,
- GimpBlendTool *blend_tool);
-static void gimp_blend_tool_editor_line_remove_slider (GimpToolLine *line,
- gint slider,
- 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 gboolean gimp_blend_tool_editor_is_gradient_editable (GimpBlendTool *blend_tool);
-
-static gboolean gimp_blend_tool_editor_handle_is_endpoint (GimpBlendTool *blend_tool,
- gint handle);
-static gboolean gimp_blend_tool_editor_handle_is_stop (GimpBlendTool *blend_tool,
- gint handle);
-static gboolean gimp_blend_tool_editor_handle_is_midpoint (GimpBlendTool *blend_tool,
- gint handle);
-static GimpGradientSegment * gimp_blend_tool_editor_handle_get_segment (GimpBlendTool *blend_tool,
- gint handle);
-
-static void gimp_blend_tool_editor_block_handlers (GimpBlendTool *blend_tool);
-static void gimp_blend_tool_editor_unblock_handlers (GimpBlendTool *blend_tool);
-static gboolean gimp_blend_tool_editor_are_handlers_blocked (GimpBlendTool *blend_tool);
-
-static void gimp_blend_tool_editor_freeze_gradient (GimpBlendTool *blend_tool);
-static void gimp_blend_tool_editor_thaw_gradient (GimpBlendTool *blend_tool);
-
-static gint gimp_blend_tool_editor_add_stop (GimpBlendTool *blend_tool,
- gdouble value);
-
-static void gimp_blend_tool_editor_update_sliders (GimpBlendTool *blend_tool);
+static gboolean gimp_blend_tool_editor_line_can_add_slider (GimpToolLine *line,
+ gdouble value,
+ GimpBlendTool *blend_tool);
+static gint gimp_blend_tool_editor_line_add_slider (GimpToolLine *line,
+ gdouble value,
+ GimpBlendTool *blend_tool);
+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,
+ gint handle);
+static gboolean gimp_blend_tool_editor_handle_is_stop (GimpBlendTool *blend_tool,
+ gint handle);
+static gboolean gimp_blend_tool_editor_handle_is_midpoint (GimpBlendTool *blend_tool,
+ gint handle);
+static GimpGradientSegment * gimp_blend_tool_editor_handle_get_segment (GimpBlendTool *blend_tool,
+ gint handle);
+
+static void gimp_blend_tool_editor_block_handlers (GimpBlendTool *blend_tool);
+static void gimp_blend_tool_editor_unblock_handlers (GimpBlendTool *blend_tool);
+static gboolean gimp_blend_tool_editor_are_handlers_blocked (GimpBlendTool *blend_tool);
+
+static void gimp_blend_tool_editor_freeze_gradient (GimpBlendTool *blend_tool);
+static void gimp_blend_tool_editor_thaw_gradient (GimpBlendTool *blend_tool);
+
+static gint gimp_blend_tool_editor_add_stop (GimpBlendTool *blend_tool,
+ gdouble value);
+
+static void gimp_blend_tool_editor_update_sliders (GimpBlendTool *blend_tool);
+
+static void gimp_blend_tool_editor_update_gui (GimpBlendTool *blend_tool);
/* private functions */
@@ -139,6 +148,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,
@@ -173,6 +189,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)
{
@@ -301,6 +332,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);
}
@@ -436,6 +468,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 */
@@ -448,6 +531,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"))
{
@@ -494,12 +578,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);
@@ -596,6 +689,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 b74d34f..3d83241 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 1a0bc87..a855bef 100644
--- a/app/tools/gimpblendtool.h
+++ b/app/tools/gimpblendtool.h
@@ -65,6 +65,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]