Merge with trunk r37546
[blender.git] / source / blender / editors / space_outliner / outliner.c
index 20b5ad7a34f58383ac8c6538bdf7d8f8bb1136c2..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
 
 
 /* ************* XXX **************** */
 
-static void error(const char *dummy, ...) {}
+static void error(const char *UNUSED(arg), ...) {}
 
 /* ********************************** */
 
@@ -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;
        
@@ -240,7 +245,7 @@ void outliner_free_tree(ListBase *lb)
                outliner_free_tree(&te->subtree);
                BLI_remlink(lb, te);
 
-               if(te->flag & TE_FREE_NAME) MEM_freeN(te->name);
+               if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name);
                MEM_freeN(te);
        }
 }
@@ -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;
        }
 }
@@ -324,7 +329,7 @@ static ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode)
 struct treesort {
        TreeElement *te;
        ID *id;
-       char *name;
+       const char *name;
        short idcode;
 };
 
@@ -340,7 +345,7 @@ static int treesort_alpha(const void *v1, const void *v2)
        if(comp==1) return 1;
        else if(comp==2) return -1;
        else if(comp==3) {
-               int comp= strcmp(x1->name, x2->name);
+               comp= strcmp(x1->name, x2->name);
                
                if( comp>0 ) return 1;
                else if( comp<0) return -1;
@@ -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)
 {
@@ -1112,8 +1117,8 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                        c= RNA_property_array_item_char(prop, index);
 
                        te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName");
-                       if(c) sprintf(te->name, "  %c", c);
-                       else sprintf(te->name, "  %d", index+1);
+                       if(c) sprintf((char *)te->name, "  %c", c);
+                       else sprintf((char *)te->name, "  %d", index+1);
                        te->flag |= TE_FREE_NAME;
                }
        }
@@ -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;
@@ -1308,7 +1313,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb)
                                outliner_free_tree(&te->subtree);
                                BLI_remlink(lb, te);
                                
-                               if(te->flag & TE_FREE_NAME) MEM_freeN(te->name);
+                               if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name);
                                MEM_freeN(te);
                        }
                }
@@ -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;
@@ -1556,7 +1596,7 @@ static void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short
 /* same check needed for both object operation and restrict column button func
  * return 0 when in edit mode (cannot restrict view or select)
  * otherwise return 1 */
-static int common_restrict_check(bContext *C, Scene *scene, Object *ob)
+static int common_restrict_check(bContext *C, Object *ob)
 {
        /* Don't allow hide an object in edit mode,
         * check the bug #22153 and #21609, #23977
@@ -1575,13 +1615,13 @@ static int common_restrict_check(bContext *C, Scene *scene, Object *ob)
        return 1;
 }
 
-void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *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;
        
        /* add check for edit mode */
-       if(!common_restrict_check(C, scene, ob)) return;
+       if(!common_restrict_check(C, ob)) return;
        
        if(base || (base= object_in_scene(ob, scene))) {
                if((base->object->restrictflag ^= OB_RESTRICT_VIEW)) {
@@ -1590,7 +1630,7 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre
        }
 }
 
-static int outliner_toggle_visibility_exec(bContext *C, wmOperator *op)
+static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceOops *soops= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
@@ -1620,7 +1660,7 @@ void OUTLINER_OT_visibility_toggle(wmOperatorType *ot)
 
 /* --- */
 
-static void object_toggle_selectability_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base= (Base *)te->directdata;
        
@@ -1630,7 +1670,7 @@ static void object_toggle_selectability_cb(bContext *C, Scene *scene, TreeElemen
        }
 }
 
-static int outliner_toggle_selectability_exec(bContext *C, wmOperator *op)
+static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceOops *soops= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
@@ -1658,7 +1698,7 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-void object_toggle_renderability_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *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;
        
@@ -1668,7 +1708,7 @@ void object_toggle_renderability_cb(bContext *C, Scene *scene, TreeElement *te,
        }
 }
 
-static int outliner_toggle_renderability_exec(bContext *C, wmOperator *op)
+static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceOops *soops= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
@@ -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;
@@ -1697,7 +1737,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot)
 
 /* --- */
 
-static int outliner_toggle_expanded_exec(bContext *C, wmOperator *op)
+static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceOops *soops= CTX_wm_space_outliner(C);
        ARegion *ar= CTX_wm_region(C);
