[gimp] app: add gimp_transform_options_show_preview()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_transform_options_show_preview()
- Date: Sun, 27 Mar 2011 19:50:27 +0000 (UTC)
commit caa8cdd4c1d62f3dcf457fa3c9e94fea23b6dcb1
Author: Michael Natterer <mitch gimp org>
Date: Sun Mar 27 21:49:34 2011 +0200
app: add gimp_transform_options_show_preview()
which returns whether or not to show a transform preview. Also clean
up gimp_transform_tool_draw() a bit and add a stroke group for the
center handle.
app/tools/gimptransformoptions.c | 11 ++++++++
app/tools/gimptransformoptions.h | 6 +++-
app/tools/gimptransformtool.c | 48 ++++++++++++++++++++-----------------
3 files changed, 41 insertions(+), 24 deletions(-)
---
diff --git a/app/tools/gimptransformoptions.c b/app/tools/gimptransformoptions.c
index 6721fec..aec0d3f 100644
--- a/app/tools/gimptransformoptions.c
+++ b/app/tools/gimptransformoptions.c
@@ -386,6 +386,17 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
return vbox;
}
+gboolean
+gimp_transform_options_show_preview (GimpTransformOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_TRANSFORM_OPTIONS (options), FALSE);
+
+ return ((options->preview_type == GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE ||
+ options->preview_type == GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID) &&
+ options->type == GIMP_TRANSFORM_TYPE_LAYER &&
+ options->direction == GIMP_TRANSFORM_FORWARD);
+}
+
/* private functions */
diff --git a/app/tools/gimptransformoptions.h b/app/tools/gimptransformoptions.h
index c12dbf8..b04251e 100644
--- a/app/tools/gimptransformoptions.h
+++ b/app/tools/gimptransformoptions.h
@@ -50,9 +50,11 @@ struct _GimpTransformOptions
};
-GType gimp_transform_options_get_type (void) G_GNUC_CONST;
+GType gimp_transform_options_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options);
+GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options);
+
+gboolean gimp_transform_options_show_preview (GimpTransformOptions *options);
#endif /* __GIMP_TRANSFORM_OPTIONS_H__ */
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 5c8f2f1..ee7c393 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -750,31 +750,28 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (draw_tool);
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
GimpImage *image = gimp_display_get_image (tool->display);
- gdouble z1, z2, z3, z4;
-
- if ((options->preview_type == GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE ||
- options->preview_type == GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID) &&
- options->type == GIMP_TRANSFORM_TYPE_LAYER &&
- options->direction == GIMP_TRANSFORM_FORWARD)
- {
- GimpCanvasItem *item;
-
- item = gimp_canvas_transform_preview_new (gimp_display_get_shell (draw_tool->display),
- tool->drawable,
- &tr_tool->transform,
- tr_tool->x1,
- tr_tool->y1,
- tr_tool->x2,
- tr_tool->y2,
- GIMP_IS_PERSPECTIVE_TOOL (tr_tool),
- options->preview_opacity);
- gimp_draw_tool_add_item (draw_tool, item);
- g_object_unref (item);
- }
if (tr_tool->use_grid)
{
GimpCanvasGroup *stroke_group;
+ gdouble z1, z2, z3, z4;
+
+ if (gimp_transform_options_show_preview (options))
+ {
+ GimpCanvasItem *item;
+
+ item = gimp_canvas_transform_preview_new (gimp_display_get_shell (draw_tool->display),
+ tool->drawable,
+ &tr_tool->transform,
+ tr_tool->x1,
+ tr_tool->y1,
+ tr_tool->x2,
+ tr_tool->y2,
+ GIMP_IS_PERSPECTIVE_TOOL (tr_tool),
+ options->preview_opacity);
+ gimp_draw_tool_add_item (draw_tool, item);
+ g_object_unref (item);
+ }
stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
@@ -906,7 +903,12 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
/* draw the center */
if (tr_tool->use_center)
{
- gint d = MIN (tr_tool->handle_w, tr_tool->handle_h);
+ GimpCanvasGroup *stroke_group;
+ gint d = MIN (tr_tool->handle_w, tr_tool->handle_h);
+
+ stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
+
+ gimp_draw_tool_push_group (draw_tool, stroke_group);
gimp_draw_tool_add_handle (draw_tool,
GIMP_HANDLE_CIRCLE,
@@ -918,6 +920,8 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
tr_tool->tcx, tr_tool->tcy,
d, d,
GIMP_HANDLE_ANCHOR_CENTER);
+
+ gimp_draw_tool_pop_group (draw_tool);
}
if (options->type == GIMP_TRANSFORM_TYPE_SELECTION)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]