[gimp/gimp-2-10] app: add "real-time preview" option to the warp tool
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add "real-time preview" option to the warp tool
- Date: Sun, 3 Mar 2019 21:24:38 +0000 (UTC)
commit 9b6604d011e6d64f855c4bf1ee481dce3a02e6eb
Author: Ell <ell_se yahoo com>
Date: Sun Mar 3 16:18:50 2019 -0500
app: add "real-time preview" option to the warp tool
Add a "real-time preview" option to the warp tool, which, when
toggled, causes the preview to be rendered synchronously during
motion. This is slower, but gives better feedback.
(cherry picked from commit a93af839fe10534310a2446cd7d824b64337b4b0)
app/tools/gimpwarpoptions.c | 18 ++++++++++++++++++
app/tools/gimpwarpoptions.h | 1 +
app/tools/gimpwarptool.c | 33 ++++++++++++++++++++++++++++-----
3 files changed, 47 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimpwarpoptions.c b/app/tools/gimpwarpoptions.c
index f534c279c4..2c2d3d961f 100644
--- a/app/tools/gimpwarpoptions.c
+++ b/app/tools/gimpwarpoptions.c
@@ -47,6 +47,7 @@ enum
PROP_INTERPOLATION,
PROP_ABYSS_POLICY,
PROP_HIGH_QUALITY_PREVIEW,
+ PROP_REAL_TIME_PREVIEW,
PROP_STROKE_DURING_MOTION,
PROP_STROKE_PERIODICALLY,
PROP_STROKE_PERIODICALLY_RATE,
@@ -137,6 +138,13 @@ gimp_warp_options_class_init (GimpWarpOptionsClass *klass)
FALSE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_REAL_TIME_PREVIEW,
+ "real-time-preview",
+ _("Real-time preview"),
+ _("Render preview in real time (slower)"),
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_STROKE_DURING_MOTION,
"stroke-during-motion",
_("During motion"),
@@ -205,6 +213,9 @@ gimp_warp_options_set_property (GObject *object,
case PROP_HIGH_QUALITY_PREVIEW:
options->high_quality_preview = g_value_get_boolean (value);
break;
+ case PROP_REAL_TIME_PREVIEW:
+ options->real_time_preview = g_value_get_boolean (value);
+ break;
case PROP_STROKE_DURING_MOTION:
options->stroke_during_motion = g_value_get_boolean (value);
break;
@@ -258,6 +269,9 @@ gimp_warp_options_get_property (GObject *object,
case PROP_HIGH_QUALITY_PREVIEW:
g_value_set_boolean (value, options->high_quality_preview);
break;
+ case PROP_REAL_TIME_PREVIEW:
+ g_value_set_boolean (value, options->real_time_preview);
+ break;
case PROP_STROKE_DURING_MOTION:
g_value_set_boolean (value, options->stroke_during_motion);
break;
@@ -337,6 +351,10 @@ gimp_warp_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
+ button = gimp_prop_check_button_new (config, "real-time-preview", NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
/* the stroke frame */
frame = gimp_frame_new (_("Stroke"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
diff --git a/app/tools/gimpwarpoptions.h b/app/tools/gimpwarpoptions.h
index d7e14fe714..eacfb714b2 100644
--- a/app/tools/gimpwarpoptions.h
+++ b/app/tools/gimpwarpoptions.h
@@ -47,6 +47,7 @@ struct _GimpWarpOptions
GimpInterpolationType interpolation;
GeglAbyssPolicy abyss_policy;
gboolean high_quality_preview;
+ gboolean real_time_preview;
gboolean stroke_during_motion;
gboolean stroke_periodically;
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index 76d414714c..1f786f77fb 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -128,7 +128,8 @@ static GeglRectangle
static void gimp_warp_tool_clear_node_bounds (GeglNode *node);
static void gimp_warp_tool_update_bounds (GimpWarpTool *wt);
static void gimp_warp_tool_update_area (GimpWarpTool *wt,
- const GeglRectangle *area);
+ const GeglRectangle *area,
+ gboolean synchronous);
static void gimp_warp_tool_update_stroke (GimpWarpTool *wt,
GeglNode *node);
static void gimp_warp_tool_stroke_append (GimpWarpTool *wt,
@@ -1091,7 +1092,8 @@ gimp_warp_tool_update_bounds (GimpWarpTool *wt)
static void
gimp_warp_tool_update_area (GimpWarpTool *wt,
- const GeglRectangle *area)
+ const GeglRectangle *area,
+ gboolean synchronous)
{
GeglRectangle rect = *area;
@@ -1105,7 +1107,28 @@ gimp_warp_tool_update_area (GimpWarpTool *wt,
rect = gegl_operation_get_invalidated_by_change (operation, "aux", &rect);
}
- gimp_drawable_filter_apply (wt->filter, &rect);
+ if (synchronous)
+ {
+ GimpTool *tool = GIMP_TOOL (wt);
+ GimpImage *image = gimp_display_get_image (tool->display);
+
+ g_signal_handlers_block_by_func (wt->filter,
+ gimp_warp_tool_filter_flush,
+ wt);
+
+ gimp_drawable_filter_apply (wt->filter, &rect);
+
+ gimp_projection_flush_now (gimp_image_get_projection (image), TRUE);
+ gimp_display_flush_now (tool->display);
+
+ g_signal_handlers_unblock_by_func (wt->filter,
+ gimp_warp_tool_filter_flush,
+ wt);
+ }
+ else
+ {
+ gimp_drawable_filter_apply (wt->filter, &rect);
+ }
}
static void
@@ -1137,7 +1160,7 @@ gimp_warp_tool_update_stroke (GimpWarpTool *wt,
bounds.width, bounds.height);
#endif
- gimp_warp_tool_update_area (wt, &bounds);
+ gimp_warp_tool_update_area (wt, &bounds, FALSE);
}
}
@@ -1175,7 +1198,7 @@ gimp_warp_tool_stroke_append (GimpWarpTool *wt,
gimp_warp_tool_update_bounds (wt);
}
- gimp_warp_tool_update_area (wt, &area);
+ gimp_warp_tool_update_area (wt, &area, options->real_time_preview);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]