Merge with trunk r37546
[blender.git] / source / blender / editors / space_outliner / outliner.c
index 393be83ad111cab12c3bb2faf5198458b4481a1c..dd484f1a659f8aec14afaceaccbfad6902495b4c 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file blender/editors/space_outliner/outliner.c
+ *  \ingroup spoutliner
+ */
+
+
 #include <math.h>
 #include <string.h>
 #include <stdlib.h>
 #include "DNA_object_types.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
 
 #if defined WIN32 && !defined _LIBC
 # include "BLI_fnmatch.h" /* use fnmatch included in blenlib */
 #else
-# define _GNU_SOURCE
+#  ifndef _GNU_SOURCE
+#    define _GNU_SOURCE
+#  endif
 # include <fnmatch.h>
 #endif
 
 #include "outliner_intern.h"
 
 
-
-#define OL_H   19
-#define OL_X   18
-
 #define OL_Y_OFFSET    2
 
-#define OL_TOG_RESTRICT_VIEWX  54
-#define OL_TOG_RESTRICT_SELECTX        36
-#define OL_TOG_RESTRICT_RENDERX        18
+#define OL_TOG_RESTRICT_VIEWX  (UI_UNIT_X*3)
+#define OL_TOG_RESTRICT_SELECTX        (UI_UNIT_X*2)
+#define OL_TOG_RESTRICT_RENDERX        UI_UNIT_X
 
 #define OL_TOGW OL_TOG_RESTRICT_VIEWX
 
-#define OL_RNA_COLX                    300
-#define OL_RNA_COL_SIZEX       150
-#define OL_RNA_COL_SPACEX      50
+#define OL_RNA_COLX                    (UI_UNIT_X*15)
+#define OL_RNA_COL_SIZEX       (UI_UNIT_X*7.5)
+#define OL_RNA_COL_SPACEX      (UI_UNIT_X*2.5)
 
 #define TS_CHUNK       128
 
@@ -187,7 +192,7 @@ static void check_persistant(SpaceOops *soops, TreeElement *te, ID *id, short ty
        
        /* case 1; no TreeStore */
        if(soops->treestore==NULL) {
-               ts= soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore");
+               soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore");
        }
        ts= soops->treestore;
        
@@ -252,7 +257,7 @@ static void outliner_height(SpaceOops *soops, ListBase *lb, int *h)
                TreeStoreElem *tselem= TREESTORE(te);
                if((tselem->flag & TSE_CLOSED)==0) 
                        outliner_height(soops, &te->subtree, h);
-               (*h) += OL_H;
+               (*h) += UI_UNIT_Y;
                te= te->next;
        }
 }
@@ -289,7 +294,7 @@ static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int start
                        *w = startx+100;
 
                if((tselem->flag & TSE_CLOSED)==0)
-                       outliner_rna_width(soops, &te->subtree, w, startx+OL_X);
+                       outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X);
                te= te->next;
        }
 }
@@ -432,7 +437,7 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb)
 static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, 
                                                                                 TreeElement *parent, short type, short index);
 
-#define LOG2I(x) (int)(log(x)/log(2.0))
+#define LOG2I(x) (int)(log(x)/M_LN2)
 
 static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl)
 {
@@ -1188,7 +1193,7 @@ static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb)
 }
 
 /* Helped function to put duplicate sequence in the same tree. */
-int need_add_seq_dup(Sequence *seq)
+static int need_add_seq_dup(Sequence *seq)
 {
        Sequence *p;
 
@@ -1225,7 +1230,7 @@ int need_add_seq_dup(Sequence *seq)
        return(1);
 }
 
-void add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *te, short index)
+static void add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *te, short index)
 {
        TreeElement *ch;
        Sequence *p;
@@ -1243,7 +1248,7 @@ void add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *te, short index)
        }
 }
 
