Merge branch 'master' into soc-2010-cage-2

This commit is contained in:
Alexia Death 2010-09-26 23:08:15 +03:00
commit 74e5864fa6
536 changed files with 19322 additions and 15658 deletions

View File

@ -45,7 +45,7 @@ header files installed.
4. You need to have installed GTK+ version 2.20.0 or newer.
GIMP also need a recent versions of GLib (>= 2.24.0) and
Pango (>= 1.20.1). Sources for these can be grabbed from
Pango (>= 1.22.0). Sources for these can be grabbed from
ftp://ftp.gtk.org/.
5. We use cairo, which is hosted at http://www.cairographics.org/.

View File

@ -275,7 +275,7 @@ dist-hook: dist-check-gimp-console dist-dump-gimprc
# in which case the git-version.h we ship is correct.
git-version.h: update-git-version-header
@if test -d "$(top_srcdir)/.git"; then \
echo "#define GIMP_GIT_VERSION \"`git log -n1 --reverse --pretty=%H`\"" > "$@.tmp"; \
echo "#define GIMP_GIT_VERSION \"`git describe`\"" > "$@.tmp"; \
elif test ! -f "$@"; then \
echo "#define GIMP_GIT_VERSION \"Unknown, shouldn't happen\"" > "$@.tmp"; \
fi

View File