@@ -1728,7 +1768,7 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot)
 
 /* --- */
 
-static int outliner_toggle_selected_exec(bContext *C, wmOperator *op)
+static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceOops *soops= CTX_wm_space_outliner(C);
        ARegion *ar= CTX_wm_region(C);
@@ -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;
@@ -1820,6 +1861,8 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot)
        RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep.");
 }
 
+/* This is not used anywhere at the moment */
+#if 0
 /* return 1 when levels were opened */
 static int outliner_open_back(SpaceOops *soops, TreeElement *te)
 {
@@ -1836,8 +1879,6 @@ static int outliner_open_back(SpaceOops *soops, TreeElement *te)
        return retval;
 }
 
-/* This is not used anywhere at the moment */
-#if 0
 static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *teFind, int *found)
 {
        TreeElement *te;
@@ -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 *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 */
@@ -2056,7 +2097,7 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo
 }
 
 
-static int tree_element_active_lamp(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
+static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set)
 {
        Object *ob;
        
@@ -2072,6 +2113,16 @@ static int tree_element_active_lamp(bContext *C, Scene *scene, SpaceOops *soops,
        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,32 +2251,54 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
 
 
 /* ebones only draw in editmode armature */
-static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set)
+static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel)
 {
-       EditBone *ebone= te->directdata;
-       
-       if(set) {
-               if(!(ebone->flag & BONE_HIDDEN_A)) {
-                       bArmature *arm= scene->obedit->data;
-                       if(set==2) ED_armature_deselectall(scene->obedit, 2);   // only clear active tag
-                       else ED_armature_deselectall(scene->obedit, 0); // deselect
+       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;
+       }
 
-                       ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL;
-                       arm->act_edbone= ebone;
+       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;
 
-                       // 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;
 }
 
-static int tree_element_active_modifier(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set)
+static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set)
 {
        if(set) {
                Object *ob= (Object *)tselem->id;
@@ -2242,7 +2311,7 @@ static int tree_element_active_modifier(bContext *C, TreeElement *te, TreeStoreE
        return 0;
 }
 
-static int tree_element_active_psys(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set)
+static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set)
 {
        if(set) {
                Object *ob= (Object *)tselem->id;
@@ -2255,7 +2324,7 @@ static int tree_element_active_psys(bContext *C, Scene *scene, TreeElement *te,
        return 0;
 }
 
-static int tree_element_active_constraint(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set)
+static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set)
 {
        if(set) {
                Object *ob= (Object *)tselem->id;
@@ -2267,7 +2336,7 @@ static int tree_element_active_constraint(bContext *C, TreeElement *te, TreeStor
        return 0;
 }
 
-static int tree_element_active_text(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
+static int tree_element_active_text(bContext *UNUSED(C), Scene *UNUSED(scene), SpaceOops *UNUSED(soops), TreeElement *UNUSED(te), int UNUSED(set))
 {
        // XXX removed
        return 0;
@@ -2288,11 +2357,13 @@ 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;
 }
 
-static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set)
+static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set)
 {
        Object *ob= (Object *)tselem->id;
        Base *base= object_in_scene(ob, scene);
@@ -2312,7 +2383,7 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *te,
        return 0;
 }
 
-static int tree_element_active_sequence(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set)
+static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(tselem), int set)
 {
        Sequence *seq= (Sequence*) te->directdata;
 
@@ -2326,7 +2397,7 @@ static int tree_element_active_sequence(bContext *C, TreeElement *te, TreeStoreE
        return(0);
 }
 
-static int tree_element_active_sequence_dup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set)
+static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set)
 {
        Sequence *seq, *p;
        Editing *ed= seq_give_editing(scene, FALSE);
@@ -2353,7 +2424,7 @@ static int tree_element_active_sequence_dup(bContext *C, Scene *scene, TreeEleme
        return(0);
 }
 
-static int tree_element_active_keymap_item(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set)
+static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, TreeStoreElem *UNUSED(tselem), int set)
 {
        wmKeyMapItem *kmi= te->directdata;
        
@@ -2398,9 +2469,9 @@ static int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops,
                case TSE_POSEGRP:
                        return tree_element_active_posegroup(C, scene, te, tselem, set);
                case TSE_SEQUENCE:
-                       return tree_element_active_sequence(C, te, tselem, set);
+                       return tree_element_active_sequence(te, tselem, set);
                case TSE_SEQUENCE_DUP:
-                       return tree_element_active_sequence_dup(C, scene, te, tselem, set);
+                       return tree_element_active_sequence_dup(scene, te, tselem, set);
                case TSE_KEYMAP_ITEM:
                        return tree_element_active_keymap_item(C, te, tselem, set);
                        
@@ -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);
                        }
