Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-12-29 15:15:42 +0300
committerTon Roosendaal <ton@blender.org>2008-12-29 15:15:42 +0300
commit1580b6bc171ed33f8006a240c0c8379405fa8c27 (patch)
tree003472b1c414990044d6369b2760e5fdb2092e70 /source/blender/editors
parent3e29ff72049f4dc831e568e5a7ecfd13348a147c (diff)
2.5
More notifier cleanups: NC_SCENE|ND_OB_SELECT : scene level object selections changed NC_SCENE|ND_OB_ACTIVE : scene level, new active object NC_OBJECT|ND_BONE_SELECT : object level, bone selection changed NC_OBJECT|ND_BONE_ACTIVE: object level, new active bone I've made view3d listen to these, so operators that change selections don't have to tag own region for redraw anymore. Also enabled selecting/activating in outliner again. BTW: Added it in space_action, but Joshua has to code the proper refresh still :)
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_object.h7
-rw-r--r--source/blender/editors/object/object_edit.c64
-rw-r--r--source/blender/editors/space_action/space_action.c9
-rw-r--r--source/blender/editors/space_outliner/outliner.c46
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c27
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c139
7 files changed, 174 insertions, 128 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 3a1e22063dc..c1f7e80d7b6 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -30,10 +30,17 @@
struct wmWindowManager;
struct Object;
+struct bContext;
+struct Base;
void ED_operatortypes_object(void);
void ED_keymap_object(struct wmWindowManager *wm);
+ /* send your own notifier for select! */
+void ED_base_object_select(struct Base *base, short mode);
+ /* includes notifier */
+void ED_base_object_activate(struct bContext *C, Base *base);
+
/* cleanup */
int object_data_is_libdata(struct Object *ob);
int object_is_libdata(struct Object *ob);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 6d5997e4a2a..4e32c6ace81 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -142,13 +142,67 @@ static void EM_select_flush() {}
/* port over here */
static bContext *C;
-static void set_active_base() {}
static void error_libdata() {}
/* ********************************** */
/* --------------------------------- */
+/* simple API for object selection, rather than just using the flag
+ * this takes into account the 'restrict selection in 3d view' flag.
+ * deselect works always, the restriction just prevents selection */
+
+/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! */
+
+void ED_base_object_select(Base *base, short mode)
+{
+ if (base) {
+ if (mode==BA_SELECT) {
+ if (!(base->object->restrictflag & OB_RESTRICT_SELECT))
+ if (mode==BA_SELECT) base->flag |= SELECT;
+ }
+ else if (mode==BA_DESELECT) {
+ base->flag &= ~SELECT;
+ }
+ base->object->flag= base->flag;
+ }
+}
+
+/* also to set active NULL */
+void ED_base_object_activate(bContext *C, Base *base)
+{
+ Scene *scene= CTX_data_scene(C);
+ Base *tbase;
+
+ /* activating a non-mesh, should end a couple of modes... */
+ // if(base && base->object->type!=OB_MESH)
+ // XXX exit_paint_modes();
+
+ /* sets scene->basact */
+ BASACT= base;
+
+ if(base) {
+
+ /* XXX old signals, remember to handle notifiers now! */
+ // allqueue(REDRAWIPO, base->object->ipowin);
+ // select_actionchannel_by_name(base->object->action, "Object", 1);
+
+ /* disable temporal locks */
+ for(tbase=FIRSTBASE; tbase; tbase= tbase->next) {
+ if(base!=tbase && (tbase->object->shapeflag & OB_SHAPE_TEMPLOCK)) {
+ tbase->object->shapeflag &= ~OB_SHAPE_TEMPLOCK;
+ DAG_object_flush_update(scene, tbase->object, OB_RECALC_DATA);
+ }
+ }
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, base->object);
+ }
+ else
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, NULL);
+}
+
+
+
+
/*
* Returns true if the Object is a from an external blend file (libdata)
*/
@@ -197,7 +251,7 @@ void add_object_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menu
// XXX if (G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */
ob= add_object(type);
- set_active_base(BASACT);
+// ED_base_object_activate(C, BASACT);
base_init_from_view3d(BASACT, v3d);
/* only undo pushes on objects without editmode... */
@@ -2791,7 +2845,7 @@ void convertmenu(Scene *scene, View3D *v3d)
/* If the original object is active then make this object active */
if (ob == obact) {
- set_active_base( basen );
+ // XXX ED_base_object_activate(C, basen);
basact = basen;
}
}
@@ -2886,7 +2940,7 @@ void convertmenu(Scene *scene, View3D *v3d)
/* If the original object is active then make this object active */
if (ob == obact) {
- set_active_base( basen );
+ // XXX ED_base_object_activate(C, basen);
basact = basen;
}
@@ -5113,7 +5167,7 @@ void adduplicate(Scene *scene, View3D *v3d, int mode, int dupflag)
// initTransform(TFM_TRANSLATION, CTX_NONE);
// Transform();
}
- set_active_base(BASACT);
+ // XXX ED_base_object_activate(C, BASACT);
if(mode!=2) { /* mode of 2 is used by python to avoid unrequested redraws */
allqueue(REDRAWNLA, 0);
allqueue(REDRAWACTION, 0); /* also oops */
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index f772896a5a3..9545421b7ef 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -292,12 +292,21 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn)
switch(wmn->category) {
case NC_SCENE:
switch(wmn->data) {
+ case ND_OB_ACTIVE:
case ND_FRAME:
case ND_MARKERS:
ED_region_tag_redraw(ar);
break;
}
break;
+ case NC_OBJECT:
+ switch(wmn->data) {
+ case ND_BONE_ACTIVE:
+ case ND_BONE_SELECT:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
}
}
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c
index 3afea2a2eb9..f6047765bc5 100644
--- a/source/blender/editors/space_outliner/outliner.c
+++ b/source/blender/editors/space_outliner/outliner.c
@@ -95,6 +95,8 @@
#include "UI_view2d.h"
#include "UI_text.h"
+#include "ED_object.h"
+
#include "outliner_intern.h"
#ifdef INTERNATIONAL
@@ -1440,7 +1442,7 @@ static int tree_element_active_renderlayer(TreeElement *te, TreeStoreElem *tsele
return 0;
}
-static void tree_element_active_object(Scene *scene, SpaceOops *soops, TreeElement *te)
+static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te)
{
TreeStoreElem *tselem= TREESTORE(te);
Scene *sce;
@@ -1468,9 +1470,10 @@ static void tree_element_active_object(Scene *scene, SpaceOops *soops, TreeEleme
if(base) {
if(shift) {
/* swap select */
- if(base->flag & SELECT) base->flag &= ~SELECT;
- else if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) base->flag |= SELECT;
- base->object->flag= base->flag;
+ if(base->flag & SELECT)
+ ED_base_object_select(base, BA_DESELECT);
+ else
+ ED_base_object_select(base, BA_SELECT);
}
else {
Base *b;
@@ -1479,16 +1482,10 @@ static void tree_element_active_object(Scene *scene, SpaceOops *soops, TreeEleme
b->flag &= ~SELECT;
b->object->flag= b->flag;
}
- if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) {
- base->flag |= SELECT;
- base->object->flag |= SELECT;
- }
+ ED_base_object_select(base, BA_SELECT);
}
-// XXX set_active_base(base); /* editview.c */
-
- allqueue(REDRAWVIEW3D, 1);
- allqueue(REDRAWOOPS, 0);
- allqueue(REDRAWINFO, 1);
+ if(C)
+ ED_base_object_activate(C, base); /* adds notifier */
}
// XXX if(ob!=G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
@@ -1981,7 +1978,8 @@ static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeS
}
/* generic call for non-id data to make/check active in UI */
-static int tree_element_type_active(Scene *scene, SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set)
+/* Context can be NULL when set==0 */
+static int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set)
{
switch(tselem->type) {
@@ -1996,7 +1994,7 @@ static int tree_element_type_active(Scene *scene, SpaceOops *soops, TreeElement
case TSE_MODIFIER:
return tree_element_active_modifier(te, tselem, set);
case TSE_LINKED_OB:
- if(set) tree_element_active_object(scene, soops, te);
+ if(set) tree_element_set_active_object(C, scene, soops, te);
else if(tselem->id==(ID *)OBACT) return 1;
break;
case TSE_LINKED_PSYS:
@@ -2023,7 +2021,7 @@ static int tree_element_type_active(Scene *scene, SpaceOops *soops, TreeElement
return 0;
}
-static int do_outliner_mouse_event(Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, short event, float *mval)
+static int do_outliner_mouse_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, short event, float *mval)
{
int shift= 0, ctrl= 0; // XXX
@@ -2073,7 +2071,7 @@ static int do_outliner_mouse_event(Scene *scene, ARegion *ar, SpaceOops *soops,
} else {
/* always makes active object */
if(tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP)
- tree_element_active_object(scene, soops, te);
+ tree_element_set_active_object(C, scene, soops, te);
if(tselem->type==0) { // the lib blocks
/* editmode? */
@@ -2094,7 +2092,7 @@ static int do_outliner_mouse_event(Scene *scene, ARegion *ar, SpaceOops *soops,
}
}
- else tree_element_type_active(scene, soops, te, tselem, 1);
+ else tree_element_type_active(C, scene, soops, te, tselem, 1);
}
}
else if(event==RIGHTMOUSE) {
@@ -2117,7 +2115,7 @@ static int do_outliner_mouse_event(Scene *scene, ARegion *ar, SpaceOops *soops,
}
for(te= te->subtree.first; te; te= te->next) {
- if(do_outliner_mouse_event(scene, ar, soops, te, event, mval)) return 1;
+ if(do_outliner_mouse_event(C, scene, ar, soops, te, event, mval)) return 1;
}
return 0;
}
@@ -2134,7 +2132,7 @@ static int outliner_activate_click(bContext *C, wmOperator *op, wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
for(te= soops->tree.first; te; te= te->next) {
- if(do_outliner_mouse_event(scene, ar, soops, te, event->type, fmval)) break;
+ if(do_outliner_mouse_event(C, scene, ar, soops, te, event->type, fmval)) break;
}
if(te) {
@@ -3183,7 +3181,7 @@ static void outliner_draw_iconrow(Scene *scene, SpaceOops *soops, ListBase *lb,
else if(G.obedit && G.obedit->data==tselem->id) active= 1;
else active= tree_element_active(scene, soops, te, 0);
}
- else active= tree_element_type_active(scene, soops, te, tselem, 0);
+ else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0);
if(active) {
uiSetRoundBox(15);
@@ -3258,7 +3256,7 @@ static void outliner_draw_tree_element(Scene *scene, ARegion *ar, SpaceOops *soo
}
}
else {
- if( tree_element_type_active(scene, soops, te, tselem, 0) ) active= 2;
+ if( tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active= 2;
glColor4ub(220, 220, 255, 100);
}
@@ -3619,7 +3617,7 @@ static void namebutton_cb(bContext *C, void *tep, void *oldnamep)
char newname[32];
// always make current object active
- tree_element_active_object(scene, soops, te);
+ tree_element_set_active_object(C, scene, soops, te);
ob= OBACT;
/* restore bone name */
@@ -3638,7 +3636,7 @@ static void namebutton_cb(bContext *C, void *tep, void *oldnamep)
char newname[32];
// always make current object active
- tree_element_active_object(scene, soops, te);
+ tree_element_set_active_object(C, scene, soops, te);
ob= OBACT;
/* restore bone name */
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index b84e337625a..35fb0cd0371 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -539,6 +539,32 @@ static void outliner_main_area_free(ARegion *ar)
{
}
+
+static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
+{
+ /* context changes */
+ switch(wmn->category) {
+ case NC_SCENE:
+ switch(wmn->data) {
+ case ND_OB_ACTIVE:
+ case ND_OB_SELECT:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_OBJECT:
+ switch(wmn->data) {
+ case ND_BONE_ACTIVE:
+ case ND_BONE_SELECT:
+ case ND_TRANSFORM:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ }
+
+}
+
+
/* ************************ header outliner area region *********************** */
/* add handlers, stuff you only do once or on area/region changes */
@@ -688,6 +714,7 @@ void ED_spacetype_outliner(void)
art->init= outliner_main_area_init;
art->draw= outliner_main_area_draw;
art->free= outliner_main_area_free;
+ art->listener= outliner_main_area_listener;
BLI_addhead(&st->regiontypes, art);
/* regions: header */
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 1503dd878d3..87b6a047ec6 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -211,10 +211,20 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
case NC_SCENE:
switch(wmn->data) {
case ND_FRAME:
+ case ND_OB_ACTIVE:
+ case ND_OB_SELECT:
ED_region_tag_redraw(ar);
break;
}
break;
+ case NC_OBJECT:
+ switch(wmn->data) {
+ case ND_BONE_ACTIVE:
+ case ND_BONE_SELECT:
+ case ND_TRANSFORM:
+ ED_region_tag_redraw(ar);
+ break;
+ }
}
}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 441f96ef5ff..1f8910d5392 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -75,6 +75,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "ED_object.h"
#include "ED_screen.h"
#include "ED_types.h"
@@ -181,22 +182,6 @@ void arrows_move_cursor(unsigned short event)
#endif
}
-/* simple API for object selection, rather than just using the flag
- * this takes into account the 'restrict selection in 3d view' flag.
- * deselect works always, the restriction just prevents selection */
-void select_base_v3d(Base *base, short mode)
-{
- if (base) {
- if (mode==BA_SELECT) {
- if (!(base->object->restrictflag & OB_RESTRICT_SELECT))
- if (mode==BA_SELECT) base->flag |= SELECT;
- }
- else if (mode==BA_DESELECT) {
- base->flag &= ~SELECT;
- }
- base->object->flag= base->flag;
- }
-}
/* *********************** GESTURE AND LASSO ******************* */
@@ -345,8 +330,8 @@ static void do_lasso_select_objects(Scene *scene, ARegion *ar, View3D *v3d, shor
project_short(ar, v3d, base->object->obmat[3], &base->sx);
if(lasso_inside(mcords, moves, base->sx, base->sy)) {
- if(select) select_base_v3d(base, BA_SELECT);
- else select_base_v3d(base, BA_DESELECT);
+ if(select) ED_base_object_select(base, BA_SELECT);
+ else ED_base_object_select(base, BA_DESELECT);
base->object->flag= base->flag;
}
if(base->object->flag & OB_POSEMODE) {
@@ -736,42 +721,6 @@ static unsigned int samplerect(unsigned int *buf, int size, unsigned int dontdo)
/* The max number of menu items in an object select menu */
#define SEL_MENU_SIZE 22
-void set_active_base(Scene *scene, Base *base)
-{
- Base *tbase;
-
- /* activating a non-mesh, should end a couple of modes... */
-// if(base && base->object->type!=OB_MESH)
-// XXX exit_paint_modes();
-
- /* sets scene->basact */
- BASACT= base;
-
- if(base) {
-
- /* signals to buttons */
-// redraw_test_buttons(base->object);
-
- /* signal to ipo */
-// allqueue(REDRAWIPO, base->object->ipowin);
-
-// allqueue(REDRAWACTION, 0);
-// allqueue(REDRAWNLA, 0);
-// allqueue(REDRAWNODE, 0);
-
- /* signal to action */
-// select_actionchannel_by_name(base->object->action, "Object", 1);
-
- /* disable temporal locks */
- for(tbase=FIRSTBASE; tbase; tbase= tbase->next) {
- if(base!=tbase && (tbase->object->shapeflag & OB_SHAPE_TEMPLOCK)) {
- tbase->object->shapeflag &= ~OB_SHAPE_TEMPLOCK;
- DAG_object_flush_update(scene, tbase->object, OB_RECALC_DATA);
- }
- }
- }
-}
-
static void deselectall_except(Scene *scene, Base *b) /* deselect all except b */
{
@@ -780,7 +729,7 @@ static void deselectall_except(Scene *scene, Base *b) /* deselect all except b
for(base= FIRSTBASE; base; base= base->next) {
if (base->flag & SELECT) {
if(b!=base) {
- select_base_v3d(base, BA_DESELECT);
+ ED_base_object_select(base, BA_DESELECT);
}
}
}
@@ -896,8 +845,11 @@ static short mixed_bones_object_selectbuffer(Scene *scene, ARegion *ar, View3D *
}
/* mval is region coords */
-static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
+static void mouse_select(bContext *C, short *mval)
{
+ ARegion *ar= CTX_wm_region(C);
+ View3D *v3d= (View3D *)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
Base *base, *startbase=NULL, *basact=NULL, *oldbasact=NULL;
unsigned int buffer[4*MAXPICKBUF];
int temp, a, dist=100;
@@ -1047,6 +999,10 @@ static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
/* prevent activating */
basact= NULL;
}
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, basact->object);
+ WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object);
+
}
/* prevent bone selecting to pass on to object selecting */
if(basact==BASACT)
@@ -1061,7 +1017,7 @@ static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
if(G.obedit) {
/* only do select */
deselectall_except(scene, basact);
- select_base_v3d(basact, BA_SELECT);
+ ED_base_object_select(basact, BA_SELECT);
}
/* also prevent making it active on mouse selection */
else if (BASE_SELECTABLE(v3d, basact)) {
@@ -1071,7 +1027,7 @@ static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
if(shift==0) {
deselectall_except(scene, basact);
- select_base_v3d(basact, BA_SELECT);
+ ED_base_object_select(basact, BA_SELECT);
}
else if(shift && alt) {
// XXX select_all_from_groups(basact);
@@ -1079,33 +1035,20 @@ static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
else {
if(basact->flag & SELECT) {
if(basact==oldbasact)
- select_base_v3d(basact, BA_DESELECT);
+ ED_base_object_select(basact, BA_DESELECT);
}
- else select_base_v3d(basact, BA_SELECT);
+ else ED_base_object_select(basact, BA_SELECT);
}
if(oldbasact != basact) {
- set_active_base(scene, basact);
+ ED_base_object_activate(C, basact); /* adds notifier */
}
- /* for visual speed, only in wire mode */
- if(v3d->drawtype==OB_WIRE) {
- /* however, not for posemodes */
-// XXX if(basact->object->flag & OB_POSEMODE);
-// else if(oldbasact && (oldbasact->object->flag & OB_POSEMODE));
-// else {
-// if(oldbasact && oldbasact != basact && (oldbasact->lay & v3d->lay))
-// draw_object_ext(oldbasact);
-// draw_object_ext(basact);
-// }
- }
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
}
}
- /* note; make it notifier! */
- ED_region_tag_redraw(ar);
-
}
/* ******************** border and circle ************************************** */
@@ -1416,6 +1359,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
if (hits>0) { /* no need to loop if there's no hit */
base= FIRSTBASE;
col = vbuffer + 3;
+
while(base && hits) {
Base *next = base->next;
if(base->lay & v3d->lay) {
@@ -1436,9 +1380,9 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
}
else if(!bone_only) {
if (selecting)
- select_base_v3d(base, BA_SELECT);
+ ED_base_object_select(base, BA_SELECT);
else
- select_base_v3d(base, BA_DESELECT);
+ ED_base_object_select(base, BA_DESELECT);
}
col+=4; /* next color */
@@ -1449,6 +1393,9 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
base= next;
}
+
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
+
}
MEM_freeN(vbuffer);
}
@@ -1488,10 +1435,7 @@ void VIEW3D_OT_borderselect(wmOperatorType *ot)
static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
- View3D *v3d= sa->spacedata.first;
- Scene *scene= CTX_data_scene(C);
short mval[2];
mval[0]= event->x - ar->winrct.xmin;
@@ -1499,7 +1443,7 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
view3d_operator_needs_opengl(C);
- mouse_select(scene, ar, v3d, mval);
+ mouse_select(C, mval);
return OPERATOR_FINISHED;
}
@@ -1533,20 +1477,19 @@ static EnumPropertyItem prop_select_object_types[] = {
static int view3d_select_by_type_exec(bContext *C, wmOperator *op)
{
- ARegion *ar= CTX_wm_region(C);
short obtype;
obtype = RNA_enum_get(op->ptr, "type");
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
if(base->object->type==obtype) {
- select_base_v3d(base, BA_SELECT);
+ ED_base_object_select(base, BA_SELECT);
}
}
CTX_DATA_END;
/* undo? */
- ED_region_tag_redraw(ar);
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -1573,19 +1516,18 @@ void VIEW3D_OT_select_by_type(wmOperatorType *ot)
static int view3d_select_by_layer_exec(bContext *C, wmOperator *op)
{
- ARegion *ar= CTX_wm_region(C);
unsigned int layernum;
layernum = RNA_int_get(op->ptr, "layer");
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
if(base->lay == (1<< (layernum -1)))
- select_base_v3d(base, BA_SELECT);
+ ED_base_object_select(base, BA_SELECT);
}
CTX_DATA_END;
/* undo? */
- ED_region_tag_redraw(ar);
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -1615,18 +1557,17 @@ static int view3d_select_invert_exec(bContext *C, wmOperator *op)
{
ScrArea *sa= CTX_wm_area(C);
View3D *v3d= sa->spacedata.first;
- ARegion *ar= CTX_wm_region(C);
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
if (TESTBASE(v3d, base))
- select_base_v3d(base, BA_DESELECT);
+ ED_base_object_select(base, BA_DESELECT);
else
- select_base_v3d(base, BA_SELECT);
+ ED_base_object_select(base, BA_SELECT);
}
CTX_DATA_END;
/* undo? */
- ED_region_tag_redraw(ar);
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -1649,7 +1590,6 @@ static int view3d_de_select_all_exec(bContext *C, wmOperator *op)
{
ScrArea *sa= CTX_wm_area(C);
View3D *v3d= sa->spacedata.first;
- ARegion *ar= CTX_wm_region(C);
int a=0, ok=0;
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
@@ -1664,13 +1604,13 @@ static int view3d_de_select_all_exec(bContext *C, wmOperator *op)
if (!ok) return OPERATOR_PASS_THROUGH;
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
- if (a) select_base_v3d(base, BA_DESELECT);
- else select_base_v3d(base, BA_SELECT);
+ if (a) ED_base_object_select(base, BA_DESELECT);
+ else ED_base_object_select(base, BA_SELECT);
}
CTX_DATA_END;
/* undo? */
- ED_region_tag_redraw(ar);
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -1693,20 +1633,19 @@ static int view3d_select_random_exec(bContext *C, wmOperator *op)
{
ScrArea *sa= CTX_wm_area(C);
View3D *v3d= sa->spacedata.first;
- ARegion *ar= CTX_wm_region(C);
int percent;
percent = RNA_int_get(op->ptr, "percent");
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
if ((!TESTBASE(v3d, base) && (BLI_frand() * 100) < percent)) {
- select_base_v3d(base, BA_SELECT);
+ ED_base_object_select(base, BA_SELECT);
}
}
CTX_DATA_END;
/* undo? */
- ED_region_tag_redraw(ar);
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -1906,6 +1845,7 @@ void obedit_selectionCB(Scene *scene, ARegion *ar, View3D *v3d, short selecting,
// force_draw(0);
}
+/* not a real operator, only for circle test */
static int view3d_circle_select(bContext *C, wmOperator *op)
{
ScrArea *sa= CTX_wm_area(C);
@@ -1925,10 +1865,11 @@ static int view3d_circle_select(bContext *C, wmOperator *op)
int dx= base->sx-x;
int dy= base->sy-y;
if( dx*dx + dy*dy < radius*radius)
- select_base_v3d(base, BA_SELECT);
+ ED_base_object_select(base, BA_SELECT);
}
}
}
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
return 0;
}