-static int outliner_filter_has_name(TreeElement *te, char *name, int flags)
+static int outliner_filter_has_name(TreeElement *te, const char *name, int flags)
 {
 #if 0
        int found= 0;
@@ -1332,8 +1337,8 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
        int show_opened= (soops->treestore==NULL); /* on first view, we open scenes */
 
        if(soops->tree.first && (soops->storeflag & SO_TREESTORE_REDRAW))
-          return;
-          
+               return;
+
        outliner_free_tree(&soops->tree);
        outliner_storage_cleanup(soops);
        
@@ -1408,7 +1413,6 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
                for(group= mainvar->group.first; group; group= group->id.next) {
                        if(group->gobject.first) {
                                te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0);
-                               tselem= TREESTORE(te);
                                
                                for(go= group->gobject.first; go; go= go->next) {
                                        ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0);
@@ -1509,6 +1513,42 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
 
 /* **************** INTERACTIVE ************* */
 
+
+static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
+{
+       ARegion *ar= CTX_wm_region(C);
+       int dy= ar->v2d.mask.ymax - ar->v2d.mask.ymin;
+       int up= 0;
+       
+       if(RNA_boolean_get(op->ptr, "up"))
+               up= 1;
+
+       if(up == 0) dy= -dy;
+       ar->v2d.cur.ymin+= dy;
+       ar->v2d.cur.ymax+= dy;
+       
+       ED_region_tag_redraw(ar);
+       
+       return OPERATOR_FINISHED;
+}
+
+
+void OUTLINER_OT_scroll_page(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Scroll Page";
+       ot->idname= "OUTLINER_OT_scroll_page";
+       ot->description= "Scroll page up or down";
+       
+       /* callbacks */
+       ot->exec= outliner_scroll_page_exec;
+       ot->poll= ED_operator_outliner_active;
+       
+       /* properties */
+       RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page.");
+}
+
+
 static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel)
 {
        TreeElement *te;
@@ -1575,7 +1615,7 @@ static int common_restrict_check(bContext *C, Object *ob)
        return 1;
 }
 
-void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base= (Base *)te->directdata;
        Object *ob = (Object *)tselem->id;
@@ -1658,7 +1698,7 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base= (Base *)te->directdata;
        
@@ -1686,7 +1726,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Toggle Renderability";
        ot->idname= "OUTLINER_OT_renderability_toggle";
-       ot->description= "Toggle the renderbility of selected items";
+       ot->description= "Toggle the renderability of selected items";
        
        /* callbacks */
        ot->exec= outliner_toggle_renderability_exec;
@@ -1809,6 +1849,7 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Show/Hide One Level";
        ot->idname= "OUTLINER_OT_show_one_level";
+       ot->description= "Expand/collapse all entries by one level";
        
        /* callbacks */
        ot->exec= outliner_one_level_exec;
@@ -1863,7 +1904,7 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te
 #endif
 
 // XXX just use View2D ops for this?
-void outliner_page_up_down(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int up)
+static void outliner_page_up_down(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int up)
 {
        int dy= ar->v2d.mask.ymax-ar->v2d.mask.ymin;
        
@@ -1985,13 +2026,13 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so
 static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
 {
        TreeElement *tep;
-       TreeStoreElem *tselem, *tselemp;
+       TreeStoreElem /* *tselem,*/ *tselemp;
        Object *ob=OBACT;
        SpaceButs *sbuts=NULL;
        
        if(ob==NULL) return 0; // no active object
        
-       tselem= TREESTORE(te);
+       /*tselem= TREESTORE(te);*/ /*UNUSED*/
        
        /* find buttons area (note, this is undefined really still, needs recode in blender) */
        /* XXX removed finding sbuts */
@@ -2072,6 +2113,16 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops
        return 0;
 }
 
+static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set)
+{
+       Object *ob= (Object *)outliner_search_back(soops, te, ID_OB);
+
+       if(set)
+               return 0;
+
+       return scene->camera == ob;
+}
+
 static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
 {
        TreeElement *tep;
@@ -2109,7 +2160,7 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement *
        ob= (Object *)tselem->id;
        if(set) {
                ob->actdef= te->index+1;
-               DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+               DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
        }
        else {
@@ -2151,8 +2202,6 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen
                        
                        if(set==2 && (pchan->bone->flag & BONE_SELECTED)) {
                                pchan->bone->flag &= ~BONE_SELECTED;
-                               if(arm->act_bone==pchan->bone)
-                                       arm->act_bone= NULL;
                        } else {
                                pchan->bone->flag |= BONE_SELECTED;
                                arm->act_bone= pchan->bone;
@@ -2182,8 +2231,6 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
                        
                        if(set==2 && (bone->flag & BONE_SELECTED)) {
                                bone->flag &= ~BONE_SELECTED;
-                               if(arm->act_bone==bone)
-                                       arm->act_bone= NULL;
                        } else {
                                bone->flag |= BONE_SELECTED;
                                arm->act_bone= bone;
@@ -2204,27 +2251,49 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
 
 
 /* ebones only draw in editmode armature */
+static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel)
+{
+       if(sel) {
+               ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL;
+               arm->act_edbone= ebone;
+               // flush to parent?
+               if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL;
+       }
+       else {
+               ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
+               // flush to parent?
+               if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL;
+       }
+
+       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)
 {
+       bArmature *arm= scene->obedit->data;
        EditBone *ebone= te->directdata;
-       
-       if(set) {
-               if(!(ebone->flag & BONE_HIDDEN_A)) {
-                       bArmature *arm= scene->obedit->data;
-                       if(set==2) ED_armature_deselect_all(scene->obedit, 2);  // only clear active tag
-                       else ED_armature_deselect_all(scene->obedit, 0);        // deselect
-
-                       ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL;
-                       arm->act_edbone= ebone;
 
-                       // flush to parent?
-                       if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL;
-                       
-                       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit);
+       if(set==1) {
+               if(!(ebone->flag & BONE_HIDDEN_A)) {
+                       ED_armature_deselect_all(scene->obedit, 0);     // deselect
+                       tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE);
+                       return 1;
                }
        }
-       else {
-               if (ebone->flag & BONE_SELECTED) return 1;
+       else if (set==2) {
+               if(!(ebone->flag & BONE_HIDDEN_A)) {
+                       if(!(ebone->flag & BONE_SELECTED)) {
+                               tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE);
+                               return 1;
+                       }
+                       else {
+                               /* entirely selected, so de-select */
+                               tree_element_active_ebone__sel(C, scene, arm, ebone, FALSE);
+                               return 0;
+                       }
+               }
+       }
+       else if (ebone->flag & BONE_SELECTED) {
+               return 1;
        }
        return 0;
 }
@@ -2288,6 +2357,8 @@ static int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, Tree
                        return tree_element_active_texture(C, scene, soops, te, set);
                case ID_TXT:
                        return tree_element_active_text(C, scene, soops, te, set);
+               case ID_CA:
+                       return tree_element_active_camera(C, scene, soops, te, set);
        }
        return 0;
 }
@@ -2408,16 +2479,16 @@ static int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops,
        return 0;
 }
 
-static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, float *mval)
+static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2])
 {
        
-       if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
+       if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) {
                TreeStoreElem *tselem= TREESTORE(te);
                int openclose= 0;
 
                /* open close icon */
                if((te->flag & TE_ICONROW)==0) {                                // hidden icon, no open/close
-                       if( mval[0]>te->xs && mval[0]<te->xs+OL_X) 
+                       if( mval[0]>te->xs && mval[0]<te->xs+UI_UNIT_X) 
                                openclose= 1;
                }
 
@@ -2436,7 +2507,7 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa
                        return 1;
                }
                /* name and first icon */
-               else if(mval[0]>te->xs+OL_X && mval[0]<te->xend) {
+               else if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) {
                        
                        /* always makes active object */
                        if(tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP)
@@ -2478,19 +2549,7 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa
                                        WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
                                }
                                else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) {
-                                       Object *obedit= CTX_data_edit_object(C);
-                                       if(obedit) 
-                                               ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO);
-                                       else {
-                                               Object *ob= CTX_data_active_object(C);
-
-                                               /* Don't allow edit mode if the object is hide!
-                                                * check the bug #22153 and #21609
-                                                */
-                                               if (ob && (!(ob->restrictflag & OB_RESTRICT_VIEW)))
-                                                       ED_object_enter_editmode(C, EM_WAITCURSOR);
-                                               // XXX extern_set_butspace(F9KEY, 0);
-                                       }
+                                       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);
                                }
@@ -2517,9 +2576,12 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event)
        TreeElement *te;
        float fmval[2];
        int extend= RNA_boolean_get(op->ptr, "extend");