@@ -2660,14 +2726,14 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T
        return 0;
 }
 
-static int outliner_item_rename(bContext *C, wmOperator *op, wmEvent *event)
+static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
 {
        ARegion *ar= CTX_wm_region(C);
        SpaceOops *soops= CTX_wm_space_outliner(C);
        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,45 +2747,13 @@ 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;
        
        ot->poll= ED_operator_outliner_active;
 }
 
-
-
-/* recursive helper for function below */
-static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty)
-{
-       TreeStoreElem *tselem= TREESTORE(te);
-       
-       /* store coord and continue, we need coordinates for elements outside view too */
-       te->xs= (float)startx;
-       te->ys= (float)(*starty);
-       *starty-= OL_H;
-       
-       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);
-               }
-       }
-       
-}
-
-/* to retrieve coordinates with redrawing the entire tree */
-static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops)
-{
-       TreeElement *te;
-       int starty= (int)(ar->v2d.tot.ymax)-OL_H;
-       int startx= 0;
-       
-       for(te= soops->tree.first; te; te= te->next) {
-               outliner_set_coordinates_element(soops, te, startx, &starty);
-       }
-}
-
 static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id)
 {
        TreeElement *te, *tes;
@@ -2730,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;
                        }
@@ -2739,7 +2773,7 @@ static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id)
        return NULL;
 }
 
-static int outliner_show_active_exec(bContext *C, wmOperator *op)
+static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceOops *so= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
@@ -2785,8 +2819,66 @@ void OUTLINER_OT_show_active(wmOperatorType *ot)
        /* callbacks */
        ot->exec= outliner_show_active_exec;
        ot->poll= ED_operator_outliner_active;
+}
+
+/* tse is not in the treestore, we use its contents to find a match */
+static TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse)
+{
+       TreeStore *ts= soops->treestore;
+       TreeStoreElem *tselem;
+       int a;
        
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       if(tse->id==NULL) return NULL;
+       
+       /* check if 'tse' is in treestore */
+       tselem= ts->data;
+       for(a=0; a<ts->usedelem; a++, tselem++) {
+               if((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) {
+                       if(tselem->id==tse->id) {
+                               break;
+                       }
+               }
+       }
+       if(tselem) 
+               return outliner_find_tree_element(&soops->tree, a);
+       
+       return NULL;
+}
+
+
+/* Called to find an item based on name.
+ */
+#if 0
+
+/* recursive helper for function below */
+static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty)
+{
+       TreeStoreElem *tselem= TREESTORE(te);
+       
+       /* store coord and continue, we need coordinates for elements outside view too */
+       te->xs= (float)startx;
+       te->ys= (float)(*starty);
+       *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+UI_UNIT_X, starty);
+               }
+       }
+       
+}
+
+/* to retrieve coordinates with redrawing the entire tree */
+static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops)
+{
+       TreeElement *te;
+       int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y;
+       int startx= 0;
+       
+       for(te= soops->tree.first; te; te= te->next) {
+               outliner_set_coordinates_element(soops, te, startx, &starty);
+       }
 }
 
 /* find next element that has this name */
@@ -2818,34 +2910,7 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na
        return NULL;
 }
 
-/* tse is not in the treestore, we use its contents to find a match */
-static TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse)
-{
-       TreeStore *ts= soops->treestore;
-       TreeStoreElem *tselem;
-       int a;
-       
-       if(tse->id==NULL) return NULL;
-       
-       /* check if 'tse' is in treestore */
-       tselem= ts->data;
-       for(a=0; a<ts->usedelem; a++, tselem++) {
-               if((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) {
-                       if(tselem->id==tse->id) {
-                               break;
-                       }
-               }
-       }
-       if(tselem) 
-               return outliner_find_tree_element(&soops->tree, a);
-       
-       return NULL;
-}
-
-
-/* Called to find an item based on name.
- */
-void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, int again, int flags) 
+static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) 
 {
        TreeElement *te= NULL;
        TreeElement *last_find;
@@ -2917,6 +2982,7 @@ void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, int again,
                error("Not found: %s", name);
        }
 }
