GPv3: Active layer poll
This is required to avoid execution of operator and disable them in UI when object has no active layer (this is same as legacy GP) Pull Request: https://projects.blender.org/blender/blender/pulls/118609
This commit is contained in:
committed by
Pratik Borhade
parent
7ae8e1dc07
commit
2bad37a219
@@ -114,7 +114,7 @@ static void GREASE_PENCIL_OT_layer_remove(wmOperatorType *ot)
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = grease_pencil_layer_remove_exec;
|
||||
ot->poll = active_grease_pencil_poll;
|
||||
ot->poll = active_grease_pencil_layer_poll;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
@@ -420,7 +420,7 @@ static void GREASE_PENCIL_OT_layer_isolate(wmOperatorType *ot)
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = grease_pencil_layer_isolate_exec;
|
||||
ot->poll = active_grease_pencil_poll;
|
||||
ot->poll = active_grease_pencil_layer_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
@@ -462,7 +462,7 @@ static void GREASE_PENCIL_OT_layer_lock_all(wmOperatorType *ot)
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = grease_pencil_layer_lock_all_exec;
|
||||
ot->poll = active_grease_pencil_poll;
|
||||
ot->poll = active_grease_pencil_layer_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
@@ -516,7 +516,7 @@ static void GREASE_PENCIL_OT_layer_duplicate(wmOperatorType *ot)
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = grease_pencil_layer_duplicate_exec;
|
||||
ot->poll = active_grease_pencil_poll;
|
||||
ot->poll = active_grease_pencil_layer_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
@@ -44,6 +44,16 @@ bool editable_grease_pencil_poll(bContext *C)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool active_grease_pencil_layer_poll(bContext *C)
|
||||
{
|
||||
Object *object = CTX_data_active_object(C);
|
||||
if (object == nullptr || object->type != OB_GREASE_PENCIL) {
|
||||
return false;
|
||||
}
|
||||
const GreasePencil *grease_pencil = static_cast<GreasePencil *>(object->data);
|
||||
return grease_pencil->has_active_layer();
|
||||
}
|
||||
|
||||
bool editable_grease_pencil_point_selection_poll(bContext *C)
|
||||
{
|
||||
if (!editable_grease_pencil_poll(C)) {
|
||||
|
||||
@@ -162,6 +162,7 @@ void create_keyframe_edit_data_selected_frames_list(KeyframeEditData *ked,
|
||||
|
||||
bool active_grease_pencil_poll(bContext *C);
|
||||
bool editable_grease_pencil_poll(bContext *C);
|
||||
bool active_grease_pencil_layer_poll(bContext *C);
|
||||
bool editable_grease_pencil_point_selection_poll(bContext *C);
|
||||
bool grease_pencil_painting_poll(bContext *C);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user