added default implementations for scale() and resize() which just set the
2003-05-09 Michael Natterer <mitch@gimp.org> * app/core/gimpitem.c: added default implementations for scale() and resize() which just set the resulting width/height and offset values. * app/core/gimpdrawable.c: chain up in scale() and resize(). * app/vectors/gimpvectors.[ch]: buncha vectors changes/features: - Removed unused "linked" and "locked" members. - Removed "changed" signal. - Added "freeze" and "thaw" signals and functions to emit them. - Added "freeze_count" member so we emit only one freeze/thaw pair even when doing nested changes. - Added GimpItem::translate() implementation. - Actually scale and resize the vectors in scale() and resize(). - Added undo for scale() and resize(). - Added freeze()/thaw() pairs around all modifying functions. - Changed gimp_vectors_copy_strokes() to work as needed. * app/core/gimpimage-resize.c * app/core/gimpimage-scale.c: resize and scale all vectors. Fixes bug #36491. * app/core/gimpimage-undo-push.c (undo_pop_vectors_mod): added freeze()/thaw() around the vectors-modifying code. Also restore width, height and offsets. * app/tools/gimpvectortool.c: connect to "freeze" and "thaw" and pause()/resume() vectors drawing accordingly.
This commit is contained in:

committed by
Michael Natterer

