53 const Bone *bone = pchan->bone_get(*parent);
68 const bool keep_transform)
74 layer.parent = parent;
79 if (
layer.parsubstr) {
94 if (
layer.parent ==
nullptr) {
101 layer.parent =
nullptr;
102 MEM_SAFE_DELETE(
layer.parsubstr);
111 if (
layer !=
nullptr) {
112 layer->set_selected(
true);
141 GreasePencilv3LayerGroup,
164 IFACE_(
"Add New Grease Pencil Layer"),
171 ot->
name =
"Add New Layer";
172 ot->
idname =
"GREASE_PENCIL_OT_layer_add";
173 ot->
description =
"Add a new Grease Pencil layer in the active object";
183 ot->
srna,
"new_layer_name",
"Layer",
INT16_MAX,
"Name",
"Name of the new layer");
213 ot->
name =
"Remove Layer";
214 ot->
idname =
"GREASE_PENCIL_OT_layer_remove";
215 ot->
description =
"Remove the active Grease Pencil layer";
229 {0,
nullptr, 0,
nullptr,
nullptr},
242 if (active_node ==
nullptr) {
284 ot->
name =
"Reorder Layer";
285 ot->
idname =
"GREASE_PENCIL_OT_layer_move";
286 ot->
description =
"Move the active Grease Pencil layer or Group";
304 if (!
grease_pencil.layers().index_range().contains(layer_index)) {
317 GreasePencilv3LayerGroup,
333 ot->
name =
"Set Active Layer";
334 ot->
idname =
"GREASE_PENCIL_OT_layer_active";
335 ot->
description =
"Set the active Grease Pencil layer";
353 std::string new_layer_group_name =
RNA_string_get(op->
ptr,
"new_layer_group_name");
370 GreasePencilv3LayerGroup,
389 ot->
name =
"Add New Layer Group";
390 ot->
idname =
"GREASE_PENCIL_OT_layer_group_add";
391 ot->
description =
"Add a new Grease Pencil layer group in the active object";
400 ot->
srna,
"new_layer_group_name",
nullptr,
INT16_MAX,
"Name",
"Name of the new layer group");
431 ot->
name =
"Remove Layer Group";
432 ot->
idname =
"GREASE_PENCIL_OT_layer_group_remove";
433 ot->
description =
"Remove Grease Pencil layer group in the active object";
444 "Keep children nodes",
445 "Keep the children nodes of the group and only delete the group itself");
465 bool should_be_visible =
false;
468 should_be_visible =
node->is_child_of(active_node->
as_group());
469 if (
node->is_group()) {
470 should_be_visible |= active_node->is_child_of(
node->as_group());
473 else if (
node->is_group()) {
474 should_be_visible = active_node->is_child_of(
node->as_group());
477 node->set_visible(should_be_visible);
479 active_node->set_visible(
true);
483 active_node->set_visible(
false);
497 ot->
name =
"Hide Layer(s)";
498 ot->
idname =
"GREASE_PENCIL_OT_layer_hide";
499 ot->
description =
"Hide selected/unselected Grease Pencil layers";
510 ot->
srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected layers");
525 node->set_visible(
true);
539 ot->
name =
"Show All Layers";
540 ot->
idname =
"GREASE_PENCIL_OT_layer_reveal";
556 bool isolate =
false;
562 if ((affect_visibility &&
layer->is_visible()) || !
layer->is_locked()) {
570 layer->set_locked(
false);
571 if (affect_visibility) {
572 layer->set_visible(
true);
576 layer->set_locked(
true);
577 if (affect_visibility) {
578 layer->set_visible(
false);
593 ot->
name =
"Isolate Layers";
594 ot->
idname =
"GREASE_PENCIL_OT_layer_isolate";
595 ot->
description =
"Make only active layer visible/editable";
606 ot->
srna,
"affect_visibility",
false,
"Affect Visibility",
"Also affect the visibility");
620 node->set_locked(lock_value);
633 ot->
name =
"Lock All Layers";
634 ot->
idname =
"GREASE_PENCIL_OT_layer_lock_all";
636 "Lock all Grease Pencil layers to prevent them from being accidentally modified";
662 const bool duplicate_frames =
true;
663 const bool duplicate_drawings = !empty_keyframes;
665 active_layer, duplicate_frames, duplicate_drawings);
685 ot->
name =
"Duplicate Layer";
686 ot->
idname =
"GREASE_PENCIL_OT_layer_duplicate";
687 ot->
description =
"Make a copy of the active Grease Pencil layer";
697 RNA_def_boolean(ot->
srna,
"empty_keyframes",
false,
"Empty Keyframes",
"Add Empty Keyframes");
715 std::string merged_layer_name;
723 if (prev_node ==
nullptr || !prev_node->wrap().is_layer()) {
727 const Layer &prev_layer = prev_node->wrap().as_layer();
729 const int prev_layer_index = *
grease_pencil.get_layer_index(prev_layer);
730 const int active_layer_index = *
grease_pencil.get_layer_index(active_layer);
735 if (layer_i == active_layer_index) {
738 else if (layer_i == prev_layer_index) {
740 src_layer_indices_by_dst_layer.
append({prev_layer_index, active_layer_index});
744 src_layer_indices_by_dst_layer.
append({layer_i});
749 merged_layer_name =
grease_pencil.layer(prev_layer_index).name();
758 if (active_group.
layers().is_empty()) {
774 if (!
layer.is_child_of(active_group)) {
775 src_layer_indices_by_dst_layer.
append({layer_i});
781 src_layer_indices_by_dst_layer.
append(indices);
784 merged_layer_name = active_group.name();
791 GreasePencilv3LayerGroup,
796 *bmain,
grease_pencil.layer(indices[0]).as_node(), merged_layer_name);
809 for (
const int layer_i :
grease_pencil.layers().index_range()) {
812 src_layer_indices_by_dst_layer.
append(indices);
814 merged_layer_name =
N_(
"Layer");
816 *bmain,
grease_pencil.layer(indices[0]).as_node(), merged_layer_name);
825 grease_pencil, src_layer_indices_by_dst_layer, *merged_grease_pencil);
854 "Combine the active layer with the layer just below (if it exists)"},
859 "Combine layers in the active group into a single layer"},
860 {int(
MergeMode::All),
"ALL", 0,
"All",
"Combine all layers into a single layer"},
861 {0,
nullptr, 0,
nullptr,
nullptr},
865 ot->
idname =
"GREASE_PENCIL_OT_layer_merge";
866 ot->
description =
"Combine layers based on the mode into one layer";
902 LayerMask *new_mask = MEM_new<LayerMask>(__func__, mask_name);
921 ot->
name =
"Add New Mask Layer";
922 ot->
idname =
"GREASE_PENCIL_OT_layer_mask_add";
945 return !active_layer.
masks.is_empty();
978 ot->
name =
"Remove Mask Layer";
979 ot->
idname =
"GREASE_PENCIL_OT_layer_mask_remove";
999 return active_layer.
masks.count() > 1;
1013 bool changed =
false;
1037 ot->
name =
"Reorder Grease Pencil Layer Mask";
1038 ot->
idname =
"GREASE_PENCIL_OT_layer_mask_reorder";
1039 ot->
description =
"Reorder the active Grease Pencil mask layer up/down in the list";
1061 {0,
nullptr, 0,
nullptr,
nullptr},
1082 ot->
name =
"Grease Pencil Group Color Tag";
1083 ot->
idname =
"GREASE_PENCIL_OT_layer_group_color_tag";
1103 const int current_frame)
1106 BLI_assert(&src_grease_pencil != &dst_grease_pencil);
1109 const int src_layer_index = *src_grease_pencil.get_layer_index(src_layer);
1111 Layer &dst_layer = dst_grease_pencil.add_layer(src_layer.name());
1112 const int dst_layer_index = dst_grease_pencil.layers().size() - 1;
1129 reader.
varray.
get(src_layer_index, buffer);
1135 std::optional<int> frame_select = std::nullopt;
1137 frame_select = current_frame;
1139 dst_grease_pencil.copy_frames_from_layer(dst_layer, src_grease_pencil, src_layer, frame_select);
1147 const int current_frame = scene->
r.
cfra;
1148 const GreasePencil &src_grease_pencil = *id_cast<GreasePencil *>(src_object->
data);
1156 GreasePencil &dst_grease_pencil = *id_cast<GreasePencil *>(ob->data);
1159 const Layer &active_layer = *src_grease_pencil.get_active_layer();
1161 dst_grease_pencil, src_grease_pencil, active_layer, copy_frame_mode, current_frame);
1164 for (
const Layer *
layer : src_grease_pencil.layers()) {
1166 dst_grease_pencil, src_grease_pencil, *
layer, copy_frame_mode, current_frame);
1181 ot->
name =
"Duplicate Layer to New Object";
1182 ot->
idname =
"GREASE_PENCIL_OT_layer_duplicate_object";
1183 ot->
description =
"Make a copy of the active Grease Pencil layer to selected object";
1196 "Copy only active Layer, uncheck to append all layers");
1201 {0,
nullptr, 0,
nullptr,
nullptr},
#define CTX_DATA_BEGIN(C, Type, instance, member)
Low-level operations for grease pencil.
General operations, lookup, etc. for blender objects.
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define BLI_assert_unreachable()
void get(int64_t index, void *r_value) const
void set_by_copy(int64_t index, const void *value)
constexpr IndexRange index_range() const
constexpr const char * c_str() const
void append(const T &value)
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader lookup(const StringRef name) const
GAttributeWriter lookup_or_add_for_write(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
const TreeNode & as_node() const
int64_t num_direct_nodes() const
Span< const Layer * > layers() const
Span< LayerGroup * > groups_for_write()
const TreeNode & as_node() const
const LayerGroup & as_group() const
const LayerGroup * parent_group() const
MatBase< C, R > inverse(MatBase< C, R >) RET
const CPPType & attribute_type_to_cpp_type(AttrType type)
static void GREASE_PENCIL_OT_layer_lock_all(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_layer_mask_reorder_exec(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_layer_mask_remove_exec(bContext *C, wmOperator *)
static bool grease_pencil_layer_mask_reorder_poll(bContext *C)
static wmOperatorStatus grease_pencil_layer_move_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem enum_layer_move_direction[]
static wmOperatorStatus grease_pencil_layer_hide_exec(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_layer_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
GreasePencil * from_context(bContext &C)
static void GREASE_PENCIL_OT_layer_group_add(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_layer_group_add_exec(bContext *C, wmOperator *op)
void grease_pencil_layer_parent_clear(bke::greasepencil::Layer &layer, const bool keep_transform)
static wmOperatorStatus grease_pencil_merge_layer_exec(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_layer_active_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_layer_group_color_tag(wmOperatorType *ot)
static float4x4 get_bone_mat(const Object *parent, const char *parsubstr)
static void GREASE_PENCIL_OT_layer_remove(wmOperatorType *ot)
static void GREASE_PENCIL_OT_layer_isolate(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_layer_duplicate_object_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_layer_hide(wmOperatorType *ot)
static void GREASE_PENCIL_OT_layer_merge(wmOperatorType *ot)
static void copy_layer_and_frames_to_target_object(GreasePencil &dst_grease_pencil, const GreasePencil &src_grease_pencil, const bke::greasepencil::Layer &src_layer, const DuplicateCopyMode copy_frame_mode, const int current_frame)
static void GREASE_PENCIL_OT_layer_add(wmOperatorType *ot)
static bool grease_pencil_layer_mask_poll(bContext *C)
static wmOperatorStatus grease_pencil_layer_add_exec(bContext *C, wmOperator *op)
bool editable_grease_pencil_poll(bContext *C)
static void GREASE_PENCIL_OT_layer_mask_add(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_layer_mask_add_exec(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_layer_remove_exec(bContext *C, wmOperator *)
static void GREASE_PENCIL_OT_layer_active(wmOperatorType *ot)
const EnumPropertyItem enum_layergroup_color_items[]
static void GREASE_PENCIL_OT_layer_move(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_layer_lock_all_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_layer_duplicate_object(wmOperatorType *ot)
static void GREASE_PENCIL_OT_layer_group_remove(wmOperatorType *ot)
static void GREASE_PENCIL_OT_layer_duplicate(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_layer_group_remove_exec(bContext *C, wmOperator *op)
bool grease_pencil_layer_parent_set(bke::greasepencil::Layer &layer, Object *parent, StringRefNull bone, const bool keep_transform)
bool grease_pencil_context_poll(bContext *C)
static wmOperatorStatus grease_pencil_layer_duplicate_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_layer_mask_reorder(wmOperatorType *ot)
void merge_layers(const GreasePencil &src_grease_pencil, const Span< Vector< int > > src_layer_indices_by_dst_layer, GreasePencil &dst_grease_pencil)
bool active_grease_pencil_layer_group_poll(bContext *C)
static wmOperatorStatus grease_pencil_layer_group_color_tag_exec(bContext *C, wmOperator *op)
void select_layer_channel(GreasePencil &grease_pencil, bke::greasepencil::Layer *layer)
static void GREASE_PENCIL_OT_layer_reveal(wmOperatorType *ot)
bool active_grease_pencil_layer_poll(bContext *C)
static wmOperatorStatus grease_pencil_layer_reveal_exec(bContext *C, wmOperator *)
static void GREASE_PENCIL_OT_layer_mask_remove(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_layer_isolate_exec(bContext *C, wmOperator *op)
static bool grease_pencil_layer_move_poll(bContext *C)
CartesianBasis invert(const CartesianBasis &basis)
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
int RNA_enum_get(PointerRNA *ptr, const char *name)
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_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
int RNA_int_get(PointerRNA *ptr, const char *name)
MatBase< float, 4, 4 > float4x4
void BKE_grease_pencil_copy_layer_parameters(const bke::greasepencil::Layer &src, bke::greasepencil::Layer &dst)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_grease_pencil_nomain_to_grease_pencil(GreasePencil *grease_pencil_src, GreasePencil *grease_pencil_dst)
void * BLI_findstring_ptr(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
void ED_operatortypes_grease_pencil_layers()
void BKE_grease_pencil_copy_parameters(const GreasePencil &src, GreasePencil &dst)
void unit_m4(float m[4][4])
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
wmOperatorStatus WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag 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)
Main * CTX_data_main(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
std::string RNA_string_get(PointerRNA *ptr, const char *name)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
@ BONE_RELATIVE_PARENTING
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
Object * CTX_data_active_object(const bContext *C)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
GreasePencil * BKE_grease_pencil_new_nomain()
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
struct GreasePencilLayerTreeNode * prev
ListBaseT< GreasePencilLayerMask > masks
static MatBase identity()
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)