mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
Minor bugfix: Handle empty patterns
Per Wormnest, we should check if there is an active pattern before trying to fill with it. If there's no pattern, we'll fall back to drawing with the selected foreground color. Also, this patch connects the modified variable as an object property.
This commit is contained in:
parent
3c63d0a6b0
commit
357f94866b
1 changed files with 55 additions and 3 deletions
|
@ -52,7 +52,8 @@
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_VECTOR_LAYER_OPTIONS
|
||||
PROP_VECTOR_LAYER_OPTIONS,
|
||||
PROP_MODIFIED
|
||||
};
|
||||
|
||||
|
||||
|
@ -76,6 +77,13 @@ static void gimp_vector_layer_set_buffer (GimpDrawable *dra
|
|||
const gchar *undo_desc,
|
||||
GeglBuffer *buffer,
|
||||
const GeglRectangle *bounds);
|
||||
static void gimp_vector_layer_push_undo (GimpDrawable *drawable,
|
||||
const gchar *undo_desc,
|
||||
GeglBuffer *buffer,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
static gint64 gimp_vector_layer_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
|
@ -139,6 +147,7 @@ gimp_vector_layer_class_init (GimpVectorLayerClass *klass)
|
|||
GimpLayerClass *layer_class = GIMP_LAYER_CLASS (klass);
|
||||
|
||||
drawable_class->set_buffer = gimp_vector_layer_set_buffer;
|
||||
drawable_class->push_undo = gimp_vector_layer_push_undo;
|
||||
|
||||
object_class->finalize = gimp_vector_layer_finalize;
|
||||
object_class->set_property = gimp_vector_layer_set_property;
|
||||
|
@ -169,6 +178,12 @@ gimp_vector_layer_class_init (GimpVectorLayerClass *klass)
|
|||
"vector-layer-options", NULL, NULL,
|
||||
GIMP_TYPE_VECTOR_LAYER_OPTIONS,
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_MODIFIED,
|
||||
"modified",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -213,6 +228,9 @@ gimp_vector_layer_get_property (GObject *object,
|
|||
case PROP_VECTOR_LAYER_OPTIONS:
|
||||
g_value_set_object (value, vector_layer->options);
|
||||
break;
|
||||
case PROP_MODIFIED:
|
||||
g_value_set_boolean (value, vector_layer->modified);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -259,6 +277,9 @@ gimp_vector_layer_set_property (GObject *object,
|
|||
|
||||
}
|
||||
break;
|
||||
case PROP_MODIFIED:
|
||||
vector_layer->modified = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -315,6 +336,35 @@ gimp_vector_layer_set_buffer (GimpDrawable *drawable,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_vector_layer_push_undo (GimpDrawable *drawable,
|
||||
const gchar *undo_desc,
|
||||
GeglBuffer *buffer,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GimpVectorLayer *layer = GIMP_VECTOR_LAYER (drawable);
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
|
||||
|
||||
if (! layer->modified)
|
||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_DRAWABLE, undo_desc);
|
||||
|
||||
GIMP_DRAWABLE_CLASS (parent_class)->push_undo (drawable, undo_desc,
|
||||
buffer,
|
||||
x, y, width, height);
|
||||
|
||||
if (! layer->modified)
|
||||
{
|
||||
gimp_image_undo_push_vector_layer_modified (image, NULL, layer);
|
||||
|
||||
g_object_set (drawable, "modified", TRUE, NULL);
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
}
|
||||
}
|
||||
|
||||
static gint64
|
||||
gimp_vector_layer_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size)
|
||||
|
@ -605,7 +655,8 @@ gimp_vector_layer_render_path (GimpVectorLayer *layer,
|
|||
|
||||
/* Convert from custom to standard styles */
|
||||
style = gimp_fill_options_get_custom_style (layer->options->fill_options);
|
||||
if (style == GIMP_CUSTOM_STYLE_SOLID_COLOR)
|
||||
if (style == GIMP_CUSTOM_STYLE_SOLID_COLOR ||
|
||||
! gimp_context_get_pattern (GIMP_CONTEXT (layer->options->fill_options)))
|
||||
gimp_fill_options_set_style (layer->options->fill_options,
|
||||
GIMP_FILL_STYLE_FG_COLOR);
|
||||
else
|
||||
|
@ -614,7 +665,8 @@ gimp_vector_layer_render_path (GimpVectorLayer *layer,
|
|||
|
||||
style =
|
||||
gimp_fill_options_get_custom_style (GIMP_FILL_OPTIONS (layer->options->stroke_options));
|
||||
if (style == GIMP_CUSTOM_STYLE_SOLID_COLOR)
|
||||
if (style == GIMP_CUSTOM_STYLE_SOLID_COLOR ||
|
||||
! gimp_context_get_pattern (GIMP_CONTEXT (layer->options->stroke_options)))
|
||||
gimp_fill_options_set_style (GIMP_FILL_OPTIONS (layer->options->stroke_options),
|
||||
GIMP_FILL_STYLE_FG_COLOR);
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue