22# include <fmt/format.h>
47 return reinterpret_cast<bGPdata *
>(ptr->owner_id);
95 frame_ptr->invalidate();
115static bGPDlayer *rna_annotation_layer_new(
bGPdata *gpd,
const char *name,
bool setactive)
133 layer_ptr->invalidate();
138static std::optional<std::string> rna_annotation_layer_path(
const PointerRNA *ptr)
141 char name_esc[
sizeof(gpl->info) * 2];
145 return fmt::format(
"layers[\"{}\"]", name_esc);
148static int rna_annotation_layer_active_frame_editable(
const PointerRNA *ptr,
160static void rna_annotation_layer_info_set(
PointerRNA *ptr,
const char *value)
162 bGPdata *gpd = rna_annotations(ptr);
165 char oldname[
sizeof(gpl->info)] =
"";
194static int rna_annotation_active_layer_index_get(
PointerRNA *ptr)
196 bGPdata *gpd = rna_annotations(ptr);
202static void rna_annotation_active_layer_index_set(
PointerRNA *ptr,
int value)
204 bGPdata *gpd = rna_annotations(ptr);
214static void rna_annotation_active_layer_index_range(
217 bGPdata *gpd = rna_annotations(ptr);
220 *
max =
max_ii(0, gpd->layers.count() - 1);
231 bGPdata *gpd = rna_annotations(ptr);
237 if (
ELEM(
nullptr,
C, gpd)) {
242 for (gpl = gpd->layers.first(), i = 0; gpl; gpl = gpl->next, i++) {
243 item_tmp.identifier = gpl->info;
244 item_tmp.name = gpl->info;
262 bGPDstroke *stroke = MEM_new<bGPDstroke>(
"gp_stroke");
263 if (stroke ==
nullptr) {
268 stroke->thickness = 1;
269 stroke->fill_opacity_fac = 1.0f;
270 stroke->hardness = 1.0f;
271 stroke->uv_scale = 1.0f;
282static void rna_annotation_stroke_remove(
bGPDframe *frame,
297 stroke_ptr->data =
nullptr;
298 stroke_ptr->type =
nullptr;
303static void rna_annotation_stroke_point_add(
bGPDstroke *stroke,
305 const float pressure,
306 const float strength)
313 const int old_count = stroke->totpoints;
314 const int new_count = old_count + count;
317 stroke->points = MEM_new_array<bGPDspoint>(new_count,
"gp_stroke_points");
320 if (old_points && old_count > 0) {
324 for (
int i = old_count; i < new_count; i++) {
327 pt->strength = strength;
335 MEM_delete(old_points);
338 stroke->totpoints = new_count;
343static void rna_annotation_stroke_point_remove(
bGPDstroke *stroke,
347 if (stroke->totpoints <= 0) {
352 if (index < 0 || index >= stroke->totpoints) {
357 if (stroke->totpoints == 1) {
362 const int new_count = stroke->totpoints - 1;
365 stroke->points = MEM_new_array<bGPDspoint>(new_count,
"gp_stroke_points");
373 if (
index < new_count) {
377 MEM_delete(old_points);
379 stroke->totpoints = new_count;
403 parm =
RNA_def_pointer(func,
"stroke",
"AnnotationStroke",
"",
"The newly created stroke");
410 parm =
RNA_def_pointer(func,
"stroke",
"AnnotationStroke",
"",
"The stroke to remove");
425 srna,
"Annotation Stroke Points",
"Collection of annotation stroke points");
429 parm =
RNA_def_int(func,
"count", 1, 1,
INT_MAX,
"Count",
"Number of points to add", 1, 100);
437 "Pressure/radius for new points",
446 "Color strength/opacity for new points",
450 func =
RNA_def_function(srna,
"remove",
"rna_annotation_stroke_point_remove");
453 parm =
RNA_def_int(func,
"index", 0, 0,
INT_MAX,
"Index",
"Index of point to remove", 0, 10000);
496 "Stroke is in 2D space, locked to the camera view"},
498 {0,
nullptr, 0,
nullptr,
nullptr},
516 srna,
"Annotation Frame",
"Collection of related sketches on a particular frame");
560 "The frame on which this sketch appears",
565 parm =
RNA_def_pointer(func,
"frame",
"AnnotationFrame",
"",
"The newly created frame");
572 parm =
RNA_def_pointer(func,
"frame",
"AnnotationFrame",
"Frame",
"The frame to remove");
578 parm =
RNA_def_pointer(func,
"source",
"AnnotationFrame",
"Source",
"The source frame");
580 parm =
RNA_def_pointer(func,
"copy",
"AnnotationFrame",
"",
"The newly copied frame");
645 prop,
"Onion Skinning",
"Display annotation onion skins before and after the current frame");
653 prop,
"Frames Before",
"Maximum number of frames to show before current frame");
661 prop,
"Frames After",
"Maximum number of frames to show after current frame");
684 "Custom Onion Skin Colors",
685 "Use custom colors for onion skinning instead of the theme");
699 prop,
"Locked",
"Protect layer from further editing and/or frame changes");
743 func,
"set_active",
true,
"Set Active",
"Set the newly created layer to the active layer");
744 parm =
RNA_def_pointer(func,
"layer",
"AnnotationLayer",
"",
"The newly created layer");
751 parm =
RNA_def_pointer(func,
"layer",
"AnnotationLayer",
"",
"The layer to remove");
757 "rna_annotation_active_layer_index_get",
758 "rna_annotation_active_layer_index_set",
759 "rna_annotation_active_layer_index_range");
766 "rna_annotation_active_layer_index_get",
767 "rna_annotation_active_layer_index_set",
768 "rna_annotation_active_layer_itemf");
#define STRNCPY_UTF8(dst, src)
#define ND_SPACE_PROPERTIES
struct bGPDframe * BKE_annotations_frame_addnew(struct bGPDlayer *gpl, int cframe)
void WM_main_add_notifier(uint type, void *reference)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
static void rna_def_annotation_strokes_api(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
void BKE_annotations_layer_active_set(struct bGPdata *gpd, struct bGPDlayer *active)
static void rna_def_annotation_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
char * STRNCPY(char(&dst)[N], const char *src)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
static void rna_def_annotation_stroke(BlenderRNA *brna)
struct bGPDframe * BKE_annotations_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
static void rna_def_annotation_data(BlenderRNA *brna)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
struct bGPDlayer * BKE_annotations_layer_addnew(struct bGPdata *gpd, const char *name, bool setactive, bool add_to_header)
std::string RNA_path_name_to_infix(const StringRefNull string)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
static void rna_def_annotation_stroke_point(BlenderRNA *brna)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
MINLINE int max_ii(int a, int b)
void BKE_annotations_free_stroke(struct bGPDstroke *gps)
void RNA_def_annotations(BlenderRNA *brna)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
struct bGPDframe * BKE_annotations_layer_frame_find(struct bGPDlayer *gpl, int cframe)
void rna_def_animdata_common(StructRNA *srna)
void BKE_animdata_fix_paths(ID &id, StringRef prefix, StringRef old_infix, StringRef new_infix, bool verify_paths, const DriverMap &driver_map)
void BKE_annotations_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_uniquename(const ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
static void rna_def_annotation_layer(BlenderRNA *brna)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
static void rna_def_annotation_frame(BlenderRNA *brna)
bool rna_GPencil_datablocks_annotations_poll(PointerRNA *ptr, const PointerRNA value)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
const EnumPropertyItem rna_enum_dummy_DEFAULT_items[]
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
struct bGPDlayer * BKE_annotations_layer_active_get(struct bGPdata *gpd)
static void rna_def_annotation_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
static void rna_def_annotation_layers_api(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
bool BKE_annotations_layer_frame_delete(struct bGPDlayer *gpl, struct bGPDframe *gpf)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
int BKE_icon_gplayer_color_ensure(bGPDlayer *gpl)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ GP_LAYER_ONIONSKIN_CUSTOM_COLOR
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void uninitialized_move_n(T *src, int64_t n, T *dst)
struct bGPDframe * BKE_annotations_frame_duplicate(const struct bGPDframe *gpf_src, bool dup_strokes)