Fix: GPv3: Wrong layer settings when adding or duplicating a layer #119821

Merged
Falk David merged 5 commits from SietseB/blender:gpv3-fix-layer-blend-mode into main 2024-03-26 11:01:11 +01:00
3 changed files with 8 additions and 4 deletions

View File

@ -89,7 +89,7 @@ class GREASE_PENCIL_MT_grease_pencil_add_layer_extra(Menu):
layout.operator("grease_pencil.layer_group_add", text="Add Group")
layout.separator()
layout.operator("grease_pencil.layer_duplicate", text="Duplicate", icon='DUPLICATE')
layout.operator("grease_pencil.layer_duplicate", text="Duplicate", icon='DUPLICATE').empty_keyframes = False
layout.operator("grease_pencil.layer_duplicate", text="Duplicate Empty Keyframes").empty_keyframes = True
layout.separator()
@ -97,7 +97,7 @@ class GREASE_PENCIL_MT_grease_pencil_add_layer_extra(Menu):
layout.operator("grease_pencil.layer_hide", icon='RESTRICT_VIEW_ON', text="Hide Others").unselected = True
layout.separator()
layout.operator("grease_pencil.layer_lock_all", icon='LOCKED', text="Lock All")
layout.operator("grease_pencil.layer_lock_all", icon='LOCKED', text="Lock All").lock = True
layout.operator("grease_pencil.layer_lock_all", icon='UNLOCKED', text="Unlock All").lock = False
layout.separator()

View File

@ -766,7 +766,7 @@ TreeNode::TreeNode()
this->parent = nullptr;
this->GreasePencilLayerTreeNode::name = nullptr;
this->flag = 0;
this->flag = GP_LAYER_TREE_NODE_HIDE_MASKS;
this->color[0] = this->color[1] = this->color[2] = 0;
}
@ -880,6 +880,7 @@ Layer::Layer()
this->frames_storage.values = nullptr;
this->frames_storage.flag = 0;
this->blend_mode = GP_LAYER_BLEND_NONE;
this->opacity = 1.0f;
this->parent = nullptr;

View File

@ -483,9 +483,12 @@ static int grease_pencil_layer_duplicate_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
/* Duplicate layer. */
Layer &active_layer = *grease_pencil.get_active_layer();
Layer &new_layer = grease_pencil.add_layer(active_layer.name());
Layer &new_layer = grease_pencil.add_layer(active_layer);
/* Clear source keyframes and recreate them with duplicated drawings. */
filedescriptor marked this conversation as resolved Outdated

Hi, can confirm the fix about lock and duplicate layer operators are correct.
But this comments looks odd :)
(Should be related to: clear default keyframe before duplicating each drawing of source layer)
Wait for Falk's reply

Hi, can confirm the fix about lock and duplicate layer operators are correct. But this comments looks odd :) (Should be related to: clear default keyframe before duplicating each drawing of source layer) Wait for Falk's reply

I made an attempt to improve the comment 🙂

I made an attempt to improve the comment :slightly_smiling_face:

I think this is good now :D

I think this is good now :D
new_layer.frames_for_write().clear();
for (auto [key, frame] : active_layer.frames().items()) {
const int duration = frame.is_implicit_hold() ? 0 : active_layer.get_frame_duration_at(key);
const int drawing_index = grease_pencil.drawings().size();