forked from bartvdbraak/blender
GPencil: H/Shift-H/Alt-H now work to Hide and Reveal Layers in Strokes Edit Mode
* H = Hide active layer * Shift-H = Hide non-active layers * Alt-H = Show all layers
This commit is contained in:
parent
146be8e258
commit
2cac2e7213
@ -350,4 +350,98 @@ void GPENCIL_OT_layer_duplicate(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* *********************** Hide Layers ******************************** */
|
||||
|
||||
static int gp_hide_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
bGPDlayer *layer = gpencil_layer_getactive(gpd);
|
||||
bool unselected = RNA_boolean_get(op->ptr, "unselected");
|
||||
|
||||
/* sanity checks */
|
||||
if (ELEM(NULL, gpd, layer))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if (unselected) {
|
||||
bGPDlayer *gpl;
|
||||
|
||||
/* hide unselected */
|
||||
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
||||
if (gpl != layer) {
|
||||
gpl->flag |= GP_LAYER_HIDE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* hide selected/active */
|
||||
layer->flag |= GP_LAYER_HIDE;
|
||||
}
|
||||
|
||||
/* notifiers */
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void GPENCIL_OT_hide(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Hide Layer(s)";
|
||||
ot->idname = "GPENCIL_OT_hide";
|
||||
ot->description = "Hide selected/unselected Grease Pencil layers";
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_hide_exec;
|
||||
ot->poll = gp_active_layer_poll; /* NOTE: we need an active layer to play with */
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected layers");
|
||||
}
|
||||
|
||||
/* ********************** Show All Layers ***************************** */
|
||||
|
||||
/* poll callback for showing layers */
|
||||
static int gp_reveal_poll(bContext *C)
|
||||
{
|
||||
return ED_gpencil_data_get_active(C) != NULL;
|
||||
}
|
||||
|
||||
static int gp_reveal_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl;
|
||||
|
||||
/* sanity checks */
|
||||
if (gpd == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* make all layers visible */
|
||||
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
||||
gpl->flag &= ~GP_LAYER_HIDE;
|
||||
}
|
||||
|
||||
/* notifiers */
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void GPENCIL_OT_reveal(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Show All Layers";
|
||||
ot->idname = "GPENCIL_OT_reveal";
|
||||
ot->description = "Show all Grease Pencil layers";
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_reveal_exec;
|
||||
ot->poll = gp_reveal_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ************************************************ */
|
||||
|
@ -144,6 +144,9 @@ void GPENCIL_OT_layer_remove(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_move(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_duplicate(struct wmOperatorType *ot);
|
||||
|
||||
void GPENCIL_OT_hide(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_reveal(struct wmOperatorType *ot);
|
||||
|
||||
void GPENCIL_OT_active_frame_delete(struct wmOperatorType *ot);
|
||||
|
||||
void GPENCIL_OT_convert(struct wmOperatorType *ot);
|
||||
|
@ -181,7 +181,18 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
|
||||
#ifdef __APPLE__
|
||||
WM_keymap_add_item(keymap, "GPENCIL_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
|
||||
WM_keymap_add_item(keymap, "GPENCIL_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Show/Hide */
|
||||
/* NOTE: These are available only in EditMode now, since they clash with general-purpose hotkeys */
|
||||
WM_keymap_add_item(keymap, "GPENCIL_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_hide", HKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "unselected", false);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "unselected", true);
|
||||
|
||||
|
||||
/* Transform Tools */
|
||||
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", GKEY, KM_PRESS, 0, 0);
|
||||
@ -260,6 +271,9 @@ void ED_operatortypes_gpencil(void)
|
||||
WM_operatortype_append(GPENCIL_OT_layer_move);
|
||||
WM_operatortype_append(GPENCIL_OT_layer_duplicate);
|
||||
|
||||
WM_operatortype_append(GPENCIL_OT_hide);
|
||||
WM_operatortype_append(GPENCIL_OT_reveal);
|
||||
|
||||
WM_operatortype_append(GPENCIL_OT_active_frame_delete);
|
||||
|
||||
WM_operatortype_append(GPENCIL_OT_convert);
|
||||
|
Loading…
Reference in New Issue
Block a user