+#endif
 
 /* helper function for tree_element_shwo_hierarchy() - recursively checks whether subtrees have any objects*/
 static int subtree_has_objects(SpaceOops *soops, ListBase *lb)
@@ -2959,7 +3025,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase
 }
 
 /* show entire object level hierarchy */
-static int outliner_show_hierarchy_exec(bContext *C, wmOperator *op)
+static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceOops *soops= CTX_wm_space_outliner(C);
        ARegion *ar= CTX_wm_region(C);
@@ -3077,7 +3143,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb,
        }
 }
 
-static void unlink_material_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
 {
        Material **matar=NULL;
        int a, totcol=0;
@@ -3111,7 +3177,7 @@ static void unlink_material_cb(bContext *C, Scene *scene, TreeElement *te, TreeS
        }
 }
 
-static void unlink_texture_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
 {
        MTex **mtex= NULL;
        int a;
@@ -3140,7 +3206,7 @@ static void unlink_texture_cb(bContext *C, Scene *scene, TreeElement *te, TreeSt
        }
 }
 
-static void unlink_group_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
        Group *group= (Group *)tselem->id;
        
@@ -3177,7 +3243,7 @@ static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *
 
 /* */
 
-static void object_select_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base= (Base *)te->directdata;
        
@@ -3188,7 +3254,7 @@ static void object_select_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
        }
 }
 
-static void object_deselect_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base= (Base *)te->directdata;
        
@@ -3199,7 +3265,7 @@ static void object_deselect_cb(bContext *C, Scene *scene, TreeElement *te, TreeS
        }
 }
 
-static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base= (Base *)te->directdata;
        
@@ -3217,16 +3283,16 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
 
 }
 
-static void id_local_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        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);
        }
 }
 
-static void group_linkobs2scene_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Group *group= (Group *)tselem->id;
        GroupObject *gob;
@@ -3279,7 +3345,7 @@ static void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOop
 
 /* ******************************************** */
 
-static void pchan_cb(int event, TreeElement *te, TreeStoreElem *tselem)
+static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem))
 {
        bPoseChannel *pchan= (bPoseChannel *)te->directdata;
        
@@ -3295,7 +3361,7 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *tselem)
                pchan->bone->flag &= ~BONE_HIDDEN_P;
 }
 
-static void bone_cb(int event, TreeElement *te, TreeStoreElem *tselem)
+static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem))
 {
        Bone *bone= (Bone *)te->directdata;
        
@@ -3311,7 +3377,7 @@ static void bone_cb(int event, TreeElement *te, TreeStoreElem *tselem)
                bone->flag &= ~BONE_HIDDEN_P;
 }
 
-static void ebone_cb(int event, TreeElement *te, TreeStoreElem *tselem)
+static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem))
 {
        EditBone *ebone= (EditBone *)te->directdata;
        
@@ -3327,7 +3393,7 @@ static void ebone_cb(int event, TreeElement *te, TreeStoreElem *tselem)
                ebone->flag &= ~BONE_HIDDEN_A;
 }
 
-static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem)
+static void sequence_cb(int event, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tselem))
 {
 //     Sequence *seq= (Sequence*) te->directdata;
        if(event==1) {
@@ -3354,7 +3420,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li
        }
 }
 
-void outliner_del(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops)
+static void outliner_del(bContext *C, Scene *scene, ARegion *UNUSED(ar), SpaceOops *soops)
 {
        
        if(soops->outlinevis==SO_SEQUENCE)
@@ -3385,7 +3451,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        SpaceOops *soops= CTX_wm_space_outliner(C);
        int event;
-       char *str= NULL;
+       const char *str= NULL;
        
        /* check for invalid states */
        if (soops == NULL)
@@ -3464,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}
 };
 
@@ -3492,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);
@@ -3659,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);
                
@@ -3714,7 +3780,7 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S
 }
 
 