@ -363,18 +363,16 @@ boundary_simplify (BoundSeg *sorted_segs,
/*Transform boundary based on a matrix*/
BoundSeg * boundary_transform (const BoundSeg *segs,
BoundSeg *
boundary_transform (const BoundSeg *segs,
gint *num_segs,
GimpMatrix3 *matrix)
{
Boundary *boundary = boundary_new (NULL);
gint i;
for (i = 0; i < *num_segs; i++)
{
/* dont transform sorting sentinels */
if (!(segs[i].x1 == -1 &&
segs[i].y1 == -1 &&
@ -400,10 +398,36 @@ BoundSeg * boundary_transform (const BoundSeg *segs,
segs[i].open);
}
}
*num_segs = boundary->num_segs;
return boundary_free (boundary, FALSE);
}
void
boundary_offset (BoundSeg *segs,
gint num_segs,
gint off_x,
gint off_y)
{
gint i;
for (i = 0; i < num_segs; i++)
{
/* dont offset sorting sentinels */
if (!(segs[i].x1 == -1 &&
segs[i].y1 == -1 &&
segs[i].x2 == -1 &&
segs[i].y2 == -1))
{
segs[i].x1 += off_x;
segs[i].y1 += off_y;
segs[i].x2 += off_x;
segs[i].y2 += off_y;
}
}
}
/* private functions */

View File

@ -60,5 +60,11 @@ BoundSeg * boundary_transform (const BoundSeg *segs,
gint *num_segs,
GimpMatrix3 *matrix);
/* offsets in-place */
void boundary_offset (BoundSeg *segs,
gint num_segs,
gint off_x,
gint off_y);
#endif /* __BOUNDARY_H__ */

View File

@ -204,7 +204,8 @@ gimp_edit_paste (GimpImage *image,
gboolean have_mask;
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
have_mask = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
have_mask = gimp_item_mask_bounds (GIMP_ITEM (drawable),
&x1, &y1, &x2, &y2);
if (! have_mask &&
viewport_width > 0 &&
@ -537,7 +538,7 @@ gimp_edit_fill_internal (GimpImage *image,
TempBuf *pat_buf = NULL;
gboolean new_buf;
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
return TRUE; /* nothing to do, but the fill succeded */
drawable_type = gimp_drawable_type (drawable);

View File

@ -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,

View File

@ -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);

View File

@ -214,7 +214,7 @@ gimp_drawable_blend (GimpDrawable *drawable,
image = gimp_item_get_image (GIMP_ITEM (drawable));
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
return;
gimp_set_busy (image->gimp);
@ -587,14 +587,14 @@ gradient_precalc_shapeburst (GimpImage *image,
if (! gimp_channel_is_empty (mask))
{
PixelRegion maskR;
gint x1, y1, x2, y2;
gint offx, offy;
gint x, y, width, height;
gint off_x, off_y;
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
gimp_item_get_offset (GIMP_ITEM (drawable), &offx, &offy);
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height);
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
pixel_region_init (&maskR, gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
x1 + offx, y1 + offy, (x2 - x1), (y2 - y1), FALSE);
x + off_x, y + off_y, width, height, FALSE);
/* copy the mask to the temp mask */
copy_region (&maskR, &tempR);

View File

@ -146,7 +146,7 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
image = gimp_item_get_image (GIMP_ITEM (drawable));
bytes = gimp_drawable_bytes (drawable);
selection = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
selection = gimp_item_mask_bounds (GIMP_ITEM (drawable), &x1, &y1, &x2, &y2);
if ((x1 == x2) || (y1 == y2))
return;

View File

@ -26,7 +26,7 @@
#include "base/gimphistogram.h"
#include "base/pixel-region.h"
#include "gimpdrawable.h"
#include "gimpchannel.h"
#include "gimpdrawable-histogram.h"
#include "gimpimage.h"
@ -35,24 +35,24 @@ void
gimp_drawable_calculate_histogram (GimpDrawable *drawable,
GimpHistogram *histogram)
{
GimpImage *image;
PixelRegion region;
PixelRegion mask;
gint x1, y1, x2, y2;
gboolean have_mask;
gint x, y, width, height;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (histogram != NULL);
have_mask = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if ((x1 == x2) || (y1 == y2))
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
return;
pixel_region_init (&region, gimp_drawable_get_tiles (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
x, y, width, height, FALSE);
if (have_mask)
image = gimp_item_get_image (GIMP_ITEM (drawable));
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
GimpChannel *sel_mask;
GimpImage *image;
@ -64,7 +64,7 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
pixel_region_init (&mask,
gimp_drawable_get_tiles (GIMP_DRAWABLE (sel_mask)),
x1 + off_x, y1 + off_y, (x2 - x1), (y2 - y1), FALSE);
x + off_x, y + off_y, width, height, FALSE);
gimp_histogram_calculate (histogram, &region, &mask);
}
else

View File

@ -112,7 +112,7 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable,
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
if (! gimp_drawable_mask_intersect (drawable, NULL, NULL, NULL, NULL))
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), NULL, NULL, NULL, NULL))
return;
config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);

View File

@ -62,7 +62,7 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
g_return_if_fail (undo_desc != NULL);
g_return_if_fail (GEGL_IS_NODE (operation));
if (! gimp_drawable_mask_intersect (drawable,
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable),
&rect.x, &rect.y,
&rect.width, &rect.height))
return;

View File

@ -45,7 +45,7 @@ gimp_drawable_process (GimpDrawable *drawable,
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
g_return_if_fail (undo_desc != NULL);
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
if (gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
PixelRegion srcPR, destPR;

View File

@ -87,7 +87,7 @@ gimp_drawable_merge_shadow_tiles (GimpDrawable *drawable,
* extents of the selection mask, as it cannot extend beyond
* them.
*/
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
if (gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
TileManager *tiles = tile_manager_ref (drawable->private->shadow);
PixelRegion shadowPR;

View File

@ -329,7 +329,7 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
PixelRegion basePR;
/* must call gimp_channel_is_empty() instead of relying on
* gimp_drawable_mask_intersect() because the selection pretends to
* gimp_item_mask_intersect() because the selection pretends to
* be empty while it is being stroked, to prevent masking itself.
*/
if (gimp_channel_is_empty (gimp_image_get_mask (image)))
@ -339,7 +339,7 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
w = gimp_item_get_width (GIMP_ITEM (drawable));
h = gimp_item_get_height (GIMP_ITEM (drawable));
}
else if (! gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h))
else if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &w, &h))
{
return;
}

View File

@ -538,7 +538,7 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
return new_tiles;
}
gboolean
GimpDrawable *
gimp_drawable_transform_affine (GimpDrawable *drawable,
GimpContext *context,
const GimpMatrix3 *matrix,
@ -551,19 +551,20 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
GimpImage *image;
TileManager *orig_tiles;
gboolean new_layer;
gboolean success = FALSE;
GimpDrawable *result = NULL;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (matrix != NULL, FALSE);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (matrix != NULL, NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
image = gimp_item_get_image (GIMP_ITEM (drawable));
/* Start a transform undo group */
gimp_image_undo_group_start (image,
GIMP_UNDO_GROUP_TRANSFORM, C_("undo-type", "Transform"));
GIMP_UNDO_GROUP_TRANSFORM,
C_("undo-type", "Transform"));
/* Cut/Copy from the specified drawable */
orig_tiles = gimp_drawable_transform_cut (drawable, context, &new_layer);
@ -607,7 +608,7 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
if (new_tiles)
{
success = gimp_drawable_transform_paste (drawable, new_tiles,
result = gimp_drawable_transform_paste (drawable, new_tiles,
new_layer);
tile_manager_unref (new_tiles);
}
@ -616,25 +617,24 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
/* push the undo group end */
gimp_image_undo_group_end (image);
return success;
return result;
}
gboolean
GimpDrawable *
gimp_drawable_transform_flip (GimpDrawable *drawable,
GimpContext *context,
GimpOrientationType flip_type,
gboolean auto_center,
gdouble axis,
gboolean clip_result)
{
GimpImage *image;
TileManager *orig_tiles;
gboolean new_layer;
gboolean success = FALSE;
GimpDrawable *result = NULL;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
image = gimp_item_get_image (GIMP_ITEM (drawable));
@ -650,31 +650,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;
@ -706,7 +681,7 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
if (new_tiles)
{
success = gimp_drawable_transform_paste (drawable, new_tiles,
result = gimp_drawable_transform_paste (drawable, new_tiles,
new_layer);
tile_manager_unref (new_tiles);
}
@ -715,14 +690,13 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
/* push the undo group end */
gimp_image_undo_group_end (image);
return success;
return result;
}
gboolean
GimpDrawable *
gimp_drawable_transform_rotate (GimpDrawable *drawable,
GimpContext *context,
GimpRotationType rotate_type,
gboolean auto_center,
gdouble center_x,
gdouble center_y,
gboolean clip_result)
@ -730,11 +704,11 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
GimpImage *image;
TileManager *orig_tiles;
gboolean new_layer;
gboolean success = FALSE;
GimpDrawable *result = NULL;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
image = gimp_item_get_image (GIMP_ITEM (drawable));
@ -750,20 +724,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;
@ -794,7 +754,7 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
if (new_tiles)
{
success = gimp_drawable_transform_paste (drawable, new_tiles,
result = gimp_drawable_transform_paste (drawable, new_tiles,
new_layer);
tile_manager_unref (new_tiles);
}
@ -803,7 +763,7 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
/* push the undo group end */
gimp_image_undo_group_end (image);
return success;
return result;
}
TileManager *
@ -830,7 +790,7 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
* gimp_layer_new_from_tiles() later which assumes that the tiles
* are either RGB or GRAY. Eeek!!! (Sven)
*/
if (gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h))
if (gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &w, &h))
{
tiles = gimp_selection_extract (GIMP_SELECTION (gimp_image_get_mask (image)),
GIMP_PICKABLE (drawable),
@ -862,7 +822,7 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
return tiles;
}
gboolean
GimpDrawable *
gimp_drawable_transform_paste (GimpDrawable *drawable,
TileManager *tiles,
gboolean new_layer)
@ -873,9 +833,9 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gint offset_x;
gint offset_y;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (tiles != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (tiles != NULL, NULL);
image = gimp_item_get_image (GIMP_ITEM (drawable));
@ -884,7 +844,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
else if (GIMP_IS_CHANNEL (drawable))
undo_desc = C_("undo-type", "Transform Channel");
else
return FALSE;
return NULL;
tile_manager_get_offsets (tiles, &offset_x, &offset_y);
@ -901,6 +861,8 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimp_item_set_offset (GIMP_ITEM (layer), offset_x, offset_y);
floating_sel_attach (layer, drawable);
drawable = GIMP_DRAWABLE (layer);
}
else
{
@ -923,5 +885,5 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimp_image_undo_group_end (image);
return TRUE;
return drawable;
}

View File

@ -56,7 +56,7 @@ TileManager * gimp_drawable_transform_tiles_rotate (GimpDrawable *draw
gdouble center_y,
gboolean clip_result);
gboolean gimp_drawable_transform_affine (GimpDrawable *drawable,
GimpDrawable * gimp_drawable_transform_affine (GimpDrawable *drawable,
GimpContext *context,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
@ -65,17 +65,15 @@ gboolean gimp_drawable_transform_affine (GimpDrawable *draw
GimpTransformResize clip_result,
GimpProgress *progress);
gboolean gimp_drawable_transform_flip (GimpDrawable *drawable,
GimpDrawable * 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,
GimpDrawable * gimp_drawable_transform_rotate (GimpDrawable *drawable,
GimpContext *context,
GimpRotationType rotate_type,
gboolean auto_center,
gdouble center_x,
gdouble center_y,
gboolean clip_result);
@ -83,7 +81,7 @@ gboolean gimp_drawable_transform_rotate (GimpDrawable *draw
TileManager * gimp_drawable_transform_cut (GimpDrawable *drawable,
GimpContext *context,
gboolean *new_layer);
gboolean gimp_drawable_transform_paste (GimpDrawable *drawable,
GimpDrawable * gimp_drawable_transform_paste (GimpDrawable *drawable,
TileManager *tiles,
gboolean new_layer);

View File

@ -1742,117 +1742,6 @@ gimp_drawable_fill_by_type (GimpDrawable *drawable,
gimp_drawable_fill (drawable, pattern ? NULL : &color, pattern);
}
gboolean
gimp_drawable_mask_bounds (GimpDrawable *drawable,
gint *x1,
gint *y1,
gint *x2,
gint *y2)
{
GimpItem *item;
GimpImage *image;
GimpChannel *selection;
gint tmp_x1, tmp_y1;
gint tmp_x2, tmp_y2;
gboolean retval;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
item = GIMP_ITEM (drawable);
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
image = gimp_item_get_image (item);
selection = gimp_image_get_mask (image);
if (GIMP_DRAWABLE (selection) != drawable &&
gimp_channel_bounds (selection, &tmp_x1, &tmp_y1, &tmp_x2, &tmp_y2))
{
gint off_x, off_y;
gimp_item_get_offset (item, &off_x, &off_y);
tmp_x1 = CLAMP (tmp_x1 - off_x, 0, gimp_item_get_width (item));
tmp_y1 = CLAMP (tmp_y1 - off_y, 0, gimp_item_get_height (item));
tmp_x2 = CLAMP (tmp_x2 - off_x, 0, gimp_item_get_width (item));
tmp_y2 = CLAMP (tmp_y2 - off_y, 0, gimp_item_get_height (item));
retval = TRUE;
}
else
{
tmp_x1 = 0;
tmp_y1 = 0;
tmp_x2 = gimp_item_get_width (item);
tmp_y2 = gimp_item_get_height (item);
retval = FALSE;
}
if (x1) *x1 = tmp_x1;
if (y1) *y1 = tmp_y1;
if (x2) *x2 = tmp_x2;
if (y2) *y2 = tmp_y2;
return retval;;
}
gboolean
gimp_drawable_mask_intersect (GimpDrawable *drawable,
gint *x,
gint *y,
gint *width,
gint *height)
{
GimpItem *item;
GimpImage *image;
GimpChannel *selection;
gint tmp_x, tmp_y;
gint tmp_width, tmp_height;
gboolean retval;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
item = GIMP_ITEM (drawable);
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
image = gimp_item_get_image (item);
selection = gimp_image_get_mask (image);
if (GIMP_DRAWABLE (selection) != drawable &&
gimp_channel_bounds (selection, &tmp_x, &tmp_y, &tmp_width, &tmp_height))
{
gint off_x, off_y;
gimp_item_get_offset (item, &off_x, &off_y);
retval = gimp_rectangle_intersect (tmp_x - off_x, tmp_y - off_y,
tmp_width - tmp_x, tmp_height - tmp_y,
0, 0,
gimp_item_get_width (item),
gimp_item_get_height (item),
&tmp_x, &tmp_y,
&tmp_width, &tmp_height);
}
else
{
tmp_x = 0;
tmp_y = 0;
tmp_width = gimp_item_get_width (item);
tmp_height = gimp_item_get_height (item);
retval = TRUE;
}
if (x) *x = tmp_x;
if (y) *y = tmp_y;
if (width) *width = tmp_width;
if (height) *height = tmp_height;
return retval;
}
gboolean
gimp_drawable_has_alpha (const GimpDrawable *drawable)
{

View File

@ -222,17 +222,6 @@ void gimp_drawable_fill_by_type (GimpDrawable *drawable,
GimpContext *context,
GimpFillType fill_type);
gboolean gimp_drawable_mask_bounds (GimpDrawable *drawable,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gboolean gimp_drawable_mask_intersect (GimpDrawable *drawable,
gint *x,
gint *y,
gint *width,
gint *height);
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type_with_alpha (const GimpDrawable *drawable);

View File

@ -834,7 +834,7 @@ gimp_group_layer_new (GimpImage *image)
image,
0, 0, 1, 1,
gimp_image_base_type_with_alpha (image),
_("Layer Group"));
NULL);
if (gimp_image_get_projection (image)->use_gegl)
group->projection->use_gegl = TRUE;

View File

@ -2652,7 +2652,7 @@ fill_inverse_cmap_rgb (QuantizeObj *quantobj,
int colorlist[MAXNUMCOLORS];
int numcolors; /* number of candidate colors */
/* This array holds the actually closest colormap index for each cell. */
int bestcolor[BOX_R_ELEMS * BOX_G_ELEMS * BOX_B_ELEMS];
int bestcolor[BOX_R_ELEMS * BOX_G_ELEMS * BOX_B_ELEMS] = { 0, };
/* Convert cell coordinates to update box id */
R >>= BOX_R_LOG;

View File

@ -59,7 +59,8 @@ gimp_image_set_grid (GimpImage *image,
return;
if (push_undo)
gimp_image_undo_push_image_grid (image, C_("undo-type", "Grid"), private->grid);
gimp_image_undo_push_image_grid (image,
C_("undo-type", "Grid"), private->grid);
gimp_config_sync (G_OBJECT (grid), G_OBJECT (private->grid), 0);
}

View File

@ -48,7 +48,8 @@ gimp_image_add_hguide (GimpImage *image,
image->gimp->next_guide_ID++);
if (push_undo)
gimp_image_undo_push_guide (image, C_("undo-type", "Add Horizontal Guide"), guide);
gimp_image_undo_push_guide (image,
C_("undo-type", "Add Horizontal Guide"), guide);
gimp_image_add_guide (image, guide, position);
g_object_unref (G_OBJECT (guide));
@ -71,7 +72,8 @@ gimp_image_add_vguide (GimpImage *image,
image->gimp->next_guide_ID++);
if (push_undo)
gimp_image_undo_push_guide (image, C_("undo-type", "Add Vertical Guide"), guide);
gimp_image_undo_push_guide (image,
C_("undo-type", "Add Vertical Guide"), guide);
gimp_image_add_guide (image, guide, position);
g_object_unref (G_OBJECT (guide));

View File

@ -78,6 +78,10 @@ struct _GimpImagePrivate
GQuark channel_name_changed_handler;
GQuark channel_color_changed_handler;
GimpTreeHandler *vectors_freeze_handler;
GimpTreeHandler *vectors_thaw_handler;
GimpTreeHandler *vectors_visible_handler;
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */

View File

@ -63,6 +63,7 @@
#include "gimpsamplepoint.h"
#include "gimpselection.h"
#include "gimptemplate.h"
#include "gimptreehandler.h"
#include "gimpundostack.h"
#include "file/file-utils.h"
@ -101,6 +102,7 @@ enum
EXPORTED,
UPDATE_GUIDE,
UPDATE_SAMPLE_POINT,
UPDATE_VECTORS,
SAMPLE_POINT_ADDED,
SAMPLE_POINT_REMOVED,
PARASITE_ATTACHED,
@ -189,6 +191,18 @@ static void gimp_image_channel_name_changed (GimpChannel *channel,
GimpImage *image);
static void gimp_image_channel_color_changed (GimpChannel *channel,
GimpImage *image);
static void gimp_image_vectors_freeze (GimpVectors *vectors,
GimpImage *image);
static void gimp_image_vectors_thaw (GimpVectors *vectors,
GimpImage *image);
static void gimp_image_vectors_visible (GimpVectors *vectors,
GimpImage *image);
static void gimp_image_vectors_add (GimpContainer *container,
GimpVectors *vectors,
GimpImage *image);
static void gimp_image_vectors_remove (GimpContainer *container,
GimpVectors *vectors,
GimpImage *image);
static void gimp_image_active_layer_notify (GimpItemTree *tree,
const GParamSpec *pspec,
GimpImage *image);
@ -428,6 +442,16 @@ gimp_image_class_init (GimpImageClass *klass)
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gimp_image_signals[UPDATE_VECTORS] =
g_signal_new ("update-vectors",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, update_vectors),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_VECTORS);
gimp_image_signals[SAMPLE_POINT_ADDED] =
g_signal_new ("sample-point-added",
G_TYPE_FROM_CLASS (klass),
@ -529,6 +553,7 @@ gimp_image_class_init (GimpImageClass *klass)
klass->exported = NULL;
klass->update_guide = NULL;
klass->update_sample_point = NULL;
klass->update_vectors = NULL;
klass->sample_point_added = NULL;
klass->sample_point_removed = NULL;
klass->parasite_attached = NULL;
@ -678,6 +703,26 @@ gimp_image_init (GimpImage *image)
G_CALLBACK (gimp_image_channel_remove),
image);
private->vectors_freeze_handler =
gimp_tree_handler_connect (private->vectors->container, "freeze",
G_CALLBACK (gimp_image_vectors_freeze),
image);
private->vectors_thaw_handler =
gimp_tree_handler_connect (private->vectors->container, "thaw",
G_CALLBACK (gimp_image_vectors_thaw),
image);
private->vectors_visible_handler =
gimp_tree_handler_connect (private->vectors->container, "visibility-changed",
G_CALLBACK (gimp_image_vectors_visible),
image);
g_signal_connect (private->vectors->container, "add",
G_CALLBACK (gimp_image_vectors_add),
image);
g_signal_connect (private->vectors->container, "remove",
G_CALLBACK (gimp_image_vectors_remove),
image);
private->floating_sel = NULL;
private->selection_mask = NULL;
@ -879,6 +924,22 @@ gimp_image_dispose (GObject *object)
gimp_image_channel_remove,
image);
gimp_tree_handler_disconnect (private->vectors_freeze_handler);
private->vectors_freeze_handler = NULL;
gimp_tree_handler_disconnect (private->vectors_thaw_handler);
private->vectors_thaw_handler = NULL;
gimp_tree_handler_disconnect (private->vectors_visible_handler);
private->vectors_visible_handler = NULL;
g_signal_handlers_disconnect_by_func (private->vectors->container,
gimp_image_vectors_add,
image);
g_signal_handlers_disconnect_by_func (private->vectors->container,
gimp_image_vectors_remove,
image);
gimp_container_foreach (private->layers->container,
(GFunc) gimp_item_removed, NULL);
gimp_container_foreach (private->channels->container,
@ -1379,6 +1440,47 @@ gimp_image_channel_color_changed (GimpChannel *channel,
}
}
static void
gimp_image_vectors_freeze (GimpVectors *vectors,
GimpImage *image)
{
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_vectors_thaw (GimpVectors *vectors,
GimpImage *image)
{
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_vectors_visible (GimpVectors *vectors,
GimpImage *image)
{
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_vectors_add (GimpContainer *container,
GimpVectors *vectors,
GimpImage *image)
{
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_vectors_remove (GimpContainer *container,
GimpVectors *vectors,
GimpImage *image)
{
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_active_layer_notify (GimpItemTree *tree,
const GParamSpec *pspec,
@ -2008,6 +2110,17 @@ gimp_image_update_sample_point (GimpImage *image,
sample_point);
}
void
gimp_image_update_vectors (GimpImage *image,
GimpVectors *vectors)
{
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
g_signal_emit (image, gimp_image_signals[UPDATE_VECTORS], 0,
vectors);
}
void
gimp_image_sample_point_added (GimpImage *image,
GimpSamplePoint *sample_point)

View File

@ -135,6 +135,8 @@ struct _GimpImageClass
GimpGuide *guide);
void (* update_sample_point) (GimpImage *image,
GimpSamplePoint *sample_point);
void (* update_vectors) (GimpImage *image,
GimpVectors *vectors);
void (* sample_point_added) (GimpImage *image,
GimpSamplePoint *sample_point);
void (* sample_point_removed) (GimpImage *image,
@ -251,6 +253,9 @@ void gimp_image_update_guide (GimpImage *image,
GimpGuide *guide);
void gimp_image_update_sample_point (GimpImage *image,
GimpSamplePoint *sample_point);
void gimp_image_update_vectors (GimpImage *image,
GimpVectors *vectors);
void gimp_image_sample_point_added (GimpImage *image,
GimpSamplePoint *sample_point);
void gimp_image_sample_point_removed (GimpImage *image,

View File

@ -348,7 +348,7 @@ gimp_image_map_apply (GimpImageMap *image_map,
return;
/* The application should occur only within selection bounds */
if (! gimp_drawable_mask_intersect (image_map->drawable,
if (! gimp_item_mask_intersect (GIMP_ITEM (image_map->drawable),
&rect.x, &rect.y,
&rect.width, &rect.height))
return;

View File

@ -29,7 +29,7 @@
#include "gimp.h"
#include "gimp-parasites.h"
#include "gimpdrawable.h"
#include "gimpchannel.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
@ -1788,6 +1788,112 @@ gimp_item_is_content_locked (const GimpItem *item)
return GIMP_ITEM_GET_CLASS (item)->is_content_locked (item);
}
gboolean
gimp_item_mask_bounds (GimpItem *item,
gint *x1,
gint *y1,
gint *x2,
gint *y2)
{
GimpImage *image;
GimpChannel *selection;
gint tmp_x1, tmp_y1;
gint tmp_x2, tmp_y2;
gboolean retval;
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
image = gimp_item_get_image (item);
selection = gimp_image_get_mask (image);
if (GIMP_ITEM (selection) != item &&
gimp_channel_bounds (selection, &tmp_x1, &tmp_y1, &tmp_x2, &tmp_y2))
{
gint off_x, off_y;
gimp_item_get_offset (item, &off_x, &off_y);
tmp_x1 = CLAMP (tmp_x1 - off_x, 0, gimp_item_get_width (item));
tmp_y1 = CLAMP (tmp_y1 - off_y, 0, gimp_item_get_height (item));
tmp_x2 = CLAMP (tmp_x2 - off_x, 0, gimp_item_get_width (item));
tmp_y2 = CLAMP (tmp_y2 - off_y, 0, gimp_item_get_height (item));
retval = TRUE;
}
else
{
tmp_x1 = 0;
tmp_y1 = 0;
tmp_x2 = gimp_item_get_width (item);
tmp_y2 = gimp_item_get_height (item);
retval = FALSE;
}
if (x1) *x1 = tmp_x1;
if (y1) *y1 = tmp_y1;
if (x2) *x2 = tmp_x2;
if (y2) *y2 = tmp_y2;
return retval;;
}
gboolean
gimp_item_mask_intersect (GimpItem *item,
gint *x,
gint *y,
gint *width,
gint *height)
{
GimpImage *image;
GimpChannel *selection;
gint tmp_x, tmp_y;
gint tmp_width, tmp_height;
gboolean retval;
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
image = gimp_item_get_image (item);
selection = gimp_image_get_mask (image);
if (GIMP_ITEM (selection) != item &&
gimp_channel_bounds (selection, &tmp_x, &tmp_y, &tmp_width, &tmp_height))
{
gint off_x, off_y;
gimp_item_get_offset (item, &off_x, &off_y);
tmp_width -= tmp_x;
tmp_height -= tmp_y;
retval = gimp_rectangle_intersect (tmp_x - off_x, tmp_y - off_y,
tmp_width, tmp_height,
0, 0,
gimp_item_get_width (item),
gimp_item_get_height (item),
&tmp_x, &tmp_y,
&tmp_width, &tmp_height);
}
else
{
tmp_x = 0;
tmp_y = 0;
tmp_width = gimp_item_get_width (item);
tmp_height = gimp_item_get_height (item);
retval = TRUE;
}
if (x) *x = tmp_x;
if (y) *y = tmp_y;
if (width) *width = tmp_width;
if (height) *height = tmp_height;
return retval;
}
gboolean
gimp_item_is_in_set (GimpItem *item,
GimpItemSet set)

View File

@ -312,6 +312,17 @@ gboolean gimp_item_get_lock_content (const GimpItem *item);
gboolean gimp_item_can_lock_content (const GimpItem *item);
gboolean gimp_item_is_content_locked (const GimpItem *item);
gboolean gimp_item_mask_bounds (GimpItem *item,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gboolean gimp_item_mask_intersect (GimpItem *item,
gint *x,
gint *y,
gint *width,
gint *height);
gboolean gimp_item_is_in_set (GimpItem *item,
GimpItemSet set);

View File

@ -474,7 +474,8 @@ gimp_palette_import_from_drawable (GimpDrawable *drawable,
if (selection_only)
{
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable),
&x, &y, &width, &height))
return NULL;
}
else

View File

@ -151,6 +151,7 @@ gimp_selection_class_init (GimpSelectionClass *klass)
item_class->flip = gimp_selection_flip;
item_class->rotate = gimp_selection_rotate;
item_class->stroke = gimp_selection_stroke;
item_class->default_name = _("Selection Mask");
item_class->translate_desc = C_("undo-type", "Move Selection");
item_class->stroke_desc = C_("undo-type", "Stroke Selection");
@ -529,7 +530,7 @@ gimp_selection_new (GimpImage *image,
image,
0, 0, width, height,
GIMP_GRAY_IMAGE,
_("Selection Mask"));
NULL);
gimp_channel_set_color (channel, &black, FALSE);
gimp_channel_set_show_masked (channel, TRUE);
@ -657,7 +658,7 @@ gimp_selection_extract (GimpSelection *selection,
* actual selection mask
*/
if (GIMP_IS_DRAWABLE (pickable))
non_empty = gimp_drawable_mask_bounds (GIMP_DRAWABLE (pickable),
non_empty = gimp_item_mask_bounds (GIMP_ITEM (pickable),
&x1, &y1, &x2, &y2);
else
non_empty = gimp_channel_bounds (GIMP_CHANNEL (selection),
@ -837,7 +838,7 @@ gimp_selection_float (GimpSelection *selection,
image = gimp_item_get_image (GIMP_ITEM (selection));
/* Make sure there is a region to float... */
if (! gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2) ||
if (! gimp_item_mask_bounds (GIMP_ITEM (drawable), &x1, &y1, &x2, &y2) ||
(x1 == x2 || y1 == y2))
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,

View File

@ -19,6 +19,28 @@ libappdisplay_a_sources = \
display-types.h \
gimpcanvas.c \
gimpcanvas.h \
gimpcanvasarc.c \
gimpcanvasarc.h \
gimpcanvasboundary.c \
gimpcanvasboundary.h \
gimpcanvascorner.c \
gimpcanvascorner.h \
gimpcanvasgroup.c \
gimpcanvasgroup.h \
gimpcanvasguide.c \
gimpcanvasguide.h \
gimpcanvashandle.c \
gimpcanvashandle.h \
gimpcanvasitem.c \
gimpcanvasitem.h \
gimpcanvasline.c \
gimpcanvasline.h \
gimpcanvaspolygon.c \
gimpcanvaspolygon.h \
gimpcanvasrectangle.c \
gimpcanvasrectangle.h \
gimpcanvastextcursor.c \
gimpcanvastextcursor.h \
gimpcursorview.c \
gimpcursorview.h \
gimpdisplay.c \

View File

@ -39,6 +39,41 @@ gimp_cursor_precision_get_type (void)
return type;
}
GType
gimp_handle_type_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_HANDLE_SQUARE, "GIMP_HANDLE_SQUARE", "square" },
{ GIMP_HANDLE_FILLED_SQUARE, "GIMP_HANDLE_FILLED_SQUARE", "filled-square" },
{ GIMP_HANDLE_CIRCLE, "GIMP_HANDLE_CIRCLE", "circle" },
{ GIMP_HANDLE_FILLED_CIRCLE, "GIMP_HANDLE_FILLED_CIRCLE", "filled-circle" },
{ GIMP_HANDLE_CROSS, "GIMP_HANDLE_CROSS", "cross" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_HANDLE_SQUARE, "GIMP_HANDLE_SQUARE", NULL },
{ GIMP_HANDLE_FILLED_SQUARE, "GIMP_HANDLE_FILLED_SQUARE", NULL },
{ GIMP_HANDLE_CIRCLE, "GIMP_HANDLE_CIRCLE", NULL },
{ GIMP_HANDLE_FILLED_CIRCLE, "GIMP_HANDLE_FILLED_CIRCLE", NULL },
{ GIMP_HANDLE_CROSS, "GIMP_HANDLE_CROSS", NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("GimpHandleType", values);
gimp_type_set_translation_context (type, "handle-type");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_zoom_focus_get_type (void)
{

View File

@ -31,6 +31,20 @@ typedef enum
} GimpCursorPrecision;
#define GIMP_TYPE_HANDLE_TYPE (gimp_handle_type_get_type ())
GType gimp_handle_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_HANDLE_SQUARE,
GIMP_HANDLE_FILLED_SQUARE,
GIMP_HANDLE_CIRCLE,
GIMP_HANDLE_FILLED_CIRCLE,
GIMP_HANDLE_CROSS
} GimpHandleType;
#define GIMP_TYPE_ZOOM_FOCUS (gimp_zoom_focus_get_type ())
GType gimp_zoom_focus_get_type (void) G_GNUC_CONST;

View File

@ -25,10 +25,11 @@
typedef struct _GimpCanvas GimpCanvas;
typedef struct _GimpCanvasItem GimpCanvasItem;
typedef struct _GimpCanvasGroup GimpCanvasGroup;
typedef struct _GimpDisplay GimpDisplay;
typedef struct _GimpDisplayShell GimpDisplayShell;
/* typedef struct _GimpDisplayOptions GimpDisplayOptions; in config-types.h */
typedef struct _GimpImageWindow GimpImageWindow;

View File

@ -64,9 +64,6 @@ static gboolean gimp_canvas_focus_out_event (GtkWidget *widget,
static gboolean gimp_canvas_focus (GtkWidget *widget,
GtkDirectionType direction);
static GdkGC * gimp_canvas_gc_new (GimpCanvas *canvas,
GimpCanvasStyle style);
G_DEFINE_TYPE (GimpCanvas, gimp_canvas, GIMP_TYPE_OVERLAY_BOX)
@ -99,15 +96,11 @@ static void
gimp_canvas_init (GimpCanvas *canvas)
{
GtkWidget *widget = GTK_WIDGET (canvas);
gint i;
gtk_widget_set_double_buffered (widget, FALSE);
gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_add_events (widget, GIMP_CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_ALL);
for (i = 0; i < GIMP_CANVAS_NUM_STYLES; i++)
canvas->gc[i] = NULL;
}
static void
@ -123,6 +116,7 @@ gimp_canvas_set_property (GObject *object,
case PROP_CONFIG:
canvas->config = g_value_get_object (value); /* don't dup */
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -142,6 +136,7 @@ gimp_canvas_get_property (GObject *object,
case PROP_CONFIG:
g_value_set_object (value, canvas->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -152,16 +147,6 @@ static void
gimp_canvas_unrealize (GtkWidget *widget)
{
GimpCanvas *canvas = GIMP_CANVAS (widget);
gint i;
for (i = 0; i < GIMP_CANVAS_NUM_STYLES; i++)
{
if (canvas->gc[i])
{
g_object_unref (canvas->gc[i]);
canvas->gc[i] = NULL;
}
}
if (canvas->layout)
{
@ -225,93 +210,6 @@ gimp_canvas_focus (GtkWidget *widget,
return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction);
}
/* Returns: %TRUE if the XOR color is not white */
static gboolean
gimp_canvas_get_xor_color (GimpCanvas *canvas,
GdkColor *color)
{
guchar r, g, b;
gimp_rgb_get_uchar (&canvas->config->xor_color, &r, &g, &b);
color->red = (r << 8) | r;
color->green = (g << 8) | g;
color->blue = (b << 8) | b;
return (r != 255 || g != 255 || b != 255);
}
static GdkGC *
gimp_canvas_gc_new (GimpCanvas *canvas,
GimpCanvasStyle style)
{
GdkGC *gc;
GdkGCValues values;
GdkGCValuesMask mask = 0;
GdkColor fg = { 0, 0, 0, 0 };
GdkColor bg = { 0, 0, 0, 0 };
if (! gtk_widget_get_realized (GTK_WIDGET (canvas)))
return NULL;
switch (style)
{
case GIMP_CANVAS_STYLE_XOR_DOTTED:
case GIMP_CANVAS_STYLE_XOR_DASHED:
mask |= GDK_GC_LINE_STYLE;
values.line_style = GDK_LINE_ON_OFF_DASH;
/* fallthrough */
case GIMP_CANVAS_STYLE_XOR:
mask |= GDK_GC_FUNCTION | GDK_GC_CAP_STYLE | GDK_GC_JOIN_STYLE;
if (gimp_canvas_get_xor_color (canvas, &fg))
values.function = GDK_XOR;
else
values.function = GDK_INVERT;
values.cap_style = GDK_CAP_NOT_LAST;
values.join_style = GDK_JOIN_MITER;
break;
default:
return NULL;
}
gc = gdk_gc_new_with_values (gtk_widget_get_window (GTK_WIDGET (canvas)),
&values, mask);
if (style == GIMP_CANVAS_STYLE_XOR_DOTTED)
{
gint8 one = 1;
gdk_gc_set_dashes (gc, 0, &one, 1);
}
switch (style)
{
default:
return gc;
case GIMP_CANVAS_STYLE_XOR_DOTTED:
case GIMP_CANVAS_STYLE_XOR_DASHED:
case GIMP_CANVAS_STYLE_XOR:
break;
}
gdk_gc_set_rgb_fg_color (gc, &fg);
gdk_gc_set_rgb_bg_color (gc, &bg);
return gc;
}
static inline gboolean
gimp_canvas_ensure_style (GimpCanvas *canvas,
GimpCanvasStyle style)
{
return (canvas->gc[style] != NULL ||
(canvas->gc[style] = gimp_canvas_gc_new (canvas, style)) != NULL);
}
/* public functions */
@ -343,179 +241,7 @@ gimp_canvas_new (GimpDisplayConfig *config)
}
/**
* gimp_canvas_draw_line:
* @canvas: a #GimpCanvas widget
* @style: one of the enumerated #GimpCanvasStyle's.
* @x1: X coordinate of the first point
* @y1: Y coordinate of the first point
* @x2: X coordinate of the second point
* @y2: Y coordinate of the second point
*
* Draw a line connecting the specified points, using the specified
* style.
**/
void
gimp_canvas_draw_line (GimpCanvas *canvas,
GimpCanvasStyle style,
gint x1,
gint y1,
gint x2,
gint y2)
{
if (! gimp_canvas_ensure_style (canvas, style))
return;
gdk_draw_line (gtk_widget_get_window (GTK_WIDGET (canvas)),
canvas->gc[style],
x1, y1, x2, y2);
}
/**
* gimp_canvas_draw_lines:
* @canvas: a #GimpCanvas widget
* @style: one of the enumerated #GimpCanvasStyle's.
* @points: a #GdkPoint array.
* @num_points: the number of points in the array.
*
* Draws a set of lines connecting the specified points, in the
* specified style.
**/
void
gimp_canvas_draw_lines (GimpCanvas *canvas,
GimpCanvasStyle style,
GdkPoint *points,
gint num_points)
{
if (! gimp_canvas_ensure_style (canvas, style))
return;
gdk_draw_lines (gtk_widget_get_window (GTK_WIDGET (canvas)),
canvas->gc[style],
points, num_points);
}
/**
* gimp_canvas_draw_rectangle:
* @canvas: a #GimpCanvas widget
* @style: one of the enumerated #GimpCanvasStyle's.
* @filled: %TRUE if the rectangle is to be filled.
* @x: X coordinate of the upper left corner.
* @y: Y coordinate of the upper left corner.
* @width: width of the rectangle.
* @height: height of the rectangle.
*
* Draws a rectangle in the specified style.
**/
void
gimp_canvas_draw_rectangle (GimpCanvas *canvas,
GimpCanvasStyle style,
gboolean filled,
gint x,
gint y,
gint width,
gint height)
{
if (! gimp_canvas_ensure_style (canvas, style))
return;
gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET (canvas)),
canvas->gc[style],
filled, x, y, width, height);
}
/**
* gimp_canvas_draw_arc:
* @canvas: a #GimpCanvas widget
* @style: one of the enumerated #GimpCanvasStyle's.
* @filled: %TRUE if the arc is to be filled, producing a 'pie slice'.
* @x: X coordinate of the left edge of the bounding rectangle.
* @y: Y coordinate of the top edge of the bounding rectangle.
* @width: width of the bounding rectangle.
* @height: height of the bounding rectangle.
* @angle1: the start angle of the arc.
* @angle2: the end angle of the arc.
*
* Draws an arc or pie slice, in the specified style.
**/
void
gimp_canvas_draw_arc (GimpCanvas *canvas,
GimpCanvasStyle style,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
if (! gimp_canvas_ensure_style (canvas, style))
return;
gdk_draw_arc (gtk_widget_get_window (GTK_WIDGET (canvas)),
canvas->gc[style],
filled, x, y, width, height, angle1, angle2);
}
/**
* gimp_canvas_draw_polygon:
* @canvas: a #GimpCanvas widget
* @style: one of the enumerated #GimpCanvasStyle's.
* @filled: if %TRUE, fill the polygon.
* @points: a #GdkPoint array.
* @num_points: the number of points in the array.
*
* Draws a polygon connecting the specified points, in the specified
* style.
**/
void
gimp_canvas_draw_polygon (GimpCanvas *canvas,
GimpCanvasStyle style,
gboolean filled,
GdkPoint *points,
gint num_points)
{
if (! gimp_canvas_ensure_style (canvas, style))
return;
gdk_draw_polygon (gtk_widget_get_window (GTK_WIDGET (canvas)),
canvas->gc[style],
filled, points, num_points);
}
/**
* gimp_canvas_draw_segments:
* @canvas: a #GimpCanvas widget
* @style: one of the enumerated #GimpCanvasStyle's.
* @segments: a #GdkSegment array.
* @num_segments: the number of segments in the array.
*
* Draws a set of line segments in the specified style.
**/
void
gimp_canvas_draw_segments (GimpCanvas *canvas,
GimpCanvasStyle style,
GdkSegment *segments,
gint num_segments)
{
if (! gimp_canvas_ensure_style (canvas, style))
return;
while (num_segments >= MAX_BATCH_SIZE)
{
gdk_draw_segments (gtk_widget_get_window (GTK_WIDGET (canvas)),
canvas->gc[style],
segments, MAX_BATCH_SIZE);
num_segments -= MAX_BATCH_SIZE;
segments += MAX_BATCH_SIZE;
}
gdk_draw_segments (gtk_widget_get_window (GTK_WIDGET (canvas)),
canvas->gc[style],
segments, num_segments);
}
/**
* gimp_canvas_draw_text:
* gimp_canvas_get_layout:
* @canvas: a #GimpCanvas widget
* @format: a standard printf() format string.
* @Varargs: the parameters to insert into the format string.
@ -549,54 +275,6 @@ gimp_canvas_get_layout (GimpCanvas *canvas,
return canvas->layout;
}
/**
* gimp_canvas_set_clip_rect:
* @canvas: a #GimpCanvas widget
* @style: one of the enumerated #GimpCanvasStyle's.
* @rect: a #GdkRectangle to set the bounds of the clipping area.
*
* Sets a rectangular clipping area for the specified style.
**/
void
gimp_canvas_set_clip_rect (GimpCanvas *canvas,
GimpCanvasStyle style,
const GdkRectangle *rect)
{
if (! canvas->gc[style])
{
if (! rect)
return;
canvas->gc[style] = gimp_canvas_gc_new (canvas, style);
}
gdk_gc_set_clip_rectangle (canvas->gc[style], rect);
}
/**
* gimp_canvas_set_clip_region:
* @canvas: a #GimpCanvas widget
* @style: one of the enumerated #GimpCanvasStyle's.
* @region: a #GdkRegion to set the bounds of the clipping area.
*
* Sets a clipping region for the specified style.
**/
void
gimp_canvas_set_clip_region (GimpCanvas *canvas,
GimpCanvasStyle style,
const GdkRegion *region)
{
if (! canvas->gc[style])
{
if (! region)
return;
canvas->gc[style] = gimp_canvas_gc_new (canvas, style);
}
gdk_gc_set_clip_region (canvas->gc[style], region);
}
/**
* gimp_canvas_set_bg_color:
* @canvas: a #GimpCanvas widget

View File

@ -22,16 +22,6 @@
#include "widgets/gimpoverlaybox.h"
typedef enum
{
GIMP_CANVAS_STYLE_XOR,
GIMP_CANVAS_STYLE_XOR_DASHED,
GIMP_CANVAS_STYLE_XOR_DOTTED,
GIMP_CANVAS_NUM_STYLES
} GimpCanvasStyle;
#define GIMP_CANVAS_NUM_STIPPLES 8
#define GIMP_CANVAS_EVENT_MASK (GDK_EXPOSURE_MASK | \
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK | \
@ -61,9 +51,6 @@ struct _GimpCanvas
GimpOverlayBox parent_instance;
GimpDisplayConfig *config;
GdkGC *gc[GIMP_CANVAS_NUM_STYLES];
GdkBitmap *stipple[GIMP_CANVAS_NUM_STIPPLES];
PangoLayout *layout;
};
@ -77,51 +64,10 @@ GType gimp_canvas_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_canvas_new (GimpDisplayConfig *config);
void gimp_canvas_draw_line (GimpCanvas *canvas,
GimpCanvasStyle style,
gint x1,
gint y1,
gint x2,
gint y2);
void gimp_canvas_draw_lines (GimpCanvas *canvas,
GimpCanvasStyle style,
GdkPoint *points,
gint num_points);
void gimp_canvas_draw_rectangle (GimpCanvas *canvas,
GimpCanvasStyle style,
gboolean filled,
gint x,
gint y,
gint width,
gint height);
void gimp_canvas_draw_arc (GimpCanvas *canvas,
GimpCanvasStyle style,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
void gimp_canvas_draw_polygon (GimpCanvas *canvas,
GimpCanvasStyle style,
gboolean filled,
GdkPoint *points,
gint num_points);
void gimp_canvas_draw_segments (GimpCanvas *canvas,
GimpCanvasStyle style,
GdkSegment *segments,
gint num_segments);
PangoLayout * gimp_canvas_get_layout (GimpCanvas *canvas,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
void gimp_canvas_set_clip_rect (GimpCanvas *canvas,
GimpCanvasStyle style,
const GdkRectangle *rect);
void gimp_canvas_set_clip_region (GimpCanvas *canvas,
GimpCanvasStyle style,
const GdkRegion *region);
void gimp_canvas_set_bg_color (GimpCanvas *canvas,
GimpRGB *color);

325
app/display/gimpcanvasarc.c Normal file
View File

@ -0,0 +1,325 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasarc.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "widgets/gimpcairo.h"
#include "gimpcanvasarc.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_CENTER_X,
PROP_CENTER_Y,
PROP_RADIUS_X,
PROP_RADIUS_Y,
PROP_START_ANGLE,
PROP_SLICE_ANGLE,
PROP_FILLED
};
typedef struct _GimpCanvasArcPrivate GimpCanvasArcPrivate;
struct _GimpCanvasArcPrivate
{
gdouble center_x;
gdouble center_y;
gdouble radius_x;
gdouble radius_y;
gdouble start_angle;
gdouble slice_angle;;
gboolean filled;
};
#define GET_PRIVATE(arc) \
G_TYPE_INSTANCE_GET_PRIVATE (arc, \
GIMP_TYPE_CANVAS_ARC, \
GimpCanvasArcPrivate)
/* local function prototypes */
static void gimp_canvas_arc_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_arc_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_arc_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_arc_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasArc, gimp_canvas_arc,
GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_arc_parent_class
static void
gimp_canvas_arc_class_init (GimpCanvasArcClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->set_property = gimp_canvas_arc_set_property;
object_class->get_property = gimp_canvas_arc_get_property;
item_class->draw = gimp_canvas_arc_draw;
item_class->get_extents = gimp_canvas_arc_get_extents;
g_object_class_install_property (object_class, PROP_CENTER_X,
g_param_spec_double ("center-x", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_CENTER_Y,
g_param_spec_double ("center-y", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_RADIUS_X,
g_param_spec_double ("radius-x", NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_RADIUS_Y,
g_param_spec_double ("radius-y", NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_START_ANGLE,
g_param_spec_double ("start-angle", NULL, NULL,
-1000, 1000, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SLICE_ANGLE,
g_param_spec_double ("slice-angle", NULL, NULL,
-1000, 1000, 2 * G_PI,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_FILLED,
g_param_spec_boolean ("filled", NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasArcPrivate));
}
static void
gimp_canvas_arc_init (GimpCanvasArc *arc)
{
}
static void
gimp_canvas_arc_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasArcPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_CENTER_X:
private->center_x = g_value_get_double (value);
break;
case PROP_CENTER_Y:
private->center_y = g_value_get_double (value);
break;
case PROP_RADIUS_X:
private->radius_x = g_value_get_double (value);
break;
case PROP_RADIUS_Y:
private->radius_y = g_value_get_double (value);
break;
case PROP_START_ANGLE:
private->start_angle = g_value_get_double (value);
break;
case PROP_SLICE_ANGLE:
private->slice_angle = g_value_get_double (value);
break;
case PROP_FILLED:
private->filled = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_arc_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasArcPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_CENTER_X:
g_value_set_double (value, private->center_x);
break;
case PROP_CENTER_Y:
g_value_set_double (value, private->center_y);
break;
case PROP_RADIUS_X:
g_value_set_double (value, private->radius_x);
break;
case PROP_RADIUS_Y:
g_value_set_double (value, private->radius_y);
break;
case PROP_START_ANGLE:
g_value_set_double (value, private->start_angle);
break;
case PROP_SLICE_ANGLE:
g_value_set_double (value, private->slice_angle);
break;
case PROP_FILLED:
g_value_set_boolean (value, private->filled);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_arc_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
gdouble *center_x,
gdouble *center_y,
gdouble *radius_x,
gdouble *radius_y)
{
GimpCanvasArcPrivate *private = GET_PRIVATE (item);
gdouble x1, y1;
gdouble x2, y2;
gimp_display_shell_transform_xy_f (shell,
private->center_x,
private->center_y,
center_x, center_y);
gimp_display_shell_transform_xy_f (shell,
private->center_x - private->radius_x,
private->center_y - private->radius_y,
&x1, &y1);
gimp_display_shell_transform_xy_f (shell,
private->center_x + private->radius_x,
private->center_y + private->radius_y,
&x2, &y2);
*radius_x = (x2 - x1) / 2.0;
*radius_y = (y2 - y1) / 2.0;
if (! private->filled)
{
*radius_x -= 0.5;
*radius_y -= 0.5;
}
}
static void
gimp_canvas_arc_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasArcPrivate *private = GET_PRIVATE (item);
gdouble center_x, center_y;
gdouble radius_x, radius_y;
gimp_canvas_arc_transform (item, shell,
&center_x, &center_y,
&radius_x, &radius_y);
cairo_save (cr);
cairo_translate (cr, center_x, center_y);
cairo_scale (cr, radius_x, radius_y);
gimp_cairo_add_arc (cr, 0.0, 0.0, 1.0,
private->start_angle, private->slice_angle);
cairo_restore (cr);
if (private->filled)
_gimp_canvas_item_fill (item, shell, cr);
else
_gimp_canvas_item_stroke (item, shell, cr);
}
static GdkRegion *
gimp_canvas_arc_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GdkRectangle rectangle;
gdouble center_x, center_y;
gdouble radius_x, radius_y;
gimp_canvas_arc_transform (item, shell,
&center_x, &center_y,
&radius_x, &radius_y);
rectangle.x = floor (center_x - radius_x - 1.5);
rectangle.y = floor (center_y - radius_y - 1.5);
rectangle.width = ceil (center_x + radius_x + 1.5) - rectangle.x;
rectangle.height = ceil (center_y + radius_y + 1.5) - rectangle.y;
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_arc_new (gdouble center_x,
gdouble center_y,
gdouble radius_x,
gdouble radius_y,
gdouble start_angle,
gdouble slice_angle,
gboolean filled)
{
return g_object_new (GIMP_TYPE_CANVAS_ARC,
"center-x", center_x,
"center-y", center_y,
"radius-x", radius_x,
"radius-y", radius_y,
"start-angle", start_angle,
"slice-angle", slice_angle,
"filled", filled,
NULL);
}

View File

@ -0,0 +1,61 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasarc.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_ARC_H__
#define __GIMP_CANVAS_ARC_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_ARC (gimp_canvas_arc_get_type ())
#define GIMP_CANVAS_ARC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_ARC, GimpCanvasArc))
#define GIMP_CANVAS_ARC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_ARC, GimpCanvasArcClass))
#define GIMP_IS_CANVAS_ARC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_ARC))
#define GIMP_IS_CANVAS_ARC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_ARC))
#define GIMP_CANVAS_ARC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_ARC, GimpCanvasArcClass))
typedef struct _GimpCanvasArc GimpCanvasArc;
typedef struct _GimpCanvasArcClass GimpCanvasArcClass;
struct _GimpCanvasArc
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasArcClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_arc_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_arc_new (gdouble center_x,
gdouble center_y,
gdouble radius_x,
gdouble radius_y,
gdouble start_angle,
gdouble slice_angle,
gboolean filled);
#endif /* __GIMP_CANVAS_ARC_H__ */

View File

@ -0,0 +1,339 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasboundary.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "base/boundary.h"
#include "core/gimpparamspecs.h"
#include "gimpcanvasboundary.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_SEGS,
PROP_OFFSET_X,
PROP_OFFSET_Y
};
typedef struct _GimpCanvasBoundaryPrivate GimpCanvasBoundaryPrivate;
struct _GimpCanvasBoundaryPrivate
{
BoundSeg *segs;
gint n_segs;
gdouble offset_x;
gdouble offset_y;
};
#define GET_PRIVATE(boundary) \
G_TYPE_INSTANCE_GET_PRIVATE (boundary, \
GIMP_TYPE_CANVAS_BOUNDARY, \
GimpCanvasBoundaryPrivate)
/* local function prototypes */
static void gimp_canvas_boundary_finalize (GObject *object);
static void gimp_canvas_boundary_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_boundary_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_boundary_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_boundary_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasBoundary, gimp_canvas_boundary,
GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_boundary_parent_class
static void
gimp_canvas_boundary_class_init (GimpCanvasBoundaryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->finalize = gimp_canvas_boundary_finalize;
object_class->set_property = gimp_canvas_boundary_set_property;
object_class->get_property = gimp_canvas_boundary_get_property;
item_class->draw = gimp_canvas_boundary_draw;
item_class->get_extents = gimp_canvas_boundary_get_extents;
g_object_class_install_property (object_class, PROP_SEGS,
gimp_param_spec_array ("segs", NULL, NULL,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_OFFSET_X,
g_param_spec_double ("offset-x", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_OFFSET_Y,
g_param_spec_double ("offset-y", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasBoundaryPrivate));
}
static void
gimp_canvas_boundary_init (GimpCanvasBoundary *boundary)
{
}
static void
gimp_canvas_boundary_finalize (GObject *object)
{
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (object);
if (private->segs)
{
g_free (private->segs);
private->segs = NULL;
private->n_segs = 0;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_canvas_boundary_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_SEGS:
break;
case PROP_OFFSET_X:
private->offset_x = g_value_get_double (value);
break;
case PROP_OFFSET_Y:
private->offset_y = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_boundary_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_SEGS:
break;
case PROP_OFFSET_X:
g_value_set_double (value, private->offset_x);
break;
case PROP_OFFSET_Y:
g_value_set_double (value, private->offset_y);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_boundary_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
BoundSeg *segs)
{
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
gint i;
for (i = 0; i < private->n_segs; i++)
{
if (private->segs[i].x1 == -1 &&
private->segs[i].y1 == -1 &&
private->segs[i].x2 == -1 &&
private->segs[i].y2 == -1)
{
segs[i] = private->segs[i];
}
else
{
gimp_display_shell_transform_xy (shell,
private->segs[i].x1 +
private->offset_x,
private->segs[i].y1 +
private->offset_y,
&segs[i].x1,
&segs[i].y1);
gimp_display_shell_transform_xy (shell,
private->segs[i].x2 +
private->offset_x,
private->segs[i].y2 +
private->offset_y,
&segs[i].x2,
&segs[i].y2);
}
}
}
static void
gimp_canvas_boundary_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
BoundSeg *segs;
gint i;
segs = g_new0 (BoundSeg, private->n_segs);
gimp_canvas_boundary_transform (item, shell, segs);
cairo_move_to (cr, segs[0].x1 + 0.5, segs[0].y1 + 0.5);
for (i = 1; i < private->n_segs; i++)
{
if (segs[i].x1 == -1 &&
segs[i].y1 == -1 &&
segs[i].x2 == -1 &&
segs[i].y2 == -1)
{
cairo_close_path (cr);
_gimp_canvas_item_stroke (item, shell, cr);
i++;
if (i == private->n_segs)
break;
cairo_move_to (cr, segs[i].x1 + 0.5, segs[i].y1 + 0.5);
}
else
{
cairo_line_to (cr, segs[i].x1 + 0.5, segs[i].y1 + 0.5);
}
}
cairo_close_path (cr);
_gimp_canvas_item_stroke (item, shell, cr);
g_free (segs);
}
static GdkRegion *
gimp_canvas_boundary_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
GdkRectangle rectangle;
BoundSeg *segs;
gint x1, y1, x2, y2;
gint i;
segs = g_new0 (BoundSeg, private->n_segs);
gimp_canvas_boundary_transform (item, shell, segs);
x1 = segs[0].x1 - 1;
y1 = segs[0].y1 - 1;
x2 = x1 + 3;
y2 = y1 + 3;
for (i = 1; i < private->n_segs; i++)
{
if (segs[i].x1 != -1 ||
segs[i].y1 != -1 ||
segs[i].x2 != -1 ||
segs[i].y2 != -1)
{
gint x3 = segs[i].x1 - 1;
gint y3 = segs[i].y1 - 1;
gint x4 = x3 + 3;
gint y4 = y3 + 3;
x1 = MIN (x1, x3);
y1 = MIN (y1, y3);
x2 = MAX (x2, x4);
y2 = MAX (y2, y4);
}
}
g_free (segs);
rectangle.x = x1;
rectangle.y = y1;
rectangle.width = x2 - x1;
rectangle.height = y2 - y1;
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_boundary_new (const BoundSeg *segs,
gint n_segs,
gdouble offset_x,
gdouble offset_y)
{
GimpCanvasItem *item;
GimpCanvasBoundaryPrivate *private;
item = g_object_new (GIMP_TYPE_CANVAS_BOUNDARY,
"offset-x", offset_x,
"offset-y", offset_y,
NULL);
private = GET_PRIVATE (item);
/* puke */
private->segs = g_memdup (segs, n_segs * sizeof (BoundSeg));
private->n_segs = n_segs;
return item;
}

View File

@ -0,0 +1,58 @@
/* GIMP - The GNU Image Manipulation Program Copyright (C) 1995
* Spencer Kimball and Peter Mattis
*
* gimpcanvasboundary.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_BOUNDARY_H__
#define __GIMP_CANVAS_BOUNDARY_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_BOUNDARY (gimp_canvas_boundary_get_type ())
#define GIMP_CANVAS_BOUNDARY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_BOUNDARY, GimpCanvasBoundary))
#define GIMP_CANVAS_BOUNDARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_BOUNDARY, GimpCanvasBoundaryClass))
#define GIMP_IS_CANVAS_BOUNDARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_BOUNDARY))
#define GIMP_IS_CANVAS_BOUNDARY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_BOUNDARY))
#define GIMP_CANVAS_BOUNDARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_BOUNDARY, GimpCanvasBoundaryClass))
typedef struct _GimpCanvasBoundary GimpCanvasBoundary;
typedef struct _GimpCanvasBoundaryClass GimpCanvasBoundaryClass;
struct _GimpCanvasBoundary
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasBoundaryClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_boundary_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_boundary_new (const BoundSeg *segs,
gint n_segs,
gdouble offset_x,
gdouble offset_y);
#endif /* __GIMP_CANVAS_BOUNDARY_H__ */

View File

@ -0,0 +1,449 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvascorner.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "gimpcanvascorner.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_X,
PROP_Y,
PROP_WIDTH,
PROP_HEIGHT,
PROP_ANCHOR,
PROP_CORNER_WIDTH,
PROP_CORNER_HEIGHT,
PROP_OUTSIDE
};
typedef struct _GimpCanvasCornerPrivate GimpCanvasCornerPrivate;
struct _GimpCanvasCornerPrivate
{
gdouble x;
gdouble y;
gdouble width;
gdouble height;
GtkAnchorType anchor;
gint corner_width;
gint corner_height;
gboolean outside;
};
#define GET_PRIVATE(corner) \
G_TYPE_INSTANCE_GET_PRIVATE (corner, \
GIMP_TYPE_CANVAS_CORNER, \
GimpCanvasCornerPrivate)
/* local function prototypes */
static void gimp_canvas_corner_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_corner_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_corner_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_corner_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasCorner, gimp_canvas_corner,
GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_corner_parent_class
static void
gimp_canvas_corner_class_init (GimpCanvasCornerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->set_property = gimp_canvas_corner_set_property;
object_class->get_property = gimp_canvas_corner_get_property;
item_class->draw = gimp_canvas_corner_draw;
item_class->get_extents = gimp_canvas_corner_get_extents;
g_object_class_install_property (object_class, PROP_X,
g_param_spec_double ("x", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_Y,
g_param_spec_double ("y", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_WIDTH,
g_param_spec_double ("width", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_HEIGHT,
g_param_spec_double ("height", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_ANCHOR,
g_param_spec_enum ("anchor", NULL, NULL,
GTK_TYPE_ANCHOR_TYPE,
GTK_ANCHOR_CENTER,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_CORNER_WIDTH,
g_param_spec_int ("corner-width", NULL, NULL,
3, GIMP_MAX_IMAGE_SIZE, 3,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_CORNER_HEIGHT,
g_param_spec_int ("corner-height", NULL, NULL,
3, GIMP_MAX_IMAGE_SIZE, 3,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_OUTSIDE,
g_param_spec_boolean ("outside", NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasCornerPrivate));
}
static void
gimp_canvas_corner_init (GimpCanvasCorner *corner)
{
}
static void
gimp_canvas_corner_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasCornerPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_X:
private->x = g_value_get_double (value);
break;
case PROP_Y:
private->y = g_value_get_double (value);
break;
case PROP_WIDTH:
private->width = g_value_get_double (value);
break;
case PROP_HEIGHT:
private->height = g_value_get_double (value);
break;
case PROP_ANCHOR:
private->anchor = g_value_get_enum (value);
break;
case PROP_CORNER_WIDTH:
private->corner_width = g_value_get_int (value);
break;
case PROP_CORNER_HEIGHT:
private->corner_height = g_value_get_int (value);
break;
case PROP_OUTSIDE:
private->outside = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_corner_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasCornerPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_X:
g_value_set_double (value, private->x);
break;
case PROP_Y:
g_value_set_double (value, private->y);
break;
case PROP_WIDTH:
g_value_set_double (value, private->width);
break;
case PROP_HEIGHT:
g_value_set_double (value, private->height);
break;
case PROP_ANCHOR:
g_value_set_enum (value, private->anchor);
break;
case PROP_CORNER_WIDTH:
g_value_set_int (value, private->corner_width);
break;
case PROP_CORNER_HEIGHT:
g_value_set_int (value, private->corner_height);
break;
case PROP_OUTSIDE:
g_value_set_boolean (value, private->outside);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_corner_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
gdouble *x,
gdouble *y,
gdouble *w,
gdouble *h)
{
GimpCanvasCornerPrivate *private = GET_PRIVATE (item);
gdouble rx, ry;
gdouble rw, rh;
gint top_and_bottom_handle_x_offset;
gint left_and_right_handle_y_offset;
gimp_display_shell_transform_xy_f (shell,
MIN (private->x,
private->x + private->width),
MIN (private->y,
private->y + private->height),
&rx, &ry);
gimp_display_shell_transform_xy_f (shell,
MAX (private->x,
private->x + private->width),
MAX (private->y,
private->y + private->height),
&rw, &rh);
rw -= rx;
rh -= ry;
rx = PROJ_ROUND (rx) + 0.5;
ry = PROJ_ROUND (ry) + 0.5;
rw = PROJ_ROUND (rw) - 1.0;
rh = PROJ_ROUND (rh) - 1.0;
top_and_bottom_handle_x_offset = (rw - private->corner_width) / 2;
left_and_right_handle_y_offset = (rh - private->corner_height) / 2;
*w = private->corner_width;
*h = private->corner_height;
switch (private->anchor)
{
case GTK_ANCHOR_CENTER:
break;
case GTK_ANCHOR_NORTH_WEST:
if (private->outside)
{
*x = rx - private->corner_width;
*y = ry - private->corner_height;
}
else
{
*x = rx;
*y = ry;
}
break;
case GTK_ANCHOR_NORTH_EAST:
if (private->outside)
{
*x = rx + rw;
*y = ry - private->corner_height;
}
else
{
*x = rx + rw - private->corner_width;
*y = ry;
}
break;
case GTK_ANCHOR_SOUTH_WEST:
if (private->outside)
{
*x = rx - private->corner_width;
*y = ry + rh;
}
else
{
*x = rx;
*y = ry + rh - private->corner_height;
}
break;
case GTK_ANCHOR_SOUTH_EAST:
if (private->outside)
{
*x = rx + rw;
*y = ry + rh;
}
else
{
*x = rx + rw - private->corner_width;
*y = ry + rh - private->corner_height;
}
break;
case GTK_ANCHOR_NORTH:
if (private->outside)
{
*x = rx;
*y = ry - private->corner_height;
*w = rw;
}
else
{
*x = rx + top_and_bottom_handle_x_offset;
*y = ry;
}
break;
case GTK_ANCHOR_SOUTH:
if (private->outside)
{
*x = rx;
*y = ry + rh;
*w = rw;
}
else
{
*x = rx + top_and_bottom_handle_x_offset;
*y = ry + rh - private->corner_height;
}
break;
case GTK_ANCHOR_WEST:
if (private->outside)
{
*x = rx - private->corner_width;
*y = ry;
*h = rh;
}
else
{
*x = rx;
*y = ry + left_and_right_handle_y_offset;
}
break;
case GTK_ANCHOR_EAST:
if (private->outside)
{
*x = rx + rw;
*y = ry;
*h = rh;
}
else
{
*x = rx + rw - private->corner_width;
*y = ry + left_and_right_handle_y_offset;
}
break;
}
}
static void
gimp_canvas_corner_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
gdouble x, y;
gdouble w, h;
gimp_canvas_corner_transform (item, shell, &x, &y, &w, &h);
cairo_rectangle (cr, x, y, w, h);
_gimp_canvas_item_stroke (item, shell, cr);
}
static GdkRegion *
gimp_canvas_corner_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GdkRectangle rectangle;
gdouble x, y;
gdouble w, h;
gimp_canvas_corner_transform (item, shell, &x, &y, &w, &h);
rectangle.x = floor (x - 1.5);
rectangle.y = floor (y - 1.5);
rectangle.width = ceil (w + 3.0);
rectangle.height = ceil (h + 3.0);
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_corner_new (gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkAnchorType anchor,
gint corner_width,
gint corner_height,
gboolean outside)
{
return g_object_new (GIMP_TYPE_CANVAS_CORNER,
"x", x,
"y", y,
"width", width,
"height", height,
"anchor", anchor,
"corner-width", corner_width,
"corner-height", corner_height,
"outside", outside,
NULL);
}

View File

@ -0,0 +1,62 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvascorner.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_CORNER_H__
#define __GIMP_CANVAS_CORNER_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_CORNER (gimp_canvas_corner_get_type ())
#define GIMP_CANVAS_CORNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_CORNER, GimpCanvasCorner))
#define GIMP_CANVAS_CORNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_CORNER, GimpCanvasCornerClass))
#define GIMP_IS_CANVAS_CORNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_CORNER))
#define GIMP_IS_CANVAS_CORNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_CORNER))
#define GIMP_CANVAS_CORNER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_CORNER, GimpCanvasCornerClass))
typedef struct _GimpCanvasCorner GimpCanvasCorner;
typedef struct _GimpCanvasCornerClass GimpCanvasCornerClass;
struct _GimpCanvasCorner
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasCornerClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_corner_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_corner_new (gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkAnchorType anchor,
gint corner_width,
gint corner_height,
gboolean outside);
#endif /* __GIMP_CANVAS_CORNER_H__ */

View File

@ -0,0 +1,259 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasgroup.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "gimpcanvasgroup.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_GROUP_STROKING
};
typedef struct _GimpCanvasGroupPrivate GimpCanvasGroupPrivate;
struct _GimpCanvasGroupPrivate
{
GList *items;
gboolean group_stroking;
};
#define GET_PRIVATE(group) \
G_TYPE_INSTANCE_GET_PRIVATE (group, \
GIMP_TYPE_CANVAS_GROUP, \
GimpCanvasGroupPrivate)
/* local function prototypes */
static void gimp_canvas_group_dispose (GObject *object);
static void gimp_canvas_group_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_group_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_group_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_group_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasGroup, gimp_canvas_group, GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_group_parent_class
static void
gimp_canvas_group_class_init (GimpCanvasGroupClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->dispose = gimp_canvas_group_dispose;
object_class->set_property = gimp_canvas_group_set_property;
object_class->get_property = gimp_canvas_group_get_property;
item_class->draw = gimp_canvas_group_draw;
item_class->get_extents = gimp_canvas_group_get_extents;
g_object_class_install_property (object_class, PROP_GROUP_STROKING,
g_param_spec_boolean ("group-stroking",
NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasGroupPrivate));
}
static void
gimp_canvas_group_init (GimpCanvasGroup *group)
{
}
static void
gimp_canvas_group_dispose (GObject *object)
{
GimpCanvasGroupPrivate *private = GET_PRIVATE (object);
if (private->items)
{
g_list_foreach (private->items, (GFunc) g_object_unref, NULL);
g_list_free (private->items);
private->items = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_canvas_group_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasGroupPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_GROUP_STROKING:
private->group_stroking = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_group_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasGroupPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_GROUP_STROKING:
g_value_set_boolean (value, private->group_stroking);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_group_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasGroupPrivate *private = GET_PRIVATE (item);
GList *list;
for (list = private->items; list; list = g_list_next (list))
{
GimpCanvasItem *sub_item = list->data;
gimp_canvas_item_draw (sub_item, shell, cr);
}
if (private->group_stroking)
_gimp_canvas_item_stroke (item, shell, cr);
}
static GdkRegion *
gimp_canvas_group_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GimpCanvasGroupPrivate *private = GET_PRIVATE (item);
GdkRegion *region = NULL;
GList *list;
for (list = private->items; list; list = g_list_next (list))
{
GimpCanvasItem *sub_item = list->data;
GdkRegion *sub_region = gimp_canvas_item_get_extents (sub_item,
shell);
if (region)
{
gdk_region_union (region, sub_region);
gdk_region_destroy (sub_region);
}
else
{
region = sub_region;
}
}
return region;
}
GimpCanvasItem *
gimp_canvas_group_new (void)
{
return g_object_new (GIMP_TYPE_CANVAS_GROUP, NULL);
}
void
gimp_canvas_group_add_item (GimpCanvasGroup *group,
GimpCanvasItem *item)
{
GimpCanvasGroupPrivate *private;
g_return_if_fail (GIMP_IS_CANVAS_GROUP (group));
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
g_return_if_fail (GIMP_CANVAS_ITEM (group) != item);
private = GET_PRIVATE (group);
if (private->group_stroking)
gimp_canvas_item_suspend_stroking (item);
private->items = g_list_append (private->items, g_object_ref (item));
}
void
gimp_canvas_group_remove_item (GimpCanvasGroup *group,
GimpCanvasItem *item)
{
GimpCanvasGroupPrivate *private;
g_return_if_fail (GIMP_IS_CANVAS_GROUP (group));
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
private = GET_PRIVATE (group);
g_return_if_fail (g_list_find (private->items, item));
private->items = g_list_remove (private->items, item);
g_object_unref (item);
}
void
gimp_canvas_group_set_group_stroking (GimpCanvasGroup *group,
gboolean group_stroking)
{
g_return_if_fail (GIMP_IS_CANVAS_GROUP (group));
g_object_set (group,
"group-stroking", group_stroking ? TRUE : FALSE,
NULL);
}

View File

@ -0,0 +1,62 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasgroup.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_GROUP_H__
#define __GIMP_CANVAS_GROUP_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_GROUP (gimp_canvas_group_get_type ())
#define GIMP_CANVAS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_GROUP, GimpCanvasGroup))
#define GIMP_CANVAS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_GROUP, GimpCanvasGroupClass))
#define GIMP_IS_CANVAS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_GROUP))
#define GIMP_IS_CANVAS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_GROUP))
#define GIMP_CANVAS_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_GROUP, GimpCanvasGroupClass))
typedef struct _GimpCanvasGroupClass GimpCanvasGroupClass;
struct _GimpCanvasGroup
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasGroupClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_group_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_group_new (void);
void gimp_canvas_group_add_item (GimpCanvasGroup *group,
GimpCanvasItem *item);
void gimp_canvas_group_remove_item (GimpCanvasGroup *group,
GimpCanvasItem *item);
void gimp_canvas_group_set_group_stroking (GimpCanvasGroup *group,
gboolean group_stroking);
#endif /* __GIMP_CANVAS_GROUP_H__ */

View File

@ -0,0 +1,236 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasguide.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "gimpcanvasguide.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_ORIENTATION,
PROP_POSITION
};
typedef struct _GimpCanvasGuidePrivate GimpCanvasGuidePrivate;
struct _GimpCanvasGuidePrivate
{
GimpOrientationType orientation;
gint position;
};
#define GET_PRIVATE(guide) \
G_TYPE_INSTANCE_GET_PRIVATE (guide, \
GIMP_TYPE_CANVAS_GUIDE, \
GimpCanvasGuidePrivate)
/* local function prototypes */
static void gimp_canvas_guide_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_guide_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_guide_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_guide_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasGuide, gimp_canvas_guide, GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_guide_parent_class
static void
gimp_canvas_guide_class_init (GimpCanvasGuideClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->set_property = gimp_canvas_guide_set_property;
object_class->get_property = gimp_canvas_guide_get_property;
item_class->draw = gimp_canvas_guide_draw;
item_class->get_extents = gimp_canvas_guide_get_extents;
g_object_class_install_property (object_class, PROP_ORIENTATION,
g_param_spec_enum ("orientation", NULL, NULL,
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_POSITION,
g_param_spec_int ("position", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasGuidePrivate));
}
static void
gimp_canvas_guide_init (GimpCanvasGuide *guide)
{
}
static void
gimp_canvas_guide_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasGuidePrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_ORIENTATION:
private->orientation = g_value_get_enum (value);
break;
case PROP_POSITION:
private->position = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_guide_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasGuidePrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_ORIENTATION:
g_value_set_enum (value, private->orientation);
break;
case PROP_POSITION:
g_value_set_int (value, private->position);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_guide_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
gdouble *x1,
gdouble *y1,
gdouble *x2,
gdouble *y2)
{
GimpCanvasGuidePrivate *private = GET_PRIVATE (item);
GtkAllocation allocation;
gint x, y;
gtk_widget_get_allocation (shell->canvas, &allocation);
*x1 = 0;
*y1 = 0;
*x2 = allocation.width;
*y2 = allocation.height;
switch (private->orientation)
{
case GIMP_ORIENTATION_HORIZONTAL:
gimp_display_shell_transform_xy (shell, 0, private->position, &x, &y);
*y1 = *y2 = y + 0.5;
break;
case GIMP_ORIENTATION_VERTICAL:
gimp_display_shell_transform_xy (shell, private->position, 0, &x, &y);
*x1 = *x2 = x + 0.5;
break;
case GIMP_ORIENTATION_UNKNOWN:
return;
}
}
static void
gimp_canvas_guide_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
gdouble x1, y1;
gdouble x2, y2;
gimp_canvas_guide_transform (item, shell, &x1, &y1, &x2, &y2);
cairo_move_to (cr, x1, y1);
cairo_line_to (cr, x2, y2);
_gimp_canvas_item_stroke (item, shell, cr);
}
static GdkRegion *
gimp_canvas_guide_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GdkRectangle rectangle;
gdouble x1, y1;
gdouble x2, y2;
gimp_canvas_guide_transform (item, shell, &x1, &y1, &x2, &y2);
rectangle.x = MIN (x1, x2) - 1.5;
rectangle.y = MIN (y1, y2) - 1.5;
rectangle.width = ABS (x2 - x1) + 3.0;
rectangle.height = ABS (y2 - y1) + 3.0;
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_guide_new (GimpOrientationType orientation,
gint position)
{
return g_object_new (GIMP_TYPE_CANVAS_GUIDE,
"orientation", orientation,
"position", position,
NULL);
}

View File

@ -0,0 +1,56 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasguide.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_GUIDE_H__
#define __GIMP_CANVAS_GUIDE_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_GUIDE (gimp_canvas_guide_get_type ())
#define GIMP_CANVAS_GUIDE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_GUIDE, GimpCanvasGuide))
#define GIMP_CANVAS_GUIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_GUIDE, GimpCanvasGuideClass))
#define GIMP_IS_CANVAS_GUIDE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_GUIDE))
#define GIMP_IS_CANVAS_GUIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_GUIDE))
#define GIMP_CANVAS_GUIDE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_GUIDE, GimpCanvasGuideClass))
typedef struct _GimpCanvasGuide GimpCanvasGuide;
typedef struct _GimpCanvasGuideClass GimpCanvasGuideClass;
struct _GimpCanvasGuide
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasGuideClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_guide_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_guide_new (GimpOrientationType orientation,
gint position);
#endif /* __GIMP_CANVAS_GUIDE_H__ */

View File

@ -0,0 +1,535 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvashandle.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "widgets/gimpcairo.h"
#include "gimpcanvashandle.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_TYPE,
PROP_ANCHOR,
PROP_X,
PROP_Y,
PROP_WIDTH,
PROP_HEIGHT,
PROP_START_ANGLE,
PROP_SLICE_ANGLE
};
typedef struct _GimpCanvasHandlePrivate GimpCanvasHandlePrivate;
struct _GimpCanvasHandlePrivate
{
GimpHandleType type;
GtkAnchorType anchor;
gdouble x;
gdouble y;
gint width;
gint height;
gdouble start_angle;
gdouble slice_angle;;
};
#define GET_PRIVATE(handle) \
G_TYPE_INSTANCE_GET_PRIVATE (handle, \
GIMP_TYPE_CANVAS_HANDLE, \
GimpCanvasHandlePrivate)
/* local function prototypes */
static void gimp_canvas_handle_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_handle_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_handle_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_handle_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasHandle, gimp_canvas_handle,
GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_handle_parent_class
static void
gimp_canvas_handle_class_init (GimpCanvasHandleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->set_property = gimp_canvas_handle_set_property;
object_class->get_property = gimp_canvas_handle_get_property;
item_class->draw = gimp_canvas_handle_draw;
item_class->get_extents = gimp_canvas_handle_get_extents;
g_object_class_install_property (object_class, PROP_TYPE,
g_param_spec_enum ("type", NULL, NULL,
GIMP_TYPE_HANDLE_TYPE,
GIMP_HANDLE_CROSS,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_ANCHOR,
g_param_spec_enum ("anchor", NULL, NULL,
GTK_TYPE_ANCHOR_TYPE,
GTK_ANCHOR_CENTER,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_X,
g_param_spec_double ("x", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_Y,
g_param_spec_double ("y", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_WIDTH,
g_param_spec_int ("width", NULL, NULL,
3, 1001, 7,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_HEIGHT,
g_param_spec_int ("height", NULL, NULL,
3, 1001, 7,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_START_ANGLE,
g_param_spec_double ("start-angle", NULL, NULL,
-1000, 1000, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SLICE_ANGLE,
g_param_spec_double ("slice-angle", NULL, NULL,
-1000, 1000, 2 * G_PI,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasHandlePrivate));
}
static void
gimp_canvas_handle_init (GimpCanvasHandle *handle)
{
GimpCanvasHandlePrivate *private = GET_PRIVATE (handle);
gimp_canvas_item_set_line_cap (GIMP_CANVAS_ITEM (handle),
CAIRO_LINE_CAP_SQUARE);
private->start_angle = 0.0;
private->slice_angle = 2.0 * G_PI;
}
static void
gimp_canvas_handle_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasHandlePrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_TYPE:
private->type = g_value_get_enum (value);
break;
case PROP_ANCHOR:
private->anchor = g_value_get_enum (value);
break;
case PROP_X:
private->x = g_value_get_double (value);
break;
case PROP_Y:
private->y = g_value_get_double (value);
break;
case PROP_WIDTH:
private->width = g_value_get_int (value);
break;
case PROP_HEIGHT:
private->height = g_value_get_int (value);
break;
case PROP_START_ANGLE:
private->start_angle = g_value_get_double (value);
break;
case PROP_SLICE_ANGLE:
private->slice_angle = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_handle_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasHandlePrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_TYPE:
g_value_set_enum (value, private->type);
break;
case PROP_ANCHOR:
g_value_set_enum (value, private->anchor);
break;
case PROP_X:
g_value_set_double (value, private->x);
break;
case PROP_Y:
g_value_set_double (value, private->y);
break;
case PROP_WIDTH:
g_value_set_int (value, private->width);
break;
case PROP_HEIGHT:
g_value_set_int (value, private->height);
break;
case PROP_START_ANGLE:
g_value_set_double (value, private->start_angle);
break;
case PROP_SLICE_ANGLE:
g_value_set_double (value, private->slice_angle);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static inline void
gimp_canvas_handle_shift_to_north_west (GtkAnchorType anchor,
gdouble x,
gdouble y,
gint handle_width,
gint handle_height,
gdouble *shifted_x,
gdouble *shifted_y)
{
switch (anchor)
{
case GTK_ANCHOR_CENTER:
x -= handle_width / 2;
y -= handle_height / 2;
break;
case GTK_ANCHOR_NORTH:
x -= handle_width / 2;
break;
case GTK_ANCHOR_NORTH_WEST:
/* nothing, this is the default */
break;
case GTK_ANCHOR_NORTH_EAST:
x -= handle_width;
break;
case GTK_ANCHOR_SOUTH:
x -= handle_width / 2;
y -= handle_height;
break;
case GTK_ANCHOR_SOUTH_WEST:
y -= handle_height;
break;
case GTK_ANCHOR_SOUTH_EAST:
x -= handle_width;
y -= handle_height;
break;
case GTK_ANCHOR_WEST:
y -= handle_height / 2;
break;
case GTK_ANCHOR_EAST:
x -= handle_width;
y -= handle_height / 2;
break;
default:
break;
}
if (shifted_x)
*shifted_x = x;
if (shifted_y)
*shifted_y = y;
}
static inline void
gimp_canvas_handle_shift_to_center (GtkAnchorType anchor,
gdouble x,
gdouble y,
gint width,
gint height,
gdouble *shifted_x,
gdouble *shifted_y)
{
switch (anchor)
{
case GTK_ANCHOR_CENTER:
/* nothing, this is the default */
break;
case GTK_ANCHOR_NORTH:
y += height / 2;
break;
case GTK_ANCHOR_NORTH_WEST:
x += width / 2;
y += height / 2;
break;
case GTK_ANCHOR_NORTH_EAST:
x -= width / 2;
y += height / 2;
break;
case GTK_ANCHOR_SOUTH:
y -= height / 2;
break;
case GTK_ANCHOR_SOUTH_WEST:
x += width / 2;
y -= height / 2;
break;
case GTK_ANCHOR_SOUTH_EAST:
x -= width / 2;
y -= height / 2;
break;
case GTK_ANCHOR_WEST:
x += width / 2;
break;
case GTK_ANCHOR_EAST:
x -= width / 2;
break;
default:
break;
}
if (shifted_x)
*shifted_x = x;
if (shifted_y)
*shifted_y = y;
}
static void
gimp_canvas_handle_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
gdouble *x,
gdouble *y)
{
GimpCanvasHandlePrivate *private = GET_PRIVATE (item);
gimp_display_shell_transform_xy_f (shell,
private->x, private->y,
x, y);
switch (private->type)
{
case GIMP_HANDLE_SQUARE:
case GIMP_HANDLE_FILLED_SQUARE:
gimp_canvas_handle_shift_to_north_west (private->anchor,
*x, *y,
private->width,
private->height,
x, y);
break;
case GIMP_HANDLE_CIRCLE:
case GIMP_HANDLE_FILLED_CIRCLE:
case GIMP_HANDLE_CROSS:
gimp_canvas_handle_shift_to_center (private->anchor,
*x, *y,
private->width,
private->height,
x, y);
break;
default:
break;
}
*x = PROJ_ROUND (*x) + 0.5;
*y = PROJ_ROUND (*y) + 0.5;
}
static void
gimp_canvas_handle_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasHandlePrivate *private = GET_PRIVATE (item);
gdouble x, y;
gimp_canvas_handle_transform (item, shell, &x, &y);
switch (private->type)
{
case GIMP_HANDLE_SQUARE:
cairo_rectangle (cr, x, y, private->width - 1.0, private->height - 1.0);
_gimp_canvas_item_stroke (item, shell, cr);
break;
case GIMP_HANDLE_FILLED_SQUARE:
cairo_rectangle (cr, x - 0.5, y - 0.5, private->width, private->height);
_gimp_canvas_item_fill (item, shell, cr);
break;
case GIMP_HANDLE_CIRCLE:
gimp_cairo_add_arc (cr, x, y, private->width / 2,
private->start_angle,
private->slice_angle);
_gimp_canvas_item_stroke (item, shell, cr);
break;
case GIMP_HANDLE_FILLED_CIRCLE:
cairo_move_to (cr, x, y);
gimp_cairo_add_arc (cr, x, y, (gdouble) private->width / 2.0,
private->start_angle,
private->slice_angle);
_gimp_canvas_item_fill (item, shell, cr);
break;
case GIMP_HANDLE_CROSS:
cairo_move_to (cr, x - private->width / 2, y);
cairo_line_to (cr, x + private->width / 2, y);
cairo_move_to (cr, x, y - private->height / 2);
cairo_line_to (cr, x, y + private->height / 2);
_gimp_canvas_item_stroke (item, shell, cr);
break;
default:
break;
}
}
static GdkRegion *
gimp_canvas_handle_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GimpCanvasHandlePrivate *private = GET_PRIVATE (item);
GdkRectangle rectangle;
gdouble x, y;
gimp_canvas_handle_transform (item, shell, &x, &y);
switch (private->type)
{
case GIMP_HANDLE_SQUARE:
case GIMP_HANDLE_FILLED_SQUARE:
rectangle.x = x - 1.5;
rectangle.y = y - 1.5;
rectangle.width = private->width + 3.0;
rectangle.height = private->height + 3.0;
break;
case GIMP_HANDLE_CIRCLE:
case GIMP_HANDLE_FILLED_CIRCLE:
case GIMP_HANDLE_CROSS:
rectangle.x = x - private->width / 2 - 1.5;
rectangle.y = y - private->height / 2 - 1.5;
rectangle.width = private->width + 3.0;
rectangle.height = private->height + 3.0;
break;
default:
break;
}
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_handle_new (GimpHandleType type,
GtkAnchorType anchor,
gdouble x,
gdouble y,
gint width,
gint height)
{
return g_object_new (GIMP_TYPE_CANVAS_HANDLE,
"type", type,
"anchor", anchor,
"x", x,
"y", y,
"width", width,
"height", height,
NULL);
}
void
gimp_canvas_handle_set_angles (GimpCanvasHandle *handle,
gdouble start_angle,
gdouble slice_angle)
{
g_return_if_fail (GIMP_IS_CANVAS_HANDLE (handle));
g_object_set (handle,
"start-angle", start_angle,
"slice-angle", slice_angle,
NULL);
}

View File

@ -0,0 +1,63 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvashandle.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_HANDLE_H__
#define __GIMP_CANVAS_HANDLE_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_HANDLE (gimp_canvas_handle_get_type ())
#define GIMP_CANVAS_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_HANDLE, GimpCanvasHandle))
#define GIMP_CANVAS_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_HANDLE, GimpCanvasHandleClass))
#define GIMP_IS_CANVAS_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_HANDLE))
#define GIMP_IS_CANVAS_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_HANDLE))
#define GIMP_CANVAS_HANDLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_HANDLE, GimpCanvasHandleClass))
typedef struct _GimpCanvasHandle GimpCanvasHandle;
typedef struct _GimpCanvasHandleClass GimpCanvasHandleClass;
struct _GimpCanvasHandle
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasHandleClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_handle_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_handle_new (GimpHandleType type,
GtkAnchorType anchor,
gdouble x,
gdouble y,
gint width,
gint height);
void gimp_canvas_handle_set_angles (GimpCanvasHandle *handle,
gdouble start_handle,
gdouble slice_handle);
#endif /* __GIMP_CANVAS_HANDLE_H__ */

View File

@ -0,0 +1,300 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasitem.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"
#include "libgimpmath/gimpmath.h"
#include "gimpcanvasitem.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-style.h"
enum
{
PROP_0,
PROP_LINE_CAP,
PROP_HIGHLIGHT
};
typedef struct _GimpCanvasItemPrivate GimpCanvasItemPrivate;
struct _GimpCanvasItemPrivate
{
cairo_line_cap_t line_cap;
gboolean highlight;
gint suspend_stroking;
};
#define GET_PRIVATE(item) \
G_TYPE_INSTANCE_GET_PRIVATE (item, \
GIMP_TYPE_CANVAS_ITEM, \
GimpCanvasItemPrivate)
/* local function prototypes */
static void gimp_canvas_item_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_item_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_item_real_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_item_real_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasItem, gimp_canvas_item,
GIMP_TYPE_OBJECT)
#define parent_class gimp_canvas_item_parent_class
static void
gimp_canvas_item_class_init (GimpCanvasItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_canvas_item_set_property;
object_class->get_property = gimp_canvas_item_get_property;
klass->draw = gimp_canvas_item_real_draw;
klass->get_extents = gimp_canvas_item_real_get_extents;
g_object_class_install_property (object_class, PROP_LINE_CAP,
g_param_spec_int ("line-cap",
NULL, NULL,
CAIRO_LINE_CAP_BUTT,
CAIRO_LINE_CAP_SQUARE,
CAIRO_LINE_CAP_ROUND,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_HIGHLIGHT,
g_param_spec_boolean ("highlight",
NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasItemPrivate));
}
static void
gimp_canvas_item_init (GimpCanvasItem *item)
{
GimpCanvasItemPrivate *private = GET_PRIVATE (item);
private->line_cap = CAIRO_LINE_CAP_ROUND;
private->highlight = FALSE;
private->suspend_stroking = 0;
}
static void
gimp_canvas_item_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasItemPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_LINE_CAP:
private->line_cap = g_value_get_int (value);
break;
case PROP_HIGHLIGHT:
private->highlight = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_item_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasItemPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_LINE_CAP:
g_value_set_int (value, private->line_cap);
break;
case PROP_HIGHLIGHT:
g_value_set_boolean (value, private->highlight);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_item_real_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
g_warn_if_reached ();
}
static GdkRegion *
gimp_canvas_item_real_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
return NULL;
}
/* public functions */
void
gimp_canvas_item_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL);
cairo_save (cr);
GIMP_CANVAS_ITEM_GET_CLASS (item)->draw (item, shell, cr);
cairo_restore (cr);
}
GdkRegion *
gimp_canvas_item_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
g_return_val_if_fail (GIMP_IS_CANVAS_ITEM (item), NULL);
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
return GIMP_CANVAS_ITEM_GET_CLASS (item)->get_extents (item, shell);
}
void
gimp_canvas_item_set_line_cap (GimpCanvasItem *item,
cairo_line_cap_t line_cap)
{
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
g_object_set (item,
"line-cap", line_cap,
NULL);
}
void
gimp_canvas_item_set_highlight (GimpCanvasItem *item,
gboolean highlight)
{
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
g_object_set (item,
"highlight", highlight,
NULL);
}
void
gimp_canvas_item_suspend_stroking (GimpCanvasItem *item)
{
GimpCanvasItemPrivate *private;
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
private = GET_PRIVATE (item);
private->suspend_stroking++;
}
void
gimp_canvas_item_resume_stroking (GimpCanvasItem *item)
{
GimpCanvasItemPrivate *private;
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
private = GET_PRIVATE (item);
g_return_if_fail (private->suspend_stroking > 0);
private->suspend_stroking--;
}
/* protected functions */
void
_gimp_canvas_item_stroke (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasItemPrivate *private = GET_PRIVATE (item);
if (private->suspend_stroking == 0)
{
cairo_set_line_cap (cr, private->line_cap);
gimp_display_shell_set_tool_bg_style (shell, cr);
cairo_stroke_preserve (cr);
gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
cairo_stroke (cr);
}
else
{
cairo_new_sub_path (cr);
}
}
void
_gimp_canvas_item_fill (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasItemPrivate *private = GET_PRIVATE (item);
if (private->suspend_stroking > 0)
g_warning ("_gimp_canvas_item_fill() on an item that is in a stroking group");
gimp_display_shell_set_tool_bg_style (shell, cr);
cairo_set_line_width (cr, 2.0);
cairo_stroke_preserve (cr);
gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
cairo_fill (cr);
}

View File

@ -0,0 +1,82 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasitem.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_ITEM_H__
#define __GIMP_CANVAS_ITEM_H__
#include "core/gimpobject.h"
#define GIMP_TYPE_CANVAS_ITEM (gimp_canvas_item_get_type ())
#define GIMP_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_ITEM, GimpCanvasItem))
#define GIMP_CANVAS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_ITEM, GimpCanvasItemClass))
#define GIMP_IS_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_ITEM))
#define GIMP_IS_CANVAS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_ITEM))
#define GIMP_CANVAS_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_ITEM, GimpCanvasItemClass))
typedef struct _GimpCanvasItemClass GimpCanvasItemClass;
struct _GimpCanvasItem
{
GimpObject parent_instance;
};
struct _GimpCanvasItemClass
{
GimpObjectClass parent_class;
void (* draw) (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
GdkRegion * (* get_extents) (GimpCanvasItem *item,
GimpDisplayShell *shell);
};
GType gimp_canvas_item_get_type (void) G_GNUC_CONST;
void gimp_canvas_item_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
GdkRegion * gimp_canvas_item_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
void gimp_canvas_item_set_line_cap (GimpCanvasItem *item,
cairo_line_cap_t line_cap);
void gimp_canvas_item_set_highlight (GimpCanvasItem *item,
gboolean highlight);
void gimp_canvas_item_suspend_stroking (GimpCanvasItem *item);
void gimp_canvas_item_resume_stroking (GimpCanvasItem *item);
/* protected */
void _gimp_canvas_item_stroke (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
void _gimp_canvas_item_fill (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
#endif /* __GIMP_CANVAS_ITEM_H__ */

View File

@ -0,0 +1,265 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasline.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "gimpcanvasline.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_X1,
PROP_Y1,
PROP_X2,
PROP_Y2
};
typedef struct _GimpCanvasLinePrivate GimpCanvasLinePrivate;
struct _GimpCanvasLinePrivate
{
gdouble x1;
gdouble y1;
gdouble x2;
gdouble y2;
};
#define GET_PRIVATE(line) \
G_TYPE_INSTANCE_GET_PRIVATE (line, \
GIMP_TYPE_CANVAS_LINE, \
GimpCanvasLinePrivate)
/* local function prototypes */
static void gimp_canvas_line_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_line_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_line_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_line_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasLine, gimp_canvas_line, GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_line_parent_class
static void
gimp_canvas_line_class_init (GimpCanvasLineClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->set_property = gimp_canvas_line_set_property;
object_class->get_property = gimp_canvas_line_get_property;
item_class->draw = gimp_canvas_line_draw;
item_class->get_extents = gimp_canvas_line_get_extents;
g_object_class_install_property (object_class, PROP_X1,
g_param_spec_double ("x1", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_Y1,
g_param_spec_double ("y1", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_X2,
g_param_spec_double ("x2", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_Y2,
g_param_spec_double ("y2", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasLinePrivate));
}
static void
gimp_canvas_line_init (GimpCanvasLine *line)
{
}
static void
gimp_canvas_line_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasLinePrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_X1:
private->x1 = g_value_get_double (value);
break;
case PROP_Y1:
private->y1 = g_value_get_double (value);
break;
case PROP_X2:
private->x2 = g_value_get_double (value);
break;
case PROP_Y2:
private->y2 = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_line_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasLinePrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_X1:
g_value_set_double (value, private->x1);
break;
case PROP_Y1:
g_value_set_double (value, private->y1);
break;
case PROP_X2:
g_value_set_double (value, private->x2);
break;
case PROP_Y2:
g_value_set_double (value, private->y2);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_line_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
gdouble *x1,
gdouble *y1,
gdouble *x2,
gdouble *y2)
{
GimpCanvasLinePrivate *private = GET_PRIVATE (item);
gimp_display_shell_transform_xy_f (shell,
private->x1, private->y1,
x1, y1);
gimp_display_shell_transform_xy_f (shell,
private->x2, private->y2,
x2, y2);
*x1 = PROJ_ROUND (*x1) + 0.5;
*y1 = PROJ_ROUND (*y1) + 0.5;
*x2 = PROJ_ROUND (*x2) + 0.5;
*y2 = PROJ_ROUND (*y2) + 0.5;
}
static void
gimp_canvas_line_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
gdouble x1, y1;
gdouble x2, y2;
gimp_canvas_line_transform (item, shell, &x1, &y1, &x2, &y2);
cairo_move_to (cr, x1, y1);
cairo_line_to (cr, x2, y2);
_gimp_canvas_item_stroke (item, shell, cr);
}
static GdkRegion *
gimp_canvas_line_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GdkRectangle rectangle;
gdouble x1, y1;
gdouble x2, y2;
gimp_canvas_line_transform (item, shell, &x1, &y1, &x2, &y2);
if (x1 == x2 || y1 == y2)
{
rectangle.x = MIN (x1, x2) - 1.5;
rectangle.y = MIN (y1, y2) - 1.5;
rectangle.width = ABS (x2 - x1) + 3.0;
rectangle.height = ABS (y2 - y1) + 3.0;
}
else
{
rectangle.x = floor (MIN (x1, x2) - 2.5);
rectangle.y = floor (MIN (y1, y2) - 2.5);
rectangle.width = ceil (ABS (x2 - x1) + 5.0);
rectangle.height = ceil (ABS (y2 - y1) + 5.0);
}
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_line_new (gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2)
{
return g_object_new (GIMP_TYPE_CANVAS_LINE,
"x1", x1,
"y1", y1,
"x2", x2,
"y2", y2,
NULL);
}

View File

@ -0,0 +1,58 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasline.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_LINE_H__
#define __GIMP_CANVAS_LINE_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_LINE (gimp_canvas_line_get_type ())
#define GIMP_CANVAS_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_LINE, GimpCanvasLine))
#define GIMP_CANVAS_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_LINE, GimpCanvasLineClass))
#define GIMP_IS_CANVAS_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_LINE))
#define GIMP_IS_CANVAS_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_LINE))
#define GIMP_CANVAS_LINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_LINE, GimpCanvasLineClass))
typedef struct _GimpCanvasLine GimpCanvasLine;
typedef struct _GimpCanvasLineClass GimpCanvasLineClass;
struct _GimpCanvasLine
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasLineClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_line_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_line_new (gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
#endif /* __GIMP_CANVAS_LINE_H__ */

View File

@ -0,0 +1,310 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvaspolygon.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "core/gimpparamspecs.h"
#include "gimpcanvaspolygon.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_POINTS,
PROP_FILLED
};
typedef struct _GimpCanvasPolygonPrivate GimpCanvasPolygonPrivate;
struct _GimpCanvasPolygonPrivate
{
GimpVector2 *points;
gint n_points;
gboolean filled;
};
#define GET_PRIVATE(polygon) \
G_TYPE_INSTANCE_GET_PRIVATE (polygon, \
GIMP_TYPE_CANVAS_POLYGON, \
GimpCanvasPolygonPrivate)
/* local function prototypes */
static void gimp_canvas_polygon_finalize (GObject *object);
static void gimp_canvas_polygon_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_polygon_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_polygon_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_polygon_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasPolygon, gimp_canvas_polygon,
GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_polygon_parent_class
static void
gimp_canvas_polygon_class_init (GimpCanvasPolygonClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->finalize = gimp_canvas_polygon_finalize;
object_class->set_property = gimp_canvas_polygon_set_property;
object_class->get_property = gimp_canvas_polygon_get_property;
item_class->draw = gimp_canvas_polygon_draw;
item_class->get_extents = gimp_canvas_polygon_get_extents;
g_object_class_install_property (object_class, PROP_POINTS,
gimp_param_spec_array ("points", NULL, NULL,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_FILLED,
g_param_spec_boolean ("filled", NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasPolygonPrivate));
}
static void
gimp_canvas_polygon_init (GimpCanvasPolygon *polygon)
{
}
static void
gimp_canvas_polygon_finalize (GObject *object)
{
GimpCanvasPolygonPrivate *private = GET_PRIVATE (object);
if (private->points)
{
g_free (private->points);
private->points = NULL;
private->n_points = 0;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_canvas_polygon_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasPolygonPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_POINTS:
break;
case PROP_FILLED:
private->filled = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_polygon_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasPolygonPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_POINTS:
break;
case PROP_FILLED:
g_value_set_boolean (value, private->filled);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_polygon_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
GimpVector2 *points)
{
GimpCanvasPolygonPrivate *private = GET_PRIVATE (item);
gint i;
for (i = 0; i < private->n_points; i++)
{
gimp_display_shell_transform_xy_f (shell,
private->points[i].x,
private->points[i].y,
&points[i].x,
&points[i].y);
points[i].x = PROJ_ROUND (points[i].x) + 0.5;
points[i].y = PROJ_ROUND (points[i].y) + 0.5;
}
}
static void
gimp_canvas_polygon_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasPolygonPrivate *private = GET_PRIVATE (item);
GimpVector2 *points;
gint i;
points = g_new0 (GimpVector2, private->n_points);
gimp_canvas_polygon_transform (item, shell, points);
cairo_move_to (cr, points[0].x, points[0].y);
for (i = 1; i < private->n_points; i++)
{
cairo_line_to (cr, points[i].x, points[i].y);
}
if (private->filled)
_gimp_canvas_item_fill (item, shell, cr);
else
_gimp_canvas_item_stroke (item, shell, cr);
g_free (points);
}
static GdkRegion *
gimp_canvas_polygon_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GimpCanvasPolygonPrivate *private = GET_PRIVATE (item);
GdkRectangle rectangle;
GimpVector2 *points;
gint x1, y1, x2, y2;
gint i;
points = g_new0 (GimpVector2, private->n_points);
gimp_canvas_polygon_transform (item, shell, points);
x1 = floor (points[0].x - 1.5);
y1 = floor (points[0].y - 1.5);
x2 = x1 + 3;
y2 = y1 + 3;
for (i = 1; i < private->n_points; i++)
{
gint x3 = floor (points[i].x - 1.5);
gint y3 = floor (points[i].y - 1.5);
gint x4 = x3 + 3;
gint y4 = y3 + 3;
x1 = MIN (x1, x3);
y1 = MIN (y1, y3);
x2 = MAX (x2, x4);
y2 = MAX (y2, y4);
}
g_free (points);
rectangle.x = x1;
rectangle.y = y1;
rectangle.width = x2 - x1;
rectangle.height = y2 - y1;
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_polygon_new (const GimpVector2 *points,
gint n_points,
gboolean filled)
{
GimpCanvasItem *item;
GimpCanvasPolygonPrivate *private;
item = g_object_new (GIMP_TYPE_CANVAS_POLYGON,
"filled", filled,
NULL);
private = GET_PRIVATE (item);
/* puke */
private->points = g_memdup (points, n_points * sizeof (GimpVector2));
private->n_points = n_points;
return item;
}
GimpCanvasItem *
gimp_canvas_polygon_new_from_coords (const GimpCoords *points,
gint n_points,
gboolean filled)
{
GimpCanvasItem *item;
GimpCanvasPolygonPrivate *private;
gint i;
item = g_object_new (GIMP_TYPE_CANVAS_POLYGON,
"filled", filled,
NULL);
private = GET_PRIVATE (item);
/* puke */
private->points = g_new (GimpVector2, n_points);
private->n_points = n_points;
for (i = 0; i < n_points; i++)
{
private->points[i].x = points[i].x;
private->points[i].y = points[i].y;
}
return item;
}

View File

@ -0,0 +1,60 @@
/* GIMP - The GNU Image Manipulation Program Copyright (C) 1995
* Spencer Kimball and Peter Mattis
*
* gimpcanvaspolygon.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_POLYGON_H__
#define __GIMP_CANVAS_POLYGON_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_POLYGON (gimp_canvas_polygon_get_type ())
#define GIMP_CANVAS_POLYGON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_POLYGON, GimpCanvasPolygon))
#define GIMP_CANVAS_POLYGON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_POLYGON, GimpCanvasPolygonClass))
#define GIMP_IS_CANVAS_POLYGON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_POLYGON))
#define GIMP_IS_CANVAS_POLYGON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_POLYGON))
#define GIMP_CANVAS_POLYGON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_POLYGON, GimpCanvasPolygonClass))
typedef struct _GimpCanvasPolygon GimpCanvasPolygon;
typedef struct _GimpCanvasPolygonClass GimpCanvasPolygonClass;
struct _GimpCanvasPolygon
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasPolygonClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_polygon_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_polygon_new (const GimpVector2 *points,
gint n_points,
gboolean filled);
GimpCanvasItem * gimp_canvas_polygon_new_from_coords (const GimpCoords *points,
gint n_points,
gboolean filled);
#endif /* __GIMP_CANVAS_POLYGON_H__ */

View File

@ -0,0 +1,304 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasrectangle.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "gimpcanvasrectangle.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_X,
PROP_Y,
PROP_WIDTH,
PROP_HEIGHT,
PROP_FILLED
};
typedef struct _GimpCanvasRectanglePrivate GimpCanvasRectanglePrivate;
struct _GimpCanvasRectanglePrivate
{
gdouble x;
gdouble y;
gdouble width;
gdouble height;
gboolean filled;
};
#define GET_PRIVATE(rectangle) \
G_TYPE_INSTANCE_GET_PRIVATE (rectangle, \
GIMP_TYPE_CANVAS_RECTANGLE, \
GimpCanvasRectanglePrivate)
/* local function prototypes */
static void gimp_canvas_rectangle_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_rectangle_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_rectangle_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasRectangle, gimp_canvas_rectangle,
GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_rectangle_parent_class
static void
gimp_canvas_rectangle_class_init (GimpCanvasRectangleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->set_property = gimp_canvas_rectangle_set_property;
object_class->get_property = gimp_canvas_rectangle_get_property;
item_class->draw = gimp_canvas_rectangle_draw;
item_class->get_extents = gimp_canvas_rectangle_get_extents;
g_object_class_install_property (object_class, PROP_X,
g_param_spec_double ("x", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_Y,
g_param_spec_double ("y", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_WIDTH,
g_param_spec_double ("width", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_HEIGHT,
g_param_spec_double ("height", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_FILLED,
g_param_spec_boolean ("filled", NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasRectanglePrivate));
}
static void
gimp_canvas_rectangle_init (GimpCanvasRectangle *rectangle)
{
}
static void
gimp_canvas_rectangle_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasRectanglePrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_X:
private->x = g_value_get_double (value);
break;
case PROP_Y:
private->y = g_value_get_double (value);
break;
case PROP_WIDTH:
private->width = g_value_get_double (value);
break;
case PROP_HEIGHT:
private->height = g_value_get_double (value);
break;
case PROP_FILLED:
private->filled = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_rectangle_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasRectanglePrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_X:
g_value_set_double (value, private->x);
break;
case PROP_Y:
g_value_set_double (value, private->y);
break;
case PROP_WIDTH:
g_value_set_double (value, private->width);
break;
case PROP_HEIGHT:
g_value_set_double (value, private->height);
break;
case PROP_FILLED:
g_value_set_boolean (value, private->filled);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_rectangle_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
gdouble *x,
gdouble *y,
gdouble *w,
gdouble *h)
{
GimpCanvasRectanglePrivate *private = GET_PRIVATE (item);
gimp_display_shell_transform_xy_f (shell,
MIN (private->x,
private->x + private->width),
MIN (private->y,
private->y + private->height),
x, y);
gimp_display_shell_transform_xy_f (shell,
MAX (private->x,
private->x + private->width),
MAX (private->y,
private->y + private->height),
w, h);
*w -= *x;
*h -= *y;
if (private->filled)
{
*x = floor (*x);
*y = floor (*y);
*w = ceil (*w);
*h = ceil (*h);
}
else
{
*x = PROJ_ROUND (*x) + 0.5;
*y = PROJ_ROUND (*y) + 0.5;
*w = PROJ_ROUND (*w) - 1.0;
*h = PROJ_ROUND (*h) - 1.0;
}
}
static void
gimp_canvas_rectangle_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasRectanglePrivate *private = GET_PRIVATE (item);
gdouble x, y;
gdouble w, h;
gimp_canvas_rectangle_transform (item, shell, &x, &y, &w, &h);
cairo_rectangle (cr, x, y, w, h);
if (private->filled)
_gimp_canvas_item_fill (item, shell, cr);
else
_gimp_canvas_item_stroke (item, shell, cr);
}
static GdkRegion *
gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GimpCanvasRectanglePrivate *private = GET_PRIVATE (item);
GdkRectangle rectangle;
gdouble x, y;
gdouble w, h;
gimp_canvas_rectangle_transform (item, shell, &x, &y, &w, &h);
if (private->filled)
{
rectangle.x = floor (x);
rectangle.y = floor (y);
rectangle.width = ceil (w);
rectangle.height = ceil (h);
}
else
{
rectangle.x = floor (x - 1.5);
rectangle.y = floor (y - 1.5);
rectangle.width = ceil (w + 3.0);
rectangle.height = ceil (h + 3.0);
}
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_rectangle_new (gdouble x,
gdouble y,
gdouble width,
gdouble height,
gboolean filled)
{
return g_object_new (GIMP_TYPE_CANVAS_RECTANGLE,
"x", x,
"y", y,
"width", width,
"height", height,
"filled", filled,
NULL);
}

View File

@ -0,0 +1,59 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvasrectangle.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_RECTANGLE_H__
#define __GIMP_CANVAS_RECTANGLE_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_RECTANGLE (gimp_canvas_rectangle_get_type ())
#define GIMP_CANVAS_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_RECTANGLE, GimpCanvasRectangle))
#define GIMP_CANVAS_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_RECTANGLE, GimpCanvasRectangleClass))
#define GIMP_IS_CANVAS_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_RECTANGLE))
#define GIMP_IS_CANVAS_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_RECTANGLE))
#define GIMP_CANVAS_RECTANGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_RECTANGLE, GimpCanvasRectangleClass))
typedef struct _GimpCanvasRectangle GimpCanvasRectangle;
typedef struct _GimpCanvasRectangleClass GimpCanvasRectangleClass;
struct _GimpCanvasRectangle
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasRectangleClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_rectangle_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_rectangle_new (gdouble x,
gdouble y,
gdouble width,
gdouble height,
gboolean filled);
#endif /* __GIMP_CANVAS_RECTANGLE_H__ */

View File

@ -0,0 +1,307 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvastextcursor.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "gimpcanvastextcursor.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
enum
{
PROP_0,
PROP_X,
PROP_Y,
PROP_WIDTH,
PROP_HEIGHT,
PROP_OVERWRITE
};
typedef struct _GimpCanvasTextCursorPrivate GimpCanvasTextCursorPrivate;
struct _GimpCanvasTextCursorPrivate
{
gint x;
gint y;
gint width;
gint height;
gboolean overwrite;
};
#define GET_PRIVATE(text_cursor) \
G_TYPE_INSTANCE_GET_PRIVATE (text_cursor, \
GIMP_TYPE_CANVAS_TEXT_CURSOR, \
GimpCanvasTextCursorPrivate)
/* local function prototypes */
static void gimp_canvas_text_cursor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_text_cursor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_text_cursor_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr);
static GdkRegion * gimp_canvas_text_cursor_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasTextCursor, gimp_canvas_text_cursor,
GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_text_cursor_parent_class
static void
gimp_canvas_text_cursor_class_init (GimpCanvasTextCursorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->set_property = gimp_canvas_text_cursor_set_property;
object_class->get_property = gimp_canvas_text_cursor_get_property;
item_class->draw = gimp_canvas_text_cursor_draw;
item_class->get_extents = gimp_canvas_text_cursor_get_extents;
g_object_class_install_property (object_class, PROP_X,
g_param_spec_int ("x", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_Y,
g_param_spec_int ("y", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_WIDTH,
g_param_spec_int ("width", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_HEIGHT,
g_param_spec_int ("height", NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_OVERWRITE,
g_param_spec_boolean ("overwrite", NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpCanvasTextCursorPrivate));
}
static void
gimp_canvas_text_cursor_init (GimpCanvasTextCursor *text_cursor)
{
}
static void
gimp_canvas_text_cursor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasTextCursorPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_X:
private->x = g_value_get_int (value);
break;
case PROP_Y:
private->y = g_value_get_int (value);
break;
case PROP_WIDTH:
private->width = g_value_get_int (value);
break;
case PROP_HEIGHT:
private->height = g_value_get_int (value);
break;
case PROP_OVERWRITE:
private->overwrite = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_text_cursor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasTextCursorPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_X:
g_value_set_int (value, private->x);
break;
case PROP_Y:
g_value_set_int (value, private->y);
break;
case PROP_WIDTH:
g_value_set_int (value, private->width);
break;
case PROP_HEIGHT:
g_value_set_int (value, private->height);
break;
case PROP_OVERWRITE:
g_value_set_boolean (value, private->overwrite);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_text_cursor_transform (GimpCanvasItem *item,
GimpDisplayShell *shell,
gdouble *x,
gdouble *y,
gdouble *w,
gdouble *h)
{
GimpCanvasTextCursorPrivate *private = GET_PRIVATE (item);
gimp_display_shell_transform_xy_f (shell,
private->x,
private->y,
x, y);
gimp_display_shell_transform_xy_f (shell,
private->x + private->width,
private->y + private->height,
w, h);
*w -= *x;
*h -= *y;
*x = PROJ_ROUND (*x) + 0.5;
*y = PROJ_ROUND (*y) + 0.5;
if (private->overwrite)
{
*w = PROJ_ROUND (*w) - 1.0;
*h = PROJ_ROUND (*h) - 1.0;
}
else
{
*w = 0;
*h = PROJ_ROUND (*h) - 1.0;
}
}
static void
gimp_canvas_text_cursor_draw (GimpCanvasItem *item,
GimpDisplayShell *shell,
cairo_t *cr)
{
GimpCanvasTextCursorPrivate *private = GET_PRIVATE (item);
gdouble x, y;
gdouble w, h;
gimp_canvas_text_cursor_transform (item, shell, &x, &y, &w, &h);
if (private->overwrite)
{
cairo_rectangle (cr, x, y, w, h);
}
else
{
cairo_move_to (cr, x, y);
cairo_line_to (cr, x, y + h);
cairo_move_to (cr, x - 3.0, y);
cairo_line_to (cr, x + 3.0, y);
cairo_move_to (cr, x - 3.0, y + h);
cairo_line_to (cr, x + 3.0, y + h);
}
_gimp_canvas_item_stroke (item, shell, cr);
}
static GdkRegion *
gimp_canvas_text_cursor_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GimpCanvasTextCursorPrivate *private = GET_PRIVATE (item);
GdkRectangle rectangle;
gdouble x, y;
gdouble w, h;
gimp_canvas_text_cursor_transform (item, shell, &x, &y, &w, &h);
if (private->overwrite)
{
rectangle.x = floor (x - 1.5);
rectangle.y = floor (y - 1.5);
rectangle.width = ceil (w + 3.0);
rectangle.height = ceil (h + 3.0);
}
else
{
rectangle.x = floor (x - 3.5);
rectangle.y = floor (y - 1.5);
rectangle.width = ceil (8.0);
rectangle.height = ceil (h + 1.5);
}
return gdk_region_rectangle (&rectangle);
}
GimpCanvasItem *
gimp_canvas_text_cursor_new (PangoRectangle *cursor,
gboolean overwrite)
{
return g_object_new (GIMP_TYPE_CANVAS_TEXT_CURSOR,
"x", cursor->x,
"y", cursor->y,
"width", cursor->width,
"height", cursor->height,
"overwrite", overwrite,
NULL);
}

View File

@ -0,0 +1,56 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvastextcursor.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_TEXT_CURSOR_H__
#define __GIMP_CANVAS_TEXT_CURSOR_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_TEXT_CURSOR (gimp_canvas_text_cursor_get_type ())
#define GIMP_CANVAS_TEXT_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_TEXT_CURSOR, GimpCanvasTextCursor))
#define GIMP_CANVAS_TEXT_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_TEXT_CURSOR, GimpCanvasTextCursorClass))
#define GIMP_IS_CANVAS_TEXT_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_TEXT_CURSOR))
#define GIMP_IS_CANVAS_TEXT_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_TEXT_CURSOR))
#define GIMP_CANVAS_TEXT_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_TEXT_CURSOR, GimpCanvasTextCursorClass))
typedef struct _GimpCanvasTextCursor GimpCanvasTextCursor;
typedef struct _GimpCanvasTextCursorClass GimpCanvasTextCursorClass;
struct _GimpCanvasTextCursor
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasTextCursorClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_text_cursor_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_text_cursor_new (PangoRectangle *cursor,
gboolean overwrite);
#endif /* __GIMP_CANVAS_RECTANGLE_H__ */

View File

@ -845,8 +845,8 @@ gimp_display_paint_area (GimpDisplay *display,
h = (y2 - y1);
/* display the area */
gimp_display_shell_transform_xy_f (shell, x, y, &x1_f, &y1_f, FALSE);
gimp_display_shell_transform_xy_f (shell, x + w, y + h, &x2_f, &y2_f, FALSE);
gimp_display_shell_transform_xy_f (shell, x, y, &x1_f, &y1_f);
gimp_display_shell_transform_xy_f (shell, x + w, y + h, &x2_f, &y2_f);
/* make sure to expose a superset of the transformed sub-pixel expose
* area, not a subset. bug #126942. --mitch

View File

@ -45,6 +45,7 @@
#include "tools/gimpmovetool.h"
#include "tools/gimppainttool.h"
#include "tools/gimptoolcontrol.h"
#include "tools/gimpvectortool.h"
#include "tools/tool_manager.h"
#include "tools/tools-enums.h"
@ -268,8 +269,6 @@ gimp_display_shell_canvas_realize (GtkWidget *canvas,
/* allow shrinking */
gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
gimp_display_shell_draw_vectors (shell);
}
void
@ -372,11 +371,15 @@ gimp_display_shell_canvas_size_allocate (GtkWidget *widget,
static gboolean
gimp_display_shell_is_double_buffered (GimpDisplayShell *shell)
{
return TRUE; /* FIXME: repair this after cairo tool drawing is done */
/* always double-buffer if there are overlay children or a
* transform preview, or they will flicker badly
* transform preview, or they will flicker badly. Also double
* buffer when we are editing paths.
*/
if (GIMP_OVERLAY_BOX (shell->canvas)->children ||
gimp_display_shell_get_show_transform (shell))
gimp_display_shell_get_show_transform (shell) ||
GIMP_IS_VECTOR_TOOL (tool_manager_get_active (shell->display->gimp)))
return TRUE;
return FALSE;
@ -2304,7 +2307,14 @@ gimp_display_shell_canvas_expose_image (GimpDisplayShell *shell,
*/
/* draw the transform tool preview */
gimp_display_shell_preview_transform (shell);
cairo_save (cr);
gimp_display_shell_preview_transform (shell, cr);
cairo_restore (cr);
/* draw the vectors */
cairo_save (cr);
gimp_display_shell_draw_vectors (shell, cr);
cairo_restore (cr);
/* draw the grid */
cairo_save (cr);
@ -2321,6 +2331,19 @@ gimp_display_shell_canvas_expose_image (GimpDisplayShell *shell,
gimp_display_shell_draw_sample_points (shell, cr);
cairo_restore (cr);
/* draw tool items */
{
GimpTool *tool = tool_manager_get_active (shell->display->gimp);
if (GIMP_IS_DRAW_TOOL (tool) &&
GIMP_DRAW_TOOL (tool)->display == shell->display)
{
cairo_save (cr);
gimp_draw_tool_draw_items (GIMP_DRAW_TOOL (tool), cr);
cairo_restore (cr);
}
}
/* and the cursor (if we have a software cursor) */
cairo_save (cr);
gimp_display_shell_draw_cursor (shell, cr);

View File

@ -163,7 +163,9 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
coords->velocity = MIN (coords->velocity, 1.0);
}
if ((fabs (delta_x) > DIRECTION_RADIUS) && (fabs (delta_y) > DIRECTION_RADIUS))
if (((fabs (delta_x) > DIRECTION_RADIUS) &&
(fabs (delta_y) > DIRECTION_RADIUS)) ||
(shell->event_history->len < 4))
{
dir_delta_x = delta_x;
dir_delta_y = delta_y;
@ -173,7 +175,8 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
gint x = 3;
while (((fabs (dir_delta_x) < DIRECTION_RADIUS) ||
(fabs (dir_delta_y) < DIRECTION_RADIUS)) && (x >= 0))
(fabs (dir_delta_y) < DIRECTION_RADIUS)) &&
(x >= 0))
{
const GimpCoords old_event = g_array_index (shell->event_history,
GimpCoords, x);

View File

@ -188,7 +188,7 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
/* ...but use the unsnapped display_coords for the info window */
if (display_x >= 0 && display_y >= 0)
gimp_display_shell_untransform_xy (shell, display_x, display_y,
&t_x, &t_y, FALSE, FALSE);
&t_x, &t_y, FALSE);
gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view),
image, shell->unit,

View File

@ -158,7 +158,7 @@ gimp_display_shell_draw_guide (GimpDisplayShell *shell,
switch (gimp_guide_get_orientation (guide))
{
case GIMP_ORIENTATION_HORIZONTAL:
gimp_display_shell_transform_xy (shell, 0, position, &x, &y, FALSE);
gimp_display_shell_transform_xy (shell, 0, position, &x, &y);
if (y >= y1 && y < y2)
{
cairo_move_to (cr, x1, y + 0.5);
@ -167,7 +167,7 @@ gimp_display_shell_draw_guide (GimpDisplayShell *shell,
break;
case GIMP_ORIENTATION_VERTICAL:
gimp_display_shell_transform_xy (shell, position, 0, &x, &y, FALSE);
gimp_display_shell_transform_xy (shell, position, 0, &x, &y);
if (x >= x1 && x < x2)
{
cairo_move_to (cr, x + 0.5, y1);
@ -265,8 +265,7 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
continue;
gimp_display_shell_transform_xy (shell,
x, 0, &x_real, &y_real,
FALSE);
x, 0, &x_real, &y_real);
if (x_real < x1 || x_real >= x2)
continue;
@ -277,8 +276,7 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
continue;
gimp_display_shell_transform_xy (shell,
x, y, &x_real, &y_real,
FALSE);
x, y, &x_real, &y_real);
if (y_real >= y1 && y_real < y2)
{
@ -296,8 +294,7 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
continue;
gimp_display_shell_transform_xy (shell,
x, 0, &x_real, &y_real,
FALSE);
x, 0, &x_real, &y_real);
if (x_real + CROSSHAIR < x1 || x_real - CROSSHAIR >= x2)
continue;
@ -308,8 +305,7 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
continue;
gimp_display_shell_transform_xy (shell,
x, y, &x_real, &y_real,
FALSE);
x, y, &x_real, &y_real);
if (y_real + CROSSHAIR < y1 || y_real - CROSSHAIR >= y2)
continue;
@ -345,11 +341,9 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
case GIMP_GRID_DOUBLE_DASH:
case GIMP_GRID_SOLID:
gimp_display_shell_transform_xy (shell,
0, 0, &x0, &y0,
FALSE);
0, 0, &x0, &y0);
gimp_display_shell_transform_xy (shell,
width, height, &x3, &y3,
FALSE);
width, height, &x3, &y3);
for (x = x_offset; x < width; x += grid->xspacing)
{
@ -357,8 +351,7 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
continue;
gimp_display_shell_transform_xy (shell,
x, 0, &x_real, &y_real,
FALSE);
x, 0, &x_real, &y_real);
if (x_real >= x1 && x_real < x2)
{
@ -373,8 +366,7 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
continue;
gimp_display_shell_transform_xy (shell,
0, y, &x_real, &y_real,
FALSE);
0, y, &x_real, &y_real);
if (y_real >= y1 && y_real < y2)
{
@ -414,7 +406,7 @@ gimp_display_shell_draw_pen (GimpDisplayShell *shell,
gimp_display_shell_transform_xy (shell,
points[0].x, points[0].y,
&x, &y, FALSE);
&x, &y);
cairo_move_to (cr, x, y);
@ -422,7 +414,7 @@ gimp_display_shell_draw_pen (GimpDisplayShell *shell,
{
gimp_display_shell_transform_xy (shell,
points[i].x, points[i].y,
&x, &y, FALSE);
&x, &y);
cairo_line_to (cr, x, y);
}
@ -465,7 +457,7 @@ gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
gimp_display_shell_transform_xy_f (shell,
sample_point->x + 0.5,
sample_point->y + 0.5,
&x, &y, FALSE);
&x, &y);
sx1 = floor (x - GIMP_SAMPLE_POINT_DRAW_SIZE);
sx2 = ceil (x + GIMP_SAMPLE_POINT_DRAW_SIZE);
@ -583,47 +575,35 @@ gimp_display_shell_draw_selection_in (GimpDisplayShell *shell,
cairo_mask (cr, mask);
}
void
gimp_display_shell_draw_vector (GimpDisplayShell *shell,
GimpVectors *vectors)
static void
gimp_display_shell_draw_one_vectors (GimpDisplayShell *shell,
cairo_t *cr,
GimpVectors *vectors,
gdouble width,
gboolean active)
{
GimpStroke *stroke = NULL;
GimpStroke *stroke;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
stroke;
stroke = gimp_vectors_stroke_get_next (vectors, stroke))
{
GArray *coords;
gboolean closed;
const GimpBezierDesc *desc = gimp_vectors_get_bezier (vectors);
coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
if (coords && coords->len > 0)
{
GdkPoint *gdk_coords = g_new (GdkPoint, coords->len);
gimp_display_shell_transform_coords (shell,
&g_array_index (coords,
GimpCoords, 0),
gdk_coords,
coords->len,
FALSE);
gimp_canvas_draw_lines (GIMP_CANVAS (shell->canvas),
GIMP_CANVAS_STYLE_XOR,
gdk_coords, coords->len);
g_free (gdk_coords);
if (desc)
cairo_append_path (cr, (cairo_path_t *) desc);
}
if (coords)
g_array_free (coords, TRUE);
}
gimp_display_shell_set_vectors_bg_style (shell, cr, width, active);
cairo_stroke_preserve (cr);
gimp_display_shell_set_vectors_fg_style (shell, cr, width, active);
cairo_stroke (cr);
}
void
gimp_display_shell_draw_vectors (GimpDisplayShell *shell)
gimp_display_shell_draw_vectors (GimpDisplayShell *shell,
cairo_t *cr)
{
GimpImage *image;
@ -633,17 +613,37 @@ gimp_display_shell_draw_vectors (GimpDisplayShell *shell)
if (image && TRUE /* gimp_display_shell_get_show_vectors (shell) */)
{
GList *all_vectors;
GList *list;
GList *all_vectors = gimp_image_get_vectors_list (image);
const GList *list;
gdouble xscale;
gdouble yscale;
gdouble width;
all_vectors = gimp_image_get_vectors_list (image);
if (! all_vectors)
return;
cairo_translate (cr, - shell->offset_x, - shell->offset_y);
cairo_scale (cr, shell->scale_x, shell->scale_y);
/* determine a reasonable line width */
xscale = yscale = 1.0;
cairo_device_to_user_distance (cr, &xscale, &yscale);
width = MAX (xscale, yscale);
width = MIN (width, 1.0);
for (list = all_vectors; list; list = list->next)
{
GimpVectors *vectors = list->data;
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_display_shell_draw_vector (shell, vectors);
{
gboolean active;
active = (vectors == gimp_image_get_active_vectors (image));
gimp_display_shell_draw_one_vectors (shell, cr, vectors,
width, active);
}
}
g_list_free (all_vectors);
@ -664,17 +664,25 @@ gimp_display_shell_draw_cursor (GimpDisplayShell *shell,
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_move_to (cr, shell->cursor_x - GIMP_CURSOR_SIZE, shell->cursor_y - 1);
cairo_line_to (cr, shell->cursor_x + GIMP_CURSOR_SIZE, shell->cursor_y - 1);
cairo_move_to (cr,
shell->cursor_x - GIMP_CURSOR_SIZE, shell->cursor_y - 1);
cairo_line_to (cr,
shell->cursor_x + GIMP_CURSOR_SIZE, shell->cursor_y - 1);
cairo_move_to (cr, shell->cursor_x - GIMP_CURSOR_SIZE, shell->cursor_y + 1);
cairo_line_to (cr, shell->cursor_x + GIMP_CURSOR_SIZE, shell->cursor_y + 1);
cairo_move_to (cr,
shell->cursor_x - GIMP_CURSOR_SIZE, shell->cursor_y + 1);
cairo_line_to (cr,
shell->cursor_x + GIMP_CURSOR_SIZE, shell->cursor_y + 1);
cairo_move_to (cr, shell->cursor_x - 1, shell->cursor_y - GIMP_CURSOR_SIZE);
cairo_line_to (cr, shell->cursor_x - 1, shell->cursor_y + GIMP_CURSOR_SIZE);
cairo_move_to (cr,
shell->cursor_x - 1, shell->cursor_y - GIMP_CURSOR_SIZE);
cairo_line_to (cr,
shell->cursor_x - 1, shell->cursor_y + GIMP_CURSOR_SIZE);
cairo_move_to (cr, shell->cursor_x + 1, shell->cursor_y - GIMP_CURSOR_SIZE);
cairo_line_to (cr, shell->cursor_x + 1, shell->cursor_y + GIMP_CURSOR_SIZE);
cairo_move_to (cr,
shell->cursor_x + 1, shell->cursor_y - GIMP_CURSOR_SIZE);
cairo_line_to (cr,
shell->cursor_x + 1, shell->cursor_y + GIMP_CURSOR_SIZE);
cairo_stroke (cr);

View File

@ -61,9 +61,8 @@ void gimp_display_shell_draw_selection_in (GimpDisplayShell *shell,
cairo_t *cr,
cairo_pattern_t *mask,
gint index);
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
GimpVectors *vectors);
void gimp_display_shell_draw_vectors (GimpDisplayShell *shell);
void gimp_display_shell_draw_vectors (GimpDisplayShell *shell,
cairo_t *cr);
void gimp_display_shell_draw_cursor (GimpDisplayShell *shell,
cairo_t *cr);
void gimp_display_shell_draw_area (GimpDisplayShell *shell,

View File

@ -27,6 +27,8 @@
#include "core/gimpguide.h"
#include "core/gimpsamplepoint.h"
#include "vectors/gimpvectors.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-expose.h"
#include "gimpdisplayshell-transform.h"
@ -44,6 +46,26 @@ gimp_display_shell_expose_area (GimpDisplayShell *shell,
gtk_widget_queue_draw_area (shell->canvas, x, y, w, h);
}
static void
gimp_display_shell_expose_region (GimpDisplayShell *shell,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gint border)
{
const gint x = floor (x1);
const gint y = floor (y1);
const gint w = ceil (x2) - x;
const gint h = ceil (y2) - y;
gimp_display_shell_expose_area (shell,
x - border,
y - border,
w + 2 * border,
h + 2 * border);
}
void
gimp_display_shell_expose_guide (GimpDisplayShell *shell,
GimpGuide *guide)
@ -61,8 +83,7 @@ gimp_display_shell_expose_guide (GimpDisplayShell *shell,
gimp_display_shell_transform_xy (shell,
position, position,
&x, &y,
FALSE);
&x, &y);
switch (gimp_guide_get_orientation (guide))
{
@ -95,8 +116,7 @@ gimp_display_shell_expose_sample_point (GimpDisplayShell *shell,
gimp_display_shell_transform_xy_f (shell,
sample_point->x + 0.5,
sample_point->y + 0.5,
&x, &y,
FALSE);
&x, &y);
x1 = MAX (0, floor (x - GIMP_SAMPLE_POINT_DRAW_SIZE));
y1 = MAX (0, floor (y - GIMP_SAMPLE_POINT_DRAW_SIZE));
@ -107,6 +127,25 @@ gimp_display_shell_expose_sample_point (GimpDisplayShell *shell,
gimp_display_shell_expose_area (shell, x1, y1, x2 - x1 + 3, y2 - y1 + 3);
}
void
gimp_display_shell_expose_vectors (GimpDisplayShell *shell,
GimpVectors *vectors)
{
gdouble x1, y1;
gdouble x2, y2;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (vectors != NULL);
if (gimp_vectors_bounds (vectors, &x1, &y1, &x2, &y2))
{
gimp_display_shell_transform_xy_f (shell, x1, y1, &x1, &y1);
gimp_display_shell_transform_xy_f (shell, x2, y2, &x2, &y2);
gimp_display_shell_expose_region (shell, x1, y1, x2, y2, 2);
}
}
void
gimp_display_shell_expose_full (GimpDisplayShell *shell)
{

View File

@ -28,6 +28,8 @@ void gimp_display_shell_expose_guide (GimpDisplayShell *shell,
GimpGuide *guide);
void gimp_display_shell_expose_sample_point (GimpDisplayShell *shell,
GimpSamplePoint *sample_point);
void gimp_display_shell_expose_vectors (GimpDisplayShell *shell,
GimpVectors *vectors);
void gimp_display_shell_expose_full (GimpDisplayShell *shell);

View File

@ -93,6 +93,9 @@ static void gimp_display_shell_update_guide_handler (GimpImage *i
static void gimp_display_shell_update_sample_point_handler(GimpImage *image,
GimpSamplePoint *sample_point,
GimpDisplayShell *shell);
static void gimp_display_shell_update_vectors_handler (GimpImage *image,
GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_invalidate_preview_handler (GimpImage *image,
GimpDisplayShell *shell);
static void gimp_display_shell_profile_changed_handler (GimpColorManaged *image,
@ -104,17 +107,7 @@ static void gimp_display_shell_exported_handler (GimpImage *i
const gchar *uri,
GimpDisplayShell *shell);
static void gimp_display_shell_vectors_freeze_handler (GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_vectors_thaw_handler (GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_vectors_visible_handler (GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_vectors_add_handler (GimpContainer *container,
GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_vectors_remove_handler (GimpContainer *container,
GimpVectors *vectors,
static void gimp_display_shell_active_vectors_handler (GimpImage *image,
GimpDisplayShell *shell);
static void gimp_display_shell_check_notify_handler (GObject *config,
@ -146,13 +139,11 @@ void
gimp_display_shell_connect (GimpDisplayShell *shell)
{
GimpImage *image;
GimpContainer *vectors;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
image = gimp_display_get_image (shell->display);
vectors = gimp_image_get_vectors (image);
g_return_if_fail (GIMP_IS_IMAGE (image));
@ -189,6 +180,9 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
g_signal_connect (image, "update-sample-point",
G_CALLBACK (gimp_display_shell_update_sample_point_handler),
shell);
g_signal_connect (image, "update-vectors",
G_CALLBACK (gimp_display_shell_update_vectors_handler),
shell);
g_signal_connect (image, "invalidate-preview",
G_CALLBACK (gimp_display_shell_invalidate_preview_handler),
shell);
@ -202,24 +196,8 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
G_CALLBACK (gimp_display_shell_exported_handler),
shell);
shell->vectors_freeze_handler =
gimp_tree_handler_connect (vectors, "freeze",
G_CALLBACK (gimp_display_shell_vectors_freeze_handler),
shell);
shell->vectors_thaw_handler =
gimp_tree_handler_connect (vectors, "thaw",
G_CALLBACK (gimp_display_shell_vectors_thaw_handler),
shell);
shell->vectors_visible_handler =
gimp_tree_handler_connect (vectors, "visibility-changed",
G_CALLBACK (gimp_display_shell_vectors_visible_handler),
shell);
g_signal_connect (vectors, "add",
G_CALLBACK (gimp_display_shell_vectors_add_handler),
shell);
g_signal_connect (vectors, "remove",
G_CALLBACK (gimp_display_shell_vectors_remove_handler),
g_signal_connect (image, "active-vectors-changed",
G_CALLBACK (gimp_display_shell_active_vectors_handler),
shell);
g_signal_connect (shell->display->config,
@ -291,7 +269,6 @@ void
gimp_display_shell_disconnect (GimpDisplayShell *shell)
{
GimpImage *image;
GimpContainer *vectors;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
@ -300,8 +277,6 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
g_return_if_fail (GIMP_IS_IMAGE (image));
vectors = gimp_image_get_vectors (image);
gimp_display_shell_icon_update_stop (shell);
g_signal_handlers_disconnect_by_func (shell->display->config,
@ -329,21 +304,9 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
gimp_display_shell_check_notify_handler,
shell);
g_signal_handlers_disconnect_by_func (vectors,
gimp_display_shell_vectors_remove_handler,
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_active_vectors_handler,
shell);
g_signal_handlers_disconnect_by_func (vectors,
gimp_display_shell_vectors_add_handler,
shell);
gimp_tree_handler_disconnect (shell->vectors_visible_handler);
shell->vectors_visible_handler = NULL;
gimp_tree_handler_disconnect (shell->vectors_thaw_handler);
shell->vectors_thaw_handler = NULL;
gimp_tree_handler_disconnect (shell->vectors_freeze_handler);
shell->vectors_freeze_handler = NULL;
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_exported_handler,
@ -363,6 +326,9 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_update_sample_point_handler,
shell);
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_update_vectors_handler,
shell);
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_quick_mask_changed_handler,
shell);
@ -508,6 +474,14 @@ gimp_display_shell_update_sample_point_handler (GimpImage *image,
gimp_display_shell_expose_sample_point (shell, sample_point);
}
static void
gimp_display_shell_update_vectors_handler (GimpImage *image,
GimpVectors *vectors,
GimpDisplayShell *shell)
{
gimp_display_shell_expose_vectors (shell, vectors);
}
static void
gimp_display_shell_size_changed_detailed_handler (GimpImage *image,
gint previous_origin_x,
@ -604,45 +578,10 @@ gimp_display_shell_exported_handler (GimpImage *image,
}
static void
gimp_display_shell_vectors_freeze_handler (GimpVectors *vectors,
gimp_display_shell_active_vectors_handler (GimpImage *image,
GimpDisplayShell *shell)
{
if (shell->paused_count == 0 && gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_display_shell_draw_vector (shell, vectors);
}
static void
gimp_display_shell_vectors_thaw_handler (GimpVectors *vectors,
GimpDisplayShell *shell)
{
if (shell->paused_count == 0 && gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_display_shell_draw_vector (shell, vectors);
}
static void
gimp_display_shell_vectors_visible_handler (GimpVectors *vectors,
GimpDisplayShell *shell)
{
if (shell->paused_count == 0)
gimp_display_shell_draw_vector (shell, vectors);
}
static void
gimp_display_shell_vectors_add_handler (GimpContainer *container,
GimpVectors *vectors,
GimpDisplayShell *shell)
{
if (shell->paused_count == 0 && gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_display_shell_draw_vector (shell, vectors);
}
static void
gimp_display_shell_vectors_remove_handler (GimpContainer *container,
GimpVectors *vectors,
GimpDisplayShell *shell)
{
if (shell->paused_count == 0 && gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_display_shell_draw_vector (shell, vectors);
gimp_display_shell_expose_full (shell);
}
static void

View File

@ -21,6 +21,7 @@
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "tools/tools-types.h"
@ -53,7 +54,7 @@
/* local function prototypes */
static void gimp_display_shell_draw_quad (GimpDrawable *texture,
GdkDrawable *dest,
cairo_t *cr,
GimpChannel *mask,
gint mask_offx,
gint mask_offy,
@ -63,8 +64,8 @@ static void gimp_display_shell_draw_quad (GimpDrawable *texture,
gfloat *v,
guchar opacity);
static void gimp_display_shell_draw_tri (GimpDrawable *texture,
GdkDrawable *dest,
GdkPixbuf *area,
cairo_t *cr,
cairo_surface_t *area,
gint area_offx,
gint area_offy,
GimpChannel *mask,
@ -76,8 +77,8 @@ static void gimp_display_shell_draw_tri (GimpDrawable *texture,
gfloat *v,
guchar opacity);
static void gimp_display_shell_draw_tri_row (GimpDrawable *texture,
GdkDrawable *dest,
GdkPixbuf *area,
cairo_t *cr,
cairo_surface_t *area,
gint area_offx,
gint area_offy,
gint x1,
@ -89,8 +90,8 @@ static void gimp_display_shell_draw_tri_row (GimpDrawable *texture,
gint y,
guchar opacity);
static void gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
GdkDrawable *dest,
GdkPixbuf *area,
cairo_t *cr,
cairo_surface_t *area,
gint area_offx,
gint area_offy,
GimpChannel *mask,
@ -131,7 +132,8 @@ static void gimp_display_shell_trace_tri_edge (gint *dest,
* except perspective, so approximate it with a few subdivisions.
**/
void
gimp_display_shell_preview_transform (GimpDisplayShell *shell)
gimp_display_shell_preview_transform (GimpDisplayShell *shell,
cairo_t *cr)
{
GimpTool *tool;
GimpTransformTool *tr_tool;
@ -157,6 +159,7 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell)
guchar opacity = 255;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL);
if (! gimp_display_shell_get_show_transform (shell) || ! shell->canvas)
return;
@ -200,7 +203,7 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell)
mask = NULL;
mask_offx = mask_offy = 0;
if (gimp_drawable_mask_bounds (tool->drawable,
if (gimp_item_mask_bounds (GIMP_ITEM (tool->drawable),
&mask_x1, &mask_y1,
&mask_x2, &mask_y2))
{
@ -247,8 +250,7 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell)
\
gimp_display_shell_transform_xy_f (shell, \
tx1, ty1, \
&tx2, &ty2, \
FALSE); \
&tx2, &ty2); \
x[sub][index] = (gint) tx2; \
y[sub][index] = (gint) ty2; \
\
@ -317,8 +319,7 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell)
k = columns * rows;
for (j = 0; j < k; j++)
gimp_display_shell_draw_quad (tool->drawable,
GDK_DRAWABLE (gtk_widget_get_window (shell->canvas)),
gimp_display_shell_draw_quad (tool->drawable, cr,
mask, mask_offx, mask_offy,
x[j], y[j], u[j], v[j],
opacity);
@ -330,7 +331,7 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell)
/**
* gimp_display_shell_draw_quad:
* @texture: the #GimpDrawable to be previewed
* @dest: the #GdkDrawable for that @texture lives on
* @cr: the #cairo_t to draw to
* @mask: a #GimpChannel
* @opacity: the opacity of the preview
*
@ -339,7 +340,7 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell)
**/
static void
gimp_display_shell_draw_quad (GimpDrawable *texture,
GdkDrawable *dest,
cairo_t *cr,
GimpChannel *mask,
gint mask_offx,
gint mask_offy,
@ -352,11 +353,9 @@ gimp_display_shell_draw_quad (GimpDrawable *texture,
gint x2[3], y2[3];
gfloat u2[3], v2[3];
gint minx, maxx, miny, maxy; /* screen bounds of the quad */
gint dwidth, dheight; /* dimensions of dest */
gdouble clip_x1, clip_y1, clip_x2, clip_y2;
gint c;
g_return_if_fail (GDK_IS_DRAWABLE (dest));
x2[0] = x[3]; y2[0] = y[3]; u2[0] = u[3]; v2[0] = v[3];
x2[1] = x[2]; y2[1] = y[2]; u2[1] = u[2]; v2[1] = v[2];
x2[2] = x[1]; y2[2] = y[1]; u2[2] = u[1]; v2[2] = v[1];
@ -365,7 +364,7 @@ gimp_display_shell_draw_quad (GimpDrawable *texture,
* and fill it with the original window contents.
*/
gdk_drawable_get_size (dest, &dwidth, &dheight);
cairo_clip_extents (cr, &clip_x1, &clip_y1, &clip_x2, &clip_y2);
/* find bounds of quad in order to only grab as much of dest as needed */
@ -379,35 +378,36 @@ gimp_display_shell_draw_quad (GimpDrawable *texture,
if (y[c] < miny) miny = y[c];
else if (y[c] > maxy) maxy = y[c];
}
if (minx < 0) minx = 0;
if (miny < 0) miny = 0;
if (maxx > dwidth - 1) maxx = dwidth - 1;
if (maxy > dheight - 1) maxy = dheight - 1;
if (minx < clip_x1) minx = clip_x1;
if (miny < clip_y1) miny = clip_y1;
if (maxx > clip_x2) maxx = clip_x2;
if (maxy > clip_y2) maxy = clip_y2;
if (minx <= maxx && miny <= maxy)
{
GdkPixbuf *area;
cairo_surface_t *area;
area = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
maxx - minx + 1, maxy - miny + 1);
area = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
maxx - minx + 1,
maxy - miny + 1);
g_return_if_fail (area != NULL);
gimp_display_shell_draw_tri (texture, dest, area, minx, miny,
gimp_display_shell_draw_tri (texture, cr, area, minx, miny,
mask, mask_offx, mask_offy,
x, y, u, v, opacity);
gimp_display_shell_draw_tri (texture, dest, area, minx, miny,
gimp_display_shell_draw_tri (texture, cr, area, minx, miny,
mask, mask_offx, mask_offy,
x2, y2, u2, v2, opacity);
g_object_unref (area);
cairo_surface_destroy (area);
}
}
/**
* gimp_display_shell_draw_tri:
* @texture: the thing being transformed
* @dest: the #GdkDrawable for that @texture lives on
* @cr: the #cairo_t to draw to
* @area: has prefetched pixel data of dest
* @area_offx: x coordinate of area in dest
* @area_offy: y coordinate of area in dest
@ -420,8 +420,8 @@ gimp_display_shell_draw_quad (GimpDrawable *texture,
**/
static void
gimp_display_shell_draw_tri (GimpDrawable *texture,
GdkDrawable *dest,
GdkPixbuf *area,
cairo_t *cr,
cairo_surface_t *area,
gint area_offx,
gint area_offy,
GimpChannel *mask,
@ -433,7 +433,7 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
gfloat *v, /* 0.0 ... tex width, height */
guchar opacity)
{
gint dwidth, dheight; /* clip boundary */
gdouble clip_x1, clip_y1, clip_x2, clip_y2;
gint j, k;
gint ry;
gint *l_edge, *r_edge; /* arrays holding x-coords of edge pixels */
@ -442,8 +442,7 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
gfloat u_l, v_l, u_r, v_r; /* left and right texture coord pairs */
g_return_if_fail (GIMP_IS_DRAWABLE (texture));
g_return_if_fail (GDK_IS_DRAWABLE (dest));
g_return_if_fail (GDK_IS_PIXBUF (area));
g_return_if_fail (area != NULL);
g_return_if_fail (x != NULL && y != NULL && u != NULL && v != NULL);
@ -451,7 +450,7 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
dul = dvl = dur = dvr = 0;
u_l = v_l = u_r = v_r = 0;
gdk_drawable_get_size (dest, &dwidth, &dheight);
cairo_clip_extents (cr, &clip_x1, &clip_y1, &clip_x2, &clip_y2);
/* sort vertices in order of y-coordinate */
@ -497,9 +496,8 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
if (mask)
for (ry = y[0]; ry < y[1]; ry++)
{
if (ry >= 0 && ry < dheight)
gimp_display_shell_draw_tri_row_mask
(texture, dest,
if (ry >= clip_y1 && ry < clip_y2)
gimp_display_shell_draw_tri_row_mask (texture, cr,
area, area_offx, area_offy,
mask, mask_offx, mask_offy,
*left, u_l, v_l,
@ -513,8 +511,8 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
else
for (ry = y[0]; ry < y[1]; ry++)
{
if (ry >= 0 && ry < dheight)
gimp_display_shell_draw_tri_row (texture, dest,
if (ry >= clip_y1 && ry < clip_y2)
gimp_display_shell_draw_tri_row (texture, cr,
area, area_offx, area_offy,
*left, u_l, v_l,
*right, u_r, v_r,
@ -539,9 +537,8 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
if (mask)
for (ry = y[1]; ry < y[2]; ry++)
{
if (ry >= 0 && ry < dheight)
gimp_display_shell_draw_tri_row_mask
(texture, dest,
if (ry >= clip_y1 && ry < clip_y2)
gimp_display_shell_draw_tri_row_mask (texture, cr,
area, area_offx, area_offy,
mask, mask_offx, mask_offy,
*left, u_l, v_l,
@ -555,8 +552,8 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
else
for (ry = y[1]; ry < y[2]; ry++)
{
if (ry >= 0 && ry < dheight)
gimp_display_shell_draw_tri_row (texture, dest,
if (ry >= clip_y1 && ry < clip_y2)
gimp_display_shell_draw_tri_row (texture, cr,
area, area_offx, area_offy,
*left, u_l, v_l,
*right, u_r, v_r,
@ -575,7 +572,7 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
/**
* gimp_display_shell_draw_tri_row:
* @texture: the thing being transformed
* @dest: the #GdkDrawable for that @texture lives on
* @cr: the #cairo_t to draw to
* @area: has prefetched pixel data of dest
*
* Called from gimp_display_shell_draw_tri(), this draws a single row of a
@ -584,8 +581,8 @@ gimp_display_shell_draw_tri (GimpDrawable *texture,
**/
static void
gimp_display_shell_draw_tri_row (GimpDrawable *texture,
GdkDrawable *dest,
GdkPixbuf *area,
cairo_t *cr,
cairo_surface_t *area,
gint area_offx,
gint area_offy,
gint x1,
@ -610,10 +607,8 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
return;
g_return_if_fail (GIMP_IS_DRAWABLE (texture));
g_return_if_fail (GDK_IS_DRAWABLE (dest));
g_return_if_fail (GDK_IS_PIXBUF (area));
g_return_if_fail (gdk_pixbuf_get_bits_per_sample (area) == 8);
g_return_if_fail (gdk_pixbuf_get_colorspace (area) == GDK_COLORSPACE_RGB);
g_return_if_fail (area != NULL);
g_return_if_fail (cairo_image_surface_get_format (area) == CAIRO_FORMAT_ARGB32);
/* make sure the pixel run goes in the positive direction */
if (x1 > x2)
@ -638,7 +633,7 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
v += dv * (area_offx - x1);
x1 = area_offx;
}
else if (x1 > area_offx + gdk_pixbuf_get_width (area) - 1)
else if (x1 > area_offx + cairo_image_surface_get_width (area) - 1)
{
return;
}
@ -647,18 +642,18 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
{
return;
}
else if (x2 > area_offx + gdk_pixbuf_get_width (area) - 1)
else if (x2 > area_offx + cairo_image_surface_get_width (area) - 1)
{
x2 = area_offx + gdk_pixbuf_get_width (area) - 1;
x2 = area_offx + cairo_image_surface_get_width (area) - 1;
}
dx = x2 - x1;
if (! dx)
return;
pptr = (gdk_pixbuf_get_pixels (area)
+ (y - area_offy) * gdk_pixbuf_get_rowstride (area)
+ (x1 - area_offx) * gdk_pixbuf_get_n_channels (area));
pptr = (cairo_image_surface_get_data (area)
+ (y - area_offy) * cairo_image_surface_get_stride (area)
+ (x1 - area_offx) * 4);
tiles = gimp_drawable_get_tiles (texture);
@ -673,10 +668,11 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = cmap[offset + 0];
pptr[1] = cmap[offset + 1];
pptr[2] = cmap[offset + 2];
pptr[3] = opacity;
GIMP_CAIRO_ARGB32_SET_PIXEL (pptr,
cmap[offset + 0],
cmap[offset + 1],
cmap[offset + 2],
opacity);
pptr += 4;
@ -696,10 +692,11 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = cmap[offset + 0];
pptr[1] = cmap[offset + 1];
pptr[2] = cmap[offset + 2];
pptr[3] = INT_MULT (opacity, pixel[1], tmp);
GIMP_CAIRO_ARGB32_SET_PIXEL (pptr,
cmap[offset + 0],
cmap[offset + 1],
cmap[offset + 2],
INT_MULT (opacity, pixel[1], tmp));
pptr += 4;
@ -713,10 +710,11 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = pixel[0];
pptr[1] = pixel[0];
pptr[2] = pixel[0];
pptr[3] = opacity;
GIMP_CAIRO_ARGB32_SET_PIXEL (pptr,
pixel[0],
pixel[0],
pixel[0],
opacity);
pptr += 4;
@ -732,10 +730,11 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = pixel[0];
pptr[1] = pixel[0];
pptr[2] = pixel[0];
pptr[3] = INT_MULT (opacity, pixel[1], tmp);
GIMP_CAIRO_ARGB32_SET_PIXEL (pptr,
pixel[0],
pixel[0],
pixel[0],
INT_MULT (opacity, pixel[1], tmp));
pptr += 4;
@ -749,10 +748,11 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = pixel[0];
pptr[1] = pixel[1];
pptr[2] = pixel[2];
pptr[3] = opacity;
GIMP_CAIRO_ARGB32_SET_PIXEL (pptr,
pixel[0],
pixel[1],
pixel[2],
opacity);
pptr += 4;
@ -768,10 +768,11 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = pixel[0];
pptr[1] = pixel[1];
pptr[2] = pixel[2];
pptr[3] = INT_MULT (opacity, pixel[3], tmp);
GIMP_CAIRO_ARGB32_SET_PIXEL (pptr,
pixel[0],
pixel[1],
pixel[2],
INT_MULT (opacity, pixel[3], tmp));
pptr += 4;
@ -784,9 +785,11 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
return;
}
gdk_draw_pixbuf (dest, NULL, area, x1 - area_offx, y - area_offy,
x1, y, x2 - x1, 1,
GDK_RGB_DITHER_NONE, 0, 0);
cairo_surface_mark_dirty (area);
cairo_set_source_surface (cr, area, area_offx, area_offy);
cairo_rectangle (cr, x1, y, x2 - x1, 1);
cairo_fill (cr);
}
/**
@ -797,8 +800,8 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
**/
static void
gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
GdkDrawable *dest,
GdkPixbuf *area,
cairo_t *cr,
cairo_surface_t *area,
gint area_offx,
gint area_offy,
GimpChannel *mask,
@ -830,10 +833,8 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
g_return_if_fail (GIMP_IS_DRAWABLE (texture));
g_return_if_fail (GIMP_IS_CHANNEL (mask));
g_return_if_fail (GDK_IS_DRAWABLE (dest));
g_return_if_fail (GDK_IS_PIXBUF (area));
g_return_if_fail (gdk_pixbuf_get_bits_per_sample (area) == 8);
g_return_if_fail (gdk_pixbuf_get_colorspace (area) == GDK_COLORSPACE_RGB);
g_return_if_fail (area != NULL);
g_return_if_fail (cairo_image_surface_get_format (area) == CAIRO_FORMAT_ARGB32);
/* make sure the pixel run goes in the positive direction */
if (x1 > x2)
@ -858,7 +859,7 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
v += dv * (area_offx - x1);
x1 = area_offx;
}
else if (x1 > area_offx + gdk_pixbuf_get_width (area) - 1)
else if (x1 > area_offx + cairo_image_surface_get_width (area) - 1)
{
return;
}
@ -867,9 +868,9 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
{
return;
}
else if (x2 > area_offx + gdk_pixbuf_get_width (area) - 1)
else if (x2 > area_offx + cairo_image_surface_get_width (area) - 1)
{
x2 = area_offx + gdk_pixbuf_get_width (area) - 1;
x2 = area_offx + cairo_image_surface_get_width (area) - 1;
}
dx = x2 - x1;
@ -879,9 +880,9 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
mu = u + mask_offx;
mv = v + mask_offy;
pptr = (gdk_pixbuf_get_pixels (area)
+ (y - area_offy) * gdk_pixbuf_get_rowstride (area)
+ (x1 - area_offx) * gdk_pixbuf_get_n_channels (area));
pptr = (cairo_image_surface_get_data (area)
+ (y - area_offy) * cairo_image_surface_get_stride (area)
+ (x1 - area_offx) * 4);
tiles = gimp_drawable_get_tiles (texture);
masktiles = gimp_drawable_get_tiles (GIMP_DRAWABLE (mask));
@ -1032,9 +1033,11 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
return;
}
gdk_draw_pixbuf (dest, NULL, area, x1 - area_offx, y - area_offy,
x1, y, x2 - x1, 1,
GDK_RGB_DITHER_NONE, 0, 0);
cairo_surface_mark_dirty (area);
cairo_set_source_surface (cr, area, area_offx, area_offy);
cairo_rectangle (cr, x1, y, x2 - x1, 1);
cairo_fill (cr);
}
/**

View File

@ -19,7 +19,8 @@
#define __GIMP_DISPLAY_SHELL_PREVIEW_H__
void gimp_display_shell_preview_transform (GimpDisplayShell *shell);
void gimp_display_shell_preview_transform (GimpDisplayShell *shell,
cairo_t *cr);
#endif /* __GIMP_DISPLAY_SHELL_PREVIEW_H__ */

View File

@ -893,8 +893,7 @@ gimp_display_shell_scale_to (GimpDisplayShell *shell,
viewport_x,
viewport_y,
&image_focus_x,
&image_focus_y,
FALSE);
&image_focus_y);
gimp_display_shell_calculate_scale_x_and_y (shell, scale, &scale_x, &scale_y);

View File

@ -385,6 +385,7 @@ selection_render_mask (Selection *selection)
cairo_push_group_with_content (cr, CAIRO_CONTENT_ALPHA);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
cairo_set_line_width (cr, 1.0);
gimp_cairo_add_segments (cr,
@ -408,7 +409,7 @@ selection_transform_segs (Selection *selection,
gint i;
gimp_display_shell_transform_segments (selection->shell,
src_segs, dest_segs, n_segs, FALSE);
src_segs, dest_segs, n_segs);
for (i = 0; i < n_segs; i++)
{

View File

@ -63,6 +63,16 @@ static const GimpRGB selection_out_bg = { 0.5, 0.5, 0.5, 1.0 };
static const GimpRGB selection_in_fg = { 0.0, 0.0, 0.0, 1.0 };
static const GimpRGB selection_in_bg = { 1.0, 1.0, 1.0, 1.0 };
static const GimpRGB vectors_normal_bg = { 1.0, 1.0, 1.0, 0.6 };
static const GimpRGB vectors_normal_fg = { 0.0, 0.0, 1.0, 0.8 };
static const GimpRGB vectors_active_bg = { 1.0, 1.0, 1.0, 0.6 };
static const GimpRGB vectors_active_fg = { 1.0, 0.0, 0.0, 0.8 };
static const GimpRGB tool_bg = { 1.0, 1.0, 1.0, 0.6 };
static const GimpRGB tool_fg = { 0.0, 0.0, 0.0, 0.8 };
static const GimpRGB tool_fg_highlight = { 0.0, 1.0, 1.0, 0.8 };
/* public functions */
@ -215,6 +225,7 @@ gimp_display_shell_set_layer_style (GimpDisplayShell *shell,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
cairo_set_line_width (cr, 1.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
if (GIMP_IS_LAYER_MASK (drawable))
{
@ -249,6 +260,7 @@ gimp_display_shell_set_selection_out_style (GimpDisplayShell *shell,
g_return_if_fail (cr != NULL);
cairo_set_line_width (cr, 1.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
pattern = gimp_cairo_stipple_pattern_create (&selection_out_fg,
&selection_out_bg,
@ -275,3 +287,67 @@ gimp_display_shell_set_selection_in_style (GimpDisplayShell *shell,
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
}
void
gimp_display_shell_set_vectors_bg_style (GimpDisplayShell *shell,
cairo_t *cr,
gdouble width,
gboolean active)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL);
cairo_set_line_width (cr, width * 3.0);
if (active)
gimp_cairo_set_source_rgba (cr, &vectors_active_bg);
else
gimp_cairo_set_source_rgba (cr, &vectors_normal_bg);
}
void
gimp_display_shell_set_vectors_fg_style (GimpDisplayShell *shell,
cairo_t *cr,
gdouble width,
gboolean active)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL);
cairo_set_line_width (cr, width);
if (active)
gimp_cairo_set_source_rgba (cr, &vectors_active_fg);
else
gimp_cairo_set_source_rgba (cr, &vectors_normal_fg);
}
void
gimp_display_shell_set_tool_bg_style (GimpDisplayShell *shell,
cairo_t *cr)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL);
cairo_set_line_width (cr, 3.0);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
gimp_cairo_set_source_rgba (cr, &tool_bg);
}
void
gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
cairo_t *cr,
gboolean highlight)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL);
cairo_set_line_width (cr, 1.0);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
if (highlight)
gimp_cairo_set_source_rgba (cr, &tool_fg_highlight);
else
gimp_cairo_set_source_rgba (cr, &tool_fg);
}

View File

@ -46,6 +46,19 @@ void gimp_display_shell_set_selection_out_style (GimpDisplayShell *shell,
void gimp_display_shell_set_selection_in_style (GimpDisplayShell *shell,
cairo_t *cr,
gint index);
void gimp_display_shell_set_vectors_bg_style (GimpDisplayShell *shell,
cairo_t *cr,
gdouble width,
gboolean active);
void gimp_display_shell_set_vectors_fg_style (GimpDisplayShell *shell,
cairo_t *cr,
gdouble width,
gboolean active);
void gimp_display_shell_set_tool_bg_style (GimpDisplayShell *shell,
cairo_t *cr);
void gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
cairo_t *cr,
gboolean highlight);
#endif /* __GIMP_DISPLAY_SHELL_STYLE_H__ */

View File

@ -96,7 +96,6 @@ gimp_display_shell_untransform_coordinate (const GimpDisplayShell *shell,
* @y:
* @nx:
* @ny:
* @use_offsets:
*
* Transforms an image coordinate to a shell coordinate.
**/
@ -105,11 +104,8 @@ gimp_display_shell_transform_xy (const GimpDisplayShell *shell,
gdouble x,
gdouble y,
gint *nx,
gint *ny,
gboolean use_offsets)
gint *ny)
{
gint offset_x = 0;
gint offset_y = 0;
gint64 tx;
gint64 ty;
@ -117,17 +113,6 @@ gimp_display_shell_transform_xy (const GimpDisplayShell *shell,
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
if (use_offsets)
{
GimpImage *image = gimp_display_get_image (shell->display);
GimpItem *item = GIMP_ITEM (gimp_image_get_active_drawable (image));
gimp_item_get_offset (item, &offset_x, &offset_y);
x += offset_x;
y += offset_y;
}
tx = ((gint64) x * shell->x_src_dec) / shell->x_dest_inc;
ty = ((gint64) y * shell->y_src_dec) / shell->y_dest_inc;
@ -149,8 +134,6 @@ gimp_display_shell_transform_xy (const GimpDisplayShell *shell,
* @ny: returns y coordinate in image coordinates
* @round: if %TRUE, round the results to the nearest integer;
* if %FALSE, simply cast them to @gint.
* @use_offsets: if %TRUE, @nx and @ny will be returned in the coordinate
* system of the active drawable instead of the image
*
* Transform from display coordinates to image coordinates, so that
* points on the display can be mapped to the corresponding points
@ -162,11 +145,8 @@ gimp_display_shell_untransform_xy (const GimpDisplayShell *shell,
gint y,
gint *nx,
gint *ny,
gboolean round,
gboolean use_offsets)
gboolean round)
{
gint offset_x = 0;
gint offset_y = 0;
gint64 tx;
gint64 ty;
@ -174,14 +154,6 @@ gimp_display_shell_untransform_xy (const GimpDisplayShell *shell,
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
if (use_offsets)
{
GimpImage *image = gimp_display_get_image (shell->display);
GimpItem *item = GIMP_ITEM (gimp_image_get_active_drawable (image));
gimp_item_get_offset (item, &offset_x, &offset_y);
}
tx = (gint64) x + shell->offset_x;
ty = (gint64) y + shell->offset_y;
@ -194,8 +166,8 @@ gimp_display_shell_untransform_xy (const GimpDisplayShell *shell,
tx /= shell->x_src_dec;
ty /= shell->y_src_dec;
*nx = CLAMP (tx - offset_x, G_MININT, G_MAXINT);
*ny = CLAMP (ty - offset_y, G_MININT, G_MAXINT);
*nx = CLAMP (tx, G_MININT, G_MAXINT);
*ny = CLAMP (ty, G_MININT, G_MAXINT);
}
/**
@ -205,8 +177,6 @@ gimp_display_shell_untransform_xy (const GimpDisplayShell *shell,
* @y: y coordinate of point in image coordinate
* @nx: returns the transformed x coordinate
* @ny: returns the transformed y coordinate
* @use_offsets: if %TRUE, the @x and @y coordinates are in the coordinate
* system of the active drawable instead of the image
*
* This function is identical to gimp_display_shell_transfrom_xy(),
* except that it returns its results as doubles rather than ints.
@ -216,26 +186,14 @@ gimp_display_shell_transform_xy_f (const GimpDisplayShell *shell,
gdouble x,
gdouble y,
gdouble *nx,
gdouble *ny,
gboolean use_offsets)
gdouble *ny)
{
gint offset_x = 0;
gint offset_y = 0;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
if (use_offsets)
{
GimpImage *image = gimp_display_get_image (shell->display);
GimpItem *item = GIMP_ITEM (gimp_image_get_active_drawable (image));
gimp_item_get_offset (item, &offset_x, &offset_y);
}
*nx = SCALEX (shell, x + offset_x) - shell->offset_x;
*ny = SCALEY (shell, y + offset_y) - shell->offset_y;
*nx = SCALEX (shell, x) - shell->offset_x;
*ny = SCALEY (shell, y) - shell->offset_y;
}
/**
@ -245,8 +203,6 @@ gimp_display_shell_transform_xy_f (const GimpDisplayShell *shell,
* @y: y coordinate in display coordinates
* @nx: place to return x coordinate in image coordinates
* @ny: place to return y coordinate in image coordinates
* @use_offsets: if %TRUE, @nx and @ny will be returned in the coordinate
* system of the active drawable instead of the image
*
* This function is identical to gimp_display_shell_untransform_xy(),
* except that the input and output coordinates are doubles rather than
@ -257,26 +213,14 @@ gimp_display_shell_untransform_xy_f (const GimpDisplayShell *shell,
gdouble x,
gdouble y,
gdouble *nx,
gdouble *ny,
gboolean use_offsets)
gdouble *ny)
{
gint offset_x = 0;
gint offset_y = 0;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
if (use_offsets)
{
GimpImage *image = gimp_display_get_image (shell->display);
GimpItem *item = GIMP_ITEM (gimp_image_get_active_drawable (image));
gimp_item_get_offset (item, &offset_x, &offset_y);
}
*nx = (x + shell->offset_x) / shell->scale_x - offset_x;
*ny = (y + shell->offset_y) / shell->scale_y - offset_y;
*nx = (x + shell->offset_x) / shell->scale_x;
*ny = (y + shell->offset_y) / shell->scale_y;
}
/**
@ -285,8 +229,6 @@ gimp_display_shell_untransform_xy_f (const GimpDisplayShell *shell,
* @points: array of GimpVectors2 coordinate pairs
* @coords: returns the corresponding display coordinates
* @n_points: number of points
* @use_offsets: if %TRUE, the source coordinates are in the coordinate
* system of the active drawable instead of the image
*
* Transforms from image coordinates to display coordinates, so that
* objects can be rendered at the correct points on the display.
@ -295,27 +237,16 @@ void
gimp_display_shell_transform_points (const GimpDisplayShell *shell,
const GimpVector2 *points,
GdkPoint *coords,
gint n_points,
gboolean use_offsets)
gint n_points)
{
gint offset_x = 0;
gint offset_y = 0;
gint i;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (use_offsets)
{
GimpImage *image = gimp_display_get_image (shell->display);
GimpItem *item = GIMP_ITEM (gimp_image_get_active_drawable (image));
gimp_item_get_offset (item, &offset_x, &offset_y);
}
for (i = 0; i < n_points ; i++)
{
gdouble x = points[i].x + offset_x;
gdouble y = points[i].y + offset_y;
gdouble x = points[i].x;
gdouble y = points[i].y;
x = x * shell->x_src_dec / shell->x_dest_inc;
y = y * shell->y_src_dec / shell->y_dest_inc;
@ -333,8 +264,6 @@ gimp_display_shell_transform_points (const GimpDisplayShell *shell,
* @image_coords: array of image coordinates
* @disp_coords: returns the corresponding display coordinates
* @n_coords: number of coordinates
* @use_offsets: if %TRUE, the source coordinates are in the coordinate
* system of the active drawable instead of the image
*
* Transforms from image coordinates to display coordinates, so that
* objects can be rendered at the correct points on the display.
@ -343,27 +272,16 @@ void
gimp_display_shell_transform_coords (const GimpDisplayShell *shell,
const GimpCoords *image_coords,
GdkPoint *disp_coords,
gint n_coords,
gboolean use_offsets)
gint n_coords)
{
gint offset_x = 0;
gint offset_y = 0;
gint i;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (use_offsets)
{
GimpImage *image = gimp_display_get_image (shell->display);
GimpItem *item =GIMP_ITEM (gimp_image_get_active_drawable (image));
gimp_item_get_offset (item, &offset_x, &offset_y);
}
for (i = 0; i < n_coords ; i++)
{
gdouble x = image_coords[i].x + offset_x;
gdouble y = image_coords[i].y + offset_y;
gdouble x = image_coords[i].x;
gdouble y = image_coords[i].y;
x = x * shell->x_src_dec / shell->x_dest_inc;
y = y * shell->y_src_dec / shell->y_dest_inc;
@ -381,8 +299,6 @@ gimp_display_shell_transform_coords (const GimpDisplayShell *shell,
* @src_segs: array of segments in image coordinates
* @dest_segs: returns the corresponding segments in display coordinates
* @n_segs: number of segments
* @use_offsets: if %TRUE, the source coordinates are in the coordinate
* system of the active drawable instead of the image
*
* Transforms from image coordinates to display coordinates, so that
* objects can be rendered at the correct points on the display.
@ -391,32 +307,21 @@ void
gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
const BoundSeg *src_segs,
GdkSegment *dest_segs,
gint n_segs,
gboolean use_offsets)
gint n_segs)
{
gint offset_x = 0;
gint offset_y = 0;
gint i;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (use_offsets)
{
GimpImage *image = gimp_display_get_image (shell->display);
GimpItem *item = GIMP_ITEM (gimp_image_get_active_drawable (image));
gimp_item_get_offset (item, &offset_x, &offset_y);
}
for (i = 0; i < n_segs ; i++)
{
gint64 x1, x2;
gint64 y1, y2;
x1 = src_segs[i].x1 + offset_x;
x2 = src_segs[i].x2 + offset_x;
y1 = src_segs[i].y1 + offset_y;
y2 = src_segs[i].y2 + offset_y;
x1 = src_segs[i].x1;
x2 = src_segs[i].x2;
y1 = src_segs[i].y1;
y2 = src_segs[i].y2;
x1 = (x1 * shell->x_src_dec) / shell->x_dest_inc;
x2 = (x2 * shell->x_src_dec) / shell->x_dest_inc;
@ -456,11 +361,11 @@ gimp_display_shell_untransform_viewport (const GimpDisplayShell *shell,
gimp_display_shell_untransform_xy (shell,
0, 0,
&x1, &y1,
FALSE, FALSE);
FALSE);
gimp_display_shell_untransform_xy (shell,
shell->disp_width, shell->disp_height,
&x2, &y2,
FALSE, FALSE);
FALSE);
image = gimp_display_get_image (shell->display);

View File

@ -30,44 +30,37 @@ void gimp_display_shell_transform_xy (const GimpDisplayShell *shell,
gdouble x,
gdouble y,
gint *nx,
gint *ny,
gboolean use_offsets);
gint *ny);
void gimp_display_shell_untransform_xy (const GimpDisplayShell *shell,
gint x,
gint y,
gint *nx,
gint *ny,
gboolean round,
gboolean use_offsets);
gboolean round);
void gimp_display_shell_transform_xy_f (const GimpDisplayShell *shell,
gdouble x,
gdouble y,
gdouble *nx,
gdouble *ny,
gboolean use_offsets);
gdouble *ny);
void gimp_display_shell_untransform_xy_f (const GimpDisplayShell *shell,
gdouble x,
gdouble y,
gdouble *nx,
gdouble *ny,
gboolean use_offsets);
gdouble *ny);
void gimp_display_shell_transform_points (const GimpDisplayShell *shell,
const GimpVector2 *points,
GdkPoint *coords,
gint n_points,
gboolean use_offsets);
gint n_points);
void gimp_display_shell_transform_coords (const GimpDisplayShell *shell,
const GimpCoords *image_coords,
GdkPoint *disp_coords,
gint n_coords,
gboolean use_offsets);
gint n_coords);
void gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
const BoundSeg *src_segs,
GdkSegment *dest_segs,
gint n_segs,
gboolean use_offsets);
gint n_segs);
void gimp_display_shell_untransform_viewport (const GimpDisplayShell *shell,
gint *x,

View File

@ -1093,8 +1093,7 @@ gimp_display_shell_transform_overlay (GimpDisplayShell *shell,
gimp_display_shell_transform_xy_f (shell,
overlay->image_x,
overlay->image_y,
x, y,
FALSE);
x, y);
gtk_widget_size_request (child, &requisition);
@ -1625,8 +1624,8 @@ gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
return FALSE;
}
gimp_display_shell_transform_xy (shell, *x1, *y1, x1, y1, FALSE);
gimp_display_shell_transform_xy (shell, *x2, *y2, x2, y2, FALSE);
gimp_display_shell_transform_xy (shell, *x1, *y1, x1, y1);
gimp_display_shell_transform_xy (shell, *x2, *y2, x2, y2);
/* Make sure the extents are within bounds */
*x1 = CLAMP (*x1, 0, shell->disp_width);
@ -1698,8 +1697,6 @@ gimp_display_shell_pause (GimpDisplayShell *shell)
tool_manager_control_active (shell->display->gimp,
GIMP_TOOL_ACTION_PAUSE,
shell->display);
gimp_display_shell_draw_vectors (shell);
}
}
@ -1722,8 +1719,6 @@ gimp_display_shell_resume (GimpDisplayShell *shell)
if (shell->paused_count == 0)
{
gimp_display_shell_draw_vectors (shell);
/* start the currently active tool */
tool_manager_control_active (shell->display->gimp,
GIMP_TOOL_ACTION_RESUME,

View File

@ -166,10 +166,6 @@ struct _GimpDisplayShell
gint paused_count;
GimpTreeHandler *vectors_freeze_handler;
GimpTreeHandler *vectors_thaw_handler;
GimpTreeHandler *vectors_visible_handler;
gboolean zoom_on_resize;
gboolean show_transform_preview;

View File

@ -1102,8 +1102,7 @@ gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
gimp_display_shell_transform_xy (shell,
0.0, 0.0,
&image_origin_shell_x, &image_origin_shell_y,
FALSE /*use_offsets*/);
&image_origin_shell_x, &image_origin_shell_y);
gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
GTK_WIDGET (window),
image_origin_shell_x, image_origin_shell_y,

View File

@ -170,13 +170,18 @@ splash_create (gboolean be_verbose)
if (gdk_pixbuf_animation_is_static_image (pixbuf))
{
GdkPixmap *pixmap = gdk_pixmap_new (gtk_widget_get_window (splash->area),
GdkPixbuf *static_pixbuf = gdk_pixbuf_animation_get_static_image (pixbuf);
GdkPixmap *pixmap;
cairo_t *cr;
pixmap = gdk_pixmap_new (gtk_widget_get_window (splash->area),
splash->width, splash->height, -1);
gdk_draw_pixbuf (pixmap, gtk_widget_get_style (splash->area)->black_gc,
gdk_pixbuf_animation_get_static_image (pixbuf),
0, 0, 0, 0, splash->width, splash->height,
GDK_RGB_DITHER_NORMAL, 0, 0);
cr = gdk_cairo_create (pixmap);
gdk_cairo_set_source_pixbuf (cr, static_pixbuf, 0.0, 0.0);
cairo_paint (cr);
cairo_destroy (cr);
gdk_window_set_back_pixmap (gtk_widget_get_window (splash->area),
pixmap, FALSE);
g_object_unref (pixmap);

View File

@ -60,6 +60,10 @@
#include "version.h"
#ifdef G_OS_WIN32
/* To get PROCESS_DEP_* defined we need _WIN32_WINNT at 0x0601. We still
* use the API optionally only if present, though.
*/
#define _WIN32_WINNT 0x0601
#include <windows.h>
#include <conio.h>
#endif
@ -279,6 +283,30 @@ main (int argc,
argv = __argv;
#endif
#ifdef G_OS_WIN32
/* Reduce risks */
{
typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
t_SetDllDirectoryA p_SetDllDirectoryA;
p_SetDllDirectoryA = GetProcAddress (GetModuleHandle ("kernel32.dll"),
"SetDllDirectoryA");
if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) ("");
}
#ifndef _WIN64
{
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
t_SetProcessDEPPolicy p_SetProcessDEPPolicy;
p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"),
"SetProcessDEPPolicy");
if (p_SetProcessDEPPolicy)
(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
}
#endif
#endif
g_thread_init (NULL);
#ifdef GIMP_UNSTABLE

View File

@ -973,12 +973,20 @@ gimp_brush_core_create_bound_segs (GimpBrushCore *core,
ratio = gimp_brush_generated_get_aspect_ratio (generated_brush);
g_signal_handlers_block_by_func (generated_brush,
gimp_brush_core_invalidate_cache,
core);
gimp_brush_generated_set_aspect_ratio (generated_brush, 1.0);
mask = gimp_brush_transform_mask (core->main_brush,
1.0, 1.0, 0.0, 1.0);
gimp_brush_generated_set_aspect_ratio (generated_brush, ratio);
g_signal_handlers_unblock_by_func (generated_brush,
gimp_brush_core_invalidate_cache,
core);
}
else
{

View File

@ -25,6 +25,8 @@ libapppdb_a_SOURCES = \
gimppdb-query.h \
gimppdb-utils.c \
gimppdb-utils.h \
gimppdbcontext.c \
gimppdbcontext.h \
gimppdberror.c \
gimppdberror.h \
gimpprocedure.c \
@ -58,6 +60,7 @@ libappinternal_procs_a_SOURCES = \
help-cmds.c \
image-cmds.c \
item-cmds.c \
item-transform-cmds.c \
layer-cmds.c \
message-cmds.c \
misc-cmds.c \

View File

@ -364,7 +364,7 @@ register_channel_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-channel-new",
"Create a new channel.",
"This procedure creates a new channel with the specified width and height. Name, opacity, and color are also supplied parameters. The new channel still needs to be added to the image, as this is not automatic. Add the new channel with the 'gimp-image-add-channel' command. Other attributes such as channel show masked, should be set with explicit procedure calls. The channel's contents are undefined initially.",
"This procedure creates a new channel with the specified width and height. Name, opacity, and color are also supplied parameters. The new channel still needs to be added to the image, as this is not automatic. Add the new channel with the 'gimp-image-insert-channel' command. Other attributes such as channel show masked, should be set with explicit procedure calls. The channel's contents are undefined initially.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",

View File

@ -27,7 +27,6 @@
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimpparamspecs.h"
#include "plug-in/gimpplugin-context.h"
@ -36,6 +35,7 @@
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimppdbcontext.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
@ -627,6 +627,328 @@ context_set_font_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
context_get_antialias_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gboolean antialias = FALSE;
g_object_get (context,
"antialias", &antialias,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_boolean (&return_vals->values[1], antialias);
return return_vals;
}
static GValueArray *
context_set_antialias_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gboolean antialias;
antialias = g_value_get_boolean (&args->values[0]);
if (success)
{
g_object_set (context,
"antialias", antialias,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_feather_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gboolean feather = FALSE;
g_object_get (context,
"feather", &feather,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_boolean (&return_vals->values[1], feather);
return return_vals;
}
static GValueArray *
context_set_feather_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gboolean feather;
feather = g_value_get_boolean (&args->values[0]);
if (success)
{
g_object_set (context,
"feather", feather,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_feather_radius_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gdouble feather_radius_x = 0.0;
gdouble feather_radius_y = 0.0;
g_object_get (context,
"feather-radius-x", &feather_radius_x,
"feather-radius-y", &feather_radius_y,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_double (&return_vals->values[1], feather_radius_x);
g_value_set_double (&return_vals->values[2], feather_radius_y);
return return_vals;
}
static GValueArray *
context_set_feather_radius_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gdouble feather_radius_x;
gdouble feather_radius_y;
feather_radius_x = g_value_get_double (&args->values[0]);
feather_radius_y = g_value_get_double (&args->values[1]);
if (success)
{
g_object_set (context,
"feather-radius-x", feather_radius_x,
"feather-radius-y", feather_radius_y,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_interpolation_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 interpolation = 0;
g_object_get (context,
"interpolation", &interpolation,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_enum (&return_vals->values[1], interpolation);
return return_vals;
}
static GValueArray *
context_set_interpolation_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint32 interpolation;
interpolation = g_value_get_enum (&args->values[0]);
if (success)
{
g_object_set (context,
"interpolation", interpolation,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_transform_direction_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 transform_direction = 0;
g_object_get (context,
"transform-direction", &transform_direction,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_enum (&return_vals->values[1], transform_direction);
return return_vals;
}
static GValueArray *
context_set_transform_direction_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint32 transform_direction;
transform_direction = g_value_get_enum (&args->values[0]);
if (success)
{
g_object_set (context,
"transform-direction", transform_direction,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_transform_resize_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 transform_resize = 0;
g_object_get (context,
"transform-resize", &transform_resize,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_enum (&return_vals->values[1], transform_resize);
return return_vals;
}
static GValueArray *
context_set_transform_resize_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint32 transform_resize;
transform_resize = g_value_get_enum (&args->values[0]);
if (success)
{
g_object_set (context,
"transform-resize", transform_resize,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_transform_recursion_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 transform_recursion = 0;
g_object_get (context,
"transform-recursion", &transform_recursion,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (&return_vals->values[1], transform_recursion);
return return_vals;
}
static GValueArray *
context_set_transform_recursion_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint32 transform_recursion;
transform_recursion = g_value_get_int (&args->values[0]);
if (success)
{
g_object_set (context,
"transform-recursion", transform_recursion,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_context_procs (GimpPDB *pdb)
{
@ -1205,4 +1527,344 @@ register_context_procs (GimpPDB *pdb)
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-antialias
*/
procedure = gimp_procedure_new (context_get_antialias_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-antialias");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-antialias",
"Get the antialias setting.",
"This procedure returns the antialias setting.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("antialias",
"antialias",
"The antialias setting",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-antialias
*/
procedure = gimp_procedure_new (context_set_antialias_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-antialias");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-antialias",
"Set the antialias setting.",
"This procedure modifies the antialias setting. This settings affects the following procedures: gimp-item-to-selection.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("antialias",
"antialias",
"The antialias setting",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-feather
*/
procedure = gimp_procedure_new (context_get_feather_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-feather");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-feather",
"Get the feather setting.",
"This procedure returns the feather setting.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("feather",
"feather",
"The feather setting",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-feather
*/
procedure = gimp_procedure_new (context_set_feather_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-feather");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-feather",
"Set the feather setting.",
"This procedure modifies the feather setting. This settings affects the following procedures: gimp-item-to-selection.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("feather",
"feather",
"The feather setting",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-feather-radius
*/
procedure = gimp_procedure_new (context_get_feather_radius_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-feather-radius");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-feather-radius",
"Get the feather radius setting.",
"This procedure returns the feather radius setting.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("feather-radius-x",
"feather radius x",
"The horizontal feather radius",
0, 1000, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("feather-radius-y",
"feather radius y",
"The vertical feather radius",
0, 1000, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-feather-radius
*/
procedure = gimp_procedure_new (context_set_feather_radius_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-feather-radius");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-feather-radius",
"Set the feather radius setting.",
"This procedure modifies the feather radius setting. This settings affects the following procedures: gimp-item-to-selection.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_double ("feather-radius-x",
"feather radius x",
"The horizontal feather radius",
0, 1000, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("feather-radius-y",
"feather radius y",
"The vertical feather radius",
0, 1000, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-interpolation
*/
procedure = gimp_procedure_new (context_get_interpolation_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-interpolation");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-interpolation",
"Get the interpolation type.",
"This procedure returns the interpolation setting. The return value is an integer which corresponds to the values listed in the argument description.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("interpolation",
"interpolation",
"The interpolation type",
GIMP_TYPE_INTERPOLATION_TYPE,
GIMP_INTERPOLATION_NONE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-interpolation
*/
procedure = gimp_procedure_new (context_set_interpolation_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-interpolation");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-interpolation",
"Set the interpolation type.",
"This procedure modifies the interpolation setting. It affects the following procedures: all transform procedures which can produce sub-pixel results, 'gimp-image-scale', 'gimp-layer-scale'.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("interpolation",
"interpolation",
"The interpolation type",
GIMP_TYPE_INTERPOLATION_TYPE,
GIMP_INTERPOLATION_NONE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-transform-direction
*/
procedure = gimp_procedure_new (context_get_transform_direction_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-transform-direction");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-transform-direction",
"Get the transform direction.",
"This procedure returns the transform direction. The return value is an integer which corresponds to the values listed in the argument description.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("transform-direction",
"transform direction",
"The transform direction",
GIMP_TYPE_TRANSFORM_DIRECTION,
GIMP_TRANSFORM_FORWARD,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-transform-direction
*/
procedure = gimp_procedure_new (context_set_transform_direction_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-transform-direction");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-transform-direction",
"Set the transform direction.",
"This procedure modifies the transform direction setting.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("transform-direction",
"transform direction",
"The transform direction",
GIMP_TYPE_TRANSFORM_DIRECTION,
GIMP_TRANSFORM_FORWARD,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-transform-resize
*/
procedure = gimp_procedure_new (context_get_transform_resize_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-transform-resize");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-transform-resize",
"Get the transform resize type.",
"This procedure returns the transform resize setting. The return value is an integer which corresponds to the values listed in the argument description.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("transform-resize",
"transform resize",
"The transform resize type",
GIMP_TYPE_TRANSFORM_RESIZE,
GIMP_TRANSFORM_RESIZE_ADJUST,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-transform-resize
*/
procedure = gimp_procedure_new (context_set_transform_resize_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-transform-resize");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-transform-resize",
"Set the transform resize type.",
"This procedure modifies the transform resize setting. When transforming pixels, if the result of a transform operation has a different size than the original area, this setting determines how the resulting area is sized.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("transform-resize",
"transform resize",
"The transform resize type",
GIMP_TYPE_TRANSFORM_RESIZE,
GIMP_TRANSFORM_RESIZE_ADJUST,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-transform-recursion
*/
procedure = gimp_procedure_new (context_get_transform_recursion_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-transform-recursion");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-transform-recursion",
"Get the transform supersampling recursion.",
"This procedure returns the transform supersampling recursion level.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("transform-recursion",
"transform recursion",
"The transform recursion level",
1, G_MAXINT32, 1,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-transform-recursion
*/
procedure = gimp_procedure_new (context_set_transform_recursion_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-transform-recursion");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-transform-recursion",
"Set the transform supersampling recursion.",
"This procedure modifies the transform supersampling recursion level setting. Whether or not a transformation does supersampling is determined by the interplolation type. The recursion level defaults to 3, which is a nice default value.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("transform-recursion",
"transform recursion",
"The transform recursion level",
1, G_MAXINT32, 1,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View File

@ -34,13 +34,10 @@
#include "core/gimpdrawable-shadow.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimpparamspecs.h"
#include "plug-in/gimpplugin-cleanup.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "text/gimptextlayer.h"
#include "gimppdb.h"
#include "gimppdb-utils.h"
@ -50,145 +47,6 @@
#include "gimp-intl.h"
static GValueArray *
drawable_is_valid_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
GimpDrawable *drawable;
gboolean valid = FALSE;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
valid = (GIMP_IS_DRAWABLE (drawable) &&
! gimp_item_is_removed (GIMP_ITEM (drawable)));
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_boolean (&return_vals->values[1], valid);
return return_vals;
}
static GValueArray *
drawable_is_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gboolean layer = FALSE;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
layer = GIMP_IS_LAYER (drawable);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], layer);
return return_vals;
}
static GValueArray *
drawable_is_text_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gboolean text_layer = FALSE;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
text_layer = gimp_drawable_is_text_layer (drawable);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], text_layer);
return return_vals;
}
static GValueArray *
drawable_is_layer_mask_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gboolean layer_mask = FALSE;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
layer_mask = GIMP_IS_LAYER_MASK (drawable);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], layer_mask);
return return_vals;
}
static GValueArray *
drawable_is_channel_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gboolean channel = FALSE;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
channel = GIMP_IS_CHANNEL (drawable);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], channel);
return return_vals;
}
static GValueArray *
drawable_type_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -483,63 +341,6 @@ drawable_offsets_invoker (GimpProcedure *procedure,
return return_vals;
}
static GValueArray *
drawable_delete_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
if (g_object_is_floating (drawable))
{
g_object_ref_sink (drawable);
g_object_unref (drawable);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
drawable_get_image_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
GimpImage *image = NULL;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
image = gimp_item_get_image (GIMP_ITEM (drawable));
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
gimp_value_set_image (&return_vals->values[1], image);
return return_vals;
}
static GValueArray *
drawable_set_image_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -565,218 +366,6 @@ drawable_set_image_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
drawable_get_name_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gchar *name = NULL;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
name = g_strdup (gimp_object_get_name (drawable));
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_string (&return_vals->values[1], name);
return return_vals;
}
static GValueArray *
drawable_set_name_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
const gchar *name;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
name = g_value_get_string (&args->values[1]);
if (success)
{
success = gimp_item_rename (GIMP_ITEM (drawable), name, error);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
drawable_get_visible_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gboolean visible = FALSE;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
visible = gimp_item_get_visible (GIMP_ITEM (drawable));
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], visible);
return return_vals;
}
static GValueArray *
drawable_set_visible_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gboolean visible;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
visible = g_value_get_boolean (&args->values[1]);
if (success)
{
gimp_item_set_visible (GIMP_ITEM (drawable), visible, TRUE);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
drawable_get_linked_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gboolean linked = FALSE;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
linked = gimp_item_get_linked (GIMP_ITEM (drawable));
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], linked);
return return_vals;
}
static GValueArray *
drawable_set_linked_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gboolean linked;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
linked = g_value_get_boolean (&args->values[1]);
if (success)
{
gimp_item_set_linked (GIMP_ITEM (drawable), linked, TRUE);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
drawable_get_tattoo_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gint32 tattoo = 0;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
tattoo = gimp_item_get_tattoo (GIMP_ITEM (drawable));
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_uint (&return_vals->values[1], tattoo);
return return_vals;
}
static GValueArray *
drawable_set_tattoo_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 tattoo;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
tattoo = g_value_get_uint (&args->values[1]);
if (success)
{
gimp_item_set_tattoo (GIMP_ITEM (drawable), tattoo);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
drawable_mask_bounds_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -799,7 +388,7 @@ drawable_mask_bounds_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error))
non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
non_empty = gimp_item_mask_bounds (GIMP_ITEM (drawable), &x1, &y1, &x2, &y2);
else
success = FALSE;
}
@ -841,7 +430,7 @@ drawable_mask_intersect_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error))
non_empty = gimp_drawable_mask_intersect (drawable,
non_empty = gimp_item_mask_intersect (GIMP_ITEM (drawable),
&x, &y, &width, &height);
else
success = FALSE;
@ -1327,151 +916,6 @@ register_drawable_procs (GimpPDB *pdb)
{
GimpProcedure *procedure;
/*
* gimp-drawable-is-valid
*/
procedure = gimp_procedure_new (drawable_is_valid_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-is-valid");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-is-valid",
"Deprecated: Use 'gimp-item-is-valid' instead.",
"Deprecated: Use 'gimp-item-is-valid' instead.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2007",
"gimp-item-is-valid");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable to check",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("valid",
"valid",
"Whether the drawable ID is valid",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-is-layer
*/
procedure = gimp_procedure_new (drawable_is_layer_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-is-layer");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-is-layer",
"Deprecated: Use 'gimp-item-is-layer' instead.",
"Deprecated: Use 'gimp-item-is-layer' instead.",
"",
"",
"",
"gimp-item-is-layer");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("layer",
"layer",
"TRUE if the drawable is a layer, FALSE otherwise",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-is-text-layer
*/
procedure = gimp_procedure_new (drawable_is_text_layer_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-is-text-layer");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-is-text-layer",
"Returns whether the drawable is a text layer.",
"This procedure returns TRUE if the specified drawable is a text layer.",
"Marcus Heese <heese@cip.ifi.lmu.de>",
"Marcus Heese",
"2008",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("text-layer",
"text layer",
"TRUE if the drawable is a text layer, FALSE otherwise.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-is-layer-mask
*/
procedure = gimp_procedure_new (drawable_is_layer_mask_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-is-layer-mask");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-is-layer-mask",
"Deprecated: Use 'gimp-item-is-layer-mask' instead.",
"Deprecated: Use 'gimp-item-is-layer-mask' instead.",
"",
"",
"",
"gimp-item-is-layer-mask");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("layer-mask",
"layer mask",
"TRUE if the drawable is a layer mask, FALSE otherwise",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-is-channel
*/
procedure = gimp_procedure_new (drawable_is_channel_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-is-channel");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-is-channel",
"Deprecated: Use 'gimp-item-is-channel' instead.",
"Deprecated: Use 'gimp-item-is-channel' instead.",
"",
"",
"",
"gimp-item-is-channel");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("channel",
"channel",
"TRUE if the drawable is a channel, FALSE otherwise",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-type
*/
@ -1776,58 +1220,6 @@ register_drawable_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-delete
*/
procedure = gimp_procedure_new (drawable_delete_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-delete");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-delete",
"Deprecated: Use 'gimp-item-delete' instead.",
"Deprecated: Use 'gimp-item-delete' instead.",
"",
"",
"",
"gimp-item-delete");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable to delete",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-get-image
*/
procedure = gimp_procedure_new (drawable_get_image_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-get-image");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-get-image",
"Deprecated: Use 'gimp-item-get-image' instead.",
"Deprecated: Use 'gimp-item-get-image' instead.",
"",
"",
"",
"gimp-item-get-image");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_image_id ("image",
"image",
"The drawable's image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-set-image
*/
@ -1857,240 +1249,6 @@ register_drawable_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-get-name
*/
procedure = gimp_procedure_new (drawable_get_name_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-get-name");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-get-name",
"Deprecated: Use 'gimp-item-get-name' instead.",
"Deprecated: Use 'gimp-item-get-name' instead.",
"",
"",
"",
"gimp-item-get-name");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_string ("name",
"name",
"The drawable name",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-set-name
*/
procedure = gimp_procedure_new (drawable_set_name_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-set-name");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-set-name",
"Deprecated: Use 'gimp-item-set-name' instead.",
"Deprecated: Use 'gimp-item-set-name' instead.",
"",
"",
"",
"gimp-item-set-name");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The new drawable name",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-get-visible
*/
procedure = gimp_procedure_new (drawable_get_visible_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-get-visible");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-get-visible",
"Deprecated: Use 'gimp-item-get-visible' instead.",
"Deprecated: Use 'gimp-item-get-visible' instead.",
"",
"",
"",
"gimp-item-get-visible");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("visible",
"visible",
"The drawable visibility",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-set-visible
*/
procedure = gimp_procedure_new (drawable_set_visible_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-set-visible");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-set-visible",
"Deprecated: Use 'gimp-item-set-visible' instead.",
"Deprecated: Use 'gimp-item-set-visible' instead.",
"",
"",
"",
"gimp-item-set-visible");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("visible",
"visible",
"The new drawable visibility",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-get-linked
*/
procedure = gimp_procedure_new (drawable_get_linked_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-get-linked");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-get-linked",
"Deprecated: Use 'gimp-item-get-linked' instead.",
"Deprecated: Use 'gimp-item-get-linked' instead.",
"Wolfgang Hofer",
"Wolfgang Hofer",
"1998",
"gimp-item-get-linked");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("linked",
"linked",
"The drawable linked state (for moves)",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-set-linked
*/
procedure = gimp_procedure_new (drawable_set_linked_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-set-linked");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-set-linked",
"Deprecated: Use 'gimp-item-set-linked' instead.",
"Deprecated: Use 'gimp-item-set-linked' instead.",
"Wolfgang Hofer",
"Wolfgang Hofer",
"1998",
"gimp-item-set-linked");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("linked",
"linked",
"The new drawable linked state",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-get-tattoo
*/
procedure = gimp_procedure_new (drawable_get_tattoo_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-get-tattoo");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-get-tattoo",
"Deprecated: Use 'gimp-item-get-tattoo' instead.",
"Deprecated: Use 'gimp-item-get-tattoo' instead.",
"Jay Cox",
"Jay Cox",
"1998",
"gimp-item-get-tattoo");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_uint ("tattoo",
"tattoo",
"The drawable tattoo",
1, G_MAXUINT32, 1,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-set-tattoo
*/
procedure = gimp_procedure_new (drawable_set_tattoo_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-set-tattoo");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-set-tattoo",
"Deprecated: Use 'gimp-item-set-tattoo' instead.",
"Deprecated: Use 'gimp-item-set-tattoo' instead.",
"Jay Cox",
"Jay Cox",
"1998",
"gimp-item-set-tattoo");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_uint ("tattoo",
"tattoo",
"The new drawable tattoo",
1, G_MAXUINT32, 1,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-mask-bounds
*/
@ -2397,7 +1555,7 @@ register_drawable_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-fill",
"Fill the drawable with the specified fill mode.",
"This procedure fills the drawable. If the fill mode is foreground the current foreground color is used. If the fill mode is background, the current background color is used. If the fill type is white, then white is used. Transparent fill only affects layers with an alpha channel, in which case the alpha channel is set to transparent. If the drawable has no alpha channel, it is filled to white. No fill leaves the drawable's contents undefined. This procedure is unlike the bucket fill tool because it fills regardless of a selection. Its main purpose is to fill a newly created drawable before adding it to the image. This operation cannot be undone.",
"This procedure fills the drawable. If the fill mode is foreground the current foreground color is used. If the fill mode is background, the current background color is used. If the fill type is white, then white is used. Transparent fill only affects layers with an alpha channel, in which case the alpha channel is set to transparent. If the drawable has no alpha channel, it is filled to white. No fill leaves the drawable's contents undefined. This procedure is unlike 'gimp-edit-fill' or the bucket fill tool because it fills regardless of a selection. Its main purpose is to fill a newly created drawable before adding it to the image. This operation cannot be undone.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",

View File

@ -71,12 +71,18 @@ drawable_transform_flip_simple_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
success = gimp_drawable_transform_flip (drawable, context,
gimp_transform_get_flip_axis (x, y, width, height,
flip_type, auto_center, &axis);
if (! gimp_drawable_transform_flip (drawable, context,
flip_type,
auto_center, axis,
clip_result);
axis,
clip_result))
{
success = FALSE;
}
}
}
@ -128,7 +134,7 @@ drawable_transform_flip_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
gint off_x, off_y;
@ -146,11 +152,13 @@ drawable_transform_flip_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Flipping"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, transform_direction,
interpolation, recursion_level,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -199,7 +207,7 @@ drawable_transform_flip_default_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
@ -221,11 +229,13 @@ drawable_transform_flip_default_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Flipping"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, GIMP_TRANSFORM_FORWARD,
interpolation_type, 3,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -288,7 +298,7 @@ drawable_transform_perspective_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
gint off_x, off_y;
@ -308,11 +318,13 @@ drawable_transform_perspective_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Perspective"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, transform_direction,
interpolation, recursion_level,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -369,7 +381,7 @@ drawable_transform_perspective_default_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
@ -393,11 +405,13 @@ drawable_transform_perspective_default_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Perspective"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, GIMP_TRANSFORM_FORWARD,
interpolation_type, 3,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -444,12 +458,21 @@ drawable_transform_rotate_simple_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, FALSE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
success = gimp_drawable_transform_rotate (drawable, context,
gdouble cx = center_x;
gdouble cy = center_y;
gimp_transform_get_rotate_center (x, y, width, height,
auto_center, &cx, &cy);
if (! gimp_drawable_transform_rotate (drawable, context,
rotate_type,
auto_center, center_x, center_y,
clip_result);
cx, cy,
clip_result))
{
success = FALSE;
}
}
}
@ -501,7 +524,7 @@ drawable_transform_rotate_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
gint off_x, off_y;
@ -523,11 +546,13 @@ drawable_transform_rotate_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Rotating"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, transform_direction,
interpolation, recursion_level,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -576,7 +601,7 @@ drawable_transform_rotate_default_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
@ -602,11 +627,13 @@ drawable_transform_rotate_default_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Rotating"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, GIMP_TRANSFORM_FORWARD,
interpolation_type, 3,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -661,7 +688,7 @@ drawable_transform_scale_invoker (GimpProcedure *procedure,
success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) && x0 < x1 && y0 < y1);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
gint off_x, off_y;
@ -680,11 +707,13 @@ drawable_transform_scale_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Scaling"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, transform_direction,
interpolation, recursion_level,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -733,7 +762,7 @@ drawable_transform_scale_default_invoker (GimpProcedure *procedure,
success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) && x0 < x1 && y0 < y1);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
@ -756,11 +785,13 @@ drawable_transform_scale_default_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Scaling"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, GIMP_TRANSFORM_FORWARD,
interpolation_type, 3,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -811,7 +842,7 @@ drawable_transform_shear_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
gint off_x, off_y;
@ -830,11 +861,13 @@ drawable_transform_shear_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Shearing"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, transform_direction,
interpolation, recursion_level,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -879,7 +912,7 @@ drawable_transform_shear_default_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
@ -902,11 +935,13 @@ drawable_transform_shear_default_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("Shearing"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, GIMP_TRANSFORM_FORWARD,
interpolation_type, 3,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -967,7 +1002,7 @@ drawable_transform_2d_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
gint off_x, off_y;
@ -987,11 +1022,13 @@ drawable_transform_2d_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("2D Transform"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, transform_direction,
interpolation, recursion_level,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -1046,7 +1083,7 @@ drawable_transform_2d_default_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
@ -1070,11 +1107,13 @@ drawable_transform_2d_default_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("2D Transforming"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, GIMP_TRANSFORM_FORWARD,
interpolation_type, 3,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -1139,7 +1178,7 @@ drawable_transform_matrix_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
gint off_x, off_y;
@ -1163,11 +1202,13 @@ drawable_transform_matrix_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("2D Transforming"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, transform_direction,
interpolation, recursion_level,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -1226,7 +1267,7 @@ drawable_transform_matrix_default_invoker (GimpProcedure *procedure,
success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
{
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
@ -1254,11 +1295,13 @@ drawable_transform_matrix_default_invoker (GimpProcedure *procedure,
if (progress)
gimp_progress_start (progress, _("2D Transforming"), FALSE);
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
if (! gimp_drawable_transform_affine (drawable, context,
&matrix, GIMP_TRANSFORM_FORWARD,
interpolation_type, 3,
clip_result, progress);
clip_result, progress))
{
success = FALSE;
}
if (progress)
gimp_progress_end (progress);
@ -1287,12 +1330,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-flip-simple");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-flip-simple",
"Flip the specified drawable either vertically or horizontally.",
"This procedure flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. If auto_center is set to TRUE, the flip is around the selection's center. Otherwise, the coordinate of the axis needs to be specified. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipped drawable.",
"Deprecated: Use 'gimp-item-transform-flip-simple' instead.",
"Deprecated: Use 'gimp-item-transform-flip-simple' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-flip-simple");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1343,12 +1386,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-flip");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-flip",
"Flip the specified drawable around a given line.",
"This procedure flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. The axis to flip around is specified by specifying two points from that line. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipped drawable. The clip results parameter specifies wheter current selection will affect the transform.",
"Deprecated: Use 'gimp-item-transform-flip' instead.",
"Deprecated: Use 'gimp-item-transform-flip' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-flip");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1428,12 +1471,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-flip-default");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-flip-default",
"Flip the specified drawable around a given line.",
"This procedure is a variant of 'gimp-drawable-transform-flip' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
"Deprecated: Use 'gimp-item-transform-flip' instead.",
"Deprecated: Use 'gimp-item-transform-flip' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-flip");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1493,12 +1536,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-perspective");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-perspective",
"Perform a possibly non-affine transformation on the specified drawable, with extra parameters.",
"This procedure performs a possibly non-affine transformation on the specified drawable by allowing the corners of the original bounding box to be arbitrarily remapped to any values. The specified drawable is remapped if no selection exists. However, if a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then remapped as specified. The return value is the ID of the remapped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and remapped drawable. The 4 coordinates specify the new locations of each corner of the original bounding box. By specifying these values, any affine transformation (rotation, scaling, translation) can be affected. Additionally, these values can be specified such that the resulting transformed drawable will appear to have been projected via a perspective transform.",
"Deprecated: Use 'gimp-item-transform-perspective' instead.",
"Deprecated: Use 'gimp-item-transform-perspective' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-perspective");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1603,12 +1646,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-perspective-default");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-perspective-default",
"Perform a possibly non-affine transformation on the specified drawable, with extra parameters.",
"This procedure is a variant of 'gimp-drawable-transform-perspective' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
"Deprecated: Use 'gimp-item-transform-perspective' instead.",
"Deprecated: Use 'gimp-item-transform-perspective' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-perspective");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1693,12 +1736,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-rotate-simple");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-rotate-simple",
"Rotate the specified drawable about given coordinates through the specified angle.",
"This function rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
"Deprecated: Use 'gimp-item-transform-rotate-simple' instead.",
"Deprecated: Use 'gimp-item-transform-rotate-simple' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-rotate-simple");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1753,12 +1796,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-rotate");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-rotate",
"Rotate the specified drawable about given coordinates through the specified angle.",
"This function rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
"Deprecated: Use 'gimp-item-transform-rotate' instead.",
"Deprecated: Use 'gimp-item-transform-rotate' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-rotate");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1839,12 +1882,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-rotate-default");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-rotate-default",
"Rotate the specified drawable about given coordinates through the specified angle.",
"This procedure is a variant of 'gimp-drawable-transform-rotate' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
"Deprecated: Use 'gimp-item-transform-rotate' instead.",
"Deprecated: Use 'gimp-item-transform-rotate' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-rotate");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1905,12 +1948,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-scale");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-scale",
"Scale the specified drawable with extra parameters",
"This procedure scales the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then scaled by the specified amount. The return value is the ID of the scaled drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and scaled drawable.",
"Deprecated: Use 'gimp-item-transform-scale' instead.",
"Deprecated: Use 'gimp-item-transform-scale' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-scale");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1991,12 +2034,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-scale-default");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-scale-default",
"Scale the specified drawable with extra parameters",
"This procedure is a variant of 'gimp-drawable-transform-scale' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
"Deprecated: Use 'gimp-item-transform-scale' instead.",
"Deprecated: Use 'gimp-item-transform-scale' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-scale");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -2057,12 +2100,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-shear");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-shear",
"Shear the specified drawable about its center by the specified magnitude, with extra parameters.",
"This procedure shears the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then sheard by the specified amount. The return value is the ID of the sheard drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and sheard drawable. The shear type parameter indicates whether the shear will be applied horizontally or vertically. The magnitude can be either positive or negative and indicates the extent (in pixels) to shear by.",
"Deprecated: Use 'gimp-item-transform-shear' instead.",
"Deprecated: Use 'gimp-item-transform-shear' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-shear");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -2134,12 +2177,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-shear-default");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-shear-default",
"Shear the specified drawable about its center by the specified magnitude, with extra parameters.",
"This procedure is a variant of 'gimp-drawable-transform-shear' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
"Deprecated: Use 'gimp-item-transform-shear' instead.",
"Deprecated: Use 'gimp-item-transform-shear' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-shear");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -2191,12 +2234,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-2d");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-2d",
"Transform the specified drawable in 2d, with extra parameters.",
"This procedure transforms the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed. The transformation is done by scaling the image by the x and y scale factors about the point (source_x, source_y), then rotating around the same point, then translating that point to the new position (dest_x, dest_y). The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and transformed drawable.",
"Deprecated: Use 'gimp-item-transform-2d' instead.",
"Deprecated: Use 'gimp-item-transform-2d' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-2d");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -2295,12 +2338,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-2d-default");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-2d-default",
"Transform the specified drawable in 2d, with extra parameters.",
"This procedure is a variant of 'gimp-drawable-transform-2d' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
"Deprecated: Use 'gimp-item-transform-2d' instead.",
"Deprecated: Use 'gimp-item-transform-2d' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-2d");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -2379,12 +2422,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-matrix");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-matrix",
"Transform the specified drawable in 2d, with extra parameters.",
"This procedure transforms the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed. The transformation is done by assembling a 3x3 matrix from the coefficients passed. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and transformed drawable.",
"Deprecated: Use 'gimp-item-transform-matrix' instead.",
"Deprecated: Use 'gimp-item-transform-matrix' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-matrix");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -2495,12 +2538,12 @@ register_drawable_transform_procs (GimpPDB *pdb)
"gimp-drawable-transform-matrix-default");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-transform-matrix-default",
"Transform the specified drawable in 2d, with extra parameters.",
"This procedure is a variant of 'gimp-drawable-transform-matrix' which uses no interpolation/supersampling at all, or default values (depending on the 'interpolate' parameter).",
"Deprecated: Use 'gimp-item-transform-matrix' instead.",
"Deprecated: Use 'gimp-item-transform-matrix' instead.",
"Jo\xc3\xa3o S. O. Bueno",
"Jo\xc3\xa3o S. O. Bueno",
"2004",
NULL);
"gimp-item-transform-matrix");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",

View File

@ -609,7 +609,7 @@ register_fileops_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-file-load-layer",
"Loads an image file as a layer for an existing image.",
"This procedure behaves like the file-load procedure but opens the specified image as a layer for an existing image. The returned layer needs to be added to the existing image with 'gimp-image-add-layer'.",
"This procedure behaves like the file-load procedure but opens the specified image as a layer for an existing image. The returned layer needs to be added to the existing image with 'gimp-image-insert-layer'.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005",
@ -654,7 +654,7 @@ register_fileops_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-file-load-layers",
"Loads an image file as layers for an existing image.",
"This procedure behaves like the file-load procedure but opens the specified image as layers for an existing image. The returned layers needs to be added to the existing image with 'gimp-image-add-layer'.",
"This procedure behaves like the file-load procedure but opens the specified image as layers for an existing image. The returned layers needs to be added to the existing image with 'gimp-image-insert-layer'.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2006",

View File

@ -365,13 +365,13 @@ gimp_pdb_compat_procs_register (GimpPDB *pdb,
{ "gimp-blend", "gimp-edit-blend" },
{ "gimp-brushes-list", "gimp-brushes-get-list" },
{ "gimp-bucket-fill", "gimp-edit-bucket-fill" },
{ "gimp-channel-delete", "gimp-drawable-delete" },
{ "gimp-channel-get-name", "gimp-drawable-get-name" },
{ "gimp-channel-get-tattoo", "gimp-drawable-get-tattoo" },
{ "gimp-channel-get-visible", "gimp-drawable-get-visible" },
{ "gimp-channel-set-name", "gimp-drawable-set-name" },
{ "gimp-channel-set-tattoo", "gimp-drawable-set-tattoo" },
{ "gimp-channel-set-visible", "gimp-drawable-set-visible" },
{ "gimp-channel-delete", "gimp-item-delete" },
{ "gimp-channel-get-name", "gimp-item-get-name" },
{ "gimp-channel-get-tattoo", "gimp-item-get-tattoo" },
{ "gimp-channel-get-visible", "gimp-item-get-visible" },
{ "gimp-channel-set-name", "gimp-item-set-name" },
{ "gimp-channel-set-tattoo", "gimp-item-set-tattoo" },
{ "gimp-channel-set-visible", "gimp-item-set-visible" },
{ "gimp-color-picker", "gimp-image-pick-color" },
{ "gimp-convert-grayscale", "gimp-image-convert-grayscale" },
{ "gimp-convert-indexed", "gimp-image-convert-indexed" },
@ -381,16 +381,16 @@ gimp_pdb_compat_procs_register (GimpPDB *pdb,
{ "gimp-drawable-image", "gimp-drawable-get-image" },
{ "gimp-image-active-drawable", "gimp-image-get-active-drawable" },
{ "gimp-image-floating-selection", "gimp-image-get-floating-sel" },
{ "gimp-layer-delete", "gimp-drawable-delete" },
{ "gimp-layer-get-linked", "gimp-drawable-get-linked" },
{ "gimp-layer-get-name", "gimp-drawable-get-name" },
{ "gimp-layer-get-tattoo", "gimp-drawable-get-tattoo" },
{ "gimp-layer-get-visible", "gimp-drawable-get-visible" },
{ "gimp-layer-delete", "gimp-item-delete" },
{ "gimp-layer-get-linked", "gimp-item-get-linked" },
{ "gimp-layer-get-name", "gimp-item-get-name" },
{ "gimp-layer-get-tattoo", "gimp-item-get-tattoo" },
{ "gimp-layer-get-visible", "gimp-item-get-visible" },
{ "gimp-layer-mask", "gimp-layer-get-mask" },
{ "gimp-layer-set-linked", "gimp-drawable-set-linked" },
{ "gimp-layer-set-name", "gimp-drawable-set-name" },
{ "gimp-layer-set-tattoo", "gimp-drawable-set-tattoo" },
{ "gimp-layer-set-visible", "gimp-drawable-set-visible" },
{ "gimp-layer-set-linked", "gimp-item-set-linked" },
{ "gimp-layer-set-name", "gimp-item-set-name" },
{ "gimp-layer-set-tattoo", "gimp-item-set-tattoo" },
{ "gimp-layer-set-visible", "gimp-item-set-visible" },
{ "gimp-palette-refresh", "gimp-palettes-refresh" },
{ "gimp-patterns-list", "gimp-patterns-get-list" },
{ "gimp-temp-PDB-name", "gimp-procedural-db-temp-name" },
@ -423,7 +423,34 @@ gimp_pdb_compat_procs_register (GimpPDB *pdb,
/* deprecations since 2.2 */
{ "gimp-layer-get-preserve-trans", "gimp-layer-get-lock-alpha" },
{ "gimp-layer-set-preserve-trans", "gimp-layer-set-lock-alpha" }
{ "gimp-layer-set-preserve-trans", "gimp-layer-set-lock-alpha" },
/* deprecations since 2.6 */
{ "gimp-drawable-is-valid", "gimp-item-is-valid" },
{ "gimp-drawable-is-layer", "gimp-item-is-layer" },
{ "gimp-drawable-is-text-layer", "gimp-item-is-text-layer" },
{ "gimp-drawable-is-layer-mask", "gimp-item-is-layer-mask" },
{ "gimp-drawable-is-channel", "gimp-item-is-channel" },
{ "gimp-drawable-delete", "gimp-item-delete" },
{ "gimp-drawable-get-image", "gimp-item-get-image" },
{ "gimp-drawable-get-name", "gimp-item-get-name" },
{ "gimp-drawable-set-name", "gimp-item-set-name" },
{ "gimp-drawable-get-visible", "gimp-item-get-visible" },
{ "gimp-drawable-set-visible", "gimp-item-set-visible" },
{ "gimp-drawable-get-linked", "gimp-item-get-linked" },
{ "gimp-drawable-set-linked", "gimp-item-set-linked" },
{ "gimp-drawable-get-tattoo", "gimp-item-get-tattoo" },
{ "gimp-drawable-set-tattoo", "gimp-item-set-tattoo" },
{ "gimp-vectors-is-valid", "gimp-item-is-valid" },
{ "gimp-vectors-get-image", "gimp-item-get-image" },
{ "gimp-vectors-get-name", "gimp-item-get-name" },
{ "gimp-vectors-set-name", "gimp-item-set-name" },
{ "gimp-vectors-get-visible", "gimp-item-get-visible" },
{ "gimp-vectors-set-visible", "gimp-item-set-visible" },
{ "gimp-vectors-get-linked", "gimp-item-get-linked" },
{ "gimp-vectors-set-linked", "gimp-item-set-linked" },
{ "gimp-vectors-get-tattoo", "gimp-item-get-tattoo" },
{ "gimp-vectors-set-tattoo", "gimp-item-set-tattoo" }
};
g_return_if_fail (GIMP_IS_PDB (pdb));

267
app/pdb/gimppdbcontext.c Normal file
View File

@ -0,0 +1,267 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimppdbcontext.c
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
#include "pdb-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "gimppdbcontext.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_ANTIALIAS,
PROP_FEATHER,
PROP_FEATHER_RADIUS_X,
PROP_FEATHER_RADIUS_Y,
PROP_INTERPOLATION,
PROP_TRANSFORM_DIRECTION,
PROP_TRANSFORM_RESIZE,
PROP_TRANSFORM_RECURSION
};
static void gimp_pdb_context_constructed (GObject *object);
static void gimp_pdb_context_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_pdb_context_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpPDBContext, gimp_pdb_context, GIMP_TYPE_CONTEXT)
#define parent_class gimp_pdb_context_parent_class
static void
gimp_pdb_context_class_init (GimpPDBContextClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = gimp_pdb_context_constructed;
object_class->set_property = gimp_pdb_context_set_property;
object_class->get_property = gimp_pdb_context_get_property;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
"antialias",
N_("Smooth edges"),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FEATHER,
"feather", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FEATHER_RADIUS_X,
"feather-radius-x", NULL,
0.0, 1000.0, 10.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FEATHER_RADIUS_Y,
"feather-radius-y", NULL,
0.0, 1000.0, 10.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION,
"interpolation", NULL,
GIMP_TYPE_INTERPOLATION_TYPE,
GIMP_INTERPOLATION_CUBIC,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSFORM_DIRECTION,
"transform-direction", NULL,
GIMP_TYPE_TRANSFORM_DIRECTION,
GIMP_TRANSFORM_FORWARD,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSFORM_RESIZE,
"transform-resize", NULL,
GIMP_TYPE_TRANSFORM_RESIZE,
GIMP_TRANSFORM_RESIZE_ADJUST,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_TRANSFORM_RECURSION,
"transform-recursion", NULL,
1, G_MAXINT32, 3,
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_pdb_context_init (GimpPDBContext *options)
{
}
static void
gimp_pdb_context_constructed (GObject *object)
{
GimpInterpolationType interpolation;
GParamSpec *pspec;
interpolation = GIMP_CONTEXT (object)->gimp->config->interpolation_type;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
"interpolation");
if (pspec)
G_PARAM_SPEC_ENUM (pspec)->default_value = interpolation;
g_object_set (object, "interpolation", interpolation, NULL);
if (G_OBJECT_CLASS (parent_class)->constructed)
G_OBJECT_CLASS (parent_class)->constructed (object);
}
static void
gimp_pdb_context_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpPDBContext *options = GIMP_PDB_CONTEXT (object);
switch (property_id)
{
case PROP_ANTIALIAS:
options->antialias = g_value_get_boolean (value);
break;
case PROP_FEATHER:
options->feather = g_value_get_boolean (value);
break;
case PROP_FEATHER_RADIUS_X:
options->feather_radius_x = g_value_get_double (value);
break;
case PROP_FEATHER_RADIUS_Y:
options->feather_radius_y = g_value_get_double (value);
break;
case PROP_INTERPOLATION:
options->interpolation = g_value_get_enum (value);
break;
case PROP_TRANSFORM_DIRECTION:
options->transform_direction = g_value_get_enum (value);
break;
case PROP_TRANSFORM_RESIZE:
options->transform_resize = g_value_get_enum (value);
break;
case PROP_TRANSFORM_RECURSION:
options->transform_recursion = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_pdb_context_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpPDBContext *options = GIMP_PDB_CONTEXT (object);
switch (property_id)
{
case PROP_ANTIALIAS:
g_value_set_boolean (value, options->antialias);
break;
case PROP_FEATHER:
g_value_set_boolean (value, options->feather);
break;
case PROP_FEATHER_RADIUS_X:
g_value_set_double (value, options->feather_radius_x);
break;
case PROP_FEATHER_RADIUS_Y:
g_value_set_double (value, options->feather_radius_y);
break;
case PROP_INTERPOLATION:
g_value_set_enum (value, options->interpolation);
break;
case PROP_TRANSFORM_DIRECTION:
g_value_set_enum (value, options->transform_direction);
break;
case PROP_TRANSFORM_RESIZE:
g_value_set_enum (value, options->transform_resize);
break;
case PROP_TRANSFORM_RECURSION:
g_value_set_int (value, options->transform_recursion);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
GimpContext *
gimp_pdb_context_new (Gimp *gimp,
GimpContext *parent,
gboolean set_parent)
{
GimpContext *context;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (parent), NULL);
context = g_object_new (GIMP_TYPE_PDB_CONTEXT,
"gimp", gimp,
"name", "PDB Context",
NULL);
gimp_config_sync (G_OBJECT (parent), G_OBJECT (context), 0);
if (set_parent)
{
gimp_context_define_properties (context,
GIMP_CONTEXT_ALL_PROPS_MASK, FALSE);
gimp_context_set_parent (context, parent);
}
return context;
}

66
app/pdb/gimppdbcontext.h Normal file
View File

@ -0,0 +1,66 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimppdbcontext.h
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_PDB_CONTEXT_H__
#define __GIMP_PDB_CONTEXT_H__
#include "core/gimpcontext.h"
#define GIMP_TYPE_PDB_CONTEXT (gimp_pdb_context_get_type ())
#define GIMP_PDB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PDB_CONTEXT, GimpPDBContext))
#define GIMP_PDB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PDB_CONTEXT, GimpPDBContextClass))
#define GIMP_IS_PDB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PDB_CONTEXT))
#define GIMP_IS_PDB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PDB_CONTEXT))
#define GIMP_PDB_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PDB_CONTEXT, GimpPDBContextClass))
typedef struct _GimpPDBContext GimpPDBContext;
typedef struct _GimpPDBContextClass GimpPDBContextClass;
struct _GimpPDBContext
{
GimpContext parent_instance;
gboolean antialias;
gboolean feather;
gdouble feather_radius_x;
gdouble feather_radius_y;
GimpInterpolationType interpolation;
GimpTransformDirection transform_direction;
GimpTransformResize transform_resize;
gint transform_recursion;
};
struct _GimpPDBContextClass
{
GimpContextClass parent_class;
};
GType gimp_pdb_context_get_type (void) G_GNUC_CONST;
GimpContext * gimp_pdb_context_new (Gimp *gimp,
GimpContext *parent,
gboolean set_parent);
#endif /* __GIMP_PDB_CONTEXT_H__ */

View File

@ -29,7 +29,6 @@
#include "core/gimp.h"
#include "core/gimp-utils.h"
#include "core/gimpcontext.h"
#include "core/gimpchannel.h"
#include "core/gimplayer.h"
#include "core/gimpparamspecs.h"
@ -37,6 +36,7 @@
#include "vectors/gimpvectors.h"
#include "gimppdbcontext.h"
#include "gimppdberror.h"
#include "gimpprocedure.h"
@ -323,6 +323,11 @@ gimp_procedure_execute (GimpProcedure *procedure,
return return_vals;
}
if (GIMP_IS_PDB_CONTEXT (context))
context = g_object_ref (context);
else
context = gimp_pdb_context_new (gimp, context, TRUE);
/* call the procedure */
return_vals = GIMP_PROCEDURE_GET_CLASS (procedure)->execute (procedure,
gimp,
@ -331,6 +336,7 @@ gimp_procedure_execute (GimpProcedure *procedure,
args,
error);
g_object_unref (context);
if (return_vals)
{
@ -398,9 +404,16 @@ gimp_procedure_execute_async (GimpProcedure *procedure,
procedure->args, procedure->num_args,
args, FALSE, error))
{
if (GIMP_IS_PDB_CONTEXT (context))
context = g_object_ref (context);
else
context = gimp_pdb_context_new (gimp, context, TRUE);
GIMP_PROCEDURE_GET_CLASS (procedure)->execute_async (procedure, gimp,
context, progress,
args, display);
g_object_unref (context);
}
}

View File

@ -28,7 +28,6 @@
#include "pdb-types.h"
#include "base/temp-buf.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
@ -57,6 +56,7 @@
#include "gimppdb.h"
#include "gimppdberror.h"
#include "gimppdb-utils.h"
#include "gimppdbcontext.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
@ -402,11 +402,13 @@ image_scale_invoker (GimpProcedure *procedure,
if (success)
{
GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
if (progress)
gimp_progress_start (progress, _("Scaling"), FALSE);
gimp_image_scale (image, new_width, new_height,
gimp->config->interpolation_type,
pdb_context->interpolation,
progress);
if (progress)
@ -916,7 +918,6 @@ image_add_layer_invoker (GimpProcedure *procedure,
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))),
error))
{
/* FIXME tree */
success = gimp_image_add_layer (image, layer,
NULL, MAX (position, -1), TRUE);
}
@ -930,6 +931,51 @@ image_add_layer_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
image_insert_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
GimpLayer *layer;
GimpLayer *parent;
gint32 position;
image = gimp_value_get_image (&args->values[0], gimp);
layer = gimp_value_get_layer (&args->values[1], gimp);
parent = gimp_value_get_layer (&args->values[2], gimp);
position = g_value_get_int (&args->values[3]);
if (success)
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (layer), image, error) &&
gimp_pdb_image_is_base_type (image,
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))),
error) &&
(parent == NULL ||
(gimp_pdb_item_is_in_tree (GIMP_ITEM (parent), image, FALSE, error) &&
gimp_pdb_item_is_group (GIMP_ITEM (parent), error))))
{
if (position == -1 && parent == NULL)
parent = GIMP_IMAGE_ACTIVE_PARENT;
success = gimp_image_add_layer (image, layer,
parent, MAX (position, -1), TRUE);
}
else
{
success = FALSE;
}
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
image_remove_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -978,7 +1024,6 @@ image_add_channel_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (channel), image, error))
{
/* FIXME tree */
success = gimp_image_add_channel (image, channel,
NULL, MAX (position, -1), TRUE);
}
@ -992,6 +1037,48 @@ image_add_channel_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
image_insert_channel_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
GimpChannel *channel;
GimpChannel *parent;
gint32 position;
image = gimp_value_get_image (&args->values[0], gimp);
channel = gimp_value_get_channel (&args->values[1], gimp);
parent = gimp_value_get_channel (&args->values[2], gimp);
position = g_value_get_int (&args->values[3]);
if (success)
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (channel), image, error) &&
(parent == NULL ||
(gimp_pdb_item_is_in_tree (GIMP_ITEM (parent), image, FALSE, error) &&
gimp_pdb_item_is_group (GIMP_ITEM (parent), error))))
{
if (position == -1 && parent == NULL)
parent = GIMP_IMAGE_ACTIVE_PARENT;
success = gimp_image_add_channel (image, channel,
parent, MAX (position, -1), TRUE);
}
else
{
success = FALSE;
}
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
image_remove_channel_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1040,7 +1127,6 @@ image_add_vectors_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (vectors), image, error))
{
/* FIXME tree */
success = gimp_image_add_vectors (image, vectors,
NULL, MAX (position, -1), TRUE);
}
@ -1054,6 +1140,48 @@ image_add_vectors_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
image_insert_vectors_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
GimpVectors *vectors;
GimpVectors *parent;
gint32 position;
image = gimp_value_get_image (&args->values[0], gimp);
vectors = gimp_value_get_vectors (&args->values[1], gimp);
parent = gimp_value_get_vectors (&args->values[2], gimp);
position = g_value_get_int (&args->values[3]);
if (success)
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (vectors), image, error) &&
(parent == NULL ||
(gimp_pdb_item_is_in_tree (GIMP_ITEM (parent), image, FALSE, error) &&
gimp_pdb_item_is_group (GIMP_ITEM (parent), error))))
{
if (position == -1 && parent == NULL)
parent = GIMP_IMAGE_ACTIVE_PARENT;
success = gimp_image_add_vectors (image, vectors,
parent, MAX (position, -1), TRUE);
}
else
{
success = FALSE;
}
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
image_remove_vectors_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -2803,7 +2931,7 @@ register_image_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-image-new",
"Creates a new image with the specified width, height, and type.",
"Creates a new image, undisplayed with the specified extents and type. A layer should be created and added before this image is displayed, or subsequent calls to 'gimp-display-new' with this image as an argument will fail. Layers can be created using the 'gimp-layer-new' commands. They can be added to an image using the 'gimp-image-add-layer' command.",
"Creates a new image, undisplayed with the specified extents and type. A layer should be created and added before this image is displayed, or subsequent calls to 'gimp-display-new' with this image as an argument will fail. Layers can be created using the 'gimp-layer-new' commands. They can be added to an image using the 'gimp-image-insert-layer' command.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -3078,7 +3206,7 @@ register_image_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-image-scale",
"Scale the image using the default interpolation method.",
"This procedure scales the image so that its new width and height are equal to the supplied parameters. All layers and channels within the image are scaled according to the specified parameters; this includes the image selection mask. The default interpolation method is used.",
"This procedure scales the image so that its new width and height are equal to the supplied parameters. All layers and channels within the image are scaled according to the specified parameters; this includes the image selection mask. The interpolation method used can be set with 'gimp-context-set-interpolation'.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -3112,12 +3240,12 @@ register_image_procs (GimpPDB *pdb)
"gimp-image-scale-full");
gimp_procedure_set_static_strings (procedure,
"gimp-image-scale-full",
"Scale the image using a specific interpolation method.",
"This procedure scales the image so that its new width and height are equal to the supplied parameters. All layers and channels within the image are scaled according to the specified parameters; this includes the image selection mask. This procedure allows you to specify the interpolation method explicitly.",
"Deprecated: Use 'gimp-image-scale' instead.",
"Deprecated: Use 'gimp-image-scale' instead.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2008",
NULL);
"gimp-image-scale");
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
@ -3582,8 +3710,43 @@ register_image_procs (GimpPDB *pdb)
"gimp-image-add-layer");
gimp_procedure_set_static_strings (procedure,
"gimp-image-add-layer",
"Deprecated: Use 'gimp-image-insert-layer' instead.",
"Deprecated: Use 'gimp-image-insert-layer' instead.",
"",
"",
"",
"gimp-image-insert-layer");
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("layer",
"layer",
"The layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("position",
"position",
"The layer position",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-insert-layer
*/
procedure = gimp_procedure_new (image_insert_layer_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-insert-layer");
gimp_procedure_set_static_strings (procedure,
"gimp-image-insert-layer",
"Add the specified layer to the image.",
"This procedure adds the specified layer to the image at the given position. If the position is specified as -1, then the layer is inserted above the active layer. The layer type must be compatible with the image base type.",
"This procedure adds the specified layer to the image at the given position. If the specified parent is a valid layer group (See 'gimp-item-is-group' and 'gimp-layer-group-new') then the layer is added inside the group. If the parent is NULL, the layer is added inside the main stack, outside of any group. The position argument specifies the location of the layer inside the stack (or the group, if a valid parent was supplied), starting from the top (0) and increasing. If the position is specified as -1 and the parent is specified as NULL, then the layer is inserted above the active layer. The layer type must be compatible with the image base type.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -3600,6 +3763,12 @@ register_image_procs (GimpPDB *pdb)
"The layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("parent",
"parent",
"The parent layer",
pdb->gimp, TRUE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("position",
"position",
@ -3646,8 +3815,43 @@ register_image_procs (GimpPDB *pdb)
"gimp-image-add-channel");
gimp_procedure_set_static_strings (procedure,
"gimp-image-add-channel",
"Deprecated: Use 'gimp-image-insert-channel' instead.",
"Deprecated: Use 'gimp-image-insert-channel' instead.",
"",
"",
"",
"gimp-image-insert-channel");
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_channel_id ("channel",
"channel",
"The channel",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("position",
"position",
"The channel position",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-insert-channel
*/
procedure = gimp_procedure_new (image_insert_channel_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-insert-channel");
gimp_procedure_set_static_strings (procedure,
"gimp-image-insert-channel",
"Add the specified channel to the image.",
"This procedure adds the specified channel to the image at the given position. If the position is specified as -1, then the channel is inserted above the active channel or, if no channel is active, at the top of the channel stack.",
"This procedure adds the specified channel to the image at the given position. Since channel groups are not currently supported, the parent argument must always be NULL. The position argument specifies the location of the channel inside the stack, starting from the top (0) and increasing. If the position is specified as -1, then the channel is inserted above the active channel.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -3664,6 +3868,12 @@ register_image_procs (GimpPDB *pdb)
"The channel",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_channel_id ("parent",
"parent",
"The parent channel",
pdb->gimp, TRUE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("position",
"position",
@ -3710,12 +3920,12 @@ register_image_procs (GimpPDB *pdb)
"gimp-image-add-vectors");
gimp_procedure_set_static_strings (procedure,
"gimp-image-add-vectors",
"Add the specified vectors object to the image.",
"This procedure adds the specified vectors object to the image at the given position. If the position is specified as -1, then the vectors object is inserted at the top of the vectors stack.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
"Deprecated: Use 'gimp-image-insert-vectors' instead.",
"Deprecated: Use 'gimp-image-insert-vectors' instead.",
"",
"",
"",
"gimp-image-insert-vectors");
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
@ -3737,6 +3947,47 @@ register_image_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-insert-vectors
*/
procedure = gimp_procedure_new (image_insert_vectors_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-insert-vectors");
gimp_procedure_set_static_strings (procedure,
"gimp-image-insert-vectors",
"Add the specified vectors to the image.",
"This procedure adds the specified vectors to the image at the given position. Since vectors groups are not currently supported, the parent argument must always be NULL. The position argument specifies the location of the vectors inside the stack, starting from the top (0) and increasing. If the position is specified as -1, then the vectors is inserted above the active vectors.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_vectors_id ("vectors",
"vectors",
"The vectors",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_vectors_id ("parent",
"parent",
"The parent vectors",
pdb->gimp, TRUE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("position",
"position",
"The vectors position",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-remove-vectors
*/
@ -3947,7 +4198,7 @@ register_image_procs (GimpPDB *pdb)
gimp_param_spec_item_id ("parent",
"parent",
"The new parent item",
pdb->gimp, FALSE,
pdb->gimp, TRUE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("position",

View File

@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 630 procedures registered total */
/* 634 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
@ -60,6 +60,7 @@ internal_procs_init (GimpPDB *pdb)
register_help_procs (pdb);
register_image_procs (pdb);
register_item_procs (pdb);
register_item_transform_procs (pdb);
register_layer_procs (pdb);
register_message_procs (pdb);
register_misc_procs (pdb);

View File

@ -49,6 +49,7 @@ void register_guides_procs (GimpPDB *pdb);
void register_help_procs (GimpPDB *pdb);
void register_image_procs (GimpPDB *pdb);
void register_item_procs (GimpPDB *pdb);
void register_item_transform_procs (GimpPDB *pdb);
void register_layer_procs (GimpPDB *pdb);
void register_message_procs (GimpPDB *pdb);
void register_misc_procs (GimpPDB *pdb);

View File

@ -34,6 +34,7 @@
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimppdbcontext.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
@ -178,6 +179,36 @@ item_is_layer_invoker (GimpProcedure *procedure,
return return_vals;
}
static GValueArray *
item_is_text_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpItem *item;
gboolean text_layer = FALSE;
item = gimp_value_get_item (&args->values[0], gimp);
if (success)
{
text_layer = (GIMP_IS_DRAWABLE (item) &&
gimp_drawable_is_text_layer (GIMP_DRAWABLE (item)));
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], text_layer);
return return_vals;
}
static GValueArray *
item_is_channel_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -676,6 +707,41 @@ item_set_tattoo_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
item_to_selection_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpItem *item;
gint32 operation;
item = gimp_value_get_item (&args->values[0], gimp);
operation = g_value_get_enum (&args->values[1]);
if (success)
{
if (gimp_pdb_item_is_attached (item, NULL, FALSE, error))
{
GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
gimp_item_to_selection (item, operation,
pdb_context->antialias,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_item_procs (GimpPDB *pdb)
{
@ -820,6 +886,35 @@ register_item_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-item-is-text-layer
*/
procedure = gimp_procedure_new (item_is_text_layer_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-item-is-text-layer");
gimp_procedure_set_static_strings (procedure,
"gimp-item-is-text-layer",
"Returns whether the item is a text layer.",
"This procedure returns TRUE if the specified item is a text layer.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_item_id ("item",
"item",
"The item",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("text-layer",
"text layer",
"TRUE if the item is a text layer, FALSE otherwise.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-item-is-channel
*/
@ -1319,4 +1414,34 @@ register_item_procs (GimpPDB *pdb)
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-item-to-selection
*/
procedure = gimp_procedure_new (item_to_selection_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-item-to-selection");
gimp_procedure_set_static_strings (procedure,
"gimp-item-to-selection",
"Transforms the specified item into a selection",
"This procedure renders the item's outline into the current selection of the image the item belongs to. What exactly the item's outline is depends on the item type: for layers, it's the layer's alpha channel, for vectors the vector's shape.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_item_id ("item",
"item",
"The item to render to the selection",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The desired operation with current selection",
GIMP_TYPE_CHANNEL_OPS,
GIMP_CHANNEL_OP_ADD,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

File diff suppressed because it is too large Load Diff

View File

@ -25,9 +25,9 @@
#include "pdb-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage.h"
#include "core/gimpitem-linked.h"
@ -39,6 +39,7 @@
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimppdbcontext.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
@ -178,6 +179,38 @@ layer_new_from_drawable_invoker (GimpProcedure *procedure,
return return_vals;
}
static GValueArray *
layer_group_new_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpImage *image;
GimpLayer *layer_group = NULL;
image = gimp_value_get_image (&args->values[0], gimp);
if (success)
{
layer_group = gimp_group_layer_new (image);
if (! layer_group)
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
gimp_value_set_layer (&return_vals->values[1], layer_group);
return return_vals;
}
static GValueArray *
layer_copy_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -294,11 +327,13 @@ layer_scale_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL, TRUE, error))
{
GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
if (progress)
gimp_progress_start (progress, _("Scaling"), FALSE);
gimp_item_scale_by_origin (GIMP_ITEM (layer), new_width, new_height,
gimp->config->interpolation_type, progress,
pdb_context->interpolation, progress,
local_origin);
if (progress)
@ -1041,7 +1076,7 @@ register_layer_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-layer-new",
"Create a new layer.",
"This procedure creates a new layer with the specified width, height, and type. Name, opacity, and mode are also supplied parameters. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp-image-add-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
"This procedure creates a new layer with the specified width, height, and type. Name, opacity, and mode are also supplied parameters. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp-image-insert-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -1109,7 +1144,7 @@ register_layer_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-layer-new-from-visible",
"Create a new layer from what is visible in an image.",
"This procedure creates a new layer from what is visible in the given image. The new layer still needs to be added to the destination image, as this is not automatic. Add the new layer with the 'gimp-image-add-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
"This procedure creates a new layer from what is visible in the given image. The new layer still needs to be added to the destination image, as this is not automatic. Add the new layer with the 'gimp-image-insert-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2008",
@ -1151,7 +1186,7 @@ register_layer_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-layer-new-from-drawable",
"Create a new layer by copying an existing drawable.",
"This procedure creates a new layer as a copy of the specified drawable. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp-image-add-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
"This procedure creates a new layer as a copy of the specified drawable. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp-image-insert-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -1177,6 +1212,35 @@ register_layer_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-layer-group-new
*/
procedure = gimp_procedure_new (layer_group_new_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-layer-group-new");
gimp_procedure_set_static_strings (procedure,
"gimp-layer-group-new",
"Create a new layer group.",
"This procedure creates a new layer group. Attributes such as layer mode and opacity should be set with explicit procedure calls. Add the new layer group (which is a kind of layer) with the 'gimp-image-insert-layer' command.",
"Barak Itkin <lightningismyname@gmail.com>",
"Barak Itkin",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image to which to add the layer group",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_layer_id ("layer-group",
"layer group",
"The newly created layer group",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-layer-copy
*/
@ -1267,7 +1331,7 @@ register_layer_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-layer-scale",
"Scale the layer using the default interpolation method.",
"This procedure scales the layer so that its new width and height are equal to the supplied parameters. The 'local-origin' parameter specifies whether to scale from the center of the layer, or from the image origin. This operation only works if the layer has been added to an image. The default interpolation method is used for scaling.",
"This procedure scales the layer so that its new width and height are equal to the supplied parameters. The 'local-origin' parameter specifies whether to scale from the center of the layer, or from the image origin. This operation only works if the layer has been added to an image. The interpolation method used can be set with 'gimp-context-set-interpolation'.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -1307,12 +1371,12 @@ register_layer_procs (GimpPDB *pdb)
"gimp-layer-scale-full");
gimp_procedure_set_static_strings (procedure,
"gimp-layer-scale-full",
"Scale the layer using a specific interpolation method.",
"This procedure scales the layer so that its new width and height are equal to the supplied parameters. The 'local-origin' parameter specifies whether to scale from the center of the layer, or from the image origin. This operation only works if the layer has been added to an image. This procedure allows you to specify the interpolation method explicitly.",
"Deprecated: Use 'gimp-layer-scale' instead.",
"Deprecated: Use 'gimp-layer-scale' instead.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2008",
NULL);
"gimp-layer-scale");
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("layer",
"layer",

View File

@ -937,12 +937,12 @@ register_selection_procs (GimpPDB *pdb)
"gimp-selection-layer-alpha");
gimp_procedure_set_static_strings (procedure,
"gimp-selection-layer-alpha",
"Transfer the specified layer's alpha channel to the selection mask.",
"The alpha channel information is used to create a selection mask such that for any pixel in the image defined in the specified layer, that layer pixel's alpha value is transferred to the selection mask. If the layer is undefined at a particular image pixel, the associated selection mask value is set to 0. A layer without an alpha channel is considered opaque.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
"Deprecated: Use 'gimp-item-to-selection' instead.",
"Deprecated: Use 'gimp-item-to-selection' instead.",
"",
"",
"",
"gimp-item-to-selection");
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("layer",
"layer",
@ -960,12 +960,12 @@ register_selection_procs (GimpPDB *pdb)
"gimp-selection-load");
gimp_procedure_set_static_strings (procedure,
"gimp-selection-load",
"Transfer the specified channel to the selection mask.",
"This procedure loads the specified channel into the selection mask.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
"Deprecated: Use 'gimp-item-to-selection' instead.",
"Deprecated: Use 'gimp-item-to-selection' instead.",
"",
"",
"",
"gimp-item-to-selection");
gimp_procedure_add_argument (procedure,
gimp_param_spec_channel_id ("channel",
"channel",
@ -1012,12 +1012,12 @@ register_selection_procs (GimpPDB *pdb)
"gimp-selection-combine");
gimp_procedure_set_static_strings (procedure,
"gimp-selection-combine",
"Combines the specified channel with the selection mask.",
"This procedure combines the specified channel into the selection mask.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
"Deprecated: Use 'gimp-item-to-selection' instead.",
"Deprecated: Use 'gimp-item-to-selection' instead.",
"",
"",
"",
"gimp-item-to-selection");
gimp_procedure_add_argument (procedure,
gimp_param_spec_channel_id ("channel",
"channel",

View File

@ -1210,7 +1210,7 @@ register_text_layer_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-text-layer-new",
"Creates a new text layer.",
"This procedure creates a new text layer. The arguments are kept as simple as necessary for the normal case. All text attributes, however, can be modified with the appropriate gimp_text_layer_set_*() procedures. The new layer still needs to be added to the image, as this is not automatic. Add the new layer using 'gimp-image-add-layer'.",
"This procedure creates a new text layer. The arguments are kept as simple as necessary for the normal case. All text attributes, however, can be modified with the appropriate gimp_text_layer_set_*() procedures. The new layer still needs to be added to the image, as this is not automatic. Add the new layer using 'gimp-image-insert-layer'.",
"Marcus Heese <heese@cip.ifi.lmu.de>",
"Marcus Heese",
"2008",

Some files were not shown because too many files have changed in this diff Show More