Update upstream
This commit is contained in:
@ -85,5 +85,12 @@ typedef enum /*< skip, pdb-skip >*/
|
||||
PIKA_PAINT_STATE_FINISH /* Cleanup and/or reset PaintFunc operation */
|
||||
} PikaPaintState;
|
||||
|
||||
/* State of lock blinking */
|
||||
typedef enum /*< skip, pdb-skip >*/
|
||||
{
|
||||
PIKA_PAINT_LOCK_NOT_BLINKED,
|
||||
PIKA_PAINT_LOCK_BLINK_PENDING,
|
||||
PIKA_PAINT_LOCK_BLINKED,
|
||||
} PikaPaintLockBlinkState;
|
||||
|
||||
#endif /* __PAINT_ENUMS_H__ */
|
||||
|
@ -819,6 +819,8 @@ pika_brush_core_get_paint_buffer (PikaPaintCore *paint_core,
|
||||
gint x1, y1, x2, y2;
|
||||
gint drawable_width, drawable_height;
|
||||
gint brush_width, brush_height;
|
||||
gint offset_change_x, offset_change_y;
|
||||
PikaCoords new_coords;
|
||||
|
||||
pika_brush_transform_size (core->brush,
|
||||
core->scale, core->aspect_ratio,
|
||||
@ -835,11 +837,31 @@ pika_brush_core_get_paint_buffer (PikaPaintCore *paint_core,
|
||||
x = (gint) floor (coords->x) - (brush_width / 2);
|
||||
y = (gint) floor (coords->y) - (brush_height / 2);
|
||||
|
||||
x1 = x - 1;
|
||||
y1 = y - 1;
|
||||
x2 = x + brush_width + 1;
|
||||
y2 = y + brush_height + 1;
|
||||
|
||||
pika_paint_core_expand_drawable (paint_core, drawable, paint_options,
|
||||
x1, x2, y1, y2,
|
||||
&offset_change_x, &offset_change_y);
|
||||
|
||||
if (offset_change_x || offset_change_y)
|
||||
{
|
||||
x += offset_change_x;
|
||||
y += offset_change_y;
|
||||
|
||||
new_coords = *coords;
|
||||
new_coords.x = coords->x + offset_change_x;
|
||||
new_coords.y = coords->y + offset_change_y;
|
||||
pika_symmetry_set_origin (paint_core->sym, drawable, &new_coords);
|
||||
}
|
||||
|
||||
drawable_width = pika_item_get_width (PIKA_ITEM (drawable));
|
||||
drawable_height = pika_item_get_height (PIKA_ITEM (drawable));
|
||||
|
||||
x1 = CLAMP (x - 1, 0, drawable_width);
|
||||
y1 = CLAMP (y - 1, 0, drawable_height);
|
||||
x1 = CLAMP (x - 1, 0, drawable_width);
|
||||
y1 = CLAMP (y - 1, 0, drawable_height);
|
||||
x2 = CLAMP (x + brush_width + 1, 0, drawable_width);
|
||||
y2 = CLAMP (y + brush_height + 1, 0, drawable_height);
|
||||
|
||||
|
@ -470,6 +470,21 @@ pika_blob_duplicate (PikaBlob *b)
|
||||
return g_memdup2 (b, sizeof (PikaBlob) + sizeof (PikaBlobSpan) * (b->height - 1));
|
||||
}
|
||||
|
||||
void
|
||||
pika_blob_move (PikaBlob *b,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
gint i = 0;
|
||||
|
||||
b->y += y;
|
||||
for (i = 0; i < b->height; i++)
|
||||
{
|
||||
b->data[i].left += x;
|
||||
b->data[i].right += x;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
pika_blob_dump (PikaBlob *b)
|
||||
|
@ -86,6 +86,9 @@ void pika_blob_bounds (PikaBlob *b,
|
||||
PikaBlob * pika_blob_convex_union (PikaBlob *b1,
|
||||
PikaBlob *b2);
|
||||
PikaBlob * pika_blob_duplicate (PikaBlob *b);
|
||||
void pika_blob_move (PikaBlob *b,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
|
||||
#endif /* __PIKA_INK_BLOB_H__ */
|
||||
|
@ -242,17 +242,49 @@ pika_ink_get_paint_buffer (PikaPaintCore *paint_core,
|
||||
gint *paint_width,
|
||||
gint *paint_height)
|
||||
{
|
||||
PikaInk *ink = PIKA_INK (paint_core);
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
gint dwidth, dheight;
|
||||
gint x1, y1, x2, y2;
|
||||
PikaInk *ink = PIKA_INK (paint_core);
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
gint dwidth, dheight;
|
||||
gint x1, y1, x2, y2;
|
||||
gint offset_change_x, offset_change_y;
|
||||
PikaCoords new_coords;
|
||||
GList *iter;
|
||||
|
||||
pika_blob_bounds (ink->cur_blob, &x, &y, &width, &height);
|
||||
|
||||
x1 = x / SUBSAMPLE - 1;
|
||||
y1 = y / SUBSAMPLE - 1;
|
||||
x2 = (x + width) / SUBSAMPLE + 2;
|
||||
y2 = (y + height) / SUBSAMPLE + 2;
|
||||
|
||||
pika_paint_core_expand_drawable (paint_core, drawable, paint_options,
|
||||
x1, x2, y1, y2,
|
||||
&offset_change_x, &offset_change_y);
|
||||
|
||||
dwidth = pika_item_get_width (PIKA_ITEM (drawable));
|
||||
dheight = pika_item_get_height (PIKA_ITEM (drawable));
|
||||
|
||||
if (offset_change_x || offset_change_y)
|
||||
{
|
||||
x += SUBSAMPLE * offset_change_x;
|
||||
y += SUBSAMPLE * offset_change_y;
|
||||
|
||||
new_coords = *coords;
|
||||
new_coords.x = coords->x + offset_change_x;
|
||||
new_coords.y = coords->y + offset_change_y;
|
||||
pika_symmetry_set_origin (paint_core->sym, drawable, &new_coords);
|
||||
|
||||
for (iter = ink->blobs_to_render; iter; iter = g_list_next (iter))
|
||||
pika_blob_move (iter->data,
|
||||
SUBSAMPLE * offset_change_x,
|
||||
SUBSAMPLE * offset_change_y);
|
||||
for (iter = ink->last_blobs; iter; iter = g_list_next (iter))
|
||||
pika_blob_move (iter->data,
|
||||
SUBSAMPLE * offset_change_x,
|
||||
SUBSAMPLE * offset_change_y);
|
||||
}
|
||||
|
||||
x1 = CLAMP (x / SUBSAMPLE - 1, 0, dwidth);
|
||||
y1 = CLAMP (y / SUBSAMPLE - 1, 0, dheight);
|
||||
x2 = CLAMP ((x + width) / SUBSAMPLE + 2, 0, dwidth);
|
||||
@ -319,7 +351,6 @@ pika_ink_motion (PikaPaintCore *paint_core,
|
||||
PikaInk *ink = PIKA_INK (paint_core);
|
||||
PikaInkOptions *options = PIKA_INK_OPTIONS (paint_options);
|
||||
PikaContext *context = PIKA_CONTEXT (paint_options);
|
||||
GList *blob_unions = NULL;
|
||||
GList *blobs_to_render = NULL;
|
||||
GeglBuffer *paint_buffer;
|
||||
gint paint_buffer_x;
|
||||
@ -338,6 +369,7 @@ pika_ink_motion (PikaPaintCore *paint_core,
|
||||
coords.x -= off_x;
|
||||
coords.y -= off_y;
|
||||
pika_symmetry_set_origin (sym, drawable, &coords);
|
||||
paint_core->sym = sym;
|
||||
|
||||
n_strokes = pika_symmetry_get_size (sym);
|
||||
|
||||
@ -377,7 +409,8 @@ pika_ink_motion (PikaPaintCore *paint_core,
|
||||
last_blob);
|
||||
ink->start_blobs = g_list_prepend (ink->start_blobs,
|
||||
pika_blob_duplicate (last_blob));
|
||||
blobs_to_render = g_list_prepend (blobs_to_render, last_blob);
|
||||
blobs_to_render = g_list_prepend (blobs_to_render,
|
||||
pika_blob_duplicate (last_blob));
|
||||
}
|
||||
ink->start_blobs = g_list_reverse (ink->start_blobs);
|
||||
ink->last_blobs = g_list_reverse (ink->last_blobs);
|
||||
@ -411,7 +444,6 @@ pika_ink_motion (PikaPaintCore *paint_core,
|
||||
g_list_nth (ink->last_blobs, i)->data = blob;
|
||||
|
||||
blobs_to_render = g_list_prepend (blobs_to_render, blob_union);
|
||||
blob_unions = g_list_prepend (blob_unions, blob_union);
|
||||
}
|
||||
blobs_to_render = g_list_reverse (blobs_to_render);
|
||||
}
|
||||
@ -422,6 +454,7 @@ pika_ink_motion (PikaPaintCore *paint_core,
|
||||
pika_pickable_srgb_to_image_color (PIKA_PICKABLE (drawable),
|
||||
&foreground, &foreground);
|
||||
color = pika_gegl_color_new (&foreground, pika_drawable_get_space (drawable));
|
||||
ink->blobs_to_render = blobs_to_render;
|
||||
|
||||
for (i = 0; i < n_strokes; i++)
|
||||
{
|
||||
@ -467,8 +500,7 @@ pika_ink_motion (PikaPaintCore *paint_core,
|
||||
|
||||
g_object_unref (color);
|
||||
|
||||
g_list_free_full (blob_unions, g_free);
|
||||
g_list_free (blobs_to_render);
|
||||
g_list_free_full (blobs_to_render, g_free);
|
||||
}
|
||||
|
||||
static PikaBlob *
|
||||
|
@ -41,10 +41,11 @@ struct _PikaInk
|
||||
{
|
||||
PikaPaintCore parent_instance;
|
||||
|
||||
GList *start_blobs; /* starting blobs per stroke (for undo) */
|
||||
GList *start_blobs; /* starting blobs per stroke (for undo) */
|
||||
|
||||
PikaBlob *cur_blob; /* current blob */
|
||||
GList *last_blobs; /* blobs for last stroke positions */
|
||||
PikaBlob *cur_blob; /* current blob */
|
||||
GList *last_blobs; /* blobs for last stroke positions */
|
||||
GList *blobs_to_render;
|
||||
};
|
||||
|
||||
struct _PikaInkClass
|
||||
|
@ -259,7 +259,7 @@ pika_mybrush_core_motion (PikaPaintCore *paint_core,
|
||||
{
|
||||
PikaMybrushCore *mybrush = PIKA_MYBRUSH_CORE (paint_core);
|
||||
MyPaintRectangle rect;
|
||||
PikaCoords coords;
|
||||
PikaCoords origin;
|
||||
GList *iter;
|
||||
gdouble dt = 0.0;
|
||||
gint off_x, off_y;
|
||||
@ -269,10 +269,10 @@ pika_mybrush_core_motion (PikaPaintCore *paint_core,
|
||||
pika_item_get_offset (PIKA_ITEM (drawable), &off_x, &off_y);
|
||||
n_strokes = pika_symmetry_get_size (sym);
|
||||
|
||||
coords = *(pika_symmetry_get_origin (sym));
|
||||
coords.x -= off_x;
|
||||
coords.y -= off_y;
|
||||
pika_symmetry_set_origin (sym, drawable, &coords);
|
||||
origin = *(pika_symmetry_get_origin (sym));
|
||||
origin.x -= off_x;
|
||||
origin.y -= off_y;
|
||||
pika_symmetry_set_origin (sym, drawable, &origin);
|
||||
|
||||
/* The number of strokes may change during a motion, depending on
|
||||
* the type of symmetry. When that happens, reset the brushes.
|
||||
@ -291,9 +291,8 @@ pika_mybrush_core_motion (PikaPaintCore *paint_core,
|
||||
iter;
|
||||
iter = g_list_next (iter), i++)
|
||||
{
|
||||
MyPaintBrush *brush = iter->data;
|
||||
|
||||
coords = *(pika_symmetry_get_coords (sym, i));
|
||||
MyPaintBrush *brush = iter->data;
|
||||
PikaCoords coords = *(pika_symmetry_get_coords (sym, i));
|
||||
|
||||
mypaint_brush_stroke_to (brush,
|
||||
(MyPaintSurface *) mybrush->private->surface,
|
||||
@ -326,6 +325,42 @@ pika_mybrush_core_motion (PikaPaintCore *paint_core,
|
||||
MyPaintBrush *brush = iter->data;
|
||||
PikaCoords coords = *(pika_symmetry_get_coords (sym, i));
|
||||
gdouble pressure = coords.pressure;
|
||||
gboolean expanded;
|
||||
gfloat radius = 100;
|
||||
gint x1, x2, y1, y2;
|
||||
gint offset_change_x, offset_change_y;
|
||||
gint off_x_surf, off_y_surf;
|
||||
gint off_x, off_y;
|
||||
|
||||
x1 = coords.x - radius;
|
||||
y1 = coords.y - radius;
|
||||
x2 = coords.x + radius;
|
||||
y2 = coords.y + radius;
|
||||
|
||||
expanded = pika_paint_core_expand_drawable (paint_core, drawable, paint_options,
|
||||
x1, x2, y1, y2,
|
||||
&offset_change_x, &offset_change_y);
|
||||
|
||||
pika_item_get_offset (PIKA_ITEM (drawable), &off_x, &off_y);
|
||||
if (expanded)
|
||||
pika_mypaint_surface_set_buffer (mybrush->private->surface, pika_drawable_get_buffer (drawable),
|
||||
off_x, off_y);
|
||||
|
||||
pika_mypaint_surface_get_offset (mybrush->private->surface, &off_x_surf, &off_y_surf);
|
||||
coords.x -= off_x_surf;
|
||||
coords.y -= off_y_surf;
|
||||
|
||||
if (offset_change_x || offset_change_y)
|
||||
{
|
||||
pika_mypaint_surface_set_offset (mybrush->private->surface,
|
||||
off_x_surf + offset_change_x,
|
||||
off_y_surf + offset_change_y);
|
||||
|
||||
origin = *(pika_symmetry_get_origin (sym));
|
||||
origin.x += offset_change_x;
|
||||
origin.y += offset_change_y;
|
||||
pika_symmetry_set_origin (sym, drawable, &origin);
|
||||
}
|
||||
|
||||
mypaint_brush_stroke_to (brush,
|
||||
(MyPaintSurface *) mybrush->private->surface,
|
||||
|
@ -38,13 +38,15 @@
|
||||
|
||||
struct _PikaMybrushSurface
|
||||
{
|
||||
MyPaintSurface surface;
|
||||
GeglBuffer *buffer;
|
||||
GeglBuffer *paint_mask;
|
||||
gint paint_mask_x;
|
||||
gint paint_mask_y;
|
||||
GeglRectangle dirty;
|
||||
PikaComponentMask component_mask;
|
||||
MyPaintSurface surface;
|
||||
GeglBuffer *buffer;
|
||||
GeglBuffer *paint_mask;
|
||||
gint paint_mask_x;
|
||||
gint paint_mask_y;
|
||||
gint off_x;
|
||||
gint off_y;
|
||||
GeglRectangle dirty;
|
||||
PikaComponentMask component_mask;
|
||||
PikaMybrushOptions *options;
|
||||
};
|
||||
|
||||
@ -382,6 +384,8 @@ pika_mypaint_surface_draw_dab (MyPaintSurface *base_surface,
|
||||
colorize = opaque * colorize;
|
||||
|
||||
/* FIXME: This should use the real matrix values to trim aspect_ratio dabs */
|
||||
x += surface->off_x;
|
||||
y += surface->off_y;
|
||||
dabRect = calculate_dab_roi (x, y, radius);
|
||||
gegl_rectangle_intersect (&dabRect, &dabRect, gegl_buffer_get_extent (surface->buffer));
|
||||
|
||||
@ -561,5 +565,40 @@ pika_mypaint_surface_new (GeglBuffer *buffer,
|
||||
surface->paint_mask_y = paint_mask_y;
|
||||
surface->dirty = *GEGL_RECTANGLE (0, 0, 0, 0);
|
||||
|
||||
surface->off_x = 0;
|
||||
surface->off_y = 0;
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
void
|
||||
pika_mypaint_surface_set_buffer (PikaMybrushSurface *surface,
|
||||
GeglBuffer *buffer,
|
||||
gint paint_mask_x,
|
||||
gint paint_mask_y)
|
||||
{
|
||||
g_object_unref (surface->buffer);
|
||||
|
||||
surface->buffer = g_object_ref (buffer);
|
||||
|
||||
surface->paint_mask_x = paint_mask_x;
|
||||
surface->paint_mask_y = paint_mask_y;
|
||||
}
|
||||
|
||||
void
|
||||
pika_mypaint_surface_set_offset (PikaMybrushSurface *surface,
|
||||
gint off_x,
|
||||
gint off_y)
|
||||
{
|
||||
surface->off_x = off_x;
|
||||
surface->off_y = off_y;
|
||||
}
|
||||
|
||||
void
|
||||
pika_mypaint_surface_get_offset (PikaMybrushSurface *surface,
|
||||
gint *off_x,
|
||||
gint *off_y)
|
||||
{
|
||||
*off_x = surface->off_x;
|
||||
*off_y = surface->off_y;
|
||||
}
|
||||
|
@ -33,5 +33,18 @@ pika_mypaint_surface_new (GeglBuffer *buffer,
|
||||
gint paint_mask_y,
|
||||
PikaMybrushOptions *options);
|
||||
|
||||
void
|
||||
pika_mypaint_surface_set_buffer (PikaMybrushSurface *surface,
|
||||
GeglBuffer *buffer,
|
||||
gint paint_mask_x,
|
||||
gint paint_mask_y);
|
||||
void
|
||||
pika_mypaint_surface_set_offset (PikaMybrushSurface *surface,
|
||||
gint off_x,
|
||||
gint off_y);
|
||||
void
|
||||
pika_mypaint_surface_get_offset (PikaMybrushSurface *surface,
|
||||
gint *off_x,
|
||||
gint *off_y);
|
||||
|
||||
#endif /* __PIKA_MYBRUSH_SURFACE_H__ */
|
||||
|
@ -193,7 +193,8 @@ pika_paintbrush_real_get_paint_params (PikaPaintbrush *paintbrush,
|
||||
|
||||
*paint_mode = pika_context_get_paint_mode (context);
|
||||
|
||||
if (pika_paint_options_get_gradient_color (paint_options, image,
|
||||
if (pika_paint_options_are_dynamics_enabled (paint_options) &&
|
||||
pika_paint_options_get_gradient_color (paint_options, image,
|
||||
grad_point,
|
||||
paint_core->pixel_dist,
|
||||
paint_color))
|
||||
@ -252,6 +253,7 @@ _pika_paintbrush_motion (PikaPaintCore *paint_core,
|
||||
coords.x -= off_x;
|
||||
coords.y -= off_y;
|
||||
pika_symmetry_set_origin (sym, drawable, &coords);
|
||||
paint_core->sym = sym;
|
||||
|
||||
/* Some settings are based on the original stroke. */
|
||||
opacity *= pika_dynamics_get_linear_value (dynamics,
|
||||
@ -313,6 +315,8 @@ _pika_paintbrush_motion (PikaPaintCore *paint_core,
|
||||
&paint_buffer_y,
|
||||
&paint_width,
|
||||
&paint_height);
|
||||
coords = *(pika_symmetry_get_coords (sym, i));
|
||||
|
||||
if (! paint_buffer)
|
||||
continue;
|
||||
|
||||
|
@ -24,10 +24,12 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <cairo.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libpikabase/pikabase.h"
|
||||
#include "libpikacolor/pikacolor.h"
|
||||
#include "libpikamath/pikamath.h"
|
||||
|
||||
#include "paint-types.h"
|
||||
@ -47,6 +49,9 @@
|
||||
#include "core/pikaimage-guides.h"
|
||||
#include "core/pikaimage-symmetry.h"
|
||||
#include "core/pikaimage-undo.h"
|
||||
#include "core/pikaimage-undo-push.h"
|
||||
#include "core/pikalayer.h"
|
||||
#include "core/pikalayermask.h"
|
||||
#include "core/pikapickable.h"
|
||||
#include "core/pikaprojection.h"
|
||||
#include "core/pikasymmetry.h"
|
||||
@ -158,7 +163,10 @@ static void
|
||||
pika_paint_core_init (PikaPaintCore *core)
|
||||
{
|
||||
core->ID = global_core_ID++;
|
||||
core->undo_buffers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
|
||||
core->undo_buffers = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
NULL, g_object_unref);
|
||||
core->original_bounds = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
NULL, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -170,6 +178,7 @@ pika_paint_core_finalize (GObject *object)
|
||||
|
||||
g_clear_pointer (&core->undo_desc, g_free);
|
||||
g_hash_table_unref (core->undo_buffers);
|
||||
g_hash_table_unref (core->original_bounds);
|
||||
if (core->applicators)
|
||||
g_hash_table_unref (core->applicators);
|
||||
|
||||
@ -357,10 +366,11 @@ pika_paint_core_start (PikaPaintCore *core,
|
||||
const PikaCoords *coords,
|
||||
GError **error)
|
||||
{
|
||||
PikaImage *image;
|
||||
PikaChannel *mask;
|
||||
gint max_width = 0;
|
||||
gint max_height = 0;
|
||||
PikaImage *image;
|
||||
PikaChannel *mask;
|
||||
gint max_width = 0;
|
||||
gint max_height = 0;
|
||||
GeglRectangle *rect;
|
||||
|
||||
g_return_val_if_fail (PIKA_IS_PAINT_CORE (core), FALSE);
|
||||
g_return_val_if_fail (g_list_length (drawables) > 0, FALSE);
|
||||
@ -418,8 +428,16 @@ pika_paint_core_start (PikaPaintCore *core,
|
||||
for (GList *iter = drawables; iter; iter = iter->next)
|
||||
{
|
||||
/* Allocate the undo structures */
|
||||
rect = g_new (GeglRectangle, 1);
|
||||
rect->width = pika_item_get_width (PIKA_ITEM (iter->data));
|
||||
rect->height = pika_item_get_height (PIKA_ITEM (iter->data));
|
||||
pika_item_get_offset (PIKA_ITEM (iter->data), &rect->x, &rect->y);
|
||||
|
||||
g_hash_table_insert (core->original_bounds, iter->data,
|
||||
rect);
|
||||
g_hash_table_insert (core->undo_buffers, iter->data,
|
||||
pika_gegl_buffer_dup (pika_drawable_get_buffer (iter->data)));
|
||||
|
||||
max_width = MAX (max_width, pika_item_get_width (iter->data));
|
||||
max_height = MAX (max_height, pika_item_get_height (iter->data));
|
||||
}
|
||||
@ -484,6 +502,9 @@ pika_paint_core_start (PikaPaintCore *core,
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize the lock_blink_state */
|
||||
core->lock_blink_state = PIKA_PAINT_LOCK_NOT_BLINKED;
|
||||
|
||||
/* Freeze the drawable preview so that it isn't constantly updated. */
|
||||
for (GList *iter = drawables; iter; iter = iter->next)
|
||||
pika_viewable_preview_freeze (PIKA_VIEWABLE (iter->data));
|
||||
@ -532,7 +553,9 @@ pika_paint_core_finish (PikaPaintCore *core,
|
||||
{
|
||||
GeglBuffer *undo_buffer;
|
||||
GeglBuffer *buffer;
|
||||
GeglBuffer *drawable_buffer;
|
||||
GeglRectangle rect;
|
||||
GeglRectangle old_rect;
|
||||
|
||||
if (! g_hash_table_steal_extended (core->undo_buffers, iter->data,
|
||||
NULL, (gpointer*) &undo_buffer))
|
||||
@ -542,16 +565,6 @@ pika_paint_core_finish (PikaPaintCore *core,
|
||||
continue;
|
||||
}
|
||||
|
||||
pika_rectangle_intersect (core->x1, core->y1,
|
||||
core->x2 - core->x1, core->y2 - core->y1,
|
||||
0, 0,
|
||||
pika_item_get_width (PIKA_ITEM (iter->data)),
|
||||
pika_item_get_height (PIKA_ITEM (iter->data)),
|
||||
&rect.x, &rect.y, &rect.width, &rect.height);
|
||||
|
||||
gegl_rectangle_align_to_buffer (&rect, &rect, undo_buffer,
|
||||
GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
|
||||
|
||||
if (! undo_group_started)
|
||||
{
|
||||
pika_image_undo_group_start (image, PIKA_UNDO_GROUP_PAINT,
|
||||
@ -559,19 +572,115 @@ pika_paint_core_finish (PikaPaintCore *core,
|
||||
undo_group_started = TRUE;
|
||||
}
|
||||
|
||||
PIKA_PAINT_CORE_GET_CLASS (core)->push_undo (core, image, NULL);
|
||||
/* get new and old bounds of drawable */
|
||||
old_rect = *(GeglRectangle*) g_hash_table_lookup (core->original_bounds, iter->data);
|
||||
|
||||
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, rect.width, rect.height),
|
||||
pika_drawable_get_format (iter->data));
|
||||
pika_item_get_offset (PIKA_ITEM (iter->data), &rect.x, &rect.y);
|
||||
rect.width = pika_item_get_width (PIKA_ITEM (iter->data));
|
||||
rect.height = pika_item_get_height (PIKA_ITEM (iter->data));
|
||||
|
||||
pika_gegl_buffer_copy (undo_buffer,
|
||||
&rect,
|
||||
GEGL_ABYSS_NONE,
|
||||
buffer,
|
||||
GEGL_RECTANGLE (0, 0, 0, 0));
|
||||
/* Making copy of entire buffer consumes more memory, so do that only when buffer has resized */
|
||||
if (rect.x == old_rect.x &&
|
||||
rect.y == old_rect.y &&
|
||||
rect.width == old_rect.width &&
|
||||
rect.height == old_rect.height)
|
||||
{
|
||||
pika_rectangle_intersect (core->x1, core->y1, core->x2 - core->x1,
|
||||
core->y2 - core->y1, 0, 0,
|
||||
pika_item_get_width (PIKA_ITEM (iter->data)),
|
||||
pika_item_get_height (PIKA_ITEM (iter->data)),
|
||||
&rect.x, &rect.y, &rect.width, &rect.height);
|
||||
|
||||
pika_drawable_push_undo (iter->data, NULL,
|
||||
buffer, rect.x, rect.y, rect.width, rect.height);
|
||||
gegl_rectangle_align_to_buffer (&rect, &rect, undo_buffer,
|
||||
GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
|
||||
|
||||
PIKA_PAINT_CORE_GET_CLASS (core)->push_undo (core, image, NULL);
|
||||
|
||||
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, rect.width, rect.height),
|
||||
pika_drawable_get_format (iter->data));
|
||||
|
||||
pika_gegl_buffer_copy (undo_buffer,
|
||||
&rect,
|
||||
GEGL_ABYSS_NONE,
|
||||
buffer,
|
||||
GEGL_RECTANGLE (0, 0, 0, 0));
|
||||
|
||||
pika_drawable_push_undo (iter->data, NULL,
|
||||
buffer, rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* drawable is expanded only if drawable is layer or layer mask*/
|
||||
g_return_if_fail (PIKA_IS_LAYER (iter->data) || PIKA_IS_LAYER_MASK (iter->data));
|
||||
|
||||
/* create a copy of original buffer from undo data */
|
||||
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
||||
old_rect.width,
|
||||
old_rect.height),
|
||||
pika_drawable_get_format (iter->data));
|
||||
|
||||
pika_gegl_buffer_copy (undo_buffer,
|
||||
GEGL_RECTANGLE (old_rect.x - rect.x,
|
||||
old_rect.y - rect.y,
|
||||
old_rect.width,
|
||||
old_rect.height),
|
||||
GEGL_ABYSS_NONE,
|
||||
buffer,
|
||||
GEGL_RECTANGLE (0, 0, 0, 0));
|
||||
|
||||
/* make a backup copy of drawable to restore */
|
||||
drawable_buffer = g_object_ref (pika_drawable_get_buffer (PIKA_DRAWABLE (iter->data)));
|
||||
|
||||
if (PIKA_IS_LAYER_MASK (drawables->data) || PIKA_LAYER (drawables->data)->mask)
|
||||
{
|
||||
GeglBuffer *other_new;
|
||||
GeglBuffer *other_old;
|
||||
PikaDrawable *other_drawable;
|
||||
|
||||
if (PIKA_IS_LAYER_MASK (drawables->data))
|
||||
other_drawable = PIKA_DRAWABLE ((PIKA_LAYER_MASK (drawables->data))->layer);
|
||||
else
|
||||
other_drawable = PIKA_DRAWABLE (PIKA_LAYER (drawables->data)->mask);
|
||||
|
||||
/* create a copy of original buffer by taking the required area */
|
||||
other_old = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
||||
old_rect.width,
|
||||
old_rect.height),
|
||||
pika_drawable_get_format (other_drawable));
|
||||
|
||||
pika_gegl_buffer_copy (pika_drawable_get_buffer (other_drawable),
|
||||
GEGL_RECTANGLE (old_rect.x - rect.x,
|
||||
old_rect.y - rect.y,
|
||||
old_rect.width,
|
||||
old_rect.height),
|
||||
GEGL_ABYSS_NONE,
|
||||
other_old,
|
||||
GEGL_RECTANGLE (0, 0, 0, 0));
|
||||
|
||||
/* make a backup copy of drawable to restore */
|
||||
other_new = g_object_ref (pika_drawable_get_buffer (other_drawable));
|
||||
|
||||
pika_drawable_set_buffer_full (other_drawable, FALSE, NULL,
|
||||
other_old, &old_rect,
|
||||
FALSE);
|
||||
pika_drawable_set_buffer_full (other_drawable, TRUE, NULL,
|
||||
other_new, &rect,
|
||||
FALSE);
|
||||
|
||||
g_object_unref (other_new);
|
||||
g_object_unref (other_old);
|
||||
}
|
||||
/* Restore drawable to state before painting started */
|
||||
pika_drawable_set_buffer_full (iter->data, FALSE, NULL,
|
||||
buffer, &old_rect,
|
||||
FALSE);
|
||||
/* Change the drawable again but push undo this time */
|
||||
pika_drawable_set_buffer_full (iter->data, TRUE, NULL,
|
||||
drawable_buffer, &rect,
|
||||
FALSE);
|
||||
|
||||
g_object_unref (drawable_buffer);
|
||||
}
|
||||
|
||||
g_object_unref (buffer);
|
||||
g_object_unref (undo_buffer);
|
||||
@ -614,7 +723,8 @@ pika_paint_core_cancel (PikaPaintCore *core,
|
||||
&x, &y, &width, &height))
|
||||
{
|
||||
GeglBuffer *undo_buffer;
|
||||
GeglRectangle rect;
|
||||
GeglRectangle new_rect;
|
||||
GeglRectangle old_rect;
|
||||
|
||||
if (! g_hash_table_steal_extended (core->undo_buffers, iter->data,
|
||||
NULL, (gpointer*) &undo_buffer))
|
||||
@ -624,21 +734,108 @@ pika_paint_core_cancel (PikaPaintCore *core,
|
||||
continue;
|
||||
}
|
||||
|
||||
gegl_rectangle_align_to_buffer (&rect,
|
||||
GEGL_RECTANGLE (x, y, width, height),
|
||||
pika_drawable_get_buffer (iter->data),
|
||||
GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
|
||||
old_rect = *(GeglRectangle*) g_hash_table_lookup (core->original_bounds, iter->data);
|
||||
|
||||
pika_item_get_offset (PIKA_ITEM (iter->data), &new_rect.x, &new_rect.y);
|
||||
new_rect.width = pika_item_get_width (PIKA_ITEM (iter->data));
|
||||
new_rect.height = pika_item_get_height (PIKA_ITEM (iter->data));
|
||||
|
||||
if (new_rect.x == old_rect.x &&
|
||||
new_rect.y == old_rect.y &&
|
||||
new_rect.width == old_rect.width &&
|
||||
new_rect.height == old_rect.height)
|
||||
{
|
||||
GeglRectangle rect;
|
||||
|
||||
gegl_rectangle_align_to_buffer (&rect,
|
||||
GEGL_RECTANGLE (x, y, width, height),
|
||||
pika_drawable_get_buffer (iter->data),
|
||||
GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
|
||||
|
||||
pika_gegl_buffer_copy (undo_buffer,
|
||||
&rect,
|
||||
GEGL_ABYSS_NONE,
|
||||
pika_drawable_get_buffer (iter->data),
|
||||
&rect);
|
||||
|
||||
pika_drawable_update (iter->data, x, y, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
GeglBuffer *buffer;
|
||||
GeglRectangle bbox;
|
||||
|
||||
/* drawable is expanded only if drawable is layer or layer mask,
|
||||
* so drawable cannot be anything else */
|
||||
g_return_if_fail (PIKA_IS_LAYER (iter->data) || PIKA_IS_LAYER_MASK (iter->data));
|
||||
|
||||
/* When canceling painting with drawable expansion, ensure that
|
||||
* the drawable display outside the reverted size is not shown. We
|
||||
* cannot use pika_drawable_update() because it won't work while
|
||||
* painting. Directly emit the "update" signal.
|
||||
* */
|
||||
bbox = pika_drawable_get_bounding_box (iter->data);
|
||||
g_signal_emit_by_name (iter->data, "update", bbox.x, bbox.y, bbox.width, bbox.height);
|
||||
|
||||
/* create a copy of original buffer from undo data */
|
||||
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
||||
old_rect.width,
|
||||
old_rect.height),
|
||||
pika_drawable_get_format (iter->data));
|
||||
|
||||
pika_gegl_buffer_copy (undo_buffer,
|
||||
GEGL_RECTANGLE (old_rect.x - new_rect.x,
|
||||
old_rect.y - new_rect.y,
|
||||
old_rect.width,
|
||||
old_rect.height),
|
||||
GEGL_ABYSS_NONE,
|
||||
buffer,
|
||||
GEGL_RECTANGLE (0, 0, 0, 0));
|
||||
|
||||
if (PIKA_IS_LAYER_MASK (drawables->data) || PIKA_LAYER (drawables->data)->mask)
|
||||
{
|
||||
GeglBuffer *other_old;
|
||||
PikaDrawable *other_drawable;
|
||||
|
||||
if (PIKA_IS_LAYER_MASK (drawables->data))
|
||||
other_drawable = PIKA_DRAWABLE ((PIKA_LAYER_MASK (drawables->data))->layer);
|
||||
else
|
||||
other_drawable = PIKA_DRAWABLE (PIKA_LAYER (drawables->data)->mask);
|
||||
|
||||
/* create a copy of original buffer by taking the required area */
|
||||
other_old = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
||||
old_rect.width,
|
||||
old_rect.height),
|
||||
pika_drawable_get_format (other_drawable));
|
||||
|
||||
pika_gegl_buffer_copy (pika_drawable_get_buffer (other_drawable),
|
||||
GEGL_RECTANGLE (old_rect.x - new_rect.x,
|
||||
old_rect.y - new_rect.y,
|
||||
old_rect.width,
|
||||
old_rect.height),
|
||||
GEGL_ABYSS_NONE,
|
||||
other_old,
|
||||
GEGL_RECTANGLE (0, 0, 0, 0));
|
||||
|
||||
pika_drawable_set_buffer_full (other_drawable, FALSE, NULL,
|
||||
other_old, &old_rect,
|
||||
FALSE);
|
||||
|
||||
g_object_unref (other_old);
|
||||
}
|
||||
/* Restore drawable to state before painting started */
|
||||
pika_drawable_set_buffer_full (iter->data, FALSE, NULL,
|
||||
buffer, &old_rect,
|
||||
FALSE);
|
||||
|
||||
pika_drawable_update (iter->data, 0, 0, -1, -1);
|
||||
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
|
||||
pika_gegl_buffer_copy (undo_buffer,
|
||||
&rect,
|
||||
GEGL_ABYSS_NONE,
|
||||
pika_drawable_get_buffer (iter->data),
|
||||
&rect);
|
||||
g_object_unref (undo_buffer);
|
||||
}
|
||||
|
||||
pika_drawable_update (iter->data, x, y, width, height);
|
||||
|
||||
pika_viewable_preview_thaw (PIKA_VIEWABLE (iter->data));
|
||||
}
|
||||
|
||||
@ -651,6 +848,7 @@ pika_paint_core_cleanup (PikaPaintCore *core)
|
||||
g_return_if_fail (PIKA_IS_PAINT_CORE (core));
|
||||
|
||||
g_hash_table_remove_all (core->undo_buffers);
|
||||
g_hash_table_remove_all (core->original_bounds);
|
||||
|
||||
g_clear_object (&core->saved_proj_buffer);
|
||||
g_clear_object (&core->canvas_buffer);
|
||||
@ -692,6 +890,227 @@ pika_paint_core_get_show_all (PikaPaintCore *core)
|
||||
return core->show_all;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
pika_paint_core_expand_drawable (PikaPaintCore *core,
|
||||
PikaDrawable *drawable,
|
||||
PikaPaintOptions *options,
|
||||
gint x1,
|
||||
gint x2,
|
||||
gint y1,
|
||||
gint y2,
|
||||
gint *new_off_x,
|
||||
gint *new_off_y)
|
||||
{
|
||||
gint drawable_width, drawable_height;
|
||||
gint drawable_offset_x, drawable_offset_y;
|
||||
gint image_width, image_height;
|
||||
gint new_width, new_height;
|
||||
gint expand_amount;
|
||||
gboolean show_all;
|
||||
gboolean outside_image;
|
||||
PikaImage *image = pika_item_get_image (PIKA_ITEM (drawable));
|
||||
PikaLayer *layer;
|
||||
|
||||
drawable_width = pika_item_get_width (PIKA_ITEM (drawable));
|
||||
drawable_height = pika_item_get_height (PIKA_ITEM (drawable));
|
||||
pika_item_get_offset (PIKA_ITEM (drawable), &drawable_offset_x, &drawable_offset_y);
|
||||
|
||||
new_width = drawable_width;
|
||||
new_height = drawable_height;
|
||||
*new_off_x = 0;
|
||||
*new_off_y = 0;
|
||||
|
||||
image_width = pika_image_get_width (image);
|
||||
image_height = pika_image_get_height (image);
|
||||
|
||||
expand_amount = options->expand_amount;
|
||||
show_all = pika_paint_core_get_show_all (core);
|
||||
outside_image = x2 < -drawable_offset_x || x1 > image_width - drawable_offset_x ||
|
||||
y2 < -drawable_offset_y || y1 > image_height - drawable_offset_y;
|
||||
|
||||
/* Don't expand if drawable is anything other
|
||||
* than layer or layer mask */
|
||||
if (PIKA_IS_LAYER_MASK (drawable))
|
||||
layer = (PIKA_LAYER_MASK (drawable))->layer;
|
||||
else if (PIKA_IS_LAYER (drawable))
|
||||
layer = PIKA_LAYER (drawable);
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
if (!pika_paint_core_get_show_all (core) && outside_image)
|
||||
return FALSE;
|
||||
|
||||
if (!options->expand_use)
|
||||
return FALSE;
|
||||
|
||||
if (x1 < 0)
|
||||
{
|
||||
if (show_all)
|
||||
{
|
||||
new_width += expand_amount - x1;
|
||||
*new_off_x += expand_amount - x1;
|
||||
}
|
||||
else if (drawable_offset_x > 0)
|
||||
{
|
||||
new_width += expand_amount - x1;
|
||||
*new_off_x += expand_amount - x1;
|
||||
if (*new_off_x > drawable_offset_x)
|
||||
{
|
||||
new_width -= *new_off_x - drawable_offset_x;
|
||||
*new_off_x = drawable_offset_x;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (y1 < 0)
|
||||
{
|
||||
if (show_all)
|
||||
{
|
||||
new_height += expand_amount - y1;
|
||||
*new_off_y += expand_amount - y1;
|
||||
}
|
||||
else if (drawable_offset_y > 0)
|
||||
{
|
||||
new_height += expand_amount - y1;
|
||||
*new_off_y += expand_amount - y1;
|
||||
if (*new_off_y > drawable_offset_y)
|
||||
{
|
||||
new_height -= *new_off_y - drawable_offset_y;
|
||||
*new_off_y = drawable_offset_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x2 > drawable_width)
|
||||
{
|
||||
if (show_all)
|
||||
{
|
||||
new_width += x2 - drawable_width + expand_amount;
|
||||
}
|
||||
else if (drawable_width + drawable_offset_x < image_width)
|
||||
{
|
||||
new_width += x2 - drawable_width + expand_amount;
|
||||
if (new_width + drawable_offset_x - *new_off_x > image_width)
|
||||
new_width = image_width + *new_off_x - drawable_offset_x;
|
||||
}
|
||||
}
|
||||
if (y2 > drawable_height)
|
||||
{
|
||||
if (show_all)
|
||||
{
|
||||
new_height += y2 - drawable_height + expand_amount;
|
||||
}
|
||||
else if (drawable_height + drawable_offset_y < image_height)
|
||||
{
|
||||
new_height += y2 - drawable_height + expand_amount;
|
||||
if (new_height + drawable_offset_y - *new_off_y > image_height)
|
||||
new_height = image_height + *new_off_y - drawable_offset_y;
|
||||
}
|
||||
}
|
||||
|
||||
if (new_width != drawable_width || *new_off_x ||
|
||||
new_height != drawable_height || *new_off_y)
|
||||
{
|
||||
PikaRGB color;
|
||||
PikaPattern *pattern;
|
||||
PikaContext *context = PIKA_CONTEXT (options);
|
||||
PikaFillType fill_type = options->expand_fill_type;
|
||||
gboolean context_has_image;
|
||||
PikaFillType mask_fill_type;
|
||||
GeglBuffer *undo_buffer;
|
||||
GeglBuffer *new_buffer;
|
||||
|
||||
if (pika_item_get_lock_position (PIKA_ITEM (layer)))
|
||||
{
|
||||
if (core->lock_blink_state == PIKA_PAINT_LOCK_NOT_BLINKED)
|
||||
core->lock_blink_state = PIKA_PAINT_LOCK_BLINK_PENDING;
|
||||
|
||||
/* Since we are not expanding, set new offset to zero */
|
||||
*new_off_x = 0;
|
||||
*new_off_y = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mask_fill_type = options->expand_mask_fill_type == PIKA_ADD_MASK_BLACK ?
|
||||
PIKA_FILL_TRANSPARENT :
|
||||
PIKA_FILL_WHITE;
|
||||
|
||||
/* The image field of context is null but
|
||||
* is required for Filling with Middle Gray */
|
||||
context_has_image = context->image != NULL;
|
||||
if (!context_has_image)
|
||||
context->image = image;
|
||||
|
||||
/* ensure that every expansion is pushed to undo stack */
|
||||
if (core->x2 == core->x1)
|
||||
core->x2++;
|
||||
if (core->y2 == core->y1)
|
||||
core->y2++;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (layer));
|
||||
|
||||
pika_drawable_disable_resize_undo (PIKA_DRAWABLE (layer));
|
||||
PIKA_LAYER_GET_CLASS (layer)->resize (layer, context, fill_type,
|
||||
new_width, new_height,
|
||||
*new_off_x, *new_off_y);
|
||||
pika_drawable_enable_resize_undo (PIKA_DRAWABLE (layer));
|
||||
|
||||
if (layer->mask)
|
||||
{
|
||||
g_object_freeze_notify (G_OBJECT (layer->mask));
|
||||
|
||||
pika_drawable_disable_resize_undo (PIKA_DRAWABLE (layer->mask));
|
||||
PIKA_ITEM_GET_CLASS (layer->mask)->resize (PIKA_ITEM (layer->mask), context,
|
||||
mask_fill_type, new_width, new_height,
|
||||
*new_off_x, *new_off_y);
|
||||
pika_drawable_enable_resize_undo (PIKA_DRAWABLE (layer->mask));
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (layer->mask));
|
||||
}
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (layer));
|
||||
|
||||
pika_image_flush (image);
|
||||
|
||||
if (PIKA_IS_LAYER_MASK (drawable))
|
||||
{
|
||||
fill_type = mask_fill_type;
|
||||
}
|
||||
else if (fill_type == PIKA_FILL_TRANSPARENT &&
|
||||
! pika_drawable_has_alpha (drawable))
|
||||
{
|
||||
fill_type = PIKA_FILL_BACKGROUND;
|
||||
}
|
||||
|
||||
new_buffer = pika_gegl_buffer_resize (core->canvas_buffer, new_width, new_height,
|
||||
-(*new_off_x), -(*new_off_y), NULL, NULL, 0, 0);
|
||||
g_object_unref (core->canvas_buffer);
|
||||
core->canvas_buffer = new_buffer;
|
||||
|
||||
pika_get_fill_params (context, fill_type, &color, &pattern, NULL);
|
||||
pika_pickable_srgb_to_image_color (PIKA_PICKABLE (drawable),
|
||||
&color, &color);
|
||||
if (! pika_drawable_has_alpha (drawable))
|
||||
pika_rgb_set_alpha (&color, 1.0);
|
||||
|
||||
undo_buffer = g_hash_table_lookup (core->undo_buffers, drawable);
|
||||
g_object_ref (undo_buffer);
|
||||
|
||||
new_buffer = pika_gegl_buffer_resize (undo_buffer, new_width, new_height,
|
||||
-(*new_off_x), -(*new_off_y), &color,
|
||||
pattern, 0, 0);
|
||||
g_hash_table_insert (core->undo_buffers, drawable, new_buffer);
|
||||
g_object_unref (undo_buffer);
|
||||
|
||||
/* Restore context to its original state */
|
||||
if (!context_has_image)
|
||||
context->image = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
pika_paint_core_set_current_coords (PikaPaintCore *core,
|
||||
const PikaCoords *coords)
|
||||
|
@ -69,12 +69,17 @@ struct _PikaPaintCore
|
||||
GeglBuffer *paint_buffer; /* the buffer to paint pixels to */
|
||||
gint paint_buffer_x;
|
||||
gint paint_buffer_y;
|
||||
GHashTable *original_bounds; /* the original bounds of drawables */
|
||||
|
||||
GeglBuffer *mask_buffer; /* the target drawable's mask */
|
||||
|
||||
GHashTable *applicators;
|
||||
|
||||
GArray *stroke_buffer;
|
||||
|
||||
PikaSymmetry *sym;
|
||||
PikaPaintLockBlinkState
|
||||
lock_blink_state;
|
||||
};
|
||||
|
||||
struct _PikaPaintCoreClass
|
||||
@ -156,6 +161,16 @@ void pika_paint_core_set_show_all (PikaPaintCore *core,
|
||||
gboolean show_all);
|
||||
gboolean pika_paint_core_get_show_all (PikaPaintCore *core);
|
||||
|
||||
gboolean pika_paint_core_expand_drawable (PikaPaintCore *paint_core,
|
||||
PikaDrawable *drawable,
|
||||
PikaPaintOptions *paint_options,
|
||||
gint x1,
|
||||
gint x2,
|
||||
gint y1,
|
||||
gint y2,
|
||||
gint *x,
|
||||
gint *y);
|
||||
|
||||
void pika_paint_core_set_current_coords (PikaPaintCore *core,
|
||||
const PikaCoords *coords);
|
||||
void pika_paint_core_get_current_coords (PikaPaintCore *core,
|
||||
|
@ -83,6 +83,11 @@
|
||||
#define DEFAULT_SMOOTHING_QUALITY 20
|
||||
#define DEFAULT_SMOOTHING_FACTOR 50
|
||||
|
||||
#define DEFAULT_EXPAND_USE FALSE
|
||||
#define DEFAULT_EXPAND_AMOUNT 100.0
|
||||
#define DEFAULT_EXPAND_FILL_TYPE PIKA_FILL_TRANSPARENT
|
||||
#define DEFAULT_EXPAND_MASK_FILL_TYPE PIKA_ADD_MASK_WHITE
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@ -134,7 +139,12 @@ enum
|
||||
|
||||
PROP_USE_SMOOTHING,
|
||||
PROP_SMOOTHING_QUALITY,
|
||||
PROP_SMOOTHING_FACTOR
|
||||
PROP_SMOOTHING_FACTOR,
|
||||
|
||||
PROP_EXPAND_USE,
|
||||
PROP_EXPAND_AMOUNT,
|
||||
PROP_EXPAND_FILL_TYPE,
|
||||
PROP_EXPAND_MASK_FILL_TYPE
|
||||
};
|
||||
|
||||
|
||||
@ -308,6 +318,36 @@ pika_paint_options_class_init (PikaPaintOptionsClass *klass)
|
||||
DEFAULT_USE_JITTER,
|
||||
PIKA_PARAM_STATIC_STRINGS);
|
||||
|
||||
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_EXPAND_USE,
|
||||
"expand-use",
|
||||
_("Expand Layers"),
|
||||
_("Expand active layer as you paint"),
|
||||
DEFAULT_EXPAND_USE,
|
||||
PIKA_PARAM_STATIC_STRINGS);
|
||||
|
||||
PIKA_CONFIG_PROP_DOUBLE (object_class, PROP_EXPAND_AMOUNT,
|
||||
"expand-amount",
|
||||
_("Amount"),
|
||||
_("Amount of expansion"),
|
||||
1.0, 1000.0, DEFAULT_EXPAND_AMOUNT,
|
||||
PIKA_PARAM_STATIC_STRINGS);
|
||||
|
||||
PIKA_CONFIG_PROP_ENUM (object_class, PROP_EXPAND_FILL_TYPE,
|
||||
"expand-fill-type",
|
||||
_("Fill With"),
|
||||
_("Fill layer with"),
|
||||
PIKA_TYPE_FILL_TYPE,
|
||||
DEFAULT_EXPAND_FILL_TYPE,
|
||||
PIKA_PARAM_STATIC_STRINGS);
|
||||
|
||||
PIKA_CONFIG_PROP_ENUM (object_class, PROP_EXPAND_MASK_FILL_TYPE,
|
||||
"expand-mask-fill-type",
|
||||
_("Fill Mask With"),
|
||||
_("Fill layer mask with"),
|
||||
PIKA_TYPE_ADD_MASK_TYPE,
|
||||
DEFAULT_EXPAND_MASK_FILL_TYPE,
|
||||
PIKA_PARAM_STATIC_STRINGS);
|
||||
|
||||
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DYNAMICS_ENABLED,
|
||||
"dynamics-enabled",
|
||||
_("Enable dynamics"),
|
||||
@ -642,6 +682,19 @@ pika_paint_options_set_property (GObject *object,
|
||||
smoothing_options->smoothing_factor = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
case PROP_EXPAND_USE:
|
||||
options->expand_use = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_EXPAND_AMOUNT:
|
||||
options->expand_amount = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_EXPAND_FILL_TYPE:
|
||||
options->expand_fill_type = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_EXPAND_MASK_FILL_TYPE:
|
||||
options->expand_mask_fill_type = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@ -788,6 +841,19 @@ pika_paint_options_get_property (GObject *object,
|
||||
g_value_set_double (value, smoothing_options->smoothing_factor);
|
||||
break;
|
||||
|
||||
case PROP_EXPAND_USE:
|
||||
g_value_set_boolean (value, options->expand_use);
|
||||
break;
|
||||
case PROP_EXPAND_AMOUNT:
|
||||
g_value_set_double (value, options->expand_amount);
|
||||
break;
|
||||
case PROP_EXPAND_FILL_TYPE:
|
||||
g_value_set_enum (value, options->expand_fill_type);
|
||||
break;
|
||||
case PROP_EXPAND_MASK_FILL_TYPE:
|
||||
g_value_set_enum (value, options->expand_mask_fill_type);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@ -1221,9 +1287,18 @@ static const gchar *gradient_props[] =
|
||||
"gradient-repeat"
|
||||
};
|
||||
|
||||
static const gchar *expand_props[] =
|
||||
{
|
||||
"expand-use",
|
||||
"expand-amount",
|
||||
"expand-fill-type",
|
||||
"expand-mask-fill-type",
|
||||
};
|
||||
|
||||
static const gint max_n_props = (G_N_ELEMENTS (brush_props) +
|
||||
G_N_ELEMENTS (dynamics_props) +
|
||||
G_N_ELEMENTS (gradient_props));
|
||||
G_N_ELEMENTS (gradient_props) +
|
||||
G_N_ELEMENTS (expand_props));
|
||||
|
||||
gboolean
|
||||
pika_paint_options_is_prop (const gchar *prop_name,
|
||||
@ -1254,6 +1329,13 @@ pika_paint_options_is_prop (const gchar *prop_name,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (prop_mask & PIKA_CONTEXT_PROP_MASK_EXPAND)
|
||||
{
|
||||
for (i = 0; i < G_N_ELEMENTS (expand_props); i++)
|
||||
if (! strcmp (prop_name, expand_props[i]))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1288,6 +1370,12 @@ pika_paint_options_copy_props (PikaPaintOptions *src,
|
||||
names[n_props++] = gradient_props[i];
|
||||
}
|
||||
|
||||
if (prop_mask & PIKA_CONTEXT_PROP_MASK_EXPAND)
|
||||
{
|
||||
for (i = 0; i < G_N_ELEMENTS (expand_props); i++)
|
||||
names[n_props++] = expand_props[i];
|
||||
}
|
||||
|
||||
if (n_props > 0)
|
||||
{
|
||||
g_object_getv (G_OBJECT (src), n_props, names, values);
|
||||
|
@ -109,6 +109,11 @@ struct _PikaPaintOptions
|
||||
|
||||
gboolean hard;
|
||||
|
||||
gboolean expand_use;
|
||||
gdouble expand_amount;
|
||||
PikaFillType expand_fill_type;
|
||||
PikaAddMaskType expand_mask_fill_type;
|
||||
|
||||
PikaJitterOptions *jitter_options;
|
||||
|
||||
gboolean dynamics_enabled;
|
||||
|
@ -406,6 +406,7 @@ pika_smudge_motion (PikaPaintCore *paint_core,
|
||||
coords.x -= off_x;
|
||||
coords.y -= off_y;
|
||||
pika_symmetry_set_origin (sym, drawable, &coords);
|
||||
paint_core->sym = sym;
|
||||
|
||||
opacity = pika_dynamics_get_linear_value (dynamics,
|
||||
PIKA_DYNAMICS_OUTPUT_OPACITY,
|
||||
|
@ -347,6 +347,7 @@ pika_source_core_motion (PikaSourceCore *source_core,
|
||||
coords.x -= off_x;
|
||||
coords.y -= off_y;
|
||||
pika_symmetry_set_origin (sym, drawable, &coords);
|
||||
paint_core->sym = sym;
|
||||
|
||||
/* Some settings are based on the original stroke. */
|
||||
opacity = pika_dynamics_get_linear_value (dynamics,
|
||||
|
Reference in New Issue
Block a user