diff --git a/app/paint/gimpmybrushcore.c b/app/paint/gimpmybrushcore.c index a833176e7d..ca8fe65191 100644 --- a/app/paint/gimpmybrushcore.c +++ b/app/paint/gimpmybrushcore.c @@ -322,6 +322,35 @@ gimp_mybrush_core_motion (GimpPaintCore *paint_core, MyPaintBrush *brush = iter->data; GimpCoords coords = *(gimp_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 = gimp_paint_core_expand_drawable (paint_core, drawable, paint_options, + x1, x2, y1, y2, + &offset_change_x, &offset_change_y); + + gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); + if (expanded) + gimp_mypaint_surface_set_buffer (mybrush->private->surface, gimp_drawable_get_buffer (drawable), + off_x, off_y); + + gimp_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) + gimp_mypaint_surface_set_offset (mybrush->private->surface, + off_x_surf + offset_change_x, + off_y_surf + offset_change_y); mypaint_brush_stroke_to (brush, (MyPaintSurface *) mybrush->private->surface, diff --git a/app/paint/gimpmybrushsurface.c b/app/paint/gimpmybrushsurface.c index 436c77ced2..7e6316b3b0 100644 --- a/app/paint/gimpmybrushsurface.c +++ b/app/paint/gimpmybrushsurface.c @@ -34,13 +34,15 @@ struct _GimpMybrushSurface { - MyPaintSurface surface; - GeglBuffer *buffer; - GeglBuffer *paint_mask; - gint paint_mask_x; - gint paint_mask_y; - GeglRectangle dirty; - GimpComponentMask 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; + GimpComponentMask component_mask; GimpMybrushOptions *options; }; @@ -378,6 +380,8 @@ gimp_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)); @@ -557,5 +561,40 @@ gimp_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 +gimp_mypaint_surface_set_buffer (GimpMybrushSurface *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 +gimp_mypaint_surface_set_offset (GimpMybrushSurface *surface, + gint off_x, + gint off_y) +{ + surface->off_x = off_x; + surface->off_y = off_y; +} + +void +gimp_mypaint_surface_get_offset (GimpMybrushSurface *surface, + gint *off_x, + gint *off_y) +{ + *off_x = surface->off_x; + *off_y = surface->off_y; +} diff --git a/app/paint/gimpmybrushsurface.h b/app/paint/gimpmybrushsurface.h index 71bc0baa22..7513aa27ac 100644 --- a/app/paint/gimpmybrushsurface.h +++ b/app/paint/gimpmybrushsurface.h @@ -29,5 +29,18 @@ gimp_mypaint_surface_new (GeglBuffer *buffer, gint paint_mask_y, GimpMybrushOptions *options); +void +gimp_mypaint_surface_set_buffer (GimpMybrushSurface *surface, + GeglBuffer *buffer, + gint paint_mask_x, + gint paint_mask_y); +void +gimp_mypaint_surface_set_offset (GimpMybrushSurface *surface, + gint off_x, + gint off_y); +void +gimp_mypaint_surface_get_offset (GimpMybrushSurface *surface, + gint *off_x, + gint *off_y); #endif /* __GIMP_MYBRUSH_SURFACE_H__ */ diff --git a/app/tools/gimpmybrushoptions-gui.c b/app/tools/gimpmybrushoptions-gui.c index a2f927f920..9fdea5c197 100644 --- a/app/tools/gimpmybrushoptions-gui.c +++ b/app/tools/gimpmybrushoptions-gui.c @@ -48,6 +48,7 @@ gimp_mybrush_options_gui (GimpToolOptions *tool_options) GtkWidget *vbox = gimp_paint_options_gui (tool_options); GtkWidget *button; GtkWidget *scale; + GtkWidget *frame; /* the brush */ button = gimp_prop_mybrush_box_new (NULL, GIMP_CONTEXT (tool_options), @@ -78,5 +79,17 @@ gimp_mybrush_options_gui (GimpToolOptions *tool_options) 0.1, 1.0, 2); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); + /* Extend layer options */ + scale = gimp_prop_spin_scale_new (config, "expand-amount", + 1, 10, 2); + gimp_spin_scale_set_constrain_drag (GIMP_SPIN_SCALE (scale), TRUE); + gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0); + gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), 1.0); + + frame = gimp_prop_expanding_frame_new (config, "expand-use", NULL, + scale, NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + return vbox; }