-       
-       UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
-       
+
+       UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1);
+
+       if(!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)
+               return OPERATOR_CANCELLED;
+
        for(te= soops->tree.first; te; te= te->next) {
                if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break;
        }
@@ -2532,7 +2594,7 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event)
                int row;
                
                /* get row number - 100 here is just a dummy value since we don't need the column */
-               UI_view2d_listview_view_to_cell(&ar->v2d, 1000, OL_H, 0.0f, OL_Y_OFFSET, 
+               UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, 
                                                fmval[0], fmval[1], NULL, &row);
                
                /* select relevant row */
@@ -2552,6 +2614,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
 {
        ot->name= "Activate Item";
        ot->idname= "OUTLINER_OT_item_activate";
+       ot->description= "Handle mouse clicks to activate/select items";
        
        ot->invoke= outliner_item_activate;
        
@@ -2562,10 +2625,10 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
 
 /* *********** */
 
-static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, float *mval)
+static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2])
 {
        
-       if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
+       if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) {
                TreeStoreElem *tselem= TREESTORE(te);
 
                /* all below close/open? */
@@ -2598,7 +2661,7 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event)
        float fmval[2];
        int all= RNA_boolean_get(op->ptr, "all");
        
-       UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
+       UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1);
        
        for(te= soops->tree.first; te; te= te->next) {
                if(do_outliner_item_openclose(C, soops, te, all, fmval)) 
@@ -2614,6 +2677,7 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
 {
        ot->name= "Open/Close Item";
        ot->idname= "OUTLINER_OT_item_openclose";
+       ot->description= "Toggle whether item under cursor is enabled or closed";
        
        ot->invoke= outliner_item_openclose;
        
@@ -2626,14 +2690,14 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
 
 /* ********************************************** */
 
-static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, float *mval)
+static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2])
 {
        
-       if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
+       if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) {
                TreeStoreElem *tselem= TREESTORE(te);
                
                /* name and first icon */
-               if(mval[0]>te->xs+OL_X && mval[0]<te->xend) {
+               if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) {
                        
                        /* can't rename rna datablocks entries */
                        if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))
@@ -2644,9 +2708,11 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T
                                error("Cannot edit sequence name");
                        else if(tselem->id->lib) {
                                // XXX                                          error_libdata();
-                       } else if(te->idcode == ID_LI && te->parent) {
+                       } 
+                       else if(te->idcode == ID_LI && te->parent) {
                                error("Cannot edit the path of an indirectly linked library");
-                       } else {
+                       } 
+                       else {
                                tselem->flag |= TSE_TEXTBUT;
                                ED_region_tag_redraw(ar);
                        }
@@ -2667,7 +2733,7 @@ static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *ev
        TreeElement *te;
        float fmval[2];
        
-       UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
+       UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1);
        
        for(te= soops->tree.first; te; te= te->next) {
                if(do_outliner_item_rename(C, ar, soops, te, fmval)) break;
@@ -2681,6 +2747,7 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot)
 {
        ot->name= "Rename Item";
        ot->idname= "OUTLINER_OT_item_rename";
+       ot->description= "Rename item under cursor";
        
        ot->invoke= outliner_item_rename;
        
@@ -2697,7 +2764,7 @@ static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id)
                if(tselem->type==0) {
                        if(tselem->id==id) return te;
                        /* only deeper on scene or object */
-                       if( te->idcode==ID_OB || te->idcode==ID_SCE) { 
+                       if( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) {
                                tes= outliner_find_id(soops, &te->subtree, id);
                                if(tes) return tes;
                        }
@@ -2752,8 +2819,6 @@ void OUTLINER_OT_show_active(wmOperatorType *ot)
        /* callbacks */
        ot->exec= outliner_show_active_exec;
        ot->poll= ED_operator_outliner_active;
-       
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
 /* tse is not in the treestore, we use its contents to find a match */
@@ -2793,12 +2858,12 @@ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te,
        /* store coord and continue, we need coordinates for elements outside view too */
        te->xs= (float)startx;
        te->ys= (float)(*starty);
-       *starty-= OL_H;
+       *starty-= UI_UNIT_Y;
        
        if((tselem->flag & TSE_CLOSED)==0) {
                TreeElement *ten;
                for(ten= te->subtree.first; ten; ten= ten->next) {
-                       outliner_set_coordinates_element(soops, ten, startx+OL_X, starty);
+                       outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty);
                }
        }
        
@@ -2808,7 +2873,7 @@ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te,
 static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops)
 {
        TreeElement *te;
-       int starty= (int)(ar->v2d.tot.ymax)-OL_H;
+       int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y;
        int startx= 0;
        
        for(te= soops->tree.first; te; te= te->next) {
@@ -3223,7 +3288,7 @@ static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *
        if(tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) {
                tselem->id->lib= NULL;
                tselem->id->flag= LIB_LOCAL;
-               new_id(0, tselem->id, 0);
+               new_id(NULL, tselem->id, NULL);
        }
 }
 
@@ -3355,7 +3420,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li
        }
 }
 
-void outliner_del(bContext *C, Scene *scene, ARegion *UNUSED(ar), SpaceOops *soops)
+static void outliner_del(bContext *C, Scene *scene, ARegion *UNUSED(ar), SpaceOops *soops)
 {
        
        if(soops->outlinevis==SO_SEQUENCE)
@@ -3465,8 +3530,8 @@ static EnumPropertyItem prop_group_op_types[] = {
        {2, "LOCAL", 0, "Make Local", ""},
        {3, "LINK", 0, "Link Group Objects to Scene", ""},
        {4, "TOGVIS", 0, "Toggle Visible", ""},
-       {5, "TOGSEL", 0, "Toggle Selectable", ""},
-       {6, "TOGREN", 0, "Toggle Renderable", ""},
+       {5, "TOGSEL", 0, "Toggle Selectable", ""},
+       {6, "TOGREN", 0, "Toggle Renderable", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
@@ -3493,7 +3558,7 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op)
        else if(event==3) {
                outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb);
                ED_undo_push(C, "Link Group Objects to Scene");
-       }   
+       }
        
        
        WM_event_add_notifier(C, NC_GROUP, NULL);
@@ -3660,10 +3725,10 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
 /* ******************** */
 
 
