[gimp] app: remove the "auto_center" params from gimpdrawable-transform.[ch]
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove the "auto_center" params from gimpdrawable-transform.[ch]
- Date: Tue, 7 Sep 2010 21:46:00 +0000 (UTC)
commit 8b38bde6424fc78d9a51ab458014e566ebd6fd80
Author: Michael Natterer <mitch gimp org>
Date: Tue Sep 7 23:43:18 2010 +0200
app: remove the "auto_center" params from gimpdrawable-transform.[ch]
Instead, add utility functions that calculate the centers for rotate
and flip and use them where we used to pass "auto_center". This looks
pretty much poinless, but a commit will follow that makes it look
better...
app/core/gimp-transform-utils.c | 49 +++++++++++++++++++++++++++++++
app/core/gimp-transform-utils.h | 15 +++++++++
app/core/gimpdrawable-transform.c | 41 --------------------------
app/core/gimpdrawable-transform.h | 2 -
app/pdb/drawable-transform-cmds.c | 13 +++++++-
app/pdb/transform-tools-cmds.c | 7 ++++-
tools/pdbgen/pdb/drawable_transform.pdb | 13 +++++++-
tools/pdbgen/pdb/transform_tools.pdb | 7 ++++-
8 files changed, 98 insertions(+), 49 deletions(-)
---
diff --git a/app/core/gimp-transform-utils.c b/app/core/gimp-transform-utils.c
index a72d553..89896f1 100644
--- a/app/core/gimp-transform-utils.c
+++ b/app/core/gimp-transform-utils.c
@@ -27,6 +27,55 @@
void
+gimp_transform_get_rotate_center (gint x,
+ gint y,
+ gint width,
+ gint height,
+ gboolean auto_center,
+ gdouble *center_x,
+ gdouble *center_y)
+{
+ g_return_if_fail (center_x != NULL);
+ g_return_if_fail (center_y != NULL);
+
+ if (auto_center)
+ {
+ *center_x = (gdouble) x + (gdouble) width / 2.0;
+ *center_y = (gdouble) y + (gdouble) height / 2.0;
+ }
+}
+
+void
+gimp_transform_get_flip_axis (gint x,
+ gint y,
+ gint width,
+ gint height,
+ GimpOrientationType flip_type,
+ gboolean auto_center,
+ gdouble *axis)
+{
+ g_return_if_fail (axis != NULL);
+
+ if (auto_center)
+ {
+ switch (flip_type)
+ {
+ case GIMP_ORIENTATION_HORIZONTAL:
+ *axis = ((gdouble) x + (gdouble) width / 2.0);
+ break;
+
+ case GIMP_ORIENTATION_VERTICAL:
+ *axis = ((gdouble) y + (gdouble) height / 2.0);
+ break;
+
+ default:
+ g_return_if_reached ();
+ break;
+ }
+ }
+}
+
+void
gimp_transform_matrix_flip (GimpMatrix3 *matrix,
GimpOrientationType flip_type,
gdouble axis)
diff --git a/app/core/gimp-transform-utils.h b/app/core/gimp-transform-utils.h
index f2fab38..532c525 100644
--- a/app/core/gimp-transform-utils.h
+++ b/app/core/gimp-transform-utils.h
@@ -19,6 +19,21 @@
#define __GIMP_TRANSFORM_UTILS_H__
+void gimp_transform_get_rotate_center (gint x,
+ gint y,
+ gint width,
+ gint height,
+ gboolean auto_center,
+ gdouble *center_x,
+ gdouble *center_y);
+void gimp_transform_get_flip_axis (gint x,
+ gint y,
+ gint width,
+ gint height,
+ GimpOrientationType flip_type,
+ gboolean auto_center,
+ gdouble *axis);
+
void gimp_transform_matrix_flip (GimpMatrix3 *matrix,
GimpOrientationType flip_type,
gdouble axis);
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index 7e152af..2ae8a77 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -623,7 +623,6 @@ gboolean
gimp_drawable_transform_flip (GimpDrawable *drawable,
GimpContext *context,
GimpOrientationType flip_type,
- gboolean auto_center,
gdouble axis,
gboolean clip_result)
{
@@ -650,31 +649,6 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
{
TileManager *new_tiles = NULL;
- if (auto_center)
- {
- gint off_x, off_y;
- gint width, height;
-
- tile_manager_get_offsets (orig_tiles, &off_x, &off_y);
-
- width = tile_manager_width (orig_tiles);
- height = tile_manager_height (orig_tiles);
-
- switch (flip_type)
- {
- case GIMP_ORIENTATION_HORIZONTAL:
- axis = ((gdouble) off_x + (gdouble) width / 2.0);
- break;
-
- case GIMP_ORIENTATION_VERTICAL:
- axis = ((gdouble) off_y + (gdouble) height / 2.0);
- break;
-
- default:
- break;
- }
- }
-
/* always clip unfloated tiles so they keep their size */
if (GIMP_IS_CHANNEL (drawable) && tile_manager_bpp (orig_tiles) == 1)
clip_result = TRUE;
@@ -722,7 +696,6 @@ gboolean
gimp_drawable_transform_rotate (GimpDrawable *drawable,
GimpContext *context,
GimpRotationType rotate_type,
- gboolean auto_center,
gdouble center_x,
gdouble center_y,
gboolean clip_result)
@@ -750,20 +723,6 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
{
TileManager *new_tiles;
- if (auto_center)
- {
- gint off_x, off_y;
- gint width, height;
-
- tile_manager_get_offsets (orig_tiles, &off_x, &off_y);
-
- width = tile_manager_width (orig_tiles);
- height = tile_manager_height (orig_tiles);
-
- center_x = (gdouble) off_x + (gdouble) width / 2.0;
- center_y = (gdouble) off_y + (gdouble) height / 2.0;
- }
-
/* always clip unfloated tiles so they keep their size */
if (GIMP_IS_CHANNEL (drawable) && tile_manager_bpp (orig_tiles) == 1)
clip_result = TRUE;
diff --git a/app/core/gimpdrawable-transform.h b/app/core/gimpdrawable-transform.h
index 2db2b2a..2b99c7f 100644
--- a/app/core/gimpdrawable-transform.h
+++ b/app/core/gimpdrawable-transform.h
@@ -68,14 +68,12 @@ gboolean gimp_drawable_transform_affine (GimpDrawable *draw
gboolean gimp_drawable_transform_flip (GimpDrawable *drawable,
GimpContext *context,
GimpOrientationType flip_type,
- gboolean auto_center,
gdouble axis,
gboolean clip_result);
gboolean gimp_drawable_transform_rotate (GimpDrawable *drawable,
GimpContext *context,
GimpRotationType rotate_type,
- gboolean auto_center,
gdouble center_x,
gdouble center_y,
gboolean clip_result);
diff --git a/app/pdb/drawable-transform-cmds.c b/app/pdb/drawable-transform-cmds.c
index 034e7d2..20b4daa 100644
--- a/app/pdb/drawable-transform-cmds.c
+++ b/app/pdb/drawable-transform-cmds.c
@@ -73,9 +73,12 @@ drawable_transform_flip_simple_invoker (GimpProcedure *procedure,
if (success &&
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
+ gimp_transform_get_flip_axis (x, y, width, height,
+ flip_type, auto_center, &axis);
+
success = gimp_drawable_transform_flip (drawable, context,
flip_type,
- auto_center, axis,
+ axis,
clip_result);
}
}
@@ -446,9 +449,15 @@ drawable_transform_rotate_simple_invoker (GimpProcedure *procedure,
if (success &&
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
+ gdouble cx = center_x;
+ gdouble cy = center_y;
+
+ gimp_transform_get_rotate_center (x, y, width, height,
+ auto_center, &cx, &cy);
+
success = gimp_drawable_transform_rotate (drawable, context,
rotate_type,
- auto_center, center_x, center_y,
+ cx, cy,
clip_result);
}
}
diff --git a/app/pdb/transform-tools-cmds.c b/app/pdb/transform-tools-cmds.c
index 4a02b81..349763c 100644
--- a/app/pdb/transform-tools-cmds.c
+++ b/app/pdb/transform-tools-cmds.c
@@ -67,8 +67,13 @@ flip_invoker (GimpProcedure *procedure,
if (success &&
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
+ gdouble axis;
+
+ gimp_transform_get_flip_axis (x, y, width, height,
+ flip_type, TRUE, &axis);
+
success = gimp_drawable_transform_flip (drawable, context,
- flip_type, TRUE, 0.0, FALSE);
+ flip_type, axis, FALSE);
}
}
diff --git a/tools/pdbgen/pdb/drawable_transform.pdb b/tools/pdbgen/pdb/drawable_transform.pdb
index eb09e24..824d3cf 100644
--- a/tools/pdbgen/pdb/drawable_transform.pdb
+++ b/tools/pdbgen/pdb/drawable_transform.pdb
@@ -170,9 +170,12 @@ HELP
if (success &&
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
+ gimp_transform_get_flip_axis (x, y, width, height,
+ flip_type, auto_center, &axis);
+
success = gimp_drawable_transform_flip (drawable, context,
flip_type,
- auto_center, axis,
+ axis,
clip_result);
}
}
@@ -467,9 +470,15 @@ HELP
if (success &&
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
+ gdouble cx = center_x;
+ gdouble cy = center_y;
+
+ gimp_transform_get_rotate_center (x, y, width, height,
+ auto_center, &cx, &cy);
+
success = gimp_drawable_transform_rotate (drawable, context,
rotate_type,
- auto_center, center_x, center_y,
+ cx, cy,
clip_result);
}
}
diff --git a/tools/pdbgen/pdb/transform_tools.pdb b/tools/pdbgen/pdb/transform_tools.pdb
index ff29fa1..e49b9ae 100644
--- a/tools/pdbgen/pdb/transform_tools.pdb
+++ b/tools/pdbgen/pdb/transform_tools.pdb
@@ -42,8 +42,13 @@ sub flip {
if (success &&
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
+ gdouble axis;
+
+ gimp_transform_get_flip_axis (x, y, width, height,
+ flip_type, TRUE, &axis);
+
success = gimp_drawable_transform_flip (drawable, context,
- flip_type, TRUE, 0.0, FALSE);
+ flip_type, axis, FALSE);
}
}
CODE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]