forked from bartvdbraak/blender
patch [#29924] Border select tool implementation for the outliner
from Perry Parks (scuey), with edits. - select row rather than icons. - adjust outliner selection rather than object selection.
This commit is contained in:
parent
57ad3b85d8
commit
831b27791d
@ -198,6 +198,8 @@ void OUTLINER_OT_show_one_level(struct wmOperatorType *ot);
|
||||
void OUTLINER_OT_show_active(struct wmOperatorType *ot);
|
||||
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_expanded_toggle(struct wmOperatorType *ot);
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
void outliner_operatortypes(void)
|
||||
{
|
||||
WM_operatortype_append(OUTLINER_OT_item_activate);
|
||||
WM_operatortype_append(OUTLINER_OT_select_border);
|
||||
WM_operatortype_append(OUTLINER_OT_item_openclose);
|
||||
WM_operatortype_append(OUTLINER_OT_item_rename);
|
||||
WM_operatortype_append(OUTLINER_OT_operation);
|
||||
@ -89,6 +90,9 @@ void outliner_keymap(wmKeyConfig *keyconf)
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
|
||||
WM_keymap_add_item(keymap, "OUTLINER_OT_select_border", BKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_select_border", EVT_TWEAK_L, KM_ANY, 0, 0)->ptr, "tweak", 1);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "all", FALSE);
|
||||
|
@ -875,3 +875,78 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
|
||||
}
|
||||
|
||||
/* ****************************************************** */
|
||||
|
||||
/* **************** Border Select Tool ****************** */
|
||||
static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *rectf, TreeElement *te, int gesture_mode)
|
||||
{
|
||||
TreeStoreElem *tselem= TREESTORE(te);
|
||||
|
||||
if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) {
|
||||
if (gesture_mode == GESTURE_MODAL_SELECT) {
|
||||
tselem->flag |= TSE_SELECTED;
|
||||
}
|
||||
else {
|
||||
tselem->flag &= ~TSE_SELECTED;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at its children. */
|
||||
if ((tselem->flag & TSE_CLOSED) == 0) {
|
||||
for (te = te->subtree.first; te; te = te->next) {
|
||||
outliner_item_border_select(scene, soops, rectf, te, gesture_mode);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static int outliner_border_select_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
SpaceOops *soops= CTX_wm_space_outliner(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
TreeElement *te;
|
||||
rcti rect;
|
||||
rctf rectf;
|
||||
int gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
|
||||
|
||||
rect.xmin= RNA_int_get(op->ptr, "xmin");
|
||||
rect.ymin= RNA_int_get(op->ptr, "ymin");
|
||||
UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
|
||||
|
||||
rect.xmax= RNA_int_get(op->ptr, "xmax");
|
||||
rect.ymax= RNA_int_get(op->ptr, "ymax");
|
||||
UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
|
||||
|
||||
for(te= soops->tree.first; te; te= te->next) {
|
||||
outliner_item_border_select(scene, soops, &rectf, te, gesture_mode);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OUTLINER_OT_select_border(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Border Select";
|
||||
ot->idname= "OUTLINER_OT_select_border";
|
||||
ot->description= "Use box selection to select tree elements";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_border_select_invoke;
|
||||
ot->exec= outliner_border_select_exec;
|
||||
ot->modal= WM_border_select_modal;
|
||||
ot->cancel= WM_border_select_cancel;
|
||||
|
||||
ot->poll= ED_operator_outliner_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* rna */
|
||||
WM_operator_properties_gesture_border(ot, FALSE);
|
||||
}
|
||||
|
||||
/* ****************************************************** */
|
||||
|
@ -3807,6 +3807,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
|
||||
WM_modalkeymap_assign(keymap, "MARKER_OT_select_border");
|
||||
WM_modalkeymap_assign(keymap, "NLA_OT_select_border");
|
||||
WM_modalkeymap_assign(keymap, "NODE_OT_select_border");
|
||||
WM_modalkeymap_assign(keymap, "OUTLINER_OT_select_border");
|
||||
// WM_modalkeymap_assign(keymap, "SCREEN_OT_border_select"); // template
|
||||
WM_modalkeymap_assign(keymap, "SEQUENCER_OT_select_border");
|
||||
WM_modalkeymap_assign(keymap, "SEQUENCER_OT_view_ghost_border");
|
||||
|
Loading…
Reference in New Issue
Block a user