-static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, float *mval)
+static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, const float mval[2])
 {
        
-       if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
+       if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) {
                int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0;
                TreeStoreElem *tselem= TREESTORE(te);
                
@@ -3723,7 +3788,7 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *even
        TreeElement *te;
        float fmval[2];
        
-       UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1);
+       UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1);
        
        for(te= soops->tree.first; te; te= te->next) {
                if(do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break;
@@ -3737,6 +3802,7 @@ void OUTLINER_OT_operation(wmOperatorType *ot)
 {
        ot->name= "Execute Operation";
        ot->idname= "OUTLINER_OT_operation";
+       ot->description= "Context menu for item operations";
        
        ot->invoke= outliner_operation;
        
@@ -3903,12 +3969,12 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
 enum {
        DRIVERS_EDITMODE_ADD    = 0,
        DRIVERS_EDITMODE_REMOVE,
-} eDrivers_EditModes;
+} /*eDrivers_EditModes*/;
 
 /* Utilities ---------------------------------- */ 
 
 /* Recursively iterate over tree, finding and working on selected items */
-static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short mode)
+static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportList *reports, short mode)
 {
        TreeElement *te;
        TreeStoreElem *tselem;
@@ -3933,6 +3999,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m
                        
                        /* only if ID and path were set, should we perform any actions */
                        if (id && path) {
+                               short dflags = CREATEDRIVER_WITH_DEFAULT_DVAR;
                                int arraylen = 1;
                                
                                /* array checks */
@@ -3954,13 +4021,13 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m
                                                case DRIVERS_EDITMODE_ADD:
                                                {
                                                        /* add a new driver with the information obtained (only if valid) */
-                                                       ANIM_add_driver(id, path, array_index, flag, DRIVER_TYPE_PYTHON);
+                                                       ANIM_add_driver(reports, id, path, array_index, dflags, DRIVER_TYPE_PYTHON);
                                                }
                                                        break;
                                                case DRIVERS_EDITMODE_REMOVE:
                                                {
                                                        /* remove driver matching the information obtained (only if valid) */
-                                                       ANIM_remove_driver(id, path, array_index, flag);
+                                                       ANIM_remove_driver(reports, id, path, array_index, dflags);
                                                }
                                                        break;
                                        }
@@ -3975,13 +4042,13 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m
                
                /* go over sub-tree */
                if ((tselem->flag & TSE_CLOSED)==0)
-                       do_outliner_drivers_editop(soops, &te->subtree, mode);
+                       do_outliner_drivers_editop(soops, &te->subtree, reports, mode);
        }
 }
 
 /* Add Operator ---------------------------------- */
 
-static int outliner_drivers_addsel_exec(bContext *C, wmOperator *UNUSED(op))
+static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op)
 {
        SpaceOops *soutliner= CTX_wm_space_outliner(C);
        
@@ -3990,10 +4057,10 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *UNUSED(op))
                return OPERATOR_CANCELLED;
        
        /* recursively go into tree, adding selected items */
-       do_outliner_drivers_editop(soutliner, &soutliner->tree, DRIVERS_EDITMODE_ADD);
+       do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD);
        
        /* send notifiers */
-       WM_event_add_notifier(C, ND_KEYS, NULL); // XXX
+       WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX
        
        return OPERATOR_FINISHED;
 }
@@ -4010,13 +4077,13 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot)
        ot->poll= ed_operator_outliner_datablocks_active;
        
        /* flags */
-       ot->flag = OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
 
 /* Remove Operator ---------------------------------- */
 
-static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *UNUSED(op))
+static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op)
 {
        SpaceOops *soutliner= CTX_wm_space_outliner(C);
        
@@ -4025,7 +4092,7 @@ static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *UNUSED(op))
                return OPERATOR_CANCELLED;
        
        /* recursively go into tree, adding selected items */
-       do_outliner_drivers_editop(soutliner, &soutliner->tree, DRIVERS_EDITMODE_REMOVE);
+       do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE);
        
        /* send notifiers */
        WM_event_add_notifier(C, ND_KEYS, NULL); // XXX
@@ -4045,7 +4112,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot)
        ot->poll= ed_operator_outliner_datablocks_active;
        
        /* flags */
-       ot->flag = OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
 /* ***************** KEYINGSET OPERATIONS *************** */
@@ -4056,7 +4123,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot)
 enum {
        KEYINGSET_EDITMODE_ADD  = 0,
        KEYINGSET_EDITMODE_REMOVE,
-} eKeyingSet_EditModes;
+} /*eKeyingSet_EditModes*/;
 
 /* Utilities ---------------------------------- */ 
  
@@ -4127,12 +4194,9 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
                                                
                                                if (ksp) {
                                                        /* free path's data */
-                                                       // TODO: we probably need an API method for this 
-                                                       if (ksp->rna_path) MEM_freeN(ksp->rna_path);
+                                                       BKE_keyingset_free_path(ks, ksp);
+
                                                        ks->active_path= 0;
-                                                       
-                                                       /* remove path from set */
-                                                       BLI_freelinkN(&ks->paths, ksp);
                                                }
                                        }
                                                break;
@@ -4178,14 +4242,15 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot)
 {
        /* identifiers */
        ot->idname= "OUTLINER_OT_keyingset_add_selected";
-       ot->name= "Keyingset Add Selected";
+       ot->name= "Keying Set Add Selected";
+       ot->description= "Add selected items (blue-grey rows) to active Keying Set";
        
        /* api callbacks */
        ot->exec= outliner_keyingset_additems_exec;
        ot->poll= ed_operator_outliner_datablocks_active;
        
        /* flags */
-       ot->flag = OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
 
@@ -4214,14 +4279,15 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot)
 {
        /* identifiers */
        ot->idname= "OUTLINER_OT_keyingset_remove_selected";
-       ot->name= "Keyingset Remove Selected";
+       ot->name= "Keying Set Remove Selected";
+       ot->description = "Remove selected items (blue-grey rows) from active Keying Set";
        
        /* api callbacks */
        ot->exec= outliner_keyingset_removeitems_exec;
        ot->poll= ed_operator_outliner_datablocks_active;
        
        /* flags */
-       ot->flag = OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
 /* ***************** DRAW *************** */
@@ -4240,7 +4306,10 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon)
        if(arg->x >= arg->xmax) 
                UI_icon_draw(arg->x, arg->y, icon);
        else {
-               uiBut *but= uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-4, arg->y, ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : "");
+               /* XXX investigate: button placement of icons is way different than UI_icon_draw? */
+               float ufac= UI_UNIT_X/20.0f;
+               uiBut *but= uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-3.0f*ufac, arg->y, UI_UNIT_X-4.0f*ufac, UI_UNIT_Y-4.0f*ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : "");
+               
                if(arg->id)
                        uiButSetDragID(but, arg->id);
        }