-static int outliner_operation(bContext *C, wmOperator *op, wmEvent *event)
+static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
 {
        Scene *scene= CTX_data_scene(C);
        ARegion *ar= CTX_wm_region(C);
@@ -3722,7 +3788,7 @@ static int outliner_operation(bContext *C, wmOperator *op, wmEvent *event)
        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;
@@ -3736,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;
        
@@ -3764,7 +3831,7 @@ static int ed_operator_outliner_datablocks_active(bContext *C)
  * this function does not do that yet 
  */
 static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, 
-                                                       ID **id, char **path, int *array_index, short *flag, short *groupmode)
+                                                       ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode))
 {
        ListBase hierarchy = {NULL, NULL};
        LinkData *ld;
@@ -3902,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;
@@ -3932,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 */
@@ -3953,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;
                                        }
@@ -3974,7 +4042,7 @@ 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);
        }
 }
 
@@ -3989,10 +4057,10 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *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;
 }
@@ -4009,7 +4077,7 @@ 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;
 }
 
 
@@ -4024,7 +4092,7 @@ static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *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
@@ -4044,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 *************** */
@@ -4055,7 +4123,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot)
 enum {
        KEYINGSET_EDITMODE_ADD  = 0,
        KEYINGSET_EDITMODE_REMOVE,
-} eKeyingSet_EditModes;
+} /*eKeyingSet_EditModes*/;
 
 /* Utilities ---------------------------------- */ 
  
@@ -4126,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;
@@ -4177,20 +4242,21 @@ 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;
 }
 
 
 /* Remove Operator ---------------------------------- */
 
-static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *op)
+static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceOops *soutliner= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
@@ -4213,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 *************** */
@@ -4239,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);
        }
@@ -4350,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;
                                }
@@ -4502,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);
@@ -4511,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?
@@ -4520,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 */
@@ -4542,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);
 
@@ -4583,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);
                                }
 
@@ -4616,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
@@ -4628,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);
 
@@ -4665,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) {
@@ -4678,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);
@@ -4696,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)
@@ -4720,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 */
@@ -4734,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);
                }
        }
 }
@@ -4750,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);
                }
        }
 }
@@ -4771,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);
        }
 }
@@ -4791,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);
@@ -4816,21 +4918,21 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio
 }
 
 
-static void outliner_back(ARegion *ar, SpaceOops *soops)
+static void outliner_back(ARegion *ar)
 {
        int ystart;
        
        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;
        }
 }
 
-static void outliner_draw_restrictcols(ARegion *ar, SpaceOops *soops)
+static void outliner_draw_restrictcols(ARegion *ar)
 {
        int ystart;
        
@@ -4840,11 +4942,11 @@ static void outliner_draw_restrictcols(ARegion *ar, SpaceOops *soops)
        
        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);
@@ -4873,7 +4975,7 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2)
        Scene *scene = (Scene *)poin;
        Object *ob = (Object *)poin2;
 
-       if(!common_restrict_check(C, scene, ob)) return;
+       if(!common_restrict_check(C, ob)) return;
        
        /* deselect objects that are invisible */
        if (ob->restrictflag & OB_RESTRICT_VIEW) {
@@ -4890,7 +4992,7 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2)
        Scene *scene = (Scene *)poin;
        Object *ob = (Object *)poin2;
        
-       if(!common_restrict_check(C, scene, ob)) return;
+       if(!common_restrict_check(C, ob)) return;
        
        /* if select restriction has just been turned on */
        if (ob->restrictflag & OB_RESTRICT_SELECT) {
@@ -4902,26 +5004,26 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2)
 
 }
 
-static void restrictbutton_rend_cb(bContext *C, void *poin, void *poin2)
+static void restrictbutton_rend_cb(bContext *C, void *poin, void *UNUSED(poin2))
 {
        WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, poin);
 }
 
-static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *poin2)
+static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2))
 {
        WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, poin);
 }
 
-static void restrictbutton_modifier_cb(bContext *C, void *poin, void *poin2)
+static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2)
 {
        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);
 }
 
-static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2)
+static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2)
 {
        Bone *bone= (Bone *)poin2;
        if(bone && (bone->flag & BONE_HIDDEN_P))
@@ -4929,7 +5031,7 @@ static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2)
        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
 }
 
-static void restrictbutton_ebone_cb(bContext *C, void *poin, void *poin2)
+static void restrictbutton_ebone_cb(bContext *C, void *UNUSED(poin), void *poin2)
 {
        EditBone *ebone= (EditBone *)poin2;
        if(ebone && (ebone->flag & BONE_HIDDEN_A))
@@ -4961,7 +5063,7 @@ static int group_select_flag(Group *gr)
        return 0;
 }
 
