[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43504] trunk/blender/source/blender: patch [#29924] Border select tool implementation for the outliner

Campbell Barton ideasman42 at gmail.com
Wed Jan 18 22:12:52 CET 2012


Revision: 43504
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43504
Author:   campbellbarton
Date:     2012-01-18 21:12:51 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_outliner/outliner_intern.h
    trunk/blender/source/blender/editors/space_outliner/outliner_ops.c
    trunk/blender/source/blender/editors/space_outliner/outliner_select.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_intern.h	2012-01-18 20:49:47 UTC (rev 43503)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_intern.h	2012-01-18 21:12:51 UTC (rev 43504)
@@ -198,6 +198,8 @@
 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);
 

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_ops.c	2012-01-18 20:49:47 UTC (rev 43503)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_ops.c	2012-01-18 21:12:51 UTC (rev 43504)
@@ -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 @@
 	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);

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_select.c	2012-01-18 20:49:47 UTC (rev 43503)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_select.c	2012-01-18 21:12:51 UTC (rev 43504)
@@ -875,3 +875,78 @@
 }
 
 /* ****************************************************** */
+
+/* **************** 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);
+}
+
+/* ****************************************************** */

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2012-01-18 20:49:47 UTC (rev 43503)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2012-01-18 21:12:51 UTC (rev 43504)
@@ -3807,6 +3807,7 @@
 	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");



More information about the Bf-blender-cvs mailing list