@@ -4351,6 +4420,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
                                                UI_icon_draw(x, y, ICON_MOD_SOLIDIFY); break;
                                        case eModifierType_Screw:
                                                UI_icon_draw(x, y, ICON_MOD_SCREW); break;
+                                       case eModifierType_DynamicPaint:
+                                               UI_icon_draw(x, y, ICON_MOD_DYNAMICPAINT); break;
                                        default:
                                                UI_icon_draw(x, y, ICON_DOT); break;
                                }
@@ -4503,7 +4574,7 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
        for(te= lb->first; te; te= te->next) {
                
                /* exit drawing early */
-               if((*offsx) - OL_X > xmax)
+               if((*offsx) - UI_UNIT_X > xmax)
                        break;
 
                tselem= TREESTORE(te);
@@ -4512,7 +4583,6 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
                if(level<1 || (tselem->type==0 && te->idcode==ID_OB)) {
 
                        /* active blocks get white circle */
-                       active= 0;
                        if(tselem->type==0) {
                                if(te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id);
                                else if(scene->obedit && scene->obedit->data==tselem->id) active= 1;    // XXX use context?
@@ -4521,19 +4591,21 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
                        else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0);
                        
                        if(active) {
+                               float ufac= UI_UNIT_X/20.0f;
+
                                uiSetRoundBox(15);
                                glColor4ub(255, 255, 255, 100);
-                               uiRoundBox( (float)*offsx-0.5f, (float)ys-1.0f, (float)*offsx+OL_H-3.0f, (float)ys+OL_H-3.0f, OL_H/2.0f-2.0f);
+                               uiRoundBox( (float)*offsx-0.5f*ufac, (float)ys-1.0f*ufac, (float)*offsx+UI_UNIT_Y-3.0f*ufac, (float)ys+UI_UNIT_Y-3.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac);
                                glEnable(GL_BLEND); /* roundbox disables */
                        }
                        
                        tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f);
                        te->xs= (float)*offsx;
                        te->ys= (float)ys;
-                       te->xend= (short)*offsx+OL_X;
+                       te->xend= (short)*offsx+UI_UNIT_X;
                        te->flag |= TE_ICONROW; // for click
                        
-                       (*offsx) += OL_X;
+                       (*offsx) += UI_UNIT_X;
                }
                
                /* this tree element always has same amount of branches, so dont draw */
@@ -4543,20 +4615,36 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
        
 }
 
+/* closed tree element */
+static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, int startx, int *starty)
+{
+       TreeElement *ten;
+       
+       /* store coord and continue, we need coordinates for elements outside view too */
+       te->xs= (float)startx;
+       te->ys= (float)(*starty);
+       
+       for(ten= te->subtree.first; ten; ten= ten->next) {
+               outliner_set_coord_tree_element(soops, ten, startx+UI_UNIT_X, starty);
+       }       
+}
+
+
 static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty)
 {
        TreeElement *ten;
        TreeStoreElem *tselem;
+       float ufac= UI_UNIT_X/20.0f;
        int offsx= 0, active=0; // active=1 active obj, else active data
        
        tselem= TREESTORE(te);
 
-       if(*starty+2*OL_H >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) {
+       if(*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) {
                int xmax= ar->v2d.cur.xmax;
                
                /* icons can be ui buts, we dont want it to overlap with restrict */
                if((soops->flag & SO_HIDE_RESTRICTCOLS)==0)
-                       xmax-= OL_TOGW+ICON_DEFAULT_WIDTH;
+                       xmax-= OL_TOGW+UI_UNIT_X;
                
                glEnable(GL_BLEND);
 
@@ -4584,16 +4672,24 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                                Object *ob= (Object *)tselem->id;
                                
                                if(ob==OBACT || (ob->flag & SELECT)) {
-                                       char col[4];
+                                       char col[4]= {0, 0, 0, 0};
                                        
-                                       active= 2;
+                                       /* outliner active ob: always white text, circle color now similar to view3d */
+                                       
+                                       active= 2; /* means it draws a color circle */
                                        if(ob==OBACT) {
-                                               UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col);
-                                               /* so black text is drawn when active and not selected */
-                                               if (ob->flag & SELECT) active= 1;
+                                               if(ob->flag & SELECT) {
+                                                       UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col);
+                                                       col[3]= 100;
+                                               }
+                                               
+                                               active= 1; /* means it draws white text */
                                        }
-                                       else UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col);
-                                       col[3]= 100;
+                                       else if(ob->flag & SELECT) {
+                                               UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col);
+                                               col[3]= 100;
+                                       }
+                                       
                                        glColor4ubv((GLubyte *)col);
                                }
 
@@ -4617,7 +4713,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                /* active circle */
                if(active) {
                        uiSetRoundBox(15);
-                       uiRoundBox( (float)startx+OL_H-1.5f, (float)*starty+2.0f, (float)startx+2.0f*OL_H-4.0f, (float)*starty+OL_H-1.0f, OL_H/2.0f-2.0f);
+                       uiRoundBox( (float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac);
                        glEnable(GL_BLEND);     /* roundbox disables it */
                        
                        te->flag |= TE_ACTIVE; // for lookup in display hierarchies
@@ -4629,35 +4725,35 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                        if(tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE))
                                icon_x = startx;
                        else
-                               icon_x = startx+5;
+                               icon_x = startx+5*ufac;
 
                                // icons a bit higher
                        if(tselem->flag & TSE_CLOSED) 
-                               UI_icon_draw((float)icon_x, (float)*starty+2, ICON_DISCLOSURE_TRI_RIGHT);
+                               UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT);
                        else