-static void restrictbutton_gr_restrict_flag(bContext *C, void *poin, void *poin2, int flag)
+static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
 {      
        Scene *scene = (Scene *)poin;           
        GroupObject *gob;
@@ -4978,28 +5080,31 @@ static void restrictbutton_gr_restrict_flag(bContext *C, void *poin, void *poin2
        }
        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);
+                       }
                }
        }
 } 
 
 static void restrictbutton_gr_restrict_view(bContext *C, void *poin, void *poin2)
 {
-       restrictbutton_gr_restrict_flag(C, poin, poin2, OB_RESTRICT_VIEW);
+       restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_VIEW);
        WM_event_add_notifier(C, NC_GROUP, NULL);
 }
 static void restrictbutton_gr_restrict_select(bContext *C, void *poin, void *poin2)
 {
-       restrictbutton_gr_restrict_flag(C, poin, poin2, OB_RESTRICT_SELECT);
+       restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_SELECT);
        WM_event_add_notifier(C, NC_GROUP, NULL);
 }
 static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poin2)
 {
-       restrictbutton_gr_restrict_flag(C, poin, poin2, OB_RESTRICT_RENDER);
+       restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_RENDER);
        WM_event_add_notifier(C, NC_GROUP, NULL);
 }
 
@@ -5034,7 +5139,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                        if (te->idcode == ID_LI) {
                                char expanded[FILE_MAXDIR + FILE_MAXFILE];
                                BLI_strncpy(expanded, ((Library *)tselem->id)->name, FILE_MAXDIR + FILE_MAXFILE);
-                               BLI_path_abs(expanded, G.sce);
+                               BLI_path_abs(expanded, G.main->name);
                                if (!BLI_exists(expanded)) {
                                        error("This path does not exist, correct this before saving");
                                }
@@ -5053,11 +5158,11 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                                bArmature *arm= (bArmature *)tselem->id;
                                if(arm->edbo) {
                                        EditBone *ebone= te->directdata;
-                                       char newname[32];
+                                       char newname[sizeof(ebone->name)];
                                        
                                        /* restore bone name */
-                                       BLI_strncpy(newname, ebone->name, 32);
-                                       BLI_strncpy(ebone->name, oldname, 32);
+                                       BLI_strncpy(newname, ebone->name, sizeof(ebone->name));
+                                       BLI_strncpy(ebone->name, oldname, sizeof(ebone->name));
                                        ED_armature_bone_rename(obedit->data, oldname, newname);
                                        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, OBACT);
                                }
@@ -5068,15 +5173,15 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                                {
                                        Bone *bone= te->directdata;
                                        Object *ob;
-                                       char newname[32];
+                                       char newname[sizeof(bone->name)];
                                        
                                        // always make current object active
                                        tree_element_set_active_object(C, scene, soops, te, 1);
                                        ob= OBACT;
                                        
                                        /* restore bone name */
-                                       BLI_strncpy(newname, bone->name, 32);
-                                       BLI_strncpy(bone->name, oldname, 32);
+                                       BLI_strncpy(newname, bone->name, sizeof(bone->name));
+                                       BLI_strncpy(bone->name, oldname, sizeof(bone->name));
                                        ED_armature_bone_rename(ob->data, oldname, newname);
                                        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
                                }
@@ -5085,15 +5190,15 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                                {
                                        bPoseChannel *pchan= te->directdata;
                                        Object *ob;
-                                       char newname[32];
+                                       char newname[sizeof(pchan->name)];
                                        
                                        // always make current object active
                                        tree_element_set_active_object(C, scene, soops, te, 1);
                                        ob= OBACT;
                                        
                                        /* restore bone name */
-                                       BLI_strncpy(newname, pchan->name, 32);
-                                       BLI_strncpy(pchan->name, oldname, 32);
+                                       BLI_strncpy(newname, pchan->name, sizeof(pchan->name));
+                                       BLI_strncpy(pchan->name, oldname, sizeof(pchan->name));
                                        ED_armature_bone_rename(ob->data, oldname, newname);
                                        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
                                }
@@ -5125,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;
@@ -5135,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);
                                
@@ -5155,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);
@@ -5190,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);
@@ -5207,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)  {
@@ -5220,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)  {
@@ -5232,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);
                        }
                }
@@ -5245,7 +5350,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
        }
 }
 
