Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_gpencil.c
| Context not available. | |||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_brush_types.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Context not available. | |||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| #ifndef RNA_RUNTIME | |||||
| static EnumPropertyItem rna_enum_gpencil_xraymodes_items[] = { | |||||
| { GP_XRAY_FRONT, "FRONT", 0, "Front", "Draw all strokes in front" }, | |||||
| { GP_XRAY_3DSPACE, "3DSPACE", 0, "3DSpace", "Draw strokes relative to other objects in 3D space" }, | |||||
| { GP_XRAY_BACK, "BACK", 0, "Back", "Draw all strokes on back" }, | |||||
| { 0, NULL, 0, NULL, NULL } | |||||
| }; | |||||
| static EnumPropertyItem rna_enum_gpencil_onion_modes_items[] = { | |||||
| { GP_ONION_MODE_ABSOLUTE, "ABSOLUTE", 0, "Frames", "Frames in absolute range of scene frame number" }, | |||||
| { GP_ONION_MODE_RELATIVE, "RELATIVE", 0, "Keyframes", "Frames in relative range of grease pencil keyframes" }, | |||||
| { GP_ONION_MODE_SELECTED, "SELECTED", 0, "Selected", "Only Selected Frames" }, | |||||
| { 0, NULL, 0, NULL, NULL } | |||||
| }; | |||||
| #endif | |||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_ghash.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| Context not available. | |||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "DEG_depsgraph.h" | |||||
| static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) | |||||
| static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) | |||||
| { | { | ||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | |||||
| DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); | |||||
| WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); | WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); | ||||
| } | } | ||||
| static void rna_GPencil_editmode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) | static void rna_GPencil_editmode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) | ||||
| { | { | ||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | |||||
| BKE_gpencil_batch_cache_dirty(gpd); | |||||
| /* Notify all places where GPencil data lives that the editing state is different */ | /* Notify all places where GPencil data lives that the editing state is different */ | ||||
| WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); | WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); | ||||
| WM_main_add_notifier(NC_SCENE | ND_MODE | NC_MOVIECLIP, NULL); | WM_main_add_notifier(NC_SCENE | ND_MODE | NC_MOVIECLIP, NULL); | ||||
| } | } | ||||
| static void rna_GPencil_onion_skinning_update(Main *bmain, Scene *scene, PointerRNA *ptr) | static void UNUSED_FUNCTION(rna_GPencil_onion_skinning_update)(Main *bmain, Scene *scene, PointerRNA *ptr) | ||||
| { | { | ||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | bGPdata *gpd = (bGPdata *)ptr->id.data; | ||||
| bGPDlayer *gpl; | bGPDlayer *gpl; | ||||
| Context not available. | |||||
| * stays in sync with the status of the actual layers | * stays in sync with the status of the actual layers | ||||
| */ | */ | ||||
| for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| if (gpl->flag & GP_LAYER_ONIONSKIN) { | if (gpl->onion_flag & GP_LAYER_ONIONSKIN) { | ||||
| enabled = true; | enabled = true; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| rna_GPencil_update(bmain, scene, ptr); | rna_GPencil_update(bmain, scene, ptr); | ||||
| } | } | ||||
| static void rna_GPencil_stroke_colorname_update(Main *bmain, Scene *scene, PointerRNA *ptr) | static char *rna_GPencilPaletteSlot_path(PointerRNA *ptr) | ||||
| { | { | ||||
| bGPDstroke *gps = (bGPDstroke *)ptr->data; | bGPdata *gpd = (bGPdata *)ptr->id.data; | ||||
| gps->flag |= GP_STROKE_RECALC_COLOR; | int index = BLI_findindex(&gpd->palette_slots, ptr->data); | ||||
| gps->palcolor = NULL; | |||||
| return BLI_sprintfN("palette_slots[%d]", index); | |||||
| } | |||||
| /* Now do standard updates... */ | static int rna_GPencilPaletteSlot_name_length(PointerRNA *ptr) | ||||
| rna_GPencil_update(bmain, scene, ptr); | { | ||||
| bGPDpaletteref *gpref = ptr->data; | |||||
| if (gpref->palette) | |||||
| return strlen(gpref->palette->id.name + 2); | |||||
| return 0; | |||||
| } | |||||
| static void rna_GPencilPaletteSlot_name_get(PointerRNA *ptr, char *str) | |||||
| { | |||||
| bGPDpaletteref *gpref = ptr->data; | |||||
| if (gpref->palette) | |||||
| strcpy(str, gpref->palette->id.name + 2); | |||||
| else | |||||
| str[0] = '\0'; | |||||
| } | |||||
| static void rna_GPencilPaletteSlot_palette_set(PointerRNA *ptr, PointerRNA value) | |||||
| { | |||||
| bGPdata *gpd = ptr->id.data; | |||||
| bGPDpaletteref *palslot = ptr->data; | |||||
| Palette *palette = value.data; | |||||
| BKE_gpencil_paletteslot_set_palette(gpd, palslot, palette); | |||||
| } | |||||
| static void rna_GPencil_active_palette_index_range(PointerRNA *ptr, int *min, int *max, | |||||
| int *UNUSED(softmin), int *UNUSED(softmax)) | |||||
| { | |||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | |||||
| *min = 0; | |||||
| *max = BLI_listbase_count(&gpd->palette_slots) - 1; | |||||
| } | |||||
| static PointerRNA rna_GPencil_active_palette_slot_get(PointerRNA *ptr) | |||||
| { | |||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | |||||
| bGPDpaletteref *palslot = BKE_gpencil_paletteslot_get_active(gpd); | |||||
| return rna_pointer_inherit_refine(ptr, &RNA_GPencilPaletteSlot, palslot); | |||||
| } | |||||
| static void rna_GPencil_active_palette_slot_set(PointerRNA *ptr, PointerRNA value) | |||||
| { | |||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | |||||
| bGPDpaletteref *palslot = value.data; | |||||
| int index = BLI_findindex(&gpd->palette_slots, palslot); | |||||
| if (index >= 0) { | |||||
| gpd->active_palette_slot = index; | |||||
| } | |||||
| } | } | ||||
| static char *rna_GPencilLayer_path(PointerRNA *ptr) | static char *rna_GPencilLayer_path(PointerRNA *ptr) | ||||
| { | { | ||||
| bGPDlayer *gpl = (bGPDlayer *)ptr->data; | bGPDlayer *gpl = (bGPDlayer *)ptr->data; | ||||
| Context not available. | |||||
| return PROP_EDITABLE; | return PROP_EDITABLE; | ||||
| } | } | ||||
| static void rna_GPencilLayer_line_width_range(PointerRNA *ptr, int *min, int *max, | static void rna_GPencilLayer_line_width_range(PointerRNA *UNUSED(ptr), int *min, int *max, | ||||
| int *softmin, int *softmax) | int *softmin, int *softmax) | ||||
| { | { | ||||
| bGPDlayer *gpl = ptr->data; | *min = -300; | ||||
| *max = 300; | |||||
| /* The restrictions on max width here are due to OpenGL on Windows not supporting | |||||
| * any widths greater than 10 (for driver-drawn) strokes/points. | |||||
| * | |||||
| * Although most of our 2D strokes also don't suffer from this restriction, | |||||
| * it's relatively hard to test for that. So, for now, only volumetric strokes | |||||
| * get to be larger... | |||||
| */ | |||||
| /* From GP v2 this value is used to increase or decrease the thickness of the stroke */ | *softmin = -100; | ||||
| if (gpl->flag & GP_LAYER_VOLUMETRIC) { | *softmax = 100; | ||||
| *min = -300; | |||||
| *max = 300; | |||||
| *softmin = -100; | |||||
| *softmax = 100; | |||||
| } | |||||
| else { | |||||
| *min = -10; | |||||
| *max = 10; | |||||
| *softmin = -10; | |||||
| *softmax = 10; | |||||
| } | |||||
| } | } | ||||
| /* set parent */ | /* set parent */ | ||||
| Context not available. | |||||
| set_parent(gpl, par, gpl->partype, gpl->parsubstr); | set_parent(gpl, par, gpl->partype, gpl->parsubstr); | ||||
| } | } | ||||
| else { | else { | ||||
| /* keep strokes in the same place, so apply current transformation */ | |||||
| if (gpl->parent != NULL) { | |||||
| bGPDspoint *pt; | |||||
| int i; | |||||
| float diff_mat[4][4]; | |||||
| /* calculate difference matrix */ | |||||
| ED_gpencil_parent_location(gpl, diff_mat); | |||||
| for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { | |||||
| for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { | |||||
| for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { | |||||
| mul_m4_v3(diff_mat, &pt->x); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| /* clear parent */ | /* clear parent */ | ||||
| gpl->parent = NULL; | gpl->parent = NULL; | ||||
| } | } | ||||
| Context not available. | |||||
| BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info); | BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info); | ||||
| } | } | ||||
| static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value) | |||||
| { | |||||
| bGPdata *gpd = ptr->id.data; | |||||
| bGPDlayer *gpl; | |||||
| /* set new value */ | |||||
| if (value) { | |||||
| /* enable on active layer (it's the one that's most likely to be of interest right now) */ | |||||
| gpl = BKE_gpencil_layer_getactive(gpd); | |||||
| if (gpl) { | |||||
| gpl->flag |= GP_LAYER_ONIONSKIN; | |||||
| } | |||||
| gpd->flag |= GP_DATA_SHOW_ONIONSKINS; | |||||
| } | |||||
| else { | |||||
| /* disable on all layers - allowa quickly turning them all off, without having to check */ | |||||
| for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | |||||
| gpl->flag &= ~GP_LAYER_ONIONSKIN; | |||||
| } | |||||
| gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS; | |||||
| } | |||||
| } | |||||
| static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd, const bGPDspoint *pt, bGPDlayer **r_gpl, bGPDframe **r_gpf) | static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd, const bGPDspoint *pt, bGPDlayer **r_gpl, bGPDframe **r_gpf) | ||||
| { | { | ||||
| bGPDlayer *gpl; | bGPDlayer *gpl; | ||||
| Context not available. | |||||
| bGPDspoint *pt = stroke->points + (stroke->totpoints + i); | bGPDspoint *pt = stroke->points + (stroke->totpoints + i); | ||||
| pt->pressure = pressure; | pt->pressure = pressure; | ||||
| pt->strength = strength; | pt->strength = strength; | ||||
| pt->totweight = 0; | |||||
| pt->weights = NULL; | |||||
| } | } | ||||
| stroke->totpoints += count; | stroke->totpoints += count; | ||||
| Context not available. | |||||
| if (index < stroke->totpoints) | if (index < stroke->totpoints) | ||||
| memcpy(&stroke->points[index], &pt_tmp[index + 1], sizeof(bGPDspoint) * (stroke->totpoints - index)); | memcpy(&stroke->points[index], &pt_tmp[index + 1], sizeof(bGPDspoint) * (stroke->totpoints - index)); | ||||
| // TODO: vgroup | |||||
| /* free temp buffer */ | /* free temp buffer */ | ||||
| MEM_freeN(pt_tmp); | MEM_freeN(pt_tmp); | ||||
| Context not available. | |||||
| WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | ||||
| } | } | ||||
| /* Palettes */ | /* info functions */ | ||||
| static bGPDpalette *rna_GPencil_palette_new(bGPdata *gpd, const char *name, int setactive) | static int rna_GPencil_info_total_layers(PointerRNA *ptr) | ||||
| { | { | ||||
| bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, name, setactive != 0); | bGPdata *gpd = (bGPdata *)ptr->id.data; | ||||
| WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | |||||
| return palette; | return BLI_listbase_count(&gpd->layers); | ||||
| } | } | ||||
| static void rna_GPencil_palette_remove(bGPdata *gpd, ReportList *reports, PointerRNA *palette_ptr) | static int rna_GPencil_info_total_frames(PointerRNA *ptr) | ||||
| { | { | ||||
| bGPDpalette *palette = palette_ptr->data; | bGPdata *gpd = (bGPdata *)ptr->id.data; | ||||
| if (BLI_findindex(&gpd->palettes, palette) == -1) { | int tot = 0; | ||||
| BKE_report(reports, RPT_ERROR, "Palette not found in grease pencil data"); | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| return; | tot += BLI_listbase_count(&gpl->frames); | ||||
| } | } | ||||
| BKE_gpencil_palette_delete(gpd, palette); | return tot; | ||||
| RNA_POINTER_INVALIDATE(palette_ptr); | |||||
| WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | |||||
| } | } | ||||
| static PointerRNA rna_GPencil_active_palette_get(PointerRNA *ptr) | static int rna_GPencil_info_total_strokes(PointerRNA *ptr) | ||||
| { | { | ||||
| bGPdata *gpd = ptr->id.data; | bGPdata *gpd = (bGPdata *)ptr->id.data; | ||||
| int tot = 0; | |||||
| if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| bGPDpalette *palette; | for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { | ||||
| tot += BLI_listbase_count(&gpf->strokes); | |||||
| for (palette = gpd->palettes.first; palette; palette = palette->next) { | |||||
| if (palette->flag & PL_PALETTE_ACTIVE) { | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (palette) { | |||||
| return rna_pointer_inherit_refine(ptr, &RNA_GPencilPalette, palette); | |||||
| } | } | ||||
| } | } | ||||
| return rna_pointer_inherit_refine(ptr, NULL, NULL); | return tot; | ||||
| } | } | ||||
| static void rna_GPencil_active_palette_set(PointerRNA *ptr, PointerRNA value) | static int rna_GPencil_info_total_points(PointerRNA *ptr) | ||||
| { | { | ||||
| bGPdata *gpd = ptr->id.data; | bGPdata *gpd = (bGPdata *)ptr->id.data; | ||||
| int tot = 0; | |||||
| if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| bGPDpalette *palette; | for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { | ||||
| for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { | |||||
| for (palette = gpd->palettes.first; palette; palette = palette->next) { | tot += gps->totpoints; | ||||
| if (palette == value.data) { | |||||
| palette->flag |= PL_PALETTE_ACTIVE; | |||||
| } | |||||
| else { | |||||
| palette->flag &= ~PL_PALETTE_ACTIVE; | |||||
| } | } | ||||
| } | } | ||||
| /* force color recalc */ | |||||
| BKE_gpencil_palette_change_strokes(gpd); | |||||
| WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); | |||||
| } | } | ||||
| } | |||||
| static int rna_GPencilPalette_index_get(PointerRNA *ptr) | |||||
| { | |||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | |||||
| bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); | |||||
| return BLI_findindex(&gpd->palettes, palette); | |||||
| } | |||||
| static void rna_GPencilPalette_index_set(PointerRNA *ptr, int value) | return tot; | ||||
| { | |||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | |||||
| bGPDpalette *palette = BLI_findlink(&gpd->palettes, value); | |||||
| BKE_gpencil_palette_setactive(gpd, palette); | |||||
| WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | |||||
| } | } | ||||
| static void rna_GPencilPalette_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) | static int rna_GPencil_info_total_palettes(PointerRNA *ptr) | ||||
| { | { | ||||
| bGPdata *gpd = (bGPdata *)ptr->id.data; | bGPdata *gpd = (bGPdata *)ptr->id.data; | ||||
| GHash *data = BLI_ghash_str_new("GP count palettes"); | |||||
| *min = 0; | int tot = 0; | ||||
| *max = max_ii(0, BLI_listbase_count(&gpd->palettes) - 1); | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { | |||||
| *softmin = *min; | for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { | ||||
| *softmax = *max; | Palette *palette = (Palette *)BLI_ghash_lookup(data, gps->palette->id.name); | ||||
| } | if (palette == NULL) { | ||||
| tot += 1; | |||||
| /* Palette colors */ | BLI_ghash_insert(data, gps->palette->id.name, gps->palette); | ||||
| static bGPDpalettecolor *rna_GPencilPalette_color_new(bGPDpalette *palette) | } | ||||
| { | } | ||||
| bGPDpalettecolor *color = BKE_gpencil_palettecolor_addnew(palette, DATA_("Color"), true); | |||||
| return color; | |||||
| } | |||||
| static void rna_GPencilPalette_color_remove(bGPDpalette *palette, ReportList *reports, PointerRNA *color_ptr) | |||||
| { | |||||
| bGPDpalettecolor *color = color_ptr->data; | |||||
| if (BLI_findindex(&palette->colors, color) == -1) { | |||||
| BKE_reportf(reports, RPT_ERROR, "Palette '%s' does not contain color given", palette->info + 2); | |||||
| return; | |||||
| } | |||||
| BKE_gpencil_palettecolor_delete(palette, color); | |||||
| RNA_POINTER_INVALIDATE(color_ptr); | |||||
| WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | |||||
| } | |||||
| static PointerRNA rna_GPencilPalette_active_color_get(PointerRNA *ptr) | |||||
| { | |||||
| bGPDpalette *palette = (bGPDpalette *)ptr->data; | |||||
| bGPDpalettecolor *color; | |||||
| for (color = palette->colors.first; color; color = color->next) { | |||||
| if (color->flag & PC_COLOR_ACTIVE) { | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| BLI_ghash_free(data, NULL, NULL); | |||||
| data = NULL; | |||||
| if (color) { | return tot; | ||||
| return rna_pointer_inherit_refine(ptr, &RNA_GPencilPaletteColor, color); | |||||
| } | |||||
| return rna_pointer_inherit_refine(ptr, NULL, NULL); | |||||
| } | } | ||||
| static void rna_GPencilPalette_active_color_set(PointerRNA *ptr, PointerRNA value) | #else | ||||
| { | |||||
| bGPDpalette *palette = (bGPDpalette *)ptr->data; | |||||
| bGPDpalettecolor *color = value.data; | |||||
| BKE_gpencil_palettecolor_setactive(palette, color); | |||||
| } | |||||
| static void rna_GPencilPalette_info_set(PointerRNA *ptr, const char *value) | |||||
| { | |||||
| bGPdata *gpd = ptr->id.data; | |||||
| bGPDpalette *palette = ptr->data; | |||||
| char oldname[64] = ""; | |||||
| BLI_strncpy(oldname, palette->info, sizeof(oldname)); | |||||
| /* copy the new name into the name slot */ | |||||
| BLI_strncpy_utf8(palette->info, value, sizeof(palette->info)); | |||||
| BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), '.', offsetof(bGPDpalette, info), | |||||
| sizeof(palette->info)); | |||||
| /* now fix animation paths */ | |||||
| BKE_animdata_fix_paths_rename_all(&gpd->id, "palettes", oldname, palette->info); | |||||
| } | |||||
| static char *rna_GPencilPalette_path(PointerRNA *ptr) | static void rna_def_gpencil_palette_slot(BlenderRNA *brna) | ||||
| { | { | ||||
| bGPDpalette *palette = ptr->data; | StructRNA *srna; | ||||
| char name_esc[sizeof(palette->info) * 2]; | PropertyRNA *prop; | ||||
| BLI_strescape(name_esc, palette->info, sizeof(name_esc)); | |||||
| return BLI_sprintfN("palettes[\"%s\"]", name_esc); | srna = RNA_def_struct(brna, "GPencilPaletteSlot", NULL); | ||||
| } | RNA_def_struct_sdna(srna, "bGPDpaletteref"); | ||||
| RNA_def_struct_path_func(srna, "rna_GPencilPaletteSlot_path"); | |||||
| static char *rna_GPencilPalette_color_path(PointerRNA *ptr) | RNA_def_struct_ui_text(srna, "Grease Pencil Palette Slot", "Reference for a Palette used in Grease Pencil datablock"); | ||||
| { | RNA_def_struct_ui_icon(srna, ICON_COLOR); | ||||
| bGPdata *gpd = ptr->id.data; | |||||
| bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); | |||||
| bGPDpalettecolor *palcolor = ptr->data; | |||||
| char name_palette[sizeof(palette->info) * 2]; | |||||
| char name_color[sizeof(palcolor->info) * 2]; | |||||
| BLI_strescape(name_palette, palette->info, sizeof(name_palette)); | |||||
| BLI_strescape(name_color, palcolor->info, sizeof(name_color)); | |||||
| return BLI_sprintfN("palettes[\"%s\"].colors[\"%s\"]", name_palette, name_color); | |||||
| } | |||||
| static void rna_GPencilPaletteColor_info_set(PointerRNA *ptr, const char *value) | |||||
| { | |||||
| bGPdata *gpd = ptr->id.data; | |||||
| bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); | |||||
| bGPDpalettecolor *palcolor = ptr->data; | |||||
| char oldname[64] = ""; | prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | ||||
| BLI_strncpy(oldname, palcolor->info, sizeof(oldname)); | RNA_def_property_string_funcs(prop, "rna_GPencilPaletteSlot_name_get", "rna_GPencilPaletteSlot_name_length", NULL); | ||||
| RNA_def_property_ui_text(prop, "Name", "Palette slot name"); | |||||
| /* copy the new name into the name slot */ | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| BLI_strncpy_utf8(palcolor->info, value, sizeof(palcolor->info)); | RNA_def_struct_name_property(srna, prop); | ||||
| BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info), | |||||
| sizeof(palcolor->info)); | |||||
| /* rename all strokes */ | prop = RNA_def_property(srna, "palette", PROP_POINTER, PROP_NONE); | ||||
| BKE_gpencil_palettecolor_changename(gpd, oldname, palcolor->info); | RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); | ||||
| RNA_def_property_pointer_funcs(prop, | |||||
| /* now fix animation paths */ | NULL, | ||||
| BKE_animdata_fix_paths_rename_all(&gpd->id, "colors", oldname, palcolor->info); | "rna_GPencilPaletteSlot_palette_set", | ||||
| } | NULL, | ||||
| NULL /*"rna_GPencilPalette_id_poll"*/); | |||||
| static void rna_GPencilStrokeColor_info_set(PointerRNA *ptr, const char *value) | RNA_def_property_ui_text(prop, "Palette", "Palette data-block used by this palette slot"); | ||||
| { | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| bGPDstroke *gps = ptr->data; | |||||
| /* copy the new name into the name slot */ | |||||
| BLI_strncpy_utf8(gps->colorname, value, sizeof(gps->colorname)); | |||||
| } | } | ||||
| static void rna_def_gpencil_palette_slots_api(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| static int rna_GPencilPaletteColor_is_stroke_visible_get(PointerRNA *ptr) | |||||
| { | { | ||||
| bGPDpalettecolor *pcolor = (bGPDpalettecolor *)ptr->data; | StructRNA *srna; | ||||
| return (pcolor->color[3] > GPENCIL_ALPHA_OPACITY_THRESH); | //PropertyRNA *prop; | ||||
| } | |||||
| static int rna_GPencilPaletteColor_is_fill_visible_get(PointerRNA *ptr) | //FunctionRNA *func; | ||||
| { | //PropertyRNA *parm; | ||||
| bGPDpalettecolor *pcolor = (bGPDpalettecolor *)ptr->data; | |||||
| return (pcolor->fill[3] > GPENCIL_ALPHA_OPACITY_THRESH); | |||||
| } | |||||
| static int rna_GPencilPaletteColor_index_get(PointerRNA *ptr) | RNA_def_property_srna(cprop, "GreasePencilPaletteSlots"); | ||||
| { | srna = RNA_def_struct(brna, "GreasePencilPaletteSlots", NULL); | ||||
| bGPDpalette *palette = (bGPDpalette *)ptr->data; | RNA_def_struct_sdna(srna, "bGPdata"); | ||||
| bGPDpalettecolor *pcolor = BKE_gpencil_palettecolor_getactive(palette); | RNA_def_struct_ui_text(srna, "Grease Pencil Palette Slots", "Collection of grease pencil palette slots"); | ||||
| return BLI_findindex(&palette->colors, pcolor); | /* TODO: API methods... new/remove/active */ | ||||
| } | } | ||||
| static void rna_GPencilPaletteColor_index_set(PointerRNA *ptr, int value) | /* information of vertex groups by point */ | ||||
| static void rna_def_gpencil_point_weight(BlenderRNA *brna) | |||||
| { | { | ||||
| bGPDpalette *palette = (bGPDpalette *)ptr->data; | StructRNA *srna; | ||||
| bGPDpalettecolor *pcolor = BLI_findlink(&palette->colors, value); | PropertyRNA *prop; | ||||
| BKE_gpencil_palettecolor_setactive(palette, pcolor); | |||||
| } | |||||
| static void rna_GPencilPaletteColor_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) | srna = RNA_def_struct(brna, "GPencilPointWeight", NULL); | ||||
| { | RNA_def_struct_sdna(srna, "bGPDweight"); | ||||
| bGPDpalette *palette = (bGPDpalette *)ptr->data; | RNA_def_struct_ui_text(srna, "Grease Pencil Point Weight", "Data for point vertex groups"); | ||||
| *min = 0; | prop = RNA_def_property(srna, "vertex_group", PROP_INT, PROP_NONE); | ||||
| *max = max_ii(0, BLI_listbase_count(&palette->colors) - 1); | RNA_def_property_int_sdna(prop, NULL, "index"); | ||||
| RNA_def_property_ui_text(prop, "Index", "Index of the vertex group"); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| *softmin = *min; | prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); | ||||
| *softmax = *max; | RNA_def_property_float_sdna(prop, NULL, "factor"); | ||||
| RNA_def_property_range(prop, 0.0f, 1.0f); | |||||
| RNA_def_property_ui_text(prop, "Weight", "Factor of weight for this vertex group"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | |||||
| } | } | ||||
| #else | |||||
| static void rna_def_gpencil_stroke_point(BlenderRNA *brna) | static void rna_def_gpencil_stroke_point(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| Context not available. | |||||
| RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_stroke_point_select_set"); | RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_stroke_point_select_set"); | ||||
| RNA_def_property_ui_text(prop, "Select", "Point is selected for viewport editing"); | RNA_def_property_ui_text(prop, "Select", "Point is selected for viewport editing"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Weights */ | |||||
| prop = RNA_def_property(srna, "weights", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_collection_sdna(prop, NULL, "weights", "totweight"); | |||||
| RNA_def_property_struct_type(prop, "GPencilPointWeight"); | |||||
| RNA_def_property_ui_text(prop, "Point Weights", "Information of Vertex Groups by point"); | |||||
| } | } | ||||
| static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop) | static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop) | ||||
| Context not available. | |||||
| srna = RNA_def_struct(brna, "GPencilTriangle", NULL); | srna = RNA_def_struct(brna, "GPencilTriangle", NULL); | ||||
| RNA_def_struct_sdna(srna, "bGPDtriangle"); | RNA_def_struct_sdna(srna, "bGPDtriangle"); | ||||
| RNA_def_struct_ui_text(srna, "Triangle", "Triangulation data for HQ fill"); | RNA_def_struct_ui_text(srna, "Triangle", "Triangulation data for Grease Pencil fills"); | ||||
| /* point v1 */ | /* point v1 */ | ||||
| prop = RNA_def_property(srna, "v1", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "v1", PROP_INT, PROP_NONE); | ||||
| Context not available. | |||||
| RNA_def_property_int_sdna(prop, NULL, "verts[2]"); | RNA_def_property_int_sdna(prop, NULL, "verts[2]"); | ||||
| RNA_def_property_ui_text(prop, "v3", "Third triangle vertex index"); | RNA_def_property_ui_text(prop, "v3", "Third triangle vertex index"); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| /* texture coord for point v1 */ | |||||
| prop = RNA_def_property(srna, "uv1", PROP_FLOAT, PROP_COORDS); | |||||
| RNA_def_property_float_sdna(prop, NULL, "uv[0]"); | |||||
| RNA_def_property_array(prop, 2); | |||||
| RNA_def_property_ui_text(prop, "uv1", "First triangle vertex texture coordinates"); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| /* texture coord for point v2 */ | |||||
| prop = RNA_def_property(srna, "uv2", PROP_FLOAT, PROP_COORDS); | |||||
| RNA_def_property_float_sdna(prop, NULL, "uv[1]"); | |||||
| RNA_def_property_array(prop, 2); | |||||
| RNA_def_property_ui_text(prop, "uv2", "Second triangle vertex texture coordinates"); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| /* texture coord for point v3 */ | |||||
| prop = RNA_def_property(srna, "uv3", PROP_FLOAT, PROP_COORDS); | |||||
| RNA_def_property_float_sdna(prop, NULL, "uv[2]"); | |||||
| RNA_def_property_array(prop, 2); | |||||
| RNA_def_property_ui_text(prop, "uv3", "Third triangle vertex texture coordinates"); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| } | } | ||||
| static void rna_def_gpencil_stroke(BlenderRNA *brna) | static void rna_def_gpencil_stroke(BlenderRNA *brna) | ||||
| Context not available. | |||||
| RNA_def_property_struct_type(prop, "GPencilTriangle"); | RNA_def_property_struct_type(prop, "GPencilTriangle"); | ||||
| RNA_def_property_ui_text(prop, "Triangles", "Triangulation data for HQ fill"); | RNA_def_property_ui_text(prop, "Triangles", "Triangulation data for HQ fill"); | ||||
| /* Palette */ | |||||
| prop = RNA_def_property(srna, "palette", PROP_POINTER, PROP_NONE); | |||||
| RNA_def_property_struct_type(prop, "Palette"); | |||||
| RNA_def_property_pointer_sdna(prop, NULL, "palette"); | |||||
| RNA_def_property_ui_text(prop, "Palette", "Palette that stroke's color comes from"); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| /* Color */ | /* Color */ | ||||
| prop = RNA_def_property(srna, "color", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "color", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "GPencilPaletteColor"); | RNA_def_property_struct_type(prop, "PaletteColor"); | ||||
| RNA_def_property_pointer_sdna(prop, NULL, "palcolor"); | RNA_def_property_pointer_sdna(prop, NULL, "palcolor"); | ||||
| RNA_def_property_ui_text(prop, "Palette Color", "Color from palette used in Stroke"); | RNA_def_property_ui_text(prop, "Palette Color", "Color from palette used in stroke"); | ||||
| RNA_def_property_update(prop, 0, "rna_GPencil_update"); | RNA_def_property_update(prop, 0, "rna_GPencil_update"); | ||||
| /* Settings */ | /* Settings */ | ||||
| prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); | RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); | ||||
| RNA_def_property_enum_items(prop, stroke_draw_mode_items); | RNA_def_property_enum_items(prop, stroke_draw_mode_items); | ||||
| RNA_def_property_ui_text(prop, "Draw Mode", ""); | RNA_def_property_ui_text(prop, "Draw Mode", "Coordinate space that stroke is in"); | ||||
| RNA_def_property_update(prop, 0, "rna_GPencil_update"); | RNA_def_property_update(prop, 0, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); | ||||
| Context not available. | |||||
| RNA_def_property_ui_text(prop, "Select", "Stroke is selected for viewport editing"); | RNA_def_property_ui_text(prop, "Select", "Stroke is selected for viewport editing"); | ||||
| RNA_def_property_update(prop, 0, "rna_GPencil_update"); | RNA_def_property_update(prop, 0, "rna_GPencil_update"); | ||||
| /* Color Name */ | |||||
| prop = RNA_def_property(srna, "colorname", PROP_STRING, PROP_NONE); | |||||
| RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilStrokeColor_info_set"); | |||||
| RNA_def_property_ui_text(prop, "Color Name", "Palette color name"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_colorname_update"); | |||||
| /* Cyclic: Draw a line from end to start point */ | /* Cyclic: Draw a line from end to start point */ | ||||
| prop = RNA_def_property(srna, "draw_cyclic", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "draw_cyclic", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_CYCLIC); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_CYCLIC); | ||||
| Context not available. | |||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| FunctionRNA *func; | FunctionRNA *func; | ||||
| static float onion_dft1[3] = { 0.145098f, 0.419608f, 0.137255f }; /* green */ | |||||
| static float onion_dft2[3] = { 0.125490f, 0.082353f, 0.529412f }; /* blue */ | |||||
| srna = RNA_def_struct(brna, "GPencilLayer", NULL); | srna = RNA_def_struct(brna, "GPencilLayer", NULL); | ||||
| RNA_def_struct_sdna(srna, "bGPDlayer"); | RNA_def_struct_sdna(srna, "bGPDlayer"); | ||||
| RNA_def_struct_ui_text(srna, "Grease Pencil Layer", "Collection of related sketches"); | RNA_def_struct_ui_text(srna, "Grease Pencil Layer", "Collection of related sketches"); | ||||
| Context not available. | |||||
| /* Line Thickness change */ | /* Line Thickness change */ | ||||
| prop = RNA_def_property(srna, "line_change", PROP_INT, PROP_PIXEL); | prop = RNA_def_property(srna, "line_change", PROP_INT, PROP_PIXEL); | ||||
| RNA_def_property_int_sdna(prop, NULL, "thickness"); | RNA_def_property_int_sdna(prop, NULL, "thickness"); | ||||
| //RNA_def_property_range(prop, 1, 10); /* 10 px limit comes from Windows OpenGL limits for natively-drawn strokes */ | |||||
| RNA_def_property_int_funcs(prop, NULL, NULL, "rna_GPencilLayer_line_width_range"); | RNA_def_property_int_funcs(prop, NULL, NULL, "rna_GPencilLayer_line_width_range"); | ||||
| RNA_def_property_ui_text(prop, "Thickness", "Thickness change to apply to current strokes (in pixels)"); | RNA_def_property_ui_text(prop, "Thickness", "Thickness change to apply to current strokes (in pixels)"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Onion-Skinning */ | /* Onion-Skinning */ | ||||
| prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ONIONSKIN); | RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_LAYER_ONIONSKIN); | ||||
| RNA_def_property_ui_text(prop, "Onion Skinning", "Ghost frames on either side of frame"); | RNA_def_property_ui_text(prop, "Onion Skinning", "Ghost frames on either side of frame"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_onion_skinning_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "gstep"); | RNA_def_property_int_sdna(prop, NULL, "gstep"); | ||||
| RNA_def_property_range(prop, -1, 120); | RNA_def_property_range(prop, 0, 120); | ||||
| RNA_def_property_int_default(prop, 1); | |||||
| RNA_def_property_ui_text(prop, "Frames Before", | RNA_def_property_ui_text(prop, "Frames Before", | ||||
| "Maximum number of frames to show before current frame " | "Maximum number of frames to show before current frame " | ||||
| "(0 = show only the previous sketch, -1 = don't show any frames before current)"); | "(0 = don't show any frames before current)"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "gstep_next"); | RNA_def_property_int_sdna(prop, NULL, "gstep_next"); | ||||
| RNA_def_property_range(prop, -1, 120); | RNA_def_property_range(prop, 0, 120); | ||||
| RNA_def_property_int_default(prop, 1); | |||||
| RNA_def_property_ui_text(prop, "Frames After", | RNA_def_property_ui_text(prop, "Frames After", | ||||
| "Maximum number of frames to show after current frame " | "Maximum number of frames to show after current frame " | ||||
| "(0 = show only the next sketch, -1 = don't show any frames after current)"); | "(0 = don't show any frames after current)"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL); | RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL); | ||||
| RNA_def_property_ui_text(prop, "Use Custom Ghost Colors", "Use custom colors for ghost frames"); | RNA_def_property_ui_text(prop, "Use Custom Ghost Colors", "Use custom colors for ghost frames"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "before_color", PROP_FLOAT, PROP_COLOR_GAMMA); | prop = RNA_def_property(srna, "before_color", PROP_FLOAT, PROP_COLOR_GAMMA); | ||||
| RNA_def_property_float_sdna(prop, NULL, "gcolor_prev"); | RNA_def_property_float_sdna(prop, NULL, "gcolor_prev"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_property_array(prop, 3); | ||||
| RNA_def_property_range(prop, 0.0f, 1.0f); | RNA_def_property_range(prop, 0.0f, 1.0f); | ||||
| RNA_def_property_float_array_default(prop, onion_dft1); | |||||
| RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame"); | RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "after_color", PROP_FLOAT, PROP_COLOR_GAMMA); | prop = RNA_def_property(srna, "after_color", PROP_FLOAT, PROP_COLOR_GAMMA); | ||||
| RNA_def_property_float_sdna(prop, NULL, "gcolor_next"); | RNA_def_property_float_sdna(prop, NULL, "gcolor_next"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_property_array(prop, 3); | ||||
| RNA_def_property_range(prop, 0.0f, 1.0f); | RNA_def_property_range(prop, 0.0f, 1.0f); | ||||
| RNA_def_property_float_array_default(prop, onion_dft2); | |||||
| RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame"); | RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "use_ghosts_always", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_ghosts_always", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_GHOST_ALWAYS); | RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_LAYER_GHOST_ALWAYS); | ||||
| RNA_def_property_ui_text(prop, "Always Show Ghosts", | RNA_def_property_ui_text(prop, "Always Show Ghosts", | ||||
| "Ghosts are shown in renders and animation playback. Useful for special effects (e.g. motion blur)"); | "Ghosts are shown in renders and animation playback. Useful for special effects (e.g. motion blur)"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | |||||
| prop = RNA_def_property(srna, "use_stroke_location", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_USE_LOCATION); | |||||
| RNA_def_property_ui_text(prop, "Use Stroke Location", | |||||
| "When draw new strokes in 3D view, use last stroke origin, as new stroke origin"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Flags */ | /* Flags */ | ||||
| prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); | ||||
| Context not available. | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_ui_text(prop, "Is Parented", "True when the layer parent object is set"); | RNA_def_property_ui_text(prop, "Is Parented", "True when the layer parent object is set"); | ||||
| /* onion modes */ | |||||
| prop = RNA_def_property(srna, "onion_mode", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "onion_mode"); | |||||
| RNA_def_property_enum_items(prop, rna_enum_gpencil_onion_modes_items); | |||||
| RNA_def_property_ui_text(prop, "Mode", "Mode to display frames"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | |||||
| prop = RNA_def_property(srna, "use_onion_fade", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_LAYER_ONION_FADE); | |||||
| RNA_def_property_ui_text(prop, "Fade", | |||||
| "Display onion keyframes with a fade in color transparency"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | |||||
| prop = RNA_def_property(srna, "override_onion", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_LAYER_ONION_OVERRIDE); | |||||
| RNA_def_property_ui_text(prop, "Override", | |||||
| "Override onion settings with layer settings"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | |||||
| prop = RNA_def_property(srna, "onion_factor", PROP_FLOAT, PROP_NONE); | |||||
| RNA_def_property_float_sdna(prop, NULL, "onion_factor"); | |||||
| RNA_def_property_float_default(prop, 0.5f); | |||||
| RNA_def_property_range(prop, 0.0, 1.0f); | |||||
| RNA_def_property_ui_text(prop, "Onion Opacity", "Change fade opacity of displayed onion frames"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | |||||
| /* Layers API */ | /* Layers API */ | ||||
| func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear"); | func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear"); | ||||
| RNA_def_function_ui_description(func, "Remove all the grease pencil layer data"); | RNA_def_function_ui_description(func, "Remove all the grease pencil layer data"); | ||||
campbellbarton: Call `show_constant_thickness` | |||||
| Context not available. | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); | ||||
| } | } | ||||
| static void rna_def_gpencil_palettecolor(BlenderRNA *brna) | static void rna_def_gpencil_data(BlenderRNA *brna) | ||||
| { | { | ||||
Not Done Inline ActionsShould be an RNA function, reading an attr should not do big lookups like this. For other counting attrs too. campbellbarton: Should be an RNA function, reading an attr should not do big lookups like this. For other… | |||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| FunctionRNA *func; | |||||
| srna = RNA_def_struct(brna, "GPencilPaletteColor", NULL); | static float default_1[4] = { 0.6f, 0.6f, 0.6f, 0.3f }; | ||||
| RNA_def_struct_sdna(srna, "bGPDpalettecolor"); | static float onion_dft1[3] = { 0.145098f, 0.419608f, 0.137255f }; /* green */ | ||||
| RNA_def_struct_ui_text(srna, "Grease Pencil Palette color", "Collection of related colors"); | static float onion_dft2[3] = { 0.125490f, 0.082353f, 0.529412f }; /* blue */ | ||||
| RNA_def_struct_path_func(srna, "rna_GPencilPalette_color_path"); | |||||
| /* Stroke Drawing Color */ | srna = RNA_def_struct(brna, "GreasePencil", "ID"); | ||||
| prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); | RNA_def_struct_sdna(srna, "bGPdata"); | ||||
| RNA_def_property_float_sdna(prop, NULL, "color"); | RNA_def_struct_ui_text(srna, "Grease Pencil", "Freehand annotation sketchbook"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_struct_ui_icon(srna, ICON_GREASEPENCIL); | ||||
| RNA_def_property_range(prop, 0.0f, 1.0f); | |||||
| RNA_def_property_ui_text(prop, "Color", "Color for strokes"); | /* Layers */ | ||||
| prop = RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_collection_sdna(prop, NULL, "layers", NULL); | |||||
| RNA_def_property_struct_type(prop, "GPencilLayer"); | |||||
| RNA_def_property_ui_text(prop, "Layers", ""); | |||||
| rna_def_gpencil_layers_api(brna, prop); | |||||
| /* Animation Data */ | |||||
| rna_def_animdata_common(srna); | |||||
| /* Palette Slots */ | |||||
| prop = RNA_def_property(srna, "palette_slots", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_collection_sdna(prop, NULL, "palette_slots", NULL); | |||||
| RNA_def_property_struct_type(prop, "GPencilPaletteSlot"); | |||||
| RNA_def_property_ui_text(prop, "Palette Slots", ""); | |||||
| rna_def_gpencil_palette_slots_api(brna, prop); | |||||
| prop = RNA_def_property(srna, "active_palette_index", PROP_INT, PROP_UNSIGNED); | |||||
| RNA_def_property_int_sdna(prop, NULL, "active_palette_slot"); | |||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | |||||
| RNA_def_property_int_funcs(prop, NULL, NULL, | |||||
| "rna_GPencil_active_palette_index_range"); | |||||
| RNA_def_property_ui_text(prop, "Active Palette Index", "Index of active palette slot"); | |||||
| RNA_def_property_update(prop, NC_MATERIAL, NULL); | |||||
| prop = RNA_def_property(srna, "active_palette_slot", PROP_POINTER, PROP_NONE); | |||||
| RNA_def_property_struct_type(prop, "GPencilPaletteSlot"); | |||||
| RNA_def_property_pointer_funcs(prop, "rna_GPencil_active_palette_slot_get", | |||||
| "rna_GPencil_active_palette_slot_set", NULL, NULL); | |||||
| RNA_def_property_flag(prop, PROP_EDITABLE); | |||||
| //RNA_def_property_editable_func(prop, "rna_GPencil_active_palette_slot_editable"); | |||||
| RNA_def_property_ui_text(prop, "Active Palette Slot", "Active palette slot being displayed"); | |||||
| RNA_def_property_update(prop, NC_MATERIAL, NULL); | |||||
| /* xray modes */ | |||||
| prop = RNA_def_property(srna, "xray_mode", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "xray_mode"); | |||||
| RNA_def_property_enum_items(prop, rna_enum_gpencil_xraymodes_items); | |||||
| RNA_def_property_ui_text(prop, "Xray", ""); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); | /* Flags */ | ||||
| RNA_def_property_float_sdna(prop, NULL, "color[3]"); | prop = RNA_def_property(srna, "use_stroke_edit_mode", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_range(prop, 0.0, 1.0f); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_EDITMODE); | ||||
| RNA_def_property_ui_text(prop, "Opacity", "Color Opacity"); | RNA_def_property_ui_text(prop, "Stroke Edit Mode", "Edit Grease Pencil strokes instead of viewport data"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); | ||||
| prop = RNA_def_property(srna, "is_stroke_paint_mode", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_PAINTMODE); | |||||
| RNA_def_property_ui_text(prop, "Stroke Paint Mode", "Draw Grease Pencil strokes on click/drag"); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); | |||||
| /* Name */ | prop = RNA_def_property(srna, "is_stroke_sculpt_mode", PROP_BOOLEAN, PROP_NONE); | ||||
| prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_SCULPTMODE); | ||||
| RNA_def_property_string_sdna(prop, NULL, "info"); | RNA_def_property_ui_text(prop, "Stroke Sculpt Mode", "Sculpt Grease Pencil strokes instead of viewport data"); | ||||
| RNA_def_property_ui_text(prop, "Name", "Color name"); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilPaletteColor_info_set"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); | ||||
| RNA_def_struct_name_property(srna, prop); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | |||||
| /* Fill Drawing Color */ | prop = RNA_def_property(srna, "is_stroke_weight_mode", PROP_BOOLEAN, PROP_NONE); | ||||
| prop = RNA_def_property(srna, "fill_color", PROP_FLOAT, PROP_COLOR_GAMMA); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_WEIGHTMODE); | ||||
| RNA_def_property_float_sdna(prop, NULL, "fill"); | RNA_def_property_ui_text(prop, "Stroke Weight Paint Mode", "Grease Pencil weight paint"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_range(prop, 0.0f, 1.0f); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); | ||||
| RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region bounded by each stroke"); | |||||
| prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_SHOW_ONIONSKINS); | |||||
| RNA_def_property_ui_text(prop, "Onion Skins", "Show ghosts of the frames before and after the current frame"); | |||||
| RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update"); | |||||
| prop = RNA_def_property(srna, "show_stroke_direction", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_SHOW_DIRECTION); | |||||
| RNA_def_property_ui_text(prop, "Show Direction", "Show stroke drawing direction with a bigger green dot (start) " | |||||
| "and smaller red dot (end) points"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Fill alpha */ | prop = RNA_def_property(srna, "keep_stroke_thickness", PROP_BOOLEAN, PROP_NONE); | ||||
| prop = RNA_def_property(srna, "fill_alpha", PROP_FLOAT, PROP_NONE); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_KEEPTHICKNESS); | ||||
| RNA_def_property_float_sdna(prop, NULL, "fill[3]"); | RNA_def_property_ui_text(prop, "Keep thickness", "Show stroke with same thickness when viewport zoom change"); | ||||
| RNA_def_property_range(prop, 0.0, 1.0f); | |||||
| RNA_def_property_ui_text(prop, "Fill Opacity", "Opacity for filling region bounded by each stroke"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Flags */ | prop = RNA_def_property(srna, "pixfactor", PROP_INT, PROP_NONE); | ||||
| prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); | RNA_def_property_int_sdna(prop, NULL, "pixfactor"); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_HIDE); | RNA_def_property_range(prop, 30, 10000); | ||||
| RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); | RNA_def_property_ui_text(prop, "Pixel Factor", "Conversion factor for pixel size (use larger values for thinner lines)"); | ||||
| RNA_def_property_ui_text(prop, "Hide", "Set color Visibility"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_multiedit", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_LOCKED); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_MULTIEDIT); | ||||
| RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); | RNA_def_property_ui_text(prop, "MultiFrame", "Edit strokes from multiple grease pencil keyframes at the same time (keyframes must be selected to be included)"); | ||||
| RNA_def_property_ui_text(prop, "Locked", "Protect color from further editing and/or frame changes"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| prop = RNA_def_property(srna, "ghost", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "show_edit_lines", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_ONIONSKIN); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_SHOW_EDIT_LINES); | ||||
| RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0); | RNA_def_property_ui_text(prop, "Edit Lines", "Show edit lines when edit strokes"); | ||||
| RNA_def_property_ui_text(prop, "Show in Ghosts", "Display strokes using this color when showing onion skins"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Draw Style */ | prop = RNA_def_property(srna, "edit_line_color", PROP_FLOAT, PROP_COLOR_GAMMA); | ||||
| prop = RNA_def_property(srna, "use_volumetric_strokes", PROP_BOOLEAN, PROP_NONE); | RNA_def_property_float_sdna(prop, NULL, "line_color"); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_VOLUMETRIC); | RNA_def_property_array(prop, 4); | ||||
| RNA_def_property_ui_text(prop, "Volumetric Strokes", "Draw strokes as a series of circular blobs, resulting in " | RNA_def_property_range(prop, 0.0f, 1.0f); | ||||
| "a volumetric effect"); | RNA_def_property_float_array_default(prop, default_1); | ||||
| RNA_def_property_ui_text(prop, "Edit Line Color", "Color for editing line"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Use High quality fill */ | prop = RNA_def_property(srna, "show_multiedit_line_only", PROP_BOOLEAN, PROP_NONE); | ||||
| prop = RNA_def_property(srna, "use_hq_fill", PROP_BOOLEAN, PROP_NONE); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_MULTIEDIT_LINES); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_HQ_FILL); | RNA_def_property_ui_text(prop, "Lines Only", "Show only edit lines for additional frames"); | ||||
| RNA_def_property_ui_text(prop, "High Quality Fill", "Fill strokes using high quality to avoid glitches " | |||||
| "(slower fps during animation play)"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Read-only state props (for simpler UI code) */ | /* info properties */ | ||||
| prop = RNA_def_property(srna, "is_stroke_visible", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "info_total_layers", PROP_INT, PROP_UNSIGNED); | ||||
| RNA_def_property_boolean_funcs(prop, "rna_GPencilPaletteColor_is_stroke_visible_get", NULL); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_ui_text(prop, "Is Stroke Visible", "True when opacity of stroke is set high enough to be visible"); | RNA_def_property_int_funcs(prop, "rna_GPencil_info_total_layers", NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Total Layers", "Number of Layers"); | |||||
| prop = RNA_def_property(srna, "is_fill_visible", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "info_total_frames", PROP_INT, PROP_UNSIGNED); | ||||
| RNA_def_property_boolean_funcs(prop, "rna_GPencilPaletteColor_is_fill_visible_get", NULL); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_ui_text(prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible"); | RNA_def_property_int_funcs(prop, "rna_GPencil_info_total_frames", NULL, NULL); | ||||
| } | RNA_def_property_ui_text(prop, "Total Frames", "Number of Frames"); | ||||
| /* palette colors api */ | |||||
| static void rna_def_gpencil_palettecolors_api(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| { | |||||
| StructRNA *srna; | |||||
| PropertyRNA *prop; | |||||
| FunctionRNA *func; | |||||
| PropertyRNA *parm; | |||||
| RNA_def_property_srna(cprop, "GPencilPaletteColors"); | |||||
| srna = RNA_def_struct(brna, "GPencilPaletteColors", NULL); | |||||
| RNA_def_struct_sdna(srna, "bGPDpalette"); | |||||
| RNA_def_struct_ui_text(srna, "Palette colors", "Collection of palette colors"); | |||||
| func = RNA_def_function(srna, "new", "rna_GPencilPalette_color_new"); | |||||
| RNA_def_function_ui_description(func, "Add a new color to the palette"); | |||||
| parm = RNA_def_pointer(func, "color", "GPencilPaletteColor", "", "The newly created color"); | |||||
| RNA_def_function_return(func, parm); | |||||
| func = RNA_def_function(srna, "remove", "rna_GPencilPalette_color_remove"); | |||||
| RNA_def_function_ui_description(func, "Remove a color from the palette"); | |||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | |||||
| parm = RNA_def_pointer(func, "color", "GPencilPaletteColor", "", "The color to remove"); | |||||
| RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); | |||||
| RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); | |||||
| prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "info_total_strokes", PROP_INT, PROP_UNSIGNED); | ||||
| RNA_def_property_struct_type(prop, "GPencilPaletteColor"); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_pointer_funcs(prop, "rna_GPencilPalette_active_color_get", "rna_GPencilPalette_active_color_set", NULL, NULL); | RNA_def_property_int_funcs(prop, "rna_GPencil_info_total_strokes", NULL, NULL); | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE); | RNA_def_property_ui_text(prop, "Total Strokes", "Number of Strokes"); | ||||
| RNA_def_property_ui_text(prop, "Active Palette Color", "Current active color"); | |||||
| prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); | |||||
| RNA_def_property_int_funcs(prop, | |||||
| "rna_GPencilPaletteColor_index_get", | |||||
| "rna_GPencilPaletteColor_index_set", | |||||
| "rna_GPencilPaletteColor_index_range"); | |||||
| RNA_def_property_ui_text(prop, "Active color Index", "Index of active palette color"); | |||||
| } | |||||
| static void rna_def_gpencil_palette(BlenderRNA *brna) | prop = RNA_def_property(srna, "info_total_points", PROP_INT, PROP_UNSIGNED); | ||||
| { | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| StructRNA *srna; | RNA_def_property_int_funcs(prop, "rna_GPencil_info_total_points", NULL, NULL); | ||||
| PropertyRNA *prop; | RNA_def_property_ui_text(prop, "Total Points", "Number of Points"); | ||||
| srna = RNA_def_struct(brna, "GPencilPalette", NULL); | prop = RNA_def_property(srna, "info_total_palettes", PROP_INT, PROP_UNSIGNED); | ||||
| RNA_def_struct_sdna(srna, "bGPDpalette"); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_struct_ui_text(srna, "Grease Pencil Palette", "Collection of related palettes"); | RNA_def_property_int_funcs(prop, "rna_GPencil_info_total_palettes", NULL, NULL); | ||||
| RNA_def_struct_path_func(srna, "rna_GPencilPalette_path"); | RNA_def_property_ui_text(prop, "Total Palettes", "Number of Palettes"); | ||||
| RNA_def_struct_ui_icon(srna, ICON_COLOR); | |||||
| /* Name */ | /* onion skinning */ | ||||
| prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_string_sdna(prop, NULL, "info"); | RNA_def_property_int_sdna(prop, NULL, "gstep"); | ||||
| RNA_def_property_ui_text(prop, "Name", "Palette name"); | RNA_def_property_range(prop, 0, 120); | ||||
| RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilPalette_info_set"); | RNA_def_property_int_default(prop, 1); | ||||
| RNA_def_struct_name_property(srna, prop); | RNA_def_property_ui_text(prop, "Frames Before", | ||||
| "Maximum number of frames to show before current frame " | |||||
| "(0 = don't show any frames before current)"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* Colors */ | prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE); | ||||
| prop = RNA_def_property(srna, "colors", PROP_COLLECTION, PROP_NONE); | RNA_def_property_int_sdna(prop, NULL, "gstep_next"); | ||||
| RNA_def_property_collection_sdna(prop, NULL, "colors", NULL); | RNA_def_property_range(prop, 0, 120); | ||||
| RNA_def_property_struct_type(prop, "GPencilPaletteColor"); | RNA_def_property_int_default(prop, 1); | ||||
| RNA_def_property_ui_text(prop, "Colors", "Colors of the palette"); | RNA_def_property_ui_text(prop, "Frames After", | ||||
| rna_def_gpencil_palettecolors_api(brna, prop); | "Maximum number of frames to show after current frame " | ||||
| "(0 = don't show any frames after current)"); | |||||
| } | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| static void rna_def_gpencil_palettes_api(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| { | |||||
| StructRNA *srna; | |||||
| PropertyRNA *prop; | |||||
| FunctionRNA *func; | |||||
| PropertyRNA *parm; | |||||
| RNA_def_property_srna(cprop, "GreasePencilPalettes"); | |||||
| srna = RNA_def_struct(brna, "GreasePencilPalettes", NULL); | |||||
| RNA_def_struct_sdna(srna, "bGPdata"); | |||||
| RNA_def_struct_ui_text(srna, "Grease Pencil Palettes", "Collection of grease pencil palettes"); | |||||
| func = RNA_def_function(srna, "new", "rna_GPencil_palette_new"); | prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_function_ui_description(func, "Add a new grease pencil palette"); | RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_GHOST_PREVCOL | GP_ONION_GHOST_NEXTCOL); | ||||
| parm = RNA_def_string(func, "name", "GPencilPalette", MAX_NAME, "Name", "Name of the palette"); | RNA_def_property_ui_text(prop, "Use Custom Ghost Colors", "Use custom colors for ghost frames"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| RNA_def_boolean(func, "set_active", true, "Set Active", "Activate the newly created palette"); | |||||
| parm = RNA_def_pointer(func, "palette", "GPencilPalette", "", "The newly created palette"); | |||||
| RNA_def_function_return(func, parm); | |||||
| func = RNA_def_function(srna, "remove", "rna_GPencil_palette_remove"); | prop = RNA_def_property(srna, "before_color", PROP_FLOAT, PROP_COLOR_GAMMA); | ||||
| RNA_def_function_ui_description(func, "Remove a grease pencil palette"); | RNA_def_property_float_sdna(prop, NULL, "gcolor_prev"); | ||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | RNA_def_property_array(prop, 3); | ||||
| parm = RNA_def_pointer(func, "palette", "GPencilPalette", "", "The palette to remove"); | RNA_def_property_range(prop, 0.0f, 1.0f); | ||||
| RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); | RNA_def_property_float_array_default(prop, onion_dft1); | ||||
| RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); | RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame"); | ||||
| RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update"); | |||||
| prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "after_color", PROP_FLOAT, PROP_COLOR_GAMMA); | ||||
| RNA_def_property_struct_type(prop, "GPencilPalette"); | RNA_def_property_float_sdna(prop, NULL, "gcolor_next"); | ||||
| RNA_def_property_pointer_funcs(prop, "rna_GPencil_active_palette_get", "rna_GPencil_active_palette_set", | RNA_def_property_array(prop, 3); | ||||
| NULL, NULL); | RNA_def_property_range(prop, 0.0f, 1.0f); | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE); | RNA_def_property_float_array_default(prop, onion_dft2); | ||||
| RNA_def_property_ui_text(prop, "Active Palette", "Current active palette"); | RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame"); | ||||
| RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update"); | |||||
| prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); | prop = RNA_def_property(srna, "use_ghosts_always", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_int_funcs(prop, | RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_GHOST_ALWAYS); | ||||
| "rna_GPencilPalette_index_get", | RNA_def_property_ui_text(prop, "Always Show Ghosts", | ||||
| "rna_GPencilPalette_index_set", | "Ghosts are shown in renders and animation playback. Useful for special effects (e.g. motion blur)"); | ||||
| "rna_GPencilPalette_index_range"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| RNA_def_property_ui_text(prop, "Active Palette Index", "Index of active palette"); | |||||
| } | |||||
| static void rna_def_gpencil_data(BlenderRNA *brna) | prop = RNA_def_property(srna, "onion_mode", PROP_ENUM, PROP_NONE); | ||||
| { | RNA_def_property_enum_sdna(prop, NULL, "onion_mode"); | ||||
| StructRNA *srna; | RNA_def_property_enum_items(prop, rna_enum_gpencil_onion_modes_items); | ||||
| PropertyRNA *prop; | RNA_def_property_ui_text(prop, "Mode", "Mode to display frames"); | ||||
| FunctionRNA *func; | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| srna = RNA_def_struct(brna, "GreasePencil", "ID"); | prop = RNA_def_property(srna, "use_onion_fade", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_struct_sdna(srna, "bGPdata"); | RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_FADE); | ||||
| RNA_def_struct_ui_text(srna, "Grease Pencil", "Freehand annotation sketchbook"); | RNA_def_property_ui_text(prop, "Fade", | ||||
| RNA_def_struct_ui_icon(srna, ICON_GREASEPENCIL); | "Display onion keyframes with a fade in color transparency"); | ||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | |||||
| /* Layers */ | |||||
| prop = RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_collection_sdna(prop, NULL, "layers", NULL); | |||||
| RNA_def_property_struct_type(prop, "GPencilLayer"); | |||||
| RNA_def_property_ui_text(prop, "Layers", ""); | |||||
| rna_def_gpencil_layers_api(brna, prop); | |||||
| /* Palettes */ | |||||
| prop = RNA_def_property(srna, "palettes", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_collection_sdna(prop, NULL, "palettes", NULL); | |||||
| RNA_def_property_struct_type(prop, "GPencilPalette"); | |||||
| RNA_def_property_ui_text(prop, "Palettes", ""); | |||||
| rna_def_gpencil_palettes_api(brna, prop); | |||||
| /* Animation Data */ | prop = RNA_def_property(srna, "onion_factor", PROP_FLOAT, PROP_NONE); | ||||
| rna_def_animdata_common(srna); | RNA_def_property_float_sdna(prop, NULL, "onion_factor"); | ||||
| RNA_def_property_float_default(prop, 0.5f); | |||||
| /* Flags */ | RNA_def_property_range(prop, 0.0, 1.0f); | ||||
| prop = RNA_def_property(srna, "use_stroke_edit_mode", PROP_BOOLEAN, PROP_NONE); | RNA_def_property_ui_text(prop, "Onion Opacity", "Change fade opacity of displayed onion frames"); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_EDITMODE); | |||||
| RNA_def_property_ui_text(prop, "Stroke Edit Mode", "Edit Grease Pencil strokes instead of viewport data"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); | |||||
| prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_SHOW_ONIONSKINS); | |||||
| RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_use_onion_skinning_set"); | |||||
| RNA_def_property_ui_text(prop, "Onion Skins", | |||||
| "Show ghosts of the frames before and after the current frame, toggle to enable on active layer or disable all"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); | |||||
| prop = RNA_def_property(srna, "show_stroke_direction", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_SHOW_DIRECTION); | |||||
| RNA_def_property_ui_text(prop, "Show Direction", "Show stroke drawing direction with a bigger green dot (start) " | |||||
| "and smaller red dot (end) points"); | |||||
| RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); | ||||
| /* API Functions */ | /* API Functions */ | ||||
| Context not available. | |||||
| rna_def_gpencil_layer(brna); | rna_def_gpencil_layer(brna); | ||||
| rna_def_gpencil_frame(brna); | rna_def_gpencil_frame(brna); | ||||
| rna_def_gpencil_triangle(brna); | |||||
| rna_def_gpencil_stroke(brna); | rna_def_gpencil_stroke(brna); | ||||
| rna_def_gpencil_stroke_point(brna); | rna_def_gpencil_stroke_point(brna); | ||||
| rna_def_gpencil_triangle(brna); | |||||
| rna_def_gpencil_palette(brna); | |||||
| rna_def_gpencil_palettecolor(brna); | rna_def_gpencil_point_weight(brna); | ||||
| rna_def_gpencil_palette_slot(brna); | |||||
| } | } | ||||
| #endif | #endif | ||||
| Context not available. | |||||
Call show_constant_thickness