-                               UI_icon_draw((float)icon_x, (float)*starty+2, ICON_DISCLOSURE_TRI_DOWN);
+                               UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN);
                }
-               offsx+= OL_X;
+               offsx+= UI_UNIT_X;
                
                /* datatype icon */
                
                if(!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) {
                        // icons a bit higher
-                       tselem_draw_icon(block, xmax, (float)startx+offsx, (float)*starty+2, tselem, te, 1.0f);
+                       tselem_draw_icon(block, xmax, (float)startx+offsx, (float)*starty+2*ufac, tselem, te, 1.0f);
                        
-                       offsx+= OL_X;
+                       offsx+= UI_UNIT_X;
                }
                else
-                       offsx+= 2;
+                       offsx+= 2*ufac;
                
                if(tselem->type==0 && tselem->id->lib) {
                        glPixelTransferf(GL_ALPHA_SCALE, 0.5f);
                        if(tselem->id->flag & LIB_INDIRECT)
-                               UI_icon_draw((float)startx+offsx, (float)*starty+2, ICON_LIBRARY_DATA_INDIRECT);
+                               UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_INDIRECT);
                        else
-                               UI_icon_draw((float)startx+offsx, (float)*starty+2, ICON_LIBRARY_DATA_DIRECT);
+                               UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_DIRECT);
                        glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
-                       offsx+= OL_X;
+                       offsx+= UI_UNIT_X;
                }               
                glDisable(GL_BLEND);
 
@@ -4666,9 +4762,9 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                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);
                
-               UI_DrawString(startx+offsx, *starty+5, te->name);
+               UI_DrawString(startx+offsx, *starty+5*ufac, te->name);
                
-               offsx+= (int)(OL_X + UI_GetStringWidth(te->name));
+               offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name));
                
                /* closed item, we draw the icons, not when it's a scene, or master-server list though */
                if(tselem->flag & TSE_CLOSED) {
@@ -4679,7 +4775,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                                        
                                        // divider
                                        UI_ThemeColorShade(TH_BACK, -40);
-                                       glRecti(tempx -10, *starty+4, tempx -8, *starty+OL_H-4);
+                                       glRecti(tempx -10, *starty+4, tempx -8, *starty+UI_UNIT_Y-4);
 
                                        glEnable(GL_BLEND);
                                        glPixelTransferf(GL_ALPHA_SCALE, 0.5);
@@ -4697,13 +4793,18 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
        te->ys= (float)*starty;
        te->xend= startx+offsx;
                
-       *starty-= OL_H;
-
        if((tselem->flag & TSE_CLOSED)==0) {
-               for(ten= te->subtree.first; ten; ten= ten->next) {
-                       outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+OL_X, starty);
-               }
+               *starty-= UI_UNIT_Y;
+               
+               for(ten= te->subtree.first; ten; ten= ten->next)
+                       outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+UI_UNIT_X, starty);
        }       
+       else {
+               for(ten= te->subtree.first; ten; ten= ten->next)
+                       outliner_set_coord_tree_element(soops, te, startx, starty);
+
+               *starty-= UI_UNIT_Y;
+       }
 }
 
 static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, int *starty)
@@ -4721,12 +4822,12 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx,
                
                /* horizontal line? */
                if(tselem->type==0 && (te->idcode==ID_OB || te->idcode==ID_SCE))
-                       glRecti(startx, *starty, startx+OL_X, *starty-1);
+                       glRecti(startx, *starty, startx+UI_UNIT_X, *starty-1);
                        
-               *starty-= OL_H;
+               *starty-= UI_UNIT_Y;
                
                if((tselem->flag & TSE_CLOSED)==0)
-                       outliner_draw_hierarchy(soops, &te->subtree, startx+OL_X, starty);
+                       outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty);
        }
        
        /* vertical line */
@@ -4735,7 +4836,7 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx,
                tselem= TREESTORE(te);
                if(tselem->type==0 && te->idcode==ID_OB) {
                        
-                       glRecti(startx, y1+OL_H, startx+1, y2);
+                       glRecti(startx, y1+UI_UNIT_Y, startx+1, y2);
                }
        }
 }
@@ -4751,13 +4852,13 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
                /* selection status */
                if((tselem->flag & TSE_CLOSED)==0)
                        if(tselem->type == TSE_RNA_STRUCT)
-                               glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+OL_H-1);
+                               glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1);
 
-               *starty-= OL_H;
+               *starty-= UI_UNIT_Y;
                if((tselem->flag & TSE_CLOSED)==0) {
                        outliner_draw_struct_marks(ar, soops, &te->subtree, starty);
                        if(tselem->type == TSE_RNA_STRUCT)
-                               fdrawline(0, (float)*starty+OL_H, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+OL_H);
+                               fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y);
                }
        }
 }
@@ -4772,9 +4873,9 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb,
                
                /* selection status */
                if(tselem->flag & TSE_SELECTED) {
-                       glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+OL_H-1);
+                       glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1);
                }
-               *starty-= OL_H;
+               *starty-= UI_UNIT_Y;
                if((tselem->flag & TSE_CLOSED)==0) outliner_draw_selection(ar, soops, &te->subtree, starty);
        }
 }
@@ -4792,24 +4893,24 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio
                /* struct marks */
                UI_ThemeColorShadeAlpha(TH_BACK, -15, -200);
                //UI_ThemeColorShade(TH_BACK, -20);
-               starty= (int)ar->v2d.tot.ymax-OL_H-OL_Y_OFFSET;
+               starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET;
                outliner_draw_struct_marks(ar, soops, &soops->tree, &starty);
        }
        
        /* always draw selection fill before hierarchy */
        UI_GetThemeColor3fv(TH_BACK, col);
        glColor3f(col[0]+0.06f, col[1]+0.08f, col[2]+0.10f);
-       starty= (int)ar->v2d.tot.ymax-OL_H-OL_Y_OFFSET;
+       starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET;
        outliner_draw_selection(ar, soops, &soops->tree, &starty);
        
        // grey hierarchy lines
        UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.2f);
-       starty= (int)ar->v2d.tot.ymax-OL_H/2-OL_Y_OFFSET;
+       starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y/2-OL_Y_OFFSET;
        startx= 6;
        outliner_draw_hierarchy(soops, &soops->tree, startx, &starty);
        
        // items themselves