-static void outliner_draw_rnacols(ARegion *ar, SpaceOops *soops, int sizex)
+static void outliner_draw_rnacols(ARegion *ar, int sizex)
 {
        View2D *v2d= &ar->v2d;
 
@@ -5277,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);
                        }
                }
                
@@ -5297,7 +5402,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
        }
 }
 
-static void operator_call_cb(struct bContext *C, void *arg_kmi, void *arg2)
+static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2)
 {
        wmOperatorType *ot= arg2;
        wmKeyMapItem *kmi= arg_kmi;
@@ -5306,7 +5411,7 @@ static void operator_call_cb(struct bContext *C, void *arg_kmi, void *arg2)
                BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME);
 }
 
-static void operator_search_cb(const struct bContext *C, void *arg_kmi, char *str, uiSearchItems *items)
+static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items)
 {
        wmOperatorType *ot = WM_operatortype_first();
        
@@ -5344,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);
@@ -5375,89 +5480,79 @@ static short keymap_menu_type(short type)
        return 0;
 }
 
-static char *keymap_type_menu(void)
+static const char *keymap_type_menu(void)
 {
-       static char string[500];
-       static char formatstr[] = "|%s %%x%d";
-       char *str= string;
-       
-       str += sprintf(str, "Event Type %%t");
-       
-       str += sprintf(str, formatstr, "Keyboard", OL_KM_KEYBOARD);
-       str += sprintf(str, formatstr, "Mouse", OL_KM_MOUSE);
-       str += sprintf(str, formatstr, "Tweak", OL_KM_TWEAK);
-//     str += sprintf(str, formatstr, "Specials", OL_KM_SPECIALS);
-       
+       static const char string[]=
+       "Event Type%t"
+       "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD)
+       "|Mouse%x" STRINGIFY(OL_KM_MOUSE)
+       "|Tweak%x" STRINGIFY(OL_KM_TWEAK)
+//     "|Specials%x" STRINGIFY(OL_KM_SPECIALS)
+       ;
+
        return string;
-}      
-
-static char *keymap_mouse_menu(void)
-{
-       static char string[500];
-       static char formatstr[] = "|%s %%x%d";
-       char *str= string;
-       
-       str += sprintf(str, "Mouse Event %%t");
-       
-       str += sprintf(str, formatstr, "Left Mouse", LEFTMOUSE);
-       str += sprintf(str, formatstr, "Middle Mouse", MIDDLEMOUSE);
-       str += sprintf(str, formatstr, "Right Mouse", RIGHTMOUSE);
-       str += sprintf(str, formatstr, "Button4 Mouse ", BUTTON4MOUSE);
-       str += sprintf(str, formatstr, "Button5 Mouse ", BUTTON5MOUSE);
-       str += sprintf(str, formatstr, "Action Mouse", ACTIONMOUSE);
-       str += sprintf(str, formatstr, "Select Mouse", SELECTMOUSE);
-       str += sprintf(str, formatstr, "Mouse Move", MOUSEMOVE);
-       str += sprintf(str, formatstr, "Wheel Up", WHEELUPMOUSE);
-       str += sprintf(str, formatstr, "Wheel Down", WHEELDOWNMOUSE);
-       str += sprintf(str, formatstr, "Wheel In", WHEELINMOUSE);
-       str += sprintf(str, formatstr, "Wheel Out", WHEELOUTMOUSE);
-       str += sprintf(str, formatstr, "Mouse/Trackpad Pan", MOUSEPAN);
-       str += sprintf(str, formatstr, "Mouse/Trackpad Zoom", MOUSEZOOM);
-       str += sprintf(str, formatstr, "Mouse/Trackpad Rotate", MOUSEROTATE);
-       
+}
+
+static const char *keymap_mouse_menu(void)
+{
+       static const char string[]=
+       "Mouse Event%t"
+       "|Left Mouse%x" STRINGIFY(LEFTMOUSE)
+       "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE)
+       "|Right Mouse%x" STRINGIFY(RIGHTMOUSE)
+       "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE)
+       "|Right Mouse%x" STRINGIFY(RIGHTMOUSE)
+       "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE)
+       "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE)
+       "|Action Mouse%x" STRINGIFY(ACTIONMOUSE)
+       "|Select Mouse%x" STRINGIFY(SELECTMOUSE)
+       "|Mouse Move%x" STRINGIFY(MOUSEMOVE)
+       "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE)
+       "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE)
+       "|Wheel In%x" STRINGIFY(WHEELINMOUSE)
+       "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE)
+       "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN)
+       "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM)
+       "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE)
+       ;
+
        return string;
 }
 
