diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-16 13:22:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-16 13:23:46 +0400 |
commit | a4e07aa825d75c98d277ef0a01c744674ffc8294 (patch) | |
tree | c45a260d4b26f1de4b63193a5dd9957d1433682b /source/blender/editors/space_outliner/outliner_draw.c | |
parent | 4f87ca47a6daf7e748ed0f1f078c884a052ba7da (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/outliner_draw.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 45 |
1 files changed, 24 insertions, 21 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); |