Keymap: outliner now uses A/Alt-A for selection

This commit is contained in:
2018-07-06 14:45:30 +02:00
parent 79dabc537e
commit 571e773fbe
3 changed files with 48 additions and 12 deletions

View File

@@ -880,6 +880,21 @@ bool outliner_flag_set(ListBase *lb, short flag, short set)
return changed;
}
bool outliner_flag_flip(ListBase *lb, short flag)
{
TreeElement *te;
TreeStoreElem *tselem;
bool changed = false;
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
tselem->flag ^= flag;
changed |= outliner_flag_flip(&te->subtree, flag);
}
return changed;
}
/* Restriction Columns ------------------------------- */
/* same check needed for both object operation and restrict column button func
@@ -940,16 +955,27 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot)
/* Toggle Selected (Outliner) ---------------------------------------- */
static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op))
static int outliner_select_all_exec(bContext *C, wmOperator *op)
{
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int action = RNA_enum_get(op->ptr, "action");
if (action == SEL_TOGGLE) {
action = outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1) ? SEL_DESELECT : SEL_SELECT;
}
if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1))
outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
else
outliner_flag_set(&soops->tree, TSE_SELECTED, 1);
switch (action) {
case SEL_SELECT:
outliner_flag_set(&soops->tree, TSE_SELECTED, 1);
break;
case SEL_DESELECT:
outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
break;
case SEL_INVERT:
outliner_flag_flip(&soops->tree, TSE_SELECTED);
break;
}
DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -958,18 +984,21 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
void OUTLINER_OT_selected_toggle(wmOperatorType *ot)
void OUTLINER_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Toggle Selected";
ot->idname = "OUTLINER_OT_selected_toggle";
ot->idname = "OUTLINER_OT_select_all";
ot->description = "Toggle the Outliner selection of items";
/* callbacks */
ot->exec = outliner_toggle_selected_exec;
ot->exec = outliner_select_all_exec;
ot->poll = ED_operator_outliner_active;
/* no undo or registry, UI option */
/* no undo or registry */
/* rna */
WM_operator_properties_select_all(ot);
}
/* ************************************************************** */

View File

@@ -247,6 +247,7 @@ int common_restrict_check(struct bContext *C, struct Object *ob);
int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel);
bool outliner_flag_set(ListBase *lb, short flag, short set);
bool outliner_flag_flip(ListBase *lb, short flag);
void object_toggle_visibility_cb(
struct bContext *C, struct ReportList *reports, struct Scene *scene,
@@ -305,7 +306,7 @@ void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot);
void OUTLINER_OT_select_border(struct wmOperatorType *ot);
void OUTLINER_OT_selected_toggle(struct wmOperatorType *ot);
void OUTLINER_OT_select_all(struct wmOperatorType *ot);
void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot);
void OUTLINER_OT_scroll_page(struct wmOperatorType *ot);

View File

@@ -431,7 +431,7 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_show_hierarchy);
WM_operatortype_append(OUTLINER_OT_scroll_page);
WM_operatortype_append(OUTLINER_OT_selected_toggle);
WM_operatortype_append(OUTLINER_OT_select_all);
WM_operatortype_append(OUTLINER_OT_expanded_toggle);
WM_operatortype_append(OUTLINER_OT_keyingset_add_selected);
@@ -542,7 +542,13 @@ void outliner_keymap(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "open", false); /* close */
WM_keymap_add_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
WM_keymap_add_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0);
/* keying sets - only for databrowse */