-static char *keymap_tweak_menu(void)
+static const char *keymap_tweak_menu(void)
 {
-       static char string[500];
-       static char formatstr[] = "|%s %%x%d";
-       char *str= string;
-       
-       str += sprintf(str, "Tweak Event %%t");
-       
-       str += sprintf(str, formatstr, "Left Mouse", EVT_TWEAK_L);
-       str += sprintf(str, formatstr, "Middle Mouse", EVT_TWEAK_M);
-       str += sprintf(str, formatstr, "Right Mouse", EVT_TWEAK_R);
-       str += sprintf(str, formatstr, "Action Mouse", EVT_TWEAK_A);
-       str += sprintf(str, formatstr, "Select Mouse", EVT_TWEAK_S);
-       
+       static const char string[]=
+       "Tweak Event%t"
+       "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L)
+       "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M)
+       "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R)
+       "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A)
+       "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S)
+       ;
+
        return string;
 }
 
-static char *keymap_tweak_dir_menu(void)
+static const char *keymap_tweak_dir_menu(void)
 {
-       static char string[500];
-       static char formatstr[] = "|%s %%x%d";
-       char *str= string;
-       
-       str += sprintf(str, "Tweak Direction %%t");
-       
-       str += sprintf(str, formatstr, "Any", KM_ANY);
-       str += sprintf(str, formatstr, "North", EVT_GESTURE_N);
-       str += sprintf(str, formatstr, "North-East", EVT_GESTURE_NE);
-       str += sprintf(str, formatstr, "East", EVT_GESTURE_E);
-       str += sprintf(str, formatstr, "Sout-East", EVT_GESTURE_SE);
-       str += sprintf(str, formatstr, "South", EVT_GESTURE_S);
-       str += sprintf(str, formatstr, "South-West", EVT_GESTURE_SW);
-       str += sprintf(str, formatstr, "West", EVT_GESTURE_W);
-       str += sprintf(str, formatstr, "North-West", EVT_GESTURE_NW);
-       
+       static const char string[]=
+       "Tweak Direction%t"
+       "|Any%x" STRINGIFY(KM_ANY)
+       "|North%x" STRINGIFY(EVT_GESTURE_N)
+       "|North-East%x" STRINGIFY(EVT_GESTURE_NE)
+       "|East%x" STRINGIFY(EVT_GESTURE_E)
+       "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE)
+       "|South%x" STRINGIFY(EVT_GESTURE_S)
+       "|South-West%x" STRINGIFY(EVT_GESTURE_SW)
+       "|West%x" STRINGIFY(EVT_GESTURE_W)
+       "|North-West%x" STRINGIFY(EVT_GESTURE_NW)
+       ;
+
        return string;
 }
 
 
-static void keymap_type_cb(bContext *C, void *kmi_v, void *unused_v)
+static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v))
 {
        wmKeyMapItem *kmi= kmi_v;
        short maptype= keymap_menu_type(kmi->type);
@@ -5493,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;
-                       char *str;
+                       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 */
 
@@ -5507,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;
                                
@@ -5515,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;
                        }
                }
                
@@ -5571,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) {
                                
@@ -5583,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, te->name, 1.0, (float)len-1, 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 */
@@ -5625,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 */
@@ -5658,17 +5754,19 @@ 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(C, v2d);
+       UI_view2d_view_ortho(v2d);
 
        /* draw outliner stuff (background, hierachy lines and names) */
-       outliner_back(ar, soops);
+       outliner_back(ar);
        block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS);
        outliner_draw_tree((bContext *)C, block, scene, ar, soops);
        
        if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {
                /* draw rna buttons */
-               outliner_draw_rnacols(ar, soops, sizex_rna);
+               outliner_draw_rnacols(ar, sizex_rna);
                outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree);
        }
        else if(soops->outlinevis == SO_KEYMAP) {
@@ -5676,7 +5774,7 @@ void draw_outliner(const bContext *C)
        }
        else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) {
                /* draw restriction columns */
-               outliner_draw_restrictcols(ar, soops);
+               outliner_draw_restrictcols(ar);
                outliner_draw_restrictbuts(block, scene, ar, soops, &soops->tree);
        }