mirror of https://github.com/GNOME/gimp.git
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...
This commit is contained in:
parent
095ae5cc9b
commit
8b38bde642
|
@ -26,6 +26,55 @@
|
|||
#include "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)
|
||||
{
|
||||
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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue