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:
authorCampbell Barton <ideasman42@gmail.com>2014-01-16 13:22:45 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-16 13:23:46 +0400
commita4e07aa825d75c98d277ef0a01c744674ffc8294 (patch)
treec45a260d4b26f1de4b63193a5dd9957d1433682b /source/blender/editors/space_outliner
parent4f87ca47a6daf7e748ed0f1f078c884a052ba7da (diff)
Code Cleanup: outliner used magic numbers for active items and selecting
Replace with enums to make it more obvious whats happening
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c45
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h22
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c329
3 files changed, 248 insertions, 148 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 2f877e56f94..b5d4734ecf7 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -480,8 +480,8 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
Object *ob;
char newname[sizeof(bone->name)];
- // always make current object active
- tree_element_active(C, scene, soops, te, 1); // was set_active_object()
+ /* always make current object active */
+ tree_element_active(C, scene, soops, te, OL_SETSEL_NORMAL);
ob = OBACT;
/* restore bone name */
@@ -497,8 +497,8 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
Object *ob;
char newname[sizeof(pchan->name)];
- // always make current object active
- tree_element_active(C, scene, soops, te, 1); // was set_active_object()
+ /* always make current pose-bone active */
+ tree_element_active(C, scene, soops, te, OL_SETSEL_NORMAL);
ob = OBACT;
/* restore bone name */
@@ -1123,7 +1123,7 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
{
TreeElement *te;
TreeStoreElem *tselem;
- int active;
+ eOLDrawState active;
for (te = lb->first; te; te = te->next) {
@@ -1139,20 +1139,20 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
/* active blocks get white circle */
if (tselem->type == 0) {
if (te->idcode == ID_OB) {
- active = (OBACT == (Object *)tselem->id);
+ active = (OBACT == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : OL_DRAWSEL_NONE;
}
else if (scene->obedit && scene->obedit->data == tselem->id) {
- active = 1; // XXX use context?
+ active = OL_DRAWSEL_NORMAL;
}
else {
- active = tree_element_active(C, scene, soops, te, 0);
+ active = tree_element_active(C, scene, soops, te, OL_SETSEL_NONE);
}
}
else {
- active = tree_element_type_active(NULL, scene, soops, te, tselem, 0, false);
+ active = tree_element_type_active(NULL, scene, soops, te, tselem, OL_SETSEL_NONE, false);
}
- if (active) {
+ if (active != OL_DRAWSEL_NONE) {
float ufac = UI_UNIT_X / 20.0f;
uiSetRoundBox(UI_CNR_ALL);
@@ -1202,7 +1202,8 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
TreeElement *ten;
TreeStoreElem *tselem;
float ufac = UI_UNIT_X / 20.0f;
- int offsx = 0, active = 0; // active=1 active obj, else active data
+ int offsx = 0;
+ eOLDrawState active = OL_DRAWSEL_NONE;
tselem = TREESTORE(te);
@@ -1240,7 +1241,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
if (te->idcode == ID_SCE) {
if (tselem->id == (ID *)scene) {
glColor4ub(255, 255, 255, alpha);
- active = 2;
+ active = OL_DRAWSEL_ACTIVE;
}
}
else if (te->idcode == ID_GR) {
@@ -1251,7 +1252,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
col[3] = alpha;
glColor4ubv((GLubyte *)col);
- active = 2;
+ active = OL_DRAWSEL_ACTIVE;
}
}
else if (te->idcode == ID_OB) {
@@ -1262,14 +1263,14 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
/* outliner active ob: always white text, circle color now similar to view3d */
- active = 2; /* means it draws a color circle */
+ active = OL_DRAWSEL_ACTIVE;
if (ob == OBACT) {
if (ob->flag & SELECT) {
UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col);
col[3] = alpha;
}
- active = 1; /* means it draws white text */
+ active = OL_DRAWSEL_NORMAL;
}
else if (ob->flag & SELECT) {
UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col);
@@ -1282,22 +1283,24 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
}
else if (scene->obedit && scene->obedit->data == tselem->id) {
glColor4ub(255, 255, 255, alpha);
- active = 2;
+ active = OL_DRAWSEL_ACTIVE;
}
else {
- if (tree_element_active(C, scene, soops, te, 0)) {
+ if (tree_element_active(C, scene, soops, te, OL_SETSEL_NONE)) {
glColor4ub(220, 220, 255, alpha);
- active = 2;
+ active = OL_DRAWSEL_ACTIVE;
}
}
}
else {
- if (tree_element_type_active(NULL, scene, soops, te, tselem, 0, false)) active = 2;
+ if (tree_element_type_active(NULL, scene, soops, te, tselem, OL_SETSEL_NONE, false) != OL_DRAWSEL_NONE) {
+ active = OL_DRAWSEL_ACTIVE;
+ }
glColor4ub(220, 220, 255, alpha);
}
/* active circle */
- if (active) {
+ if (active != OL_DRAWSEL_NONE) {
uiSetRoundBox(UI_CNR_ALL);
uiRoundBox((float)startx + UI_UNIT_X,
(float)*starty + 1.0f * ufac,
@@ -1348,7 +1351,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
glDisable(GL_BLEND);
/* name */
- if (active == 1) UI_ThemeColor(TH_TEXT_HI);
+ if (active == OL_DRAWSEL_NORMAL) UI_ThemeColor(TH_TEXT_HI);
else if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f);
else UI_ThemeColor(TH_TEXT);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 015d8d64627..34d7f87e44d 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -108,6 +108,18 @@ typedef struct TreeElement {
/* button events */
#define OL_NAMEBUTTON 1
+typedef enum {
+ OL_DRAWSEL_NONE = 0, /* inactive (regular black text) */
+ OL_DRAWSEL_NORMAL = 1, /* active object (draws white text) */
+ OL_DRAWSEL_ACTIVE = 2, /* active obdata (draws a circle around the icon) */
+} eOLDrawState;
+
+typedef enum {
+ OL_SETSEL_NONE = 0, /* don't change the selection state */
+ OL_SETSEL_NORMAL = 1, /* select the item */
+ OL_SETSEL_EXTEND = 2, /* select the item and extend (also toggles selection) */
+} eOLSetState;
+
/* get TreeStoreElem associated with a TreeElement
* < a: (TreeElement) tree element to find stored element for
*/
@@ -166,8 +178,12 @@ void draw_outliner(const struct bContext *C);
void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag);
/* outliner_select.c -------------------------------------------- */
-int tree_element_type_active(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set, bool recursive);
-int tree_element_active(struct bContext *C, struct Scene *scene, SpaceOops *soops, TreeElement *te, int set);
+eOLDrawState tree_element_type_active(
+ struct bContext *C, struct Scene *scene, struct SpaceOops *soops,
+ TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive);
+eOLDrawState tree_element_active(
+ struct bContext *C, struct Scene *scene, SpaceOops *soops,
+ TreeElement *te, const eOLSetState set);
int outliner_item_do_activate(struct bContext *C, int x, int y, bool extend, bool recursive);
/* outliner_edit.c ---------------------------------------------- */
@@ -177,7 +193,7 @@ void outliner_do_object_operation(struct bContext *C, struct Scene *scene, struc
int common_restrict_check(struct bContext *C, struct Object *ob);
-bool outliner_has_one_flag(struct SpaceOops *soops, ListBase *lb, short flag, const int curlevel);
+int outliner_has_one_flag(struct SpaceOops *soops, ListBase *lb, short flag, const int curlevel);
void outliner_set_flag(struct SpaceOops *soops, ListBase *lb, short flag, short set);
void object_toggle_visibility_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index b10b8a46ec6..688695e3ded 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -124,23 +124,24 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se
/* ****************************************************** */
/* Outliner Element Selection/Activation on Click */
-static int tree_element_active_renderlayer(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set)
+static eOLDrawState tree_element_active_renderlayer(
+ bContext *C, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
{
Scene *sce;
/* paranoia check */
if (te->idcode != ID_SCE)
- return 0;
+ return OL_DRAWSEL_NONE;
sce = (Scene *)tselem->id;
- if (set) {
+ if (set != OL_SETSEL_NONE) {
sce->r.actlay = tselem->nr;
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, sce);
}
else {
return sce->r.actlay == tselem->nr;
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
/**
@@ -185,8 +186,9 @@ static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_p
}
}
-static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops *soops,
- TreeElement *te, int set, bool recursive)
+static eOLDrawState tree_element_set_active_object(
+ bContext *C, Scene *scene, SpaceOops *soops,
+ TreeElement *te, const eOLSetState set, bool recursive)
{
TreeStoreElem *tselem = TREESTORE(te);
Scene *sce;
@@ -199,9 +201,13 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
}
else {
ob = (Object *)outliner_search_back(soops, te, ID_OB);
- if (ob == OBACT) return 0;
+ if (ob == OBACT) {
+ return OL_DRAWSEL_NONE;
+ }
+ }
+ if (ob == NULL) {
+ return OL_DRAWSEL_NONE;
}
- if (ob == NULL) return 0;
sce = (Scene *)outliner_search_back(soops, te, ID_SCE);
if (sce && scene != sce) {
@@ -213,7 +219,7 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
base = BKE_scene_base_find(scene, ob);
if (base) {
- if (set == 2) {
+ if (set == OL_SETSEL_EXTEND) {
/* swap select */
if (base->flag & SELECT)
ED_base_object_select(base, BA_DESELECT);
@@ -240,10 +246,12 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
if (ob != scene->obedit)
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
- return 1;
+ return OL_DRAWSEL_NORMAL;
}
-static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
+static eOLDrawState tree_element_active_material(
+ bContext *C, Scene *scene, SpaceOops *soops,
+ TreeElement *te, const eOLSetState set)
{
TreeElement *tes;
Object *ob;
@@ -251,45 +259,58 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so
/* we search for the object parent */
ob = (Object *)outliner_search_back(soops, te, ID_OB);
// note: ob->matbits can be NULL when a local object points to a library mesh.
- if (ob == NULL || ob != OBACT || ob->matbits == NULL) return 0; // just paranoia
+ if (ob == NULL || ob != OBACT || ob->matbits == NULL) {
+ return OL_DRAWSEL_NONE; /* just paranoia */
+ }
/* searching in ob mat array? */
tes = te->parent;
if (tes->idcode == ID_OB) {
- if (set) {
+ if (set != OL_SETSEL_NONE) {
ob->actcol = te->index + 1;
ob->matbits[te->index] = 1; // make ob material active too
}
else {
- if (ob->actcol == te->index + 1)
- if (ob->matbits[te->index]) return 1;
+ if (ob->actcol == te->index + 1) {
+ if (ob->matbits[te->index]) {
+ return OL_DRAWSEL_NORMAL;
+ }
+ }
}
}
/* or we search for obdata material */
else {
- if (set) {
+ if (set != OL_SETSEL_NONE) {
ob->actcol = te->index + 1;
ob->matbits[te->index] = 0; // make obdata material active too
}
else {
- if (ob->actcol == te->index + 1)
- if (ob->matbits[te->index] == 0) return 1;
+ if (ob->actcol == te->index + 1) {
+ if (ob->matbits[te->index] == 0) {
+ return OL_DRAWSEL_NORMAL;
+ }
+ }
}
}
- if (set) {
+ if (set != OL_SETSEL_NONE) {
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, NULL);
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *UNUSED(soops), TreeElement *te, int set)
+static eOLDrawState tree_element_active_texture(
+ bContext *C, Scene *scene, SpaceOops *UNUSED(soops),
+ TreeElement *te, const eOLSetState set)
{
TreeElement *tep;
TreeStoreElem /* *tselem,*/ *tselemp;
Object *ob = OBACT;
SpaceButs *sbuts = NULL;
- if (ob == NULL) return 0; // no active object
+ if (ob == NULL) {
+ /* no active object */
+ return OL_DRAWSEL_NONE;
+ }
/*tselem = TREESTORE(te);*/ /*UNUSED*/
@@ -303,7 +324,7 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *UNU
if (tep->idcode == ID_WO) {
World *wrld = (World *)tselemp->id;
- if (set) {
+ if (set != OL_SETSEL_NONE) {
if (sbuts) {
// XXX sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
// XXX sbuts->texfrom = 1;
@@ -312,12 +333,14 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *UNU
wrld->texact = te->index;
}
else if (tselemp->id == (ID *)(scene->world)) {
- if (wrld->texact == te->index) return 1;
+ if (wrld->texact == te->index) {
+ return OL_DRAWSEL_NORMAL;
+ }
}
}
else if (tep->idcode == ID_LA) {
Lamp *la = (Lamp *)tselemp->id;
- if (set) {
+ if (set != OL_SETSEL_NONE) {
if (sbuts) {
// XXX sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
// XXX sbuts->texfrom = 2;
@@ -327,13 +350,15 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *UNU
}
else {
if (tselemp->id == ob->data) {
- if (la->texact == te->index) return 1;
+ if (la->texact == te->index) {
+ return OL_DRAWSEL_NORMAL;
+ }
}
}
}
else if (tep->idcode == ID_MA) {
Material *ma = (Material *)tselemp->id;
- if (set) {
+ if (set != OL_SETSEL_NONE) {
if (sbuts) {
//sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
// XXX sbuts->texfrom = 0;
@@ -345,46 +370,60 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *UNU
ob->actcol = tep->index + 1;
}
else if (tep->flag & TE_ACTIVE) { // this is active material
- if (ma->texact == te->index) return 1;
+ if (ma->texact == te->index) {
+ return OL_DRAWSEL_NORMAL;
+ }
}
}
- if (set)
+ if (set != OL_SETSEL_NONE) {
WM_event_add_notifier(C, NC_TEXTURE, NULL);
+ }
- return 0;
+ /* no active object */
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set)
+static eOLDrawState tree_element_active_lamp(
+ bContext *UNUSED(C), Scene *scene, SpaceOops *soops,
+ TreeElement *te, const eOLSetState set)
{
Object *ob;
/* we search for the object parent */
ob = (Object *)outliner_search_back(soops, te, ID_OB);
- if (ob == NULL || ob != OBACT) return 0; // just paranoia
+ if (ob == NULL || ob != OBACT) {
+ /* just paranoia */
+ return OL_DRAWSEL_NONE;
+ }
- if (set) {
+ if (set != OL_SETSEL_NONE) {
// XXX extern_set_butspace(F5KEY, 0);
}
else {
- return 1;
+ return OL_DRAWSEL_NORMAL;
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set)
+static eOLDrawState tree_element_active_camera(
+ bContext *UNUSED(C), Scene *scene, SpaceOops *soops,
+ TreeElement *te, const eOLSetState set)
{
Object *ob = (Object *)outliner_search_back(soops, te, ID_OB);
- if (set)
- return 0;
+ if (set != OL_SETSEL_NONE) {
+ return OL_DRAWSEL_NONE;
+ }
return scene->camera == ob;
}
-static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *UNUSED(soops), TreeElement *te, int set)
+static eOLDrawState tree_element_active_world(
+ bContext *C, Scene *scene, SpaceOops *UNUSED(soops),
+ TreeElement *te, const eOLSetState set)
{
TreeElement *tep;
TreeStoreElem *tselem = NULL;
@@ -397,30 +436,32 @@ static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *UNUSE
sce = (Scene *)tselem->id;
}
- if (set) { // make new scene active
+ if (set != OL_SETSEL_NONE) {
+ /* make new scene active */
if (sce && scene != sce) {
ED_screen_set_scene(C, CTX_wm_screen(C), sce);
}
}
if (tep == NULL || tselem->id == (ID *)scene) {
- if (set) {
+ if (set != OL_SETSEL_NONE) {
// XXX extern_set_butspace(F8KEY, 0);
}
else {
- return 1;
+ return OL_DRAWSEL_NORMAL;
}
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set)
+static eOLDrawState tree_element_active_defgroup(
+ bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
{
Object *ob;
/* id in tselem is object */
ob = (Object *)tselem->id;
- if (set) {
+ if (set != OL_SETSEL_NONE) {
BLI_assert(te->index + 1 >= 0);
ob->actdef = te->index + 1;
@@ -429,16 +470,19 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement *
}
else {
if (ob == OBACT)
- if (ob->actdef == te->index + 1) return 1;
+ if (ob->actdef == te->index + 1) {
+ return OL_DRAWSEL_NORMAL;
+ }
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set)
+static eOLDrawState tree_element_active_posegroup(
+ bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
{
Object *ob = (Object *)tselem->id;
- if (set) {
+ if (set != OL_SETSEL_NONE) {
if (ob->pose) {
ob->pose->active_group = te->index + 1;
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -446,29 +490,32 @@ static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement
}
else {
if (ob == OBACT && ob->pose) {
- if (ob->pose->active_group == te->index + 1) return 1;
+ if (ob->pose->active_group == te->index + 1) {
+ return OL_DRAWSEL_NORMAL;
+ }
}
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set, bool recursive)
+static eOLDrawState tree_element_active_posechannel(
+ bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive)
{
Object *ob = (Object *)tselem->id;
bArmature *arm = ob->data;
bPoseChannel *pchan = te->directdata;
- if (set) {
+ if (set != OL_SETSEL_NONE) {
if (!(pchan->bone->flag & BONE_HIDDEN_P)) {
- if (set != 2) {
+ if (set != OL_SETSEL_EXTEND) {
bPoseChannel *pchannel;
/* single select forces all other bones to get unselected */
for (pchannel = ob->pose->chanbase.first; pchannel; pchannel = pchannel->next)
pchannel->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
}
- if (set == 2 && (pchan->bone->flag & BONE_SELECTED)) {
+ if ((set == OL_SETSEL_EXTEND) && (pchan->bone->flag & BONE_SELECTED)) {
pchan->bone->flag &= ~BONE_SELECTED;
}
else {
@@ -487,22 +534,25 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen
}
else {
if (ob == OBACT && ob->pose) {
- if (pchan->bone->flag & BONE_SELECTED) return 1;
+ if (pchan->bone->flag & BONE_SELECTED) {
+ return OL_DRAWSEL_NORMAL;
+ }
}
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set, bool recursive)
+static eOLDrawState tree_element_active_bone(
+ bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive)
{
bArmature *arm = (bArmature *)tselem->id;
Bone *bone = te->directdata;
- if (set) {
+ if (set != OL_SETSEL_NONE) {
if (!(bone->flag & BONE_HIDDEN_P)) {
Object *ob = OBACT;
if (ob) {
- if (set != 2) {
+ if (set != OL_SETSEL_EXTEND) {
bPoseChannel *pchannel;
/* single select forces all other bones to get unselected */
for (pchannel = ob->pose->chanbase.first; pchannel; pchannel = pchannel->next)
@@ -510,7 +560,7 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
}
}
- if (set == 2 && (bone->flag & BONE_SELECTED)) {
+ if (set == OL_SETSEL_EXTEND && (bone->flag & BONE_SELECTED)) {
bone->flag &= ~BONE_SELECTED;
}
else {
@@ -531,10 +581,12 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
Object *ob = OBACT;
if (ob && ob->data == arm) {
- if (bone->flag & BONE_SELECTED) return 1;
+ if (bone->flag & BONE_SELECTED) {
+ return OL_DRAWSEL_NORMAL;
+ }
}
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
@@ -555,29 +607,31 @@ static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, scene->obedit);
}
-static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set, bool recursive)
+static eOLDrawState tree_element_active_ebone(
+ bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set, bool recursive)
{
bArmature *arm = scene->obedit->data;
EditBone *ebone = te->directdata;
- int status = 0;
- if (set) {
- if (set == 1) {
+ eOLDrawState status = OL_DRAWSEL_NONE;
+
+ if (set != OL_SETSEL_NONE) {
+ if (set == OL_SETSEL_NORMAL) {
if (!(ebone->flag & BONE_HIDDEN_A)) {
ED_armature_deselect_all(scene->obedit, 0); // deselect
tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE);
- status = 1;
+ status = OL_DRAWSEL_NORMAL;
}
}
- else if (set == 2) {
+ else if (set == OL_SETSEL_EXTEND) {
if (!(ebone->flag & BONE_HIDDEN_A)) {
if (!(ebone->flag & BONE_SELECTED)) {
tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE);
- status = 1;
+ status = OL_DRAWSEL_NORMAL;
}
else {
/* entirely selected, so de-select */
tree_element_active_ebone__sel(C, scene, arm, ebone, FALSE);
- status = 0;
+ status = OL_DRAWSEL_NONE;
}
}
}
@@ -588,14 +642,16 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te,
}
}
else if (ebone->flag & BONE_SELECTED) {
- status = 1;
+ status = OL_DRAWSEL_NORMAL;
}
+
return status;
}
-static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set)
+static eOLDrawState tree_element_active_modifier(
+ bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set)
{
- if (set) {
+ if (set != OL_SETSEL_NONE) {
Object *ob = (Object *)tselem->id;
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -603,12 +659,13 @@ static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), Tr
// XXX extern_set_butspace(F9KEY, 0);
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set)
+static eOLDrawState tree_element_active_psys(
+ bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set)
{
- if (set) {
+ if (set != OL_SETSEL_NONE) {
Object *ob = (Object *)tselem->id;
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
@@ -616,33 +673,37 @@ static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeEleme
// XXX extern_set_butspace(F7KEY, 0);
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set)
+static int tree_element_active_constraint(
+ bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set)
{
- if (set) {
+ if (set != OL_SETSEL_NONE) {
Object *ob = (Object *)tselem->id;
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
// XXX extern_set_butspace(F7KEY, 0);
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_text(bContext *UNUSED(C), Scene *UNUSED(scene), SpaceOops *UNUSED(soops), TreeElement *UNUSED(te), int UNUSED(set))
+static eOLDrawState tree_element_active_text(
+ bContext *UNUSED(C), Scene *UNUSED(scene), SpaceOops *UNUSED(soops),
+ TreeElement *UNUSED(te), int UNUSED(set))
{
// XXX removed
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set)
+static eOLDrawState tree_element_active_pose(
+ bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set)
{
Object *ob = (Object *)tselem->id;
Base *base = BKE_scene_base_find(scene, ob);
- if (set) {
+ if (set != OL_SETSEL_NONE) {
if (scene->obedit)
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
@@ -652,25 +713,28 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUS
ED_armature_enter_posemode(C, base);
}
else {
- if (ob->mode & OB_MODE_POSE) return 1;
+ if (ob->mode & OB_MODE_POSE) {
+ return OL_DRAWSEL_NORMAL;
+ }
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_sequence(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set)
+static eOLDrawState tree_element_active_sequence(
+ bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set)
{
Sequence *seq = (Sequence *) te->directdata;
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
- if (set) {
+ if (set != OL_SETSEL_NONE) {
/* only check on setting */
if (BLI_findindex(ed->seqbasep, seq) != -1) {
- if (set == 2) {
+ if (set == OL_SETSEL_EXTEND) {
BKE_sequencer_active_set(scene, NULL);
}
ED_sequencer_deselect_all(scene);
- if (set == 2 && seq->flag & SELECT) {
+ if ((set == OL_SETSEL_EXTEND) && seq->flag & SELECT) {
seq->flag &= ~SELECT;
}
else {
@@ -683,22 +747,23 @@ static int tree_element_active_sequence(bContext *C, Scene *scene, TreeElement *
}
else {
if (ed->act_seq == seq && seq->flag & SELECT) {
- return 1;
+ return OL_DRAWSEL_NORMAL;
}
}
- return(0);
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set)
+static eOLDrawState tree_element_active_sequence_dup(
+ Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set)
{
Sequence *seq, *p;
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
seq = (Sequence *)te->directdata;
- if (set == 0) {
+ if (set == OL_SETSEL_NONE) {
if (seq->flag & SELECT)
- return(1);
- return(0);
+ return OL_DRAWSEL_NORMAL;
+ return OL_DRAWSEL_NONE;
}
// XXX select_single_seq(seq, 1);
@@ -713,27 +778,32 @@ static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeS
// XXX select_single_seq(p, 0);
p = p->next;
}
- return(0);
+ return OL_DRAWSEL_NONE;
}
-static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, TreeStoreElem *UNUSED(tselem), int set)
+static eOLDrawState tree_element_active_keymap_item(
+ bContext *UNUSED(C), TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set)
{
wmKeyMapItem *kmi = te->directdata;
- if (set == 0) {
- if (kmi->flag & KMI_INACTIVE) return 0;
- return 1;
+ if (set == OL_SETSEL_NONE) {
+ if (kmi->flag & KMI_INACTIVE) {
+ return OL_DRAWSEL_NONE;
+ }
+ return OL_DRAWSEL_NORMAL;
}
else {
kmi->flag ^= KMI_INACTIVE;
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
/* ---------------------------------------------- */
/* generic call for ID data check or make/check active in UI */
-int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
+eOLDrawState tree_element_active(
+ bContext *C, Scene *scene, SpaceOops *soops,
+ TreeElement *te, const eOLSetState set)
{
switch (te->idcode) {
@@ -752,13 +822,17 @@ int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement
case ID_CA:
return tree_element_active_camera(C, scene, soops, te, set);
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
-/* generic call for non-id data to make/check active in UI */
-/* Context can be NULL when set==0 */
-int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops,
- TreeElement *te, TreeStoreElem *tselem, int set, bool recursive)
+/**
+ * Generic call for non-id data to make/check active in UI
+ *
+ * \note Context can be NULL when ``(set == OL_SETSEL_NONE)``
+ */
+eOLDrawState tree_element_type_active(
+ bContext *C, Scene *scene, SpaceOops *soops,
+ TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive)
{
switch (tselem->type) {
case TSE_DEFGROUP:
@@ -770,8 +844,12 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops,
case TSE_MODIFIER:
return tree_element_active_modifier(C, te, tselem, set);
case TSE_LINKED_OB:
- if (set) tree_element_set_active_object(C, scene, soops, te, set, FALSE);
- else if (tselem->id == (ID *)OBACT) return 1;
+ if (set != OL_SETSEL_NONE) {
+ tree_element_set_active_object(C, scene, soops, te, set, false);
+ }
+ else if (tselem->id == (ID *)OBACT) {
+ return OL_DRAWSEL_NORMAL;
+ }
break;
case TSE_LINKED_PSYS:
return tree_element_active_psys(C, scene, te, tselem, set);
@@ -793,23 +871,23 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops,
return tree_element_active_keymap_item(C, te, tselem, set);
}
- return 0;
+ return OL_DRAWSEL_NONE;
}
/* ================================================ */
-static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops,
- TreeElement *te, bool extend, bool recursive, const float mval[2])
+static bool do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops,
+ TreeElement *te, bool extend, bool recursive, const float mval[2])
{
if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
TreeStoreElem *tselem = TREESTORE(te);
- int openclose = 0;
+ bool openclose = false;
/* open close icon */
if ((te->flag & TE_ICONROW) == 0) { // hidden icon, no open/close
if (mval[0] > te->xs && mval[0] < te->xs + UI_UNIT_X)
- openclose = 1;
+ openclose = true;
}
if (openclose) {
@@ -824,7 +902,7 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa
}
- return 1;
+ return true;
}
/* name and first icon */
else if (mval[0] > te->xs + UI_UNIT_X && mval[0] < te->xend) {
@@ -832,7 +910,7 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa
/* always makes active object */
if (tselem->type != TSE_SEQUENCE && tselem->type != TSE_SEQ_STRIP && tselem->type != TSE_SEQUENCE_DUP)
tree_element_set_active_object(C, scene, soops, te,
- 1 + (extend != 0 && tselem->type == 0),
+ (extend && tselem->type == 0) ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL,
recursive && tselem->type == 0 );
if (tselem->type == 0) { // the lib blocks
@@ -874,22 +952,26 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa
WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
}
else { // rest of types
- tree_element_active(C, scene, soops, te, 1);
+ tree_element_active(C, scene, soops, te, OL_SETSEL_NORMAL);
}
}
else {
- tree_element_type_active(C, scene, soops, te, tselem, 1 + (extend != 0), recursive);
+ tree_element_type_active(C, scene, soops, te, tselem,
+ extend ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL,
+ recursive);
}
- return 1;
+ return true;
}
}
for (te = te->subtree.first; te; te = te->next) {
- if (do_outliner_item_activate(C, scene, ar, soops, te, extend, recursive, mval)) return 1;
+ if (do_outliner_item_activate(C, scene, ar, soops, te, extend, recursive, mval)) {
+ return true;
+ }
}
- return 0;
+ return false;
}
int outliner_item_do_activate(bContext *C, int x, int y, bool extend, bool recursive)
@@ -986,7 +1068,6 @@ static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *re
outliner_item_border_select(scene, soops, rectf, te, gesture_mode);
}
}
- return;
}
static int outliner_border_select_exec(bContext *C, wmOperator *op)