parent
33b7d779d6
commit
882a8eca80
32
ChangeLog
32
ChangeLog
@ -1,3 +1,35 @@
|
||||
2003-05-09 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpitem.c: added default implementations for scale()
|
||||
and resize() which just set the resulting width/height and offset
|
||||
values.
|
||||
|
||||
* app/core/gimpdrawable.c: chain up in scale() and resize().
|
||||
|
||||
* app/vectors/gimpvectors.[ch]: buncha vectors changes/features:
|
||||
|
||||
- Removed unused "linked" and "locked" members.
|
||||
- Removed "changed" signal.
|
||||
- Added "freeze" and "thaw" signals and functions to emit them.
|
||||
- Added "freeze_count" member so we emit only one freeze/thaw pair
|
||||
even when doing nested changes.
|
||||
- Added GimpItem::translate() implementation.
|
||||
- Actually scale and resize the vectors in scale() and resize().
|
||||
- Added undo for scale() and resize().
|
||||
- Added freeze()/thaw() pairs around all modifying functions.
|
||||
- Changed gimp_vectors_copy_strokes() to work as needed.
|
||||
|
||||
* app/core/gimpimage-resize.c
|
||||
* app/core/gimpimage-scale.c: resize and scale all vectors.
|
||||
Fixes bug #36491.
|
||||
|
||||
* app/core/gimpimage-undo-push.c (undo_pop_vectors_mod): added
|
||||
freeze()/thaw() around the vectors-modifying code. Also restore
|
||||
width, height and offsets.
|
||||
|
||||
* app/tools/gimpvectortool.c: connect to "freeze" and "thaw"
|
||||
and pause()/resume() vectors drawing accordingly.
|
||||
|
||||
2003-05-08 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimplayer.[ch]: removed "linked" member and API...
|
||||
|
@ -329,17 +329,15 @@ gimp_drawable_scale (GimpItem *item,
|
||||
* resampling because that doesn't necessarily make sense for indexed
|
||||
* images.
|
||||
*/
|
||||
if (gimp_drawable_is_indexed (drawable))
|
||||
interpolation_type = GIMP_INTERPOLATION_NONE;
|
||||
scale_region (&srcPR, &destPR,
|
||||
gimp_drawable_is_indexed (drawable) ?
|
||||
GIMP_INTERPOLATION_NONE : interpolation_type);
|
||||
|
||||
scale_region (&srcPR, &destPR, interpolation_type);
|
||||
|
||||
/* Configure the new channel */
|
||||
drawable->tiles = new_tiles;
|
||||
item->width = new_width;
|
||||
item->height = new_height;
|
||||
item->offset_x = new_offset_x;
|
||||
item->offset_y = new_offset_y;
|
||||
|
||||
GIMP_ITEM_CLASS (parent_class)->scale (item, new_width, new_height,
|
||||
new_offset_x, new_offset_y,
|
||||
interpolation_type);
|
||||
|
||||
/* Update the new position */
|
||||
gimp_drawable_update (drawable, 0, 0, item->width, item->height);
|
||||
@ -445,12 +443,10 @@ gimp_drawable_resize (GimpItem *item,
|
||||
copy_region (&srcPR, &destPR);
|
||||
}
|
||||
|
||||
/* Configure the new drawable */
|
||||
drawable->tiles = new_tiles;
|
||||
item->offset_x = x1 + item->offset_x - x2;
|
||||
item->offset_y = y1 + item->offset_y - y2;
|
||||
item->width = new_width;
|
||||
item->height = new_height;
|
||||
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, new_width, new_height,
|
||||
offset_x, offset_y);
|
||||
|
||||
/* update the new area */
|
||||
gimp_drawable_update (drawable, 0, 0, item->width, item->height);
|
||||
|
@ -80,6 +80,16 @@ gimp_image_resize (GimpImage *gimage,
|
||||
gimp_item_resize (item, new_width, new_height, offset_x, offset_y);
|
||||
}
|
||||
|
||||
/* Resize all vectors */
|
||||
for (list = GIMP_LIST (gimage->vectors)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpItem *item = list->data;
|
||||
|
||||
gimp_item_resize (item, new_width, new_height, offset_x, offset_y);
|
||||
}
|
||||
|
||||
/* Reposition or remove any guides */
|
||||
list = gimage->guides;
|
||||
while (list)
|
||||
|
@ -58,6 +58,7 @@ gimp_image_scale (GimpImage *gimage,
|
||||
gdouble img_scale_h = 1.0;
|
||||
gint num_channels;
|
||||
gint num_layers;
|
||||
gint num_vectors;
|
||||
gint progress_current = 1;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
@ -67,6 +68,7 @@ gimp_image_scale (GimpImage *gimage,
|
||||
|
||||
num_channels = gimage->channels->num_children;
|
||||
num_layers = gimage->layers->num_children;
|
||||
num_vectors = gimage->vectors->num_children;
|
||||
|
||||
/* Get the floating layer if one exists */
|
||||
floating_layer = gimp_image_floating_sel (gimage);
|
||||
@ -101,7 +103,24 @@ gimp_image_scale (GimpImage *gimage,
|
||||
|
||||
if (progress_func)
|
||||
{
|
||||
(* progress_func) (0, num_channels + num_layers,
|
||||
(* progress_func) (0, num_vectors + num_channels + num_layers,
|
||||
progress_current++,
|
||||
progress_data);
|
||||
}
|
||||
}
|
||||
|
||||
/* Scale all vectors */
|
||||
for (list = GIMP_LIST (gimage->vectors)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
item = (GimpItem *) list->data;
|
||||
|
||||
gimp_item_scale (item, new_width, new_height, 0, 0, interpolation_type);
|
||||
|
||||
if (progress_func)
|
||||
{
|
||||
(* progress_func) (0, num_vectors + num_channels + num_layers,
|
||||
progress_current++,
|
||||
progress_data);
|
||||
}
|
||||
@ -137,7 +156,7 @@ gimp_image_scale (GimpImage *gimage,
|
||||
|
||||
if (progress_func)
|
||||
{
|
||||
(* progress_func) (0, num_channels + num_layers,
|
||||
(* progress_func) (0, num_vectors + num_channels + num_layers,
|
||||
progress_current++,
|
||||
progress_data);
|
||||
}
|
||||
|
@ -2635,10 +2635,19 @@ undo_pop_vectors_mod (GimpUndo *undo,
|
||||
G_TYPE_FROM_INSTANCE (vectors),
|
||||
FALSE));
|
||||
|
||||
gimp_vectors_freeze (vectors);
|
||||
|
||||
gimp_vectors_copy_strokes (temp, vectors);
|
||||
|
||||
GIMP_ITEM (vectors)->width = GIMP_ITEM (temp)->width;
|
||||
GIMP_ITEM (vectors)->height = GIMP_ITEM (temp)->height;
|
||||
GIMP_ITEM (vectors)->offset_x = GIMP_ITEM (temp)->offset_x;
|
||||
GIMP_ITEM (vectors)->offset_y = GIMP_ITEM (temp)->offset_y;
|
||||
|
||||
g_object_unref (temp);
|
||||
|
||||
gimp_vectors_thaw (vectors);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,17 @@ static void gimp_item_real_rename (GimpItem *item,
|
||||
static void gimp_item_real_translate (GimpItem *item,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
static void gimp_item_real_scale (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint new_offset_x,
|
||||
gint new_offset_y,
|
||||
GimpInterpolationType interp_type);
|
||||
static void gimp_item_real_resize (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
|
||||
|
||||
/* private variables */
|
||||
@ -148,8 +159,8 @@ gimp_item_class_init (GimpItemClass *klass)
|
||||
klass->duplicate = gimp_item_real_duplicate;
|
||||
klass->rename = gimp_item_real_rename;
|
||||
klass->translate = gimp_item_real_translate;
|
||||
klass->scale = NULL;
|
||||
klass->resize = NULL;
|
||||
klass->scale = gimp_item_real_scale;
|
||||
klass->resize = gimp_item_real_resize;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -300,6 +311,62 @@ gimp_item_real_translate (GimpItem *item,
|
||||
item->offset_y += offset_y;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_real_scale (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint new_offset_x,
|
||||
gint new_offset_y,
|
||||
GimpInterpolationType interp_type)
|
||||
{
|
||||
item->width = new_width;
|
||||
item->height = new_height;
|
||||
item->offset_x = new_offset_x;
|
||||
item->offset_y = new_offset_y;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_real_resize (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
x1 = CLAMP (offset_x, 0, new_width);
|
||||
y1 = CLAMP (offset_y, 0, new_height);
|
||||
x2 = CLAMP (offset_x + item->width, 0, new_width);
|
||||
y2 = CLAMP (offset_y + item->height, 0, new_height);
|
||||
|
||||
if (offset_x > 0)
|
||||
{
|
||||
x1 = 0;
|
||||
x2 = offset_x;
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 = -offset_x;
|
||||
x2 = 0;
|
||||
}
|
||||
|
||||
if (offset_y > 0)
|
||||
{
|
||||
y1 = 0;
|
||||
y2 = offset_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
y1 = -offset_y;
|
||||
y2 = 0;
|
||||
}
|
||||
|
||||
item->offset_x = x1 + item->offset_x - x2;
|
||||
item->offset_y = y1 + item->offset_y - y2;
|
||||
item->width = new_width;
|
||||
item->height = new_height;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_item_removed (GimpItem *item)
|
||||
{
|
||||
|
@ -90,7 +90,10 @@ static gboolean gimp_vector_tool_on_handle (GimpTool *tool,
|
||||
static void gimp_vector_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static void gimp_vector_tool_clear_vectors (GimpVectorTool *vector_tool);
|
||||
static void gimp_vector_tool_vectors_changed (GimpVectors *vectors,
|
||||
|
||||
static void gimp_vector_tool_vectors_freeze (GimpVectors *vectors,
|
||||
GimpVectorTool *vector_tool);
|
||||
static void gimp_vector_tool_vectors_thaw (GimpVectors *vectors,
|
||||
GimpVectorTool *vector_tool);
|
||||
|
||||
|
||||
@ -214,7 +217,6 @@ gimp_vector_tool_control (GimpTool *tool,
|
||||
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vector_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
@ -296,7 +298,7 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
||||
}
|
||||
}
|
||||
|
||||
if (!vector_tool->vectors || vector_tool->function == VECTORS_CREATING)
|
||||
if (! vector_tool->vectors || vector_tool->function == VECTORS_CREATING)
|
||||
{
|
||||
if (gimp_tool_control_is_active (tool->control))
|
||||
{
|
||||
@ -318,8 +320,12 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
||||
G_CALLBACK (gimp_vector_tool_clear_vectors),
|
||||
vector_tool,
|
||||
G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (vectors, "changed",
|
||||
G_CALLBACK (gimp_vector_tool_vectors_changed),
|
||||
g_signal_connect_object (vectors, "freeze",
|
||||
G_CALLBACK (gimp_vector_tool_vectors_freeze),
|
||||
vector_tool,
|
||||
0);
|
||||
g_signal_connect_object (vectors, "thaw",
|
||||
G_CALLBACK (gimp_vector_tool_vectors_thaw),
|
||||
vector_tool,
|
||||
0);
|
||||
}
|
||||
@ -371,7 +377,6 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
||||
gimp_tool_control_activate (tool->control);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vector_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
@ -394,7 +399,6 @@ gimp_vector_tool_button_release (GimpTool *tool,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vector_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
@ -409,7 +413,7 @@ gimp_vector_tool_motion (GimpTool *tool,
|
||||
vector_tool = GIMP_VECTOR_TOOL (tool);
|
||||
options = GIMP_VECTOR_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (vector_tool));
|
||||
gimp_vectors_freeze (vector_tool->vectors);
|
||||
|
||||
switch (vector_tool->function)
|
||||
{
|
||||
@ -425,10 +429,9 @@ gimp_vector_tool_motion (GimpTool *tool,
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (vector_tool));
|
||||
gimp_vectors_thaw (vector_tool->vectors);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gimp_vector_tool_on_handle (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
@ -493,7 +496,6 @@ gimp_vector_tool_on_handle (GimpTool *tool,
|
||||
return (anchor != NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vector_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
@ -535,7 +537,6 @@ gimp_vector_tool_cursor_update (GimpTool *tool,
|
||||
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vector_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
@ -630,7 +631,6 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vector_tool_clear_vectors (GimpVectorTool *vector_tool)
|
||||
{
|
||||
@ -639,14 +639,33 @@ gimp_vector_tool_clear_vectors (GimpVectorTool *vector_tool)
|
||||
gimp_vector_tool_set_vectors (vector_tool, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vector_tool_vectors_changed (GimpVectors *vectors,
|
||||
GimpVectorTool *vector_tool)
|
||||
gimp_vector_tool_vectors_freeze (GimpVectors *vectors,
|
||||
GimpVectorTool *vector_tool)
|
||||
{
|
||||
g_print ("vectors changed\n");
|
||||
GimpDrawTool *draw_tool;
|
||||
|
||||
draw_tool = GIMP_DRAW_TOOL (vector_tool);
|
||||
|
||||
g_print ("vectors freeze\n");
|
||||
|
||||
if (draw_tool->gdisp)
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_vector_tool_vectors_thaw (GimpVectors *vectors,
|
||||
GimpVectorTool *vector_tool)
|
||||
{
|
||||
GimpDrawTool *draw_tool;
|
||||
|
||||
draw_tool = GIMP_DRAW_TOOL (vector_tool);
|
||||
|
||||
g_print ("vectors thaw\n");
|
||||
|
||||
if (draw_tool->gdisp)
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
|
||||
@ -682,7 +701,10 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
|
||||
gimp_vector_tool_clear_vectors,
|
||||
vector_tool);
|
||||
g_signal_handlers_disconnect_by_func (vector_tool->vectors,
|
||||
gimp_vector_tool_vectors_changed,
|
||||
gimp_vector_tool_vectors_freeze,
|
||||
vector_tool);
|
||||
g_signal_handlers_disconnect_by_func (vector_tool->vectors,
|
||||
gimp_vector_tool_vectors_thaw,
|
||||
vector_tool);
|
||||
g_object_unref (vector_tool->vectors);
|
||||
}
|
||||
@ -707,8 +729,12 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
|
||||
G_CALLBACK (gimp_vector_tool_clear_vectors),
|
||||
vector_tool,
|
||||
G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (vectors, "changed",
|
||||
G_CALLBACK (gimp_vector_tool_vectors_changed),
|
||||
g_signal_connect_object (vectors, "freeze",
|
||||
G_CALLBACK (gimp_vector_tool_vectors_freeze),
|
||||
vector_tool,
|
||||
0);
|
||||
g_signal_connect_object (vectors, "thaw",
|
||||
G_CALLBACK (gimp_vector_tool_vectors_thaw),
|
||||
vector_tool,
|
||||
0);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "vectors-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-undo-push.h"
|
||||
#include "core/gimpmarshal.h"
|
||||
|
||||
#include "gimpanchor.h"
|
||||
@ -38,32 +39,38 @@
|
||||
|
||||
enum
|
||||
{
|
||||
CHANGED,
|
||||
FREEZE,
|
||||
THAW,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
static void gimp_vectors_class_init (GimpVectorsClass *klass);
|
||||
static void gimp_vectors_init (GimpVectors *vectors);
|
||||
static void gimp_vectors_class_init (GimpVectorsClass *klass);
|
||||
static void gimp_vectors_init (GimpVectors *vectors);
|
||||
|
||||
static void gimp_vectors_finalize (GObject *object);
|
||||
static void gimp_vectors_finalize (GObject *object);
|
||||
|
||||
static gsize gimp_vectors_get_memsize (GimpObject *object);
|
||||
static gsize gimp_vectors_get_memsize (GimpObject *object);
|
||||
|
||||
static GimpItem * gimp_vectors_duplicate (GimpItem *item,
|
||||
GType new_type,
|
||||
gboolean add_alpha);
|
||||
static void gimp_vectors_scale (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint new_offset_x,
|
||||
gint new_offset_y,
|
||||
GimpInterpolationType interp_type);
|
||||
static void gimp_vectors_resize (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
static GimpItem * gimp_vectors_duplicate (GimpItem *item,
|
||||
GType new_type,
|
||||
gboolean add_alpha);
|
||||
static void gimp_vectors_translate (GimpItem *item,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
static void gimp_vectors_scale (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint new_offset_x,
|
||||
gint new_offset_y,
|
||||
GimpInterpolationType interp_type);
|
||||
static void gimp_vectors_resize (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
|
||||
static void gimp_vectors_real_thaw (GimpVectors *vectors);
|
||||
|
||||
|
||||
/* private variables */
|
||||
@ -101,7 +108,6 @@ gimp_vectors_get_type (void)
|
||||
return vectors_type;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vectors_class_init (GimpVectorsClass *klass)
|
||||
{
|
||||
@ -117,11 +123,20 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gimp_vectors_signals[CHANGED] =
|
||||
g_signal_new ("changed",
|
||||
gimp_vectors_signals[FREEZE] =
|
||||
g_signal_new ("freeze",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpVectorsClass, changed),
|
||||
G_STRUCT_OFFSET (GimpVectorsClass, freeze),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_vectors_signals[THAW] =
|
||||
g_signal_new ("thaw",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpVectorsClass, thaw),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
@ -133,12 +148,15 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
|
||||
viewable_class->get_new_preview = gimp_vectors_get_new_preview;
|
||||
|
||||
item_class->duplicate = gimp_vectors_duplicate;
|
||||
item_class->translate = gimp_vectors_translate;
|
||||
item_class->scale = gimp_vectors_scale;
|
||||
item_class->resize = gimp_vectors_resize;
|
||||
item_class->default_name = _("Path");
|
||||
item_class->rename_desc = _("Rename Path");
|
||||
item_class->translate_desc = _("Move Path");
|
||||
|
||||
klass->changed = NULL;
|
||||
klass->freeze = NULL;
|
||||
klass->thaw = gimp_vectors_real_thaw;
|
||||
|
||||
klass->stroke_add = NULL;
|
||||
klass->stroke_get = NULL;
|
||||
@ -154,17 +172,20 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
|
||||
klass->make_bezier = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_vectors_init (GimpVectors *vectors)
|
||||
{
|
||||
vectors->strokes = NULL;
|
||||
vectors->strokes = NULL;
|
||||
vectors->freeze_count = 0;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
gimp_vectors_finalize (GObject *object)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
|
||||
vectors = GIMP_VECTORS (object);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: implement gimp_vectors_finalize()
|
||||
#endif
|
||||
@ -172,7 +193,6 @@ gimp_vectors_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static gsize
|
||||
gimp_vectors_get_memsize (GimpObject *object)
|
||||
{
|
||||
@ -215,14 +235,60 @@ gimp_vectors_duplicate (GimpItem *item,
|
||||
return new_item;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_vectors_translate (GimpItem *item,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
|
||||
vectors = GIMP_VECTORS (item);
|
||||
|
||||
gimp_vectors_freeze (vectors);
|
||||
|
||||
GIMP_ITEM_CLASS (parent_class)->translate (item, offset_x, offset_y);
|
||||
|
||||
gimp_vectors_thaw (vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_vectors_scale (GimpItem *item,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
gint new_offset_x,
|
||||
gint new_offset_y,
|
||||
GimpInterpolationType interp_type)
|
||||
GimpInterpolationType interpolation_type)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
GList *list;
|
||||
|
||||
vectors = GIMP_VECTORS (item);
|
||||
|
||||
gimp_vectors_freeze (vectors);
|
||||
|
||||
gimp_image_undo_push_vectors_mod (gimp_item_get_image (item),
|
||||
_("Scale Path"),
|
||||
vectors);
|
||||
|
||||
for (list = vectors->strokes; list; list = g_list_next (list))
|
||||
{
|
||||
GimpStroke *stroke = list->data;
|
||||
GList *list2;
|
||||
|
||||
for (list2 = stroke->anchors; list2; list2 = g_list_next (list2))
|
||||
{
|
||||
GimpAnchor *anchor = list2->data;
|
||||
|
||||
anchor->position.x *= (gdouble) new_width / (gdouble) item->width;
|
||||
anchor->position.y *= (gdouble) new_height / (gdouble) item->height;
|
||||
}
|
||||
}
|
||||
|
||||
GIMP_ITEM_CLASS (parent_class)->scale (item, new_width, new_height,
|
||||
new_offset_x, new_offset_y,
|
||||
interpolation_type);
|
||||
|
||||
gimp_vectors_thaw (vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -232,6 +298,41 @@ gimp_vectors_resize (GimpItem *item,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
GList *list;
|
||||
|
||||
vectors = GIMP_VECTORS (item);
|
||||
|
||||
gimp_vectors_freeze (vectors);
|
||||
|
||||
gimp_image_undo_push_vectors_mod (gimp_item_get_image (item),
|
||||
_("Resize Path"),
|
||||
vectors);
|
||||
|
||||
for (list = vectors->strokes; list; list = g_list_next (list))
|
||||
{
|
||||
GimpStroke *stroke = list->data;
|
||||
GList *list2;
|
||||
|
||||
for (list2 = stroke->anchors; list2; list2 = g_list_next (list2))
|
||||
{
|
||||
GimpAnchor *anchor = list2->data;
|
||||
|
||||
anchor->position.x += offset_x;
|
||||
anchor->position.y += offset_y;
|
||||
}
|
||||
}
|
||||
|
||||
GIMP_ITEM_CLASS (parent_class)->resize (item, new_width, new_height,
|
||||
offset_x, offset_y);
|
||||
|
||||
gimp_vectors_thaw (vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_vectors_real_thaw (GimpVectors *vectors)
|
||||
{
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (vectors));
|
||||
}
|
||||
|
||||
|
||||
@ -254,6 +355,28 @@ gimp_vectors_new (GimpImage *gimage,
|
||||
return vectors;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vectors_freeze (GimpVectors *vectors)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
||||
|
||||
vectors->freeze_count++;
|
||||
|
||||
if (vectors->freeze_count == 1)
|
||||
g_signal_emit (vectors, gimp_vectors_signals[FREEZE], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vectors_thaw (GimpVectors *vectors)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
||||
g_return_if_fail (vectors->freeze_count > 0);
|
||||
|
||||
vectors->freeze_count--;
|
||||
|
||||
if (vectors->freeze_count == 0)
|
||||
g_signal_emit (vectors, gimp_vectors_signals[THAW], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vectors_copy_strokes (const GimpVectors *src_vectors,
|
||||
@ -263,7 +386,15 @@ gimp_vectors_copy_strokes (const GimpVectors *src_vectors,
|
||||
|
||||
g_return_if_fail (GIMP_IS_VECTORS (src_vectors));
|
||||
g_return_if_fail (GIMP_IS_VECTORS (dest_vectors));
|
||||
g_return_if_fail (dest_vectors->strokes == NULL);
|
||||
|
||||
gimp_vectors_freeze (dest_vectors);
|
||||
|
||||
if (dest_vectors->strokes)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: free old dest_vectors->strokes
|
||||
#endif
|
||||
}
|
||||
|
||||
dest_vectors->strokes = g_list_copy (src_vectors->strokes);
|
||||
current_lstroke = dest_vectors->strokes;
|
||||
@ -273,6 +404,8 @@ gimp_vectors_copy_strokes (const GimpVectors *src_vectors,
|
||||
current_lstroke->data = gimp_stroke_duplicate (current_lstroke->data);
|
||||
current_lstroke = g_list_next (current_lstroke);
|
||||
}
|
||||
|
||||
gimp_vectors_thaw (dest_vectors);
|
||||
}
|
||||
|
||||
|
||||
@ -333,6 +466,8 @@ gimp_vectors_stroke_add (GimpVectors *vectors,
|
||||
|
||||
vectors_class = GIMP_VECTORS_GET_CLASS (vectors);
|
||||
|
||||
gimp_vectors_freeze (vectors);
|
||||
|
||||
if (vectors_class->stroke_add)
|
||||
{
|
||||
vectors_class->stroke_add (vectors, stroke);
|
||||
@ -342,6 +477,8 @@ gimp_vectors_stroke_add (GimpVectors *vectors,
|
||||
vectors->strokes = g_list_prepend (vectors->strokes, stroke);
|
||||
g_object_ref (stroke);
|
||||
}
|
||||
|
||||
gimp_vectors_thaw (vectors);
|
||||
}
|
||||
|
||||
|
||||
@ -515,4 +652,3 @@ gimp_vectors_make_bezier (const GimpVectors *vectors)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -37,11 +37,9 @@ struct _GimpVectors
|
||||
{
|
||||
GimpItem parent_instance;
|
||||
|
||||
gboolean visible; /* controls visibility */
|
||||
gboolean locked; /* transformation locking */
|
||||
|
||||
GList *strokes; /* The List of GimpStrokes */
|
||||
|
||||
gint freeze_count;
|
||||
/* Stuff missing */
|
||||
};
|
||||
|
||||
@ -51,7 +49,8 @@ struct _GimpVectorsClass
|
||||
GimpItemClass parent_class;
|
||||
|
||||
/* signals */
|
||||
void (* changed) (GimpVectors *vectors);
|
||||
void (* freeze) (GimpVectors *vectors);
|
||||
void (* thaw) (GimpVectors *vectors);
|
||||
|
||||
/* virtual functions */
|
||||
void (* stroke_add) (GimpVectors *vectors,
|
||||
@ -87,6 +86,9 @@ GType gimp_vectors_get_type (void) G_GNUC_CONST;
|
||||
GimpVectors * gimp_vectors_new (GimpImage *gimage,
|
||||
const gchar *name);
|
||||
|
||||
void gimp_vectors_freeze (GimpVectors *vectors);
|
||||
void gimp_vectors_thaw (GimpVectors *vectors);
|
||||
|
||||
void gimp_vectors_copy_strokes (const GimpVectors *src_vectors,
|
||||
GimpVectors *dest_vectors);
|
||||
|
||||
|
Reference in New Issue
Block a user