forked from bartvdbraak/blender
ensure grease pencil layer names are unique when set through rna.
This commit is contained in:
parent
49b1a319c4
commit
03c72a5ba0
@ -185,7 +185,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd)
|
|||||||
|
|
||||||
/* auto-name */
|
/* auto-name */
|
||||||
strcpy(gpl->info, "GP_Layer");
|
strcpy(gpl->info, "GP_Layer");
|
||||||
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), sizeof(gpl->info));
|
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
|
||||||
|
|
||||||
/* make this one the active one */
|
/* make this one the active one */
|
||||||
gpencil_layer_setactive(gpd, gpl);
|
gpencil_layer_setactive(gpd, gpl);
|
||||||
|
@ -99,7 +99,8 @@ typedef struct bGPDlayer {
|
|||||||
|
|
||||||
float color[4]; /* color that should be used to draw all the strokes in this layer */
|
float color[4]; /* color that should be used to draw all the strokes in this layer */
|
||||||
|
|
||||||
char info[128]; /* optional reference info about this layer (i.e. "director's comments, 12/3") */
|
char info[128]; /* optional reference info about this layer (i.e. "director's comments, 12/3")
|
||||||
|
* this is used for the name of the layer too and kept unique. */
|
||||||
} bGPDlayer;
|
} bGPDlayer;
|
||||||
|
|
||||||
/* bGPDlayer->flag */
|
/* bGPDlayer->flag */
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
|
|
||||||
#ifdef RNA_RUNTIME
|
#ifdef RNA_RUNTIME
|
||||||
|
|
||||||
|
#include "BLI_path_util.h"
|
||||||
|
|
||||||
static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
|
static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
|
||||||
{
|
{
|
||||||
bGPDlayer *gpl= (bGPDlayer *)ptr->data;
|
bGPDlayer *gpl= (bGPDlayer *)ptr->data;
|
||||||
@ -90,6 +92,17 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
|
||||||
|
{
|
||||||
|
bGPdata *gpd= ptr->id.data;
|
||||||
|
bGPDlayer *gpl= ptr->data;
|
||||||
|
|
||||||
|
/* copy the new name into the name slot */
|
||||||
|
BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info));
|
||||||
|
|
||||||
|
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
|
static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
|
||||||
@ -176,6 +189,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
|
|||||||
/* Name */
|
/* Name */
|
||||||
prop= RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
|
prop= RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
|
||||||
RNA_def_property_ui_text(prop, "Info", "Layer name");
|
RNA_def_property_ui_text(prop, "Info", "Layer name");
|
||||||
|
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_info_set");
|
||||||
RNA_def_struct_name_property(srna, prop);
|
RNA_def_struct_name_property(srna, prop);
|
||||||
|
|
||||||
/* Frames */
|
/* Frames */
|
||||||
|
Loading…
Reference in New Issue
Block a user