Blender V4.3
rna_grease_pencil_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#include "DNA_scene_types.h"
11
12#include "RNA_define.hh"
13
14#include "WM_api.hh"
15
16#include "rna_internal.hh" /* own include */
17
19 {-1, "DOWN", 0, "Down", ""},
20 {1, "UP", 0, "Up", ""},
21 {0, nullptr, 0, nullptr, nullptr},
22};
23
24#ifdef RNA_RUNTIME
25
26# include "BKE_attribute.hh"
27# include "BKE_context.hh"
28# include "BKE_curves.hh"
29# include "BKE_grease_pencil.hh"
30# include "BKE_report.hh"
31
32# include "DEG_depsgraph.hh"
33
34# include "rna_curves_utils.hh"
35
36static void rna_GreasePencilDrawing_add_curves(ID *grease_pencil_id,
37 GreasePencilDrawing *drawing_ptr,
38 ReportList *reports,
39 const int *sizes,
40 const int sizes_num)
41{
42 using namespace blender;
43 bke::greasepencil::Drawing &drawing = drawing_ptr->wrap();
44 bke::CurvesGeometry &curves = drawing.strokes_for_write();
45 if (!rna_CurvesGeometry_add_curves(curves, reports, sizes, sizes_num)) {
46 return;
47 }
48
49 /* Default to `POLY` curves for the newly added ones. */
50 drawing.strokes_for_write().curve_types_for_write().take_back(sizes_num).fill(CURVE_TYPE_POLY);
52
53 drawing.tag_topology_changed();
54
55 /* Avoid updates for importers. */
56 if (grease_pencil_id->us > 0) {
57 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
58 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
59 }
60}
61
62static void rna_GreasePencilDrawing_remove_curves(ID *grease_pencil_id,
63 GreasePencilDrawing *drawing_ptr,
64 ReportList *reports,
65 const int *indices_ptr,
66 const int indices_num)
67{
68 using namespace blender;
69 bke::greasepencil::Drawing &drawing = drawing_ptr->wrap();
70 bke::CurvesGeometry &curves = drawing.strokes_for_write();
71 if (!rna_CurvesGeometry_remove_curves(curves, reports, indices_ptr, indices_num)) {
72 return;
73 }
74
75 drawing.tag_topology_changed();
76
77 /* Avoid updates for importers. */
78 if (grease_pencil_id->us > 0) {
79 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
80 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
81 }
82}
83
84static void rna_GreasePencilDrawing_resize_curves(ID *grease_pencil_id,
85 GreasePencilDrawing *drawing_ptr,
86 ReportList *reports,
87 const int *sizes_ptr,
88 const int sizes_num,
89 const int *indices_ptr,
90 const int indices_num)
91{
92 using namespace blender;
93 bke::greasepencil::Drawing &drawing = drawing_ptr->wrap();
94 bke::CurvesGeometry &curves = drawing.strokes_for_write();
95 if (!rna_CurvesGeometry_resize_curves(
96 curves, reports, sizes_ptr, sizes_num, indices_ptr, indices_num))
97 {
98 return;
99 }
100
101 drawing.tag_topology_changed();
102
103 /* Avoid updates for importers. */
104 if (grease_pencil_id->us > 0) {
105 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
106 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
107 }
108}
109
110static void rna_GreasePencilDrawing_tag_positions_changed(GreasePencilDrawing *drawing_ptr)
111{
112 drawing_ptr->wrap().tag_positions_changed();
113}
114
115static GreasePencilFrame *rna_Frames_frame_new(ID *id,
116 GreasePencilLayer *layer_in,
117 ReportList *reports,
118 int frame_number)
119{
120 using namespace blender::bke::greasepencil;
121 GreasePencil &grease_pencil = *reinterpret_cast<GreasePencil *>(id);
122 Layer &layer = static_cast<GreasePencilLayer *>(layer_in)->wrap();
123
124 if (layer.frames().contains(frame_number)) {
125 BKE_reportf(reports, RPT_ERROR, "Frame already exists on frame number %d", frame_number);
126 return nullptr;
127 }
128
129 grease_pencil.insert_frame(layer, frame_number, 0, BEZT_KEYTYPE_KEYFRAME);
130 DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
131 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, &grease_pencil);
132
133 return layer.frame_at(frame_number);
134}
135
136static void rna_Frames_frame_remove(ID *id,
137 GreasePencilLayer *layer_in,
138 ReportList *reports,
139 int frame_number)
140{
141 using namespace blender::bke::greasepencil;
142 GreasePencil &grease_pencil = *reinterpret_cast<GreasePencil *>(id);
143 Layer &layer = static_cast<GreasePencilLayer *>(layer_in)->wrap();
144
145 if (!layer.frames().contains(frame_number)) {
146 BKE_reportf(reports, RPT_ERROR, "Frame doesn't exists on frame number %d", frame_number);
147 return;
148 }
149
150 if (grease_pencil.remove_frames(layer, {frame_number})) {
151 DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
152 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, &grease_pencil);
153 }
154}
155
156static GreasePencilFrame *rna_Frames_frame_copy(ID *id,
157 GreasePencilLayer *layer_in,
158 ReportList *reports,
159 int from_frame_number,
160 int to_frame_number,
161 bool instance_drawing)
162{
163 using namespace blender::bke::greasepencil;
164 GreasePencil &grease_pencil = *reinterpret_cast<GreasePencil *>(id);
165 Layer &layer = static_cast<GreasePencilLayer *>(layer_in)->wrap();
166
167 if (!layer.frames().contains(from_frame_number)) {
168 BKE_reportf(reports, RPT_ERROR, "Frame doesn't exists on frame number %d", from_frame_number);
169 return nullptr;
170 }
171 if (layer.frames().contains(to_frame_number)) {
172 BKE_reportf(reports, RPT_ERROR, "Frame already exists on frame number %d", to_frame_number);
173 return nullptr;
174 }
175
176 grease_pencil.insert_duplicate_frame(
177 layer, from_frame_number, to_frame_number, instance_drawing);
178 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, &grease_pencil);
179
180 return layer.frame_at(to_frame_number);
181}
182
183static GreasePencilFrame *rna_Frames_frame_move(ID *id,
184 GreasePencilLayer *layer_in,
185 ReportList *reports,
186 int from_frame_number,
187 int to_frame_number)
188{
189 using namespace blender::bke::greasepencil;
190 GreasePencil &grease_pencil = *reinterpret_cast<GreasePencil *>(id);
191 Layer &layer = static_cast<GreasePencilLayer *>(layer_in)->wrap();
192
193 if (!layer.frames().contains(from_frame_number)) {
194 BKE_reportf(reports, RPT_ERROR, "Frame doesn't exists on frame number %d", from_frame_number);
195 return nullptr;
196 }
197 if (layer.frames().contains(to_frame_number)) {
198 BKE_reportf(reports, RPT_ERROR, "Frame already exists on frame number %d", to_frame_number);
199 return nullptr;
200 }
201
202 grease_pencil.insert_duplicate_frame(layer, from_frame_number, to_frame_number, true);
203 grease_pencil.remove_frames(layer, {from_frame_number});
204 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, &grease_pencil);
205
206 return layer.frame_at(to_frame_number);
207}
208
209static GreasePencilFrame *rna_GreasePencilLayer_get_frame_at(GreasePencilLayer *layer,
210 int frame_number)
211{
212 using namespace blender::bke::greasepencil;
213 return static_cast<Layer *>(layer)->frame_at(frame_number);
214}
215
216static GreasePencilFrame *rna_GreasePencilLayer_current_frame(GreasePencilLayer *layer,
217 bContext *C)
218{
219 using namespace blender::bke::greasepencil;
220 Scene *scene = CTX_data_scene(C);
221 return static_cast<Layer *>(layer)->frame_at(scene->r.cfra);
222}
223
224static GreasePencilLayer *rna_GreasePencil_layer_new(GreasePencil *grease_pencil,
225 const char *name,
226 const bool set_active,
227 PointerRNA *layer_group_ptr)
228{
229 using namespace blender::bke::greasepencil;
230 LayerGroup *layer_group = nullptr;
231 if (layer_group_ptr && layer_group_ptr->data) {
232 layer_group = static_cast<LayerGroup *>(layer_group_ptr->data);
233 }
234 Layer *layer;
235 if (layer_group) {
236 layer = &grease_pencil->add_layer(*layer_group, name);
237 }
238 else {
239 layer = &grease_pencil->add_layer(name);
240 }
241 if (set_active) {
242 grease_pencil->set_active_layer(layer);
243 }
244
245 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
246
247 return layer;
248}
249
250static void rna_GreasePencil_layer_remove(GreasePencil *grease_pencil, PointerRNA *layer_ptr)
251{
253 layer_ptr->data);
254 grease_pencil->remove_layer(layer);
255
256 RNA_POINTER_INVALIDATE(layer_ptr);
257 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
259}
260
261static void rna_GreasePencil_layer_move(GreasePencil *grease_pencil,
262 PointerRNA *layer_ptr,
263 const int direction)
264{
265 if (direction == 0) {
266 return;
267 }
268
270 static_cast<blender::bke::greasepencil::Layer *>(layer_ptr->data)->as_node();
271 switch (direction) {
272 case -1:
273 grease_pencil->move_node_down(layer_node, 1);
274 break;
275 case 1:
276 grease_pencil->move_node_up(layer_node, 1);
277 break;
278 }
279
280 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
281 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
282}
283
284static void rna_GreasePencil_layer_move_top(GreasePencil *grease_pencil, PointerRNA *layer_ptr)
285{
287 static_cast<blender::bke::greasepencil::Layer *>(layer_ptr->data)->as_node();
288 grease_pencil->move_node_top(layer_node);
289
290 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
291 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
292}
293
294static void rna_GreasePencil_layer_move_bottom(GreasePencil *grease_pencil, PointerRNA *layer_ptr)
295{
297 static_cast<blender::bke::greasepencil::Layer *>(layer_ptr->data)->as_node();
298 grease_pencil->move_node_bottom(layer_node);
299
300 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
301 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
302}
303
304static void rna_GreasePencil_layer_move_to_layer_group(GreasePencil *grease_pencil,
305 PointerRNA *layer_ptr,
306 PointerRNA *layer_group_ptr)
307{
308 using namespace blender::bke::greasepencil;
309 TreeNode &layer_node = static_cast<Layer *>(layer_ptr->data)->as_node();
310 LayerGroup *layer_group;
311 if (layer_group_ptr && layer_group_ptr->data) {
312 layer_group = static_cast<LayerGroup *>(layer_group_ptr->data);
313 }
314 else {
315 layer_group = &grease_pencil->root_group();
316 }
317 if (layer_group == nullptr) {
318 return;
319 }
320 grease_pencil->move_node_into(layer_node, *layer_group);
321
322 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
323 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
324}
325
326static PointerRNA rna_GreasePencil_layer_group_new(GreasePencil *grease_pencil,
327 const char *name,
328 PointerRNA *parent_group_ptr)
329{
330 using namespace blender::bke::greasepencil;
331 LayerGroup *parent_group;
332 if (parent_group_ptr && parent_group_ptr->data) {
333 parent_group = static_cast<LayerGroup *>(parent_group_ptr->data);
334 }
335 else {
336 parent_group = &grease_pencil->root_group();
337 }
338 LayerGroup *new_layer_group = &grease_pencil->add_layer_group(*parent_group, name);
339
340 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
341
343 &grease_pencil->id, &RNA_GreasePencilLayerGroup, new_layer_group);
344 return ptr;
345}
346
347static void rna_GreasePencil_layer_group_remove(GreasePencil *grease_pencil,
348 PointerRNA *layer_group_ptr,
349 bool keep_children)
350{
351 using namespace blender::bke::greasepencil;
352 LayerGroup &layer_group = *static_cast<LayerGroup *>(layer_group_ptr->data);
353 grease_pencil->remove_group(layer_group, keep_children);
354
355 RNA_POINTER_INVALIDATE(layer_group_ptr);
356 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
358}
359
360static void rna_GreasePencil_layer_group_move(GreasePencil *grease_pencil,
361 PointerRNA *layer_group_ptr,
362 int direction)
363{
364 if (direction == 0) {
365 return;
366 }
367
368 blender::bke::greasepencil::TreeNode &layer_group_node =
369 static_cast<blender::bke::greasepencil::LayerGroup *>(layer_group_ptr->data)->as_node();
370 switch (direction) {
371 case -1:
372 grease_pencil->move_node_down(layer_group_node, 1);
373 break;
374 case 1:
375 grease_pencil->move_node_up(layer_group_node, 1);
376 break;
377 }
378
379 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
380 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
381}
382
383static void rna_GreasePencil_layer_group_move_top(GreasePencil *grease_pencil,
384 PointerRNA *layer_group_ptr)
385{
386 blender::bke::greasepencil::TreeNode &layer_group_node =
387 static_cast<blender::bke::greasepencil::LayerGroup *>(layer_group_ptr->data)->as_node();
388 grease_pencil->move_node_top(layer_group_node);
389
390 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
391 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
392}
393
394static void rna_GreasePencil_layer_group_move_bottom(GreasePencil *grease_pencil,
395 PointerRNA *layer_group_ptr)
396{
397 blender::bke::greasepencil::TreeNode &layer_group_node =
398 static_cast<blender::bke::greasepencil::LayerGroup *>(layer_group_ptr->data)->as_node();
399 grease_pencil->move_node_bottom(layer_group_node);
400
401 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
402 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
403}
404
405static void rna_GreasePencil_layer_group_move_to_layer_group(GreasePencil *grease_pencil,
406 PointerRNA *layer_group_ptr,
407 PointerRNA *parent_group_ptr)
408{
409 using namespace blender::bke::greasepencil;
410 TreeNode &layer_group_node = static_cast<LayerGroup *>(layer_group_ptr->data)->as_node();
411 LayerGroup *parent_group;
412 if (parent_group_ptr && parent_group_ptr->data) {
413 parent_group = static_cast<LayerGroup *>(parent_group_ptr->data);
414 }
415 else {
416 parent_group = &grease_pencil->root_group();
417 }
418 grease_pencil->move_node_into(layer_group_node, *parent_group);
419
420 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
421 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, grease_pencil);
422}
423
424#else
425
427{
428 FunctionRNA *func;
429 PropertyRNA *parm;
430
431 func = RNA_def_function(srna, "add_strokes", "rna_GreasePencilDrawing_add_curves");
432 RNA_def_function_ui_description(func, "Add new strokes with provided sizes at the end");
434 parm = RNA_def_int_array(func,
435 "sizes",
436 1,
437 nullptr,
438 1,
439 INT_MAX,
440 "Sizes",
441 "The number of points in each stroke",
442 1,
443 10000);
445
446 func = RNA_def_function(srna, "remove_strokes", "rna_GreasePencilDrawing_remove_curves");
448 "Remove all strokes. If indices are provided, remove only the "
449 "strokes with the given indices.");
451 parm = RNA_def_int_array(func,
452 "indices",
453 1,
454 nullptr,
455 0,
456 INT_MAX,
457 "Indices",
458 "The indices of the strokes to remove",
459 0,
460 10000);
462
463 func = RNA_def_function(srna, "resize_strokes", "rna_GreasePencilDrawing_resize_curves");
465 func,
466 "Resize all existing strokes. If indices are provided, resize only the strokes with the "
467 "given indices. If the new size for a stroke is smaller, the stroke is trimmed. If "
468 "the new size for a stroke is larger, the new end values are default initialized.");
470 parm = RNA_def_int_array(func,
471 "sizes",
472 1,
473 nullptr,
474 1,
475 INT_MAX,
476 "Sizes",
477 "The number of points in each stroke",
478 1,
479 10000);
481 parm = RNA_def_int_array(func,
482 "indices",
483 1,
484 nullptr,
485 0,
486 INT_MAX,
487 "Indices",
488 "The indices of the stroke to resize",
489 0,
490 10000);
492
493 func = RNA_def_function(
494 srna, "tag_positions_changed", "rna_GreasePencilDrawing_tag_positions_changed");
496 func, "Indicate that the positions of points in the drawing have changed");
497}
498
500{
501 FunctionRNA *func;
502 PropertyRNA *parm;
503
504 func = RNA_def_function(srna, "new", "rna_Frames_frame_new");
505 RNA_def_function_ui_description(func, "Add a new Grease Pencil frame");
507 parm = RNA_def_int(func,
508 "frame_number",
509 1,
510 MINAFRAME,
511 MAXFRAME,
512 "Frame Number",
513 "The frame on which the drawing appears",
514 MINAFRAME,
515 MAXFRAME);
517 parm = RNA_def_pointer(func, "frame", "GreasePencilFrame", "", "The newly created frame");
518 RNA_def_function_return(func, parm);
519
520 func = RNA_def_function(srna, "remove", "rna_Frames_frame_remove");
521 RNA_def_function_ui_description(func, "Remove a Grease Pencil frame");
523 parm = RNA_def_int(func,
524 "frame_number",
525 1,
526 MINAFRAME,
527 MAXFRAME,
528 "Frame Number",
529 "The frame number of the frame to remove",
530 MINAFRAME,
531 MAXFRAME);
533
534 func = RNA_def_function(srna, "copy", "rna_Frames_frame_copy");
535 RNA_def_function_ui_description(func, "Copy a Grease Pencil frame");
537 parm = RNA_def_int(func,
538 "from_frame_number",
539 1,
540 MINAFRAME,
541 MAXFRAME,
542 "Source Frame Number",
543 "The frame number of the source frame",
544 MINAFRAME,
545 MAXFRAME);
547 parm = RNA_def_int(func,
548 "to_frame_number",
549 2,
550 MINAFRAME,
551 MAXFRAME,
552 "Frame Number of Copy",
553 "The frame number to copy the frame to",
554 MINAFRAME,
555 MAXFRAME);
557 parm = RNA_def_boolean(func,
558 "instance_drawing",
559 false,
560 "Instance Drawing",
561 "Let the copied frame use the same drawing as the source");
562 parm = RNA_def_pointer(func, "copy", "GreasePencilFrame", "", "The newly copied frame");
563 RNA_def_function_return(func, parm);
564
565 func = RNA_def_function(srna, "move", "rna_Frames_frame_move");
566 RNA_def_function_ui_description(func, "Move a Grease Pencil frame");
568 parm = RNA_def_int(func,
569 "from_frame_number",
570 1,
571 MINAFRAME,
572 MAXFRAME,
573 "Source Frame Number",
574 "The frame number of the source frame",
575 MINAFRAME,
576 MAXFRAME);
578 parm = RNA_def_int(func,
579 "to_frame_number",
580 2,
581 MINAFRAME,
582 MAXFRAME,
583 "Target Frame Number",
584 "The frame number to move the frame to",
585 MINAFRAME,
586 MAXFRAME);
588 parm = RNA_def_pointer(func, "moved", "GreasePencilFrame", "", "The moved frame");
589 RNA_def_function_return(func, parm);
590}
591
593{
594 FunctionRNA *func;
595 PropertyRNA *parm;
596
597 func = RNA_def_function(srna, "get_frame_at", "rna_GreasePencilLayer_get_frame_at");
598 RNA_def_function_ui_description(func, "Get the frame at given frame number");
599 parm = RNA_def_int(
600 func, "frame_number", 1, MINAFRAME, MAXFRAME, "Frame Number", "", MINAFRAME, MAXFRAME);
602 parm = RNA_def_pointer(func, "frame", "GreasePencilFrame", "Frame", "");
603 RNA_def_function_return(func, parm);
604
605 func = RNA_def_function(srna, "current_frame", "rna_GreasePencilLayer_current_frame");
607 func, "The Grease Pencil frame at the current scene time on this layer");
609 parm = RNA_def_pointer(func, "frame", "GreasePencilFrame", "", "");
610 RNA_def_function_return(func, parm);
611}
612
614{
615 FunctionRNA *func;
616 PropertyRNA *parm;
617
618 func = RNA_def_function(srna, "new", "rna_GreasePencil_layer_new");
619 RNA_def_function_ui_description(func, "Add a new Grease Pencil layer");
620 parm = RNA_def_string(func, "name", "GreasePencilLayer", MAX_NAME, "Name", "Name of the layer");
623 func, "set_active", true, "Set Active", "Set the newly created layer as the active layer");
624 parm = RNA_def_pointer(
625 func,
626 "layer_group",
627 "GreasePencilLayerGroup",
628 "",
629 "The layer group the new layer will be created in (use None for the main stack)");
631 parm = RNA_def_pointer(func, "layer", "GreasePencilLayer", "", "The newly created layer");
632 RNA_def_function_return(func, parm);
633
634 func = RNA_def_function(srna, "remove", "rna_GreasePencil_layer_remove");
635 RNA_def_function_ui_description(func, "Remove a Grease Pencil layer");
636 parm = RNA_def_pointer(func, "layer", "GreasePencilLayer", "", "The layer to remove");
639
640 func = RNA_def_function(srna, "move", "rna_GreasePencil_layer_move");
642 "Move a Grease Pencil layer in the layer group or main stack");
643 parm = RNA_def_pointer(func, "layer", "GreasePencilLayer", "", "The layer to move");
646 parm = RNA_def_enum(
647 func, "type", rna_enum_tree_node_move_type_items, 1, "", "Direction of movement");
649
650 func = RNA_def_function(srna, "move_top", "rna_GreasePencil_layer_move_top");
652 func, "Move a Grease Pencil layer to the top of the layer group or main stack");
653 parm = RNA_def_pointer(func, "layer", "GreasePencilLayer", "", "The layer to move");
656
657 func = RNA_def_function(srna, "move_bottom", "rna_GreasePencil_layer_move_bottom");
659 func, "Move a Grease Pencil layer to the bottom of the layer group or main stack");
660 parm = RNA_def_pointer(func, "layer", "GreasePencilLayer", "", "The layer to move");
663
664 func = RNA_def_function(
665 srna, "move_to_layer_group", "rna_GreasePencil_layer_move_to_layer_group");
666 RNA_def_function_ui_description(func, "Move a Grease Pencil layer into a layer group");
667 parm = RNA_def_pointer(func, "layer", "GreasePencilLayer", "", "The layer to move");
670 parm = RNA_def_pointer(
671 func,
672 "layer_group",
673 "GreasePencilLayerGroup",
674 "",
675 "The layer group the layer will be moved into (use None for the main stack)");
678}
679
681{
682 FunctionRNA *func;
683 PropertyRNA *parm;
684
685 func = RNA_def_function(srna, "new", "rna_GreasePencil_layer_group_new");
686 RNA_def_function_ui_description(func, "Add a new Grease Pencil layer group");
687 parm = RNA_def_string(
688 func, "name", "GreasePencilLayerGroup", MAX_NAME, "Name", "Name of the layer group");
690 parm = RNA_def_pointer(func,
691 "parent_group",
692 "GreasePencilLayerGroup",
693 "",
694 "The parent layer group the new group will be created in (use None "
695 "for the main stack)");
697 parm = RNA_def_pointer(
698 func, "layer_group", "GreasePencilLayerGroup", "", "The newly created layer group");
700 RNA_def_function_return(func, parm);
701
702 func = RNA_def_function(srna, "remove", "rna_GreasePencil_layer_group_remove");
703 RNA_def_function_ui_description(func, "Remove a new Grease Pencil layer group");
704 parm = RNA_def_pointer(
705 func, "layer_group", "GreasePencilLayerGroup", "", "The layer group to remove");
708 parm = RNA_def_boolean(func,
709 "keep_children",
710 false,
711 "",
712 "Keep the children nodes of the group and only delete the group itself");
713
714 func = RNA_def_function(srna, "move", "rna_GreasePencil_layer_group_move");
716 "Move a layer group in the parent layer group or main stack");
717 parm = RNA_def_pointer(
718 func, "layer_group", "GreasePencilLayerGroup", "", "The layer group to move");
721 parm = RNA_def_enum(
722 func, "type", rna_enum_tree_node_move_type_items, 1, "", "Direction of movement");
724
725 func = RNA_def_function(srna, "move_top", "rna_GreasePencil_layer_group_move_top");
727 func, "Move a layer group to the top of the parent layer group or main stack");
728 parm = RNA_def_pointer(
729 func, "layer_group", "GreasePencilLayerGroup", "", "The layer group to move");
732
733 func = RNA_def_function(srna, "move_bottom", "rna_GreasePencil_layer_group_move_bottom");
735 func, "Move a layer group to the bottom of the parent layer group or main stack");
736 parm = RNA_def_pointer(
737 func, "layer_group", "GreasePencilLayerGroup", "", "The layer group to move");
740
741 func = RNA_def_function(
742 srna, "move_to_layer_group", "rna_GreasePencil_layer_group_move_to_layer_group");
743 RNA_def_function_ui_description(func, "Move a layer group into a parent layer group");
744 parm = RNA_def_pointer(
745 func, "layer_group", "GreasePencilLayerGroup", "", "The layer group to move");
748 parm = RNA_def_pointer(func,
749 "parent_group",
750 "GreasePencilLayerGroup",
751 "",
752 "The parent layer group the layer group will be moved into (use "
753 "None for the main stack)");
756}
757
758#endif
Scene * CTX_data_scene(const bContext *C)
Low-level operations for curves.
Low-level operations for grease pencil.
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
@ BEZT_KEYTYPE_KEYFRAME
@ CURVE_TYPE_POLY
#define MAX_NAME
Definition DNA_defs.h:50
#define MINAFRAME
#define MAXFRAME
#define RNA_POINTER_INVALIDATE(ptr)
ParameterFlag
Definition RNA_types.hh:396
@ PARM_RNAPTR
Definition RNA_types.hh:399
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_DYNAMIC
Definition RNA_types.hh:317
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
#define NC_GEOM
Definition WM_types.hh:360
#define ND_DATA
Definition WM_types.hh:475
#define NA_EDITED
Definition WM_types.hh:550
#define NC_GPENCIL
Definition WM_types.hh:366
#define NA_SELECTED
Definition WM_types.hh:555
MutableSpan< int8_t > curve_types_for_write()
bke::CurvesGeometry & strokes_for_write()
float wrap(float value, float max, float min)
Definition node_math.h:71
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, 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 RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_function_flag(FunctionRNA *func, int flag)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
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 RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_api_grease_pencil_drawing(StructRNA *srna)
void RNA_api_grease_pencil_frames(StructRNA *srna)
const EnumPropertyItem rna_enum_tree_node_move_type_items[]
void RNA_api_grease_pencil_layer(StructRNA *srna)
void RNA_api_grease_pencil_layers(StructRNA *srna)
void RNA_api_grease_pencil_layer_groups(StructRNA *srna)
Definition DNA_ID.h:413
int us
Definition DNA_ID.h:435
void * data
Definition RNA_types.hh:42
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126