-       starty= (int)ar->v2d.tot.ymax-OL_H-OL_Y_OFFSET;
+       starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET;
        startx= 0;
        for(te= soops->tree.first; te; te= te->next) {
                outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty);
@@ -4823,11 +4924,11 @@ static void outliner_back(ARegion *ar)
        
        UI_ThemeColorShade(TH_BACK, 6);
        ystart= (int)ar->v2d.tot.ymax;
-       ystart= OL_H*(ystart/(OL_H))-OL_Y_OFFSET;
+       ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET;
        
-       while(ystart+2*OL_H > ar->v2d.cur.ymin) {
-               glRecti(0, ystart, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, ystart+OL_H);
-               ystart-= 2*OL_H;
+       while(ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) {
+               glRecti(0, ystart, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, ystart+UI_UNIT_Y);
+               ystart-= 2*UI_UNIT_Y;
        }
 }
 
@@ -4841,11 +4942,11 @@ static void outliner_draw_restrictcols(ARegion *ar)
        
        UI_ThemeColorShade(TH_BACK, 6);
        ystart= (int)ar->v2d.tot.ymax;
-       ystart= OL_H*(ystart/(OL_H))-OL_Y_OFFSET;
+       ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET;
        
-       while(ystart+2*OL_H > ar->v2d.cur.ymin) {
-               glRecti((int)ar->v2d.cur.xmax-OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart+OL_H);
-               ystart-= 2*OL_H;
+       while(ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) {
+               glRecti((int)ar->v2d.cur.xmax-OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart+UI_UNIT_Y);
+               ystart-= 2*UI_UNIT_Y;
        }
        
        UI_ThemeColorShadeAlpha(TH_BACK, -15, -200);
@@ -4917,7 +5018,7 @@ static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *po
 {
        Object *ob = (Object *)poin2;
        
-       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
 }
@@ -4979,11 +5080,14 @@ static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
        }
        else {
                for(gob= gr->gobject.first; gob; gob= gob->next) {
-                       gob->ob->restrictflag |= flag;
+                       /* not in editmode */
+                       if(scene->obedit!=gob->ob) {
+                               gob->ob->restrictflag |= flag;
 
-                       if(flag==OB_RESTRICT_VIEW)
-                               if((gob->ob->flag & SELECT) == 0)
-                                       ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT);
+                               if(flag==OB_RESTRICT_VIEW)
+                                       if((gob->ob->flag & SELECT) == 0)
+                                               ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT);
+                       }
                }
        }
 } 
@@ -5126,7 +5230,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
 
        for(te= lb->first; te; te= te->next) {
                tselem= TREESTORE(te);
-               if(te->ys+2*OL_H >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {   
+               if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {      
                        /* objects have toggle-able restriction flags */
                        if(tselem->type==0 && te->idcode==ID_OB) {
                                PointerRNA ptr;
@@ -5136,17 +5240,17 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF,
-                                                         (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1,
+                                                         (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1,
                                                          &ptr, "hide", -1, 0, 0, -1, -1, NULL);
                                uiButSetFunc(bt, restrictbutton_view_cb, scene, ob);
                                
                                bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF,
-                                                                 (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1,
+                                                                 (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1,
                                                                  &ptr, "hide_select", -1, 0, 0, -1, -1, NULL);
                                uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob);
                                
                                bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF,
-                                                                 (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1,
+                                                                 (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1,
                                                                  &ptr, "hide_render", -1, 0, 0, -1, -1, NULL);
                                uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob);
                                
@@ -5156,29 +5260,29 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                        if(tselem->type==0 && te->idcode==ID_GR){ 
                                int restrict_bool;
                                gr = (Group *)tselem->id;
-                               
+
                                uiBlockSetEmboss(block, UI_EMBOSSN);
 
                                restrict_bool= group_restrict_flag(gr, OB_RESTRICT_VIEW);
-                               bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
+                               bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
                                uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr);
 
                                restrict_bool= group_restrict_flag(gr, OB_RESTRICT_SELECT);
-                               bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
+                               bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
                                uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr);
 
                                restrict_bool= group_restrict_flag(gr, OB_RESTRICT_RENDER);
-                               bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow renderability");
+                               bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability");
                                uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr);
 
                                uiBlockSetEmboss(block, UI_EMBOSS);
-                       }
+                       }
                        /* scene render layers and passes have toggle-able flags too! */
                        else if(tselem->type==TSE_R_LAYER) {
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                
                                bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, 
-                                                                        (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer");
+                                                                        (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer");
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
                                
                                uiBlockSetEmboss(block, UI_EMBOSS);
@@ -5191,13 +5295,13 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                
                                bt= uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT-1, 
-                                                                        (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Render this Pass");
+                                                                        (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Render this Pass");
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
                                
                                layflag++;      /* is lay_xor */
                                if(ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT))
                                        bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, 
-                                                                        (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined");
+                                                                        (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined");
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
                                
                                uiBlockSetEmboss(block, UI_EMBOSS);
@@ -5208,11 +5312,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, 
-                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
+                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
                                uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
                                
                                bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, 
-                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability");
+                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability");
                                uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
                        }
                        else if(tselem->type==TSE_POSE_CHANNEL)  {
@@ -5221,11 +5325,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, 
-                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
+                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
                                uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone);
                                
                                bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, 
-                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
+                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
                                uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
                        }
                        else if(tselem->type==TSE_EBONE)  {
@@ -5233,11 +5337,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, 
-                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
+                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
                                uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone);
                                
                                bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, 
-                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
+                                               (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
                                uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL);
                        }
                }
@@ -5278,19 +5382,19 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
 
        for(te= lb->first; te; te= te->next) {
                tselem= TREESTORE(te);
-               if(te->ys+2*OL_H >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {   
+               if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {      
                        if(tselem->type == TSE_RNA_PROPERTY) {
                                ptr= &te->rnaptr;
                                prop= te->directdata;
                                
                                if(!(RNA_property_type(prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
-                                       uiDefAutoButR(block, ptr, prop, -1, "", 0, sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1);
+                                       uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1);
                        }
                        else if(tselem->type == TSE_RNA_ARRAY_ELEM) {
                                ptr= &te->rnaptr;
                                prop= te->directdata;
                                
-                               uiDefAutoButR(block, ptr, prop, te->index, "", 0, sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1);
+                               uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1);
                        }
                }
                
@@ -5345,7 +5449,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi)
        /* fake button, it holds space for search items */
        uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
        
-       but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, 19, 0, 0, "");
+       but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, UI_UNIT_Y, 0, 0, "");
        uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot);
        
        uiBoundsBlock(block, 6);
@@ -5484,11 +5588,11 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
        
        for(te= lb->first; te; te= te->next) {
                tselem= TREESTORE(te);
-               if(te->ys+2*OL_H >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {
+               if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {
                        uiBut *but;
                        const char *str;
                        int xstart= 240;
-                       int butw1= 20; /* operator */
+                       int butw1= UI_UNIT_X; /* operator */
                        int butw2= 90; /* event type, menus */
                        int butw3= 43; /* modifiers */
 
@@ -5498,7 +5602,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
                                /* modal map? */
                                if(kmi->propvalue);
                                else {
-                                       uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys+1, butw1, OL_H-1, "Assign new Operator");
+                                       uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys+1, butw1, UI_UNIT_Y-1, "Assign new Operator");
                                }
                                xstart+= butw1+10;
                                
@@ -5506,45 +5610,46 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
                                kmi->maptype= keymap_menu_type(kmi->type);
                                
                                str= keymap_type_menu();
-                               but= uiDefButS(block, MENU, 0, str,     xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->maptype, 0, 0, 0, 0, "Event type");
+                               but= uiDefButS(block, MENU, 0, str,     xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->maptype, 0, 0, 0, 0, "Event type");
                                uiButSetFunc(but, keymap_type_cb, kmi, NULL);
                                xstart+= butw2+5;
                                
                                /* edit actual event */
                                switch(kmi->maptype) {
                                        case OL_KM_KEYBOARD:
-                                               uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->type, "Key code");
+                                               uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, "Key code");
                                                xstart+= butw2+5;
                                                break;
                                        case OL_KM_MOUSE:
                                                str= keymap_mouse_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart,(int)te->ys+1, butw2, OL_H-1, &kmi->type, 0, 0, 0, 0,  "Mouse button");   
+                                               uiDefButS(block, MENU, 0, str, xstart,(int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0,  "Mouse button");      
                                                xstart+= butw2+5;
                                                break;
                                        case OL_KM_TWEAK:
                                                str= keymap_tweak_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->type, 0, 0, 0, 0,  "Tweak gesture"); 
+                                               uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0,  "Tweak gesture");    
                                                xstart+= butw2+5;
                                                str= keymap_tweak_dir_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->val, 0, 0, 0, 0,  "Tweak gesture direction");        
+                                               uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->val, 0, 0, 0, 0,  "Tweak gesture direction");   
                                                xstart+= butw2+5;
                                                break;
                                }
                                
                                /* modifiers */
-                               uiDefButS(block, OPTION, 0, "Shift",    xstart, (int)te->ys+1, butw3+5, OL_H-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5;
-                               uiDefButS(block, OPTION, 0, "Ctrl",     xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
-                               uiDefButS(block, OPTION, 0, "Alt",      xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
-                               uiDefButS(block, OPTION, 0, "OS",       xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
+                               uiDefButS(block, OPTION, 0, "Shift",    xstart, (int)te->ys+1, butw3+5, UI_UNIT_Y-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5;
+                               uiDefButS(block, OPTION, 0, "Ctrl",     xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
+                               uiDefButS(block, OPTION, 0, "Alt",      xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
+                               uiDefButS(block, OPTION, 0, "OS",       xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
                                xstart+= 5;
-                               uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->keymodifier, "Key Modifier code");
+                               uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->keymodifier, "Key Modifier code");
                                xstart+= butw3+5;
                                
                                /* rna property */
-                               if(kmi->ptr && kmi->ptr->data)
-                                       uiDefBut(block, LABEL, 0, "(RNA property)",     xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2;
-                                       
-                               
+                               if(kmi->ptr && kmi->ptr->data) {
+                                       uiDefBut(block, LABEL, 0, "(RNA property)",     xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2;
+                               }
+
+                               (void)xstart;
                        }
                }
                
@@ -5562,7 +5667,7 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa
        
        for(te= lb->first; te; te= te->next) {
                tselem= TREESTORE(te);
-               if(te->ys+2*OL_H >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {
+               if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {
                        
                        if(tselem->flag & TSE_TEXTBUT) {
                                
@@ -5574,15 +5679,15 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa
                                if(tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name);
                                else if (tselem->type==TSE_MODIFIER) len = sizeof(((ModifierData*) 0)->name);
                                else if(tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name);
-                               else len= sizeof(((ID*) 0)->name)-2;
+                               else len= MAX_ID_NAME-2;
                                
 
                                dx= (int)UI_GetStringWidth(te->name);
                                if(dx<100) dx= 100;
-                               spx=te->xs+2*OL_X-4;
+                               spx=te->xs+2*UI_UNIT_X-4;
                                if(spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10;
 
-                               bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (short)te->ys, dx+10, OL_H-1, (void *)te->name, 1.0, (float)len, 0, 0, "");
+                               bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx+10, UI_UNIT_Y-1, (void *)te->name, 1.0, (float)len, 0, 0, "");
                                uiButSetRenameFunc(bt, namebutton_cb, tselem);
                                
                                /* returns false if button got removed */
@@ -5616,7 +5721,7 @@ void draw_outliner(const bContext *C)
                 *                               (OL_RNA_COL_X), whichever is wider...
                 *      - column 2 is fixed at OL_RNA_COL_SIZEX
                 *
-                *  (*) XXX max width for now is a fixed factor of OL_X*(max_indention+100)
+                *  (*) XXX max width for now is a fixed factor of UI_UNIT_X*(max_indention+100)
                 */
                 
                /* get actual width of column 1 */
@@ -5649,6 +5754,8 @@ void draw_outliner(const bContext *C)
        /* update size of tot-rect (extents of data/viewable area) */
        UI_view2d_totRect_set(v2d, sizex, sizey);
 
+       /* force display to pixel coords */
+       v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
        /* set matrix for 2d-view controls */
        UI_view2d_view_ortho(v2d);