[gimp/wip/gradient-edit: 27/35] app: add support for adding gradient stops to the blend tool
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/gradient-edit: 27/35] app: add support for adding gradient stops to the blend tool
- Date: Sun, 6 Aug 2017 05:43:01 +0000 (UTC)
commit 8e1053fbed20b2bc127d2d7260401bfcf968c702
Author: Ell <ell_se yahoo com>
Date: Tue Aug 1 16:58:13 2017 -0400
app: add support for adding gradient stops to the blend tool
... by responding to the line's can-add-slider and add-slider
signals.
app/tools/gimpblendtool-editor.c | 71 ++++++++++++++++++++++++++++++++++++++
app/tools/gimpblendtool-editor.h | 2 +
app/tools/gimpblendtool.c | 2 +
3 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimpblendtool-editor.c b/app/tools/gimpblendtool-editor.c
index 45da5cf..121f8e8 100644
--- a/app/tools/gimpblendtool-editor.c
+++ b/app/tools/gimpblendtool-editor.c
@@ -49,6 +49,13 @@
/* 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 gboolean gimp_blend_tool_editor_is_gradient_editable (GimpBlendTool *blend_tool);
static GimpGradientSegment * gimp_blend_tool_editor_handle_get_segment (GimpBlendTool *blend_tool,
@@ -64,6 +71,59 @@ static void gimp_blend_tool_editor_update_sliders (GimpBl
static gboolean
+gimp_blend_tool_editor_line_can_add_slider (GimpToolLine *line,
+ gdouble value,
+ GimpBlendTool *blend_tool)
+{
+ GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
+ gdouble offset = options->offset / 100.0;
+
+ return gimp_blend_tool_editor_is_gradient_editable (blend_tool) &&
+ value >= offset;
+}
+
+static gint
+gimp_blend_tool_editor_line_add_slider (GimpToolLine *line,
+ gdouble value,
+ GimpBlendTool *blend_tool)
+{
+ GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
+ GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
+ gdouble offset = options->offset / 100.0;
+ GimpGradientSegment *seg;
+ gint slider;
+
+ g_assert (! blend_tool->modifying);
+
+ blend_tool->modifying = TRUE;
+
+ gimp_blend_tool_editor_freeze_gradient (blend_tool);
+
+ /* adjust slider value according to the offset */
+ value = (value - offset) / (1.0 - offset);
+
+ /* flip the slider value, if necessary */
+ if (paint_options->gradient_options->gradient_reverse)
+ value = 1.0 - value;
+
+ gimp_gradient_split_at (blend_tool->gradient,
+ GIMP_CONTEXT (options), NULL, value, &seg, NULL);
+
+ slider =
+ gimp_gradient_segment_range_get_n_segments (blend_tool->gradient,
+ blend_tool->gradient->segments,
+ seg) - 1;
+
+ gimp_blend_tool_editor_thaw_gradient (blend_tool);
+
+ blend_tool->modifying = FALSE;
+
+ gimp_blend_tool_editor_update_sliders (blend_tool);
+
+ return slider;
+}
+
+static gboolean
gimp_blend_tool_editor_is_gradient_editable (GimpBlendTool *blend_tool)
{
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
@@ -293,6 +353,17 @@ gimp_blend_tool_editor_options_notify (GimpBlendTool *blend_tool,
}
void
+gimp_blend_tool_editor_start (GimpBlendTool *blend_tool)
+{
+ g_signal_connect (blend_tool->widget, "can-add-slider",
+ G_CALLBACK (gimp_blend_tool_editor_line_can_add_slider),
+ blend_tool);
+ g_signal_connect (blend_tool->widget, "add-slider",
+ G_CALLBACK (gimp_blend_tool_editor_line_add_slider),
+ blend_tool);
+}
+
+void
gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
{
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
diff --git a/app/tools/gimpblendtool-editor.h b/app/tools/gimpblendtool-editor.h
index 0012ad3..8fdcd5f 100644
--- a/app/tools/gimpblendtool-editor.h
+++ b/app/tools/gimpblendtool-editor.h
@@ -23,6 +23,8 @@ void gimp_blend_tool_editor_options_notify (GimpBlendTool *blend_tool,
GimpToolOptions *options,
const GParamSpec *pspec);
+void gimp_blend_tool_editor_start (GimpBlendTool *blend_tool);
+
void gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool);
void gimp_blend_tool_editor_gradient_dirty (GimpBlendTool *blend_tool);
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 8b91866..ebbc157 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -651,6 +651,8 @@ gimp_blend_tool_start (GimpBlendTool *blend_tool,
gimp_blend_tool_precalc_shapeburst (blend_tool);
gimp_draw_tool_start (GIMP_DRAW_TOOL (blend_tool), display);
+
+ gimp_blend_tool_editor_start (blend_tool);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]