[gimp/wip/gradient-edit: 29/42] 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: 29/42] app: add support for adding gradient stops to the blend tool
- Date: Fri, 6 Oct 2017 22:29:28 +0000 (UTC)
commit d1f9a6a40bb96fbda62b58f71039f2f5cfbf7ee8
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 | 63 ++++++++++++++++++++++++++++++++++++++
app/tools/gimpblendtool-editor.h | 2 +
app/tools/gimpblendtool.c | 2 +
3 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimpblendtool-editor.c b/app/tools/gimpblendtool-editor.c
index effa1b8..bab0ca8 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,
@@ -68,6 +75,51 @@ 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;
+
+ 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);
+
+ return slider;
+}
+
+static gboolean
gimp_blend_tool_editor_is_gradient_editable (GimpBlendTool *blend_tool)
{
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
@@ -323,6 +375,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 7fd8eb8..a00d920 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -653,6 +653,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]