Cycles Merge
[blender-staging.git] / source / blender / editors / interface / resources.c
index 52e9a395c4e2212e6d420e3e2b29cabcf8dc4613..104cf18ebdfde24083363b56dd990bfd2968c689 100644 (file)
@@ -1,6 +1,4 @@
-/**
- * $Id$
- *
+/*
  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
 
+/** \file blender/editors/interface/resources.c
+ *  \ingroup edinterface
+ */
+
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
@@ -127,18 +129,12 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                        case SPACE_IMAGE:
                                ts= &btheme->tima;
                                break;
-                       case SPACE_IMASEL:
-                               ts= &btheme->timasel;
-                               break;
                        case SPACE_TEXT:
                                ts= &btheme->text;
                                break;
                        case SPACE_OUTLINER:
                                ts= &btheme->toops;
                                break;
-                       case SPACE_SOUND:
-                               ts= &btheme->tsnd;
-                               break;
                        case SPACE_INFO:
                                ts= &btheme->tinfo;
                                break;
@@ -157,6 +153,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                        case SPACE_LOGIC:
                                ts= &btheme->tlogic;
                                break;
+                       case SPACE_CLIP:
+                               ts= &btheme->tclip;
+                               break;
                        default:
                                ts= &btheme->tv3d;
                                break;
@@ -246,6 +245,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                cp= ts->wire; break;
                        case TH_LAMP:
                                cp= ts->lamp; break;
+                       case TH_SPEAKER:
+                               cp= ts->speaker; break;
                        case TH_SELECT:
                                cp= ts->select; break;
                        case TH_ACTIVE:
@@ -262,6 +263,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                cp= ts->vertex_select; break;
                        case TH_VERTEX_SIZE:
                                cp= &ts->vertex_size; break;
+                       case TH_OUTLINE_WIDTH:
+                               cp= &ts->outline_width; break;
                        case TH_EDGE:
                                cp= ts->edge; break;
                        case TH_EDGE_SELECT:
@@ -320,6 +323,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                cp= ts->handle_free; break;
                        case TH_HANDLE_AUTO:
                                cp= ts->handle_auto; break;
+                       case TH_HANDLE_AUTOCLAMP:
+                               cp= ts->handle_auto_clamped; break;
                        case TH_HANDLE_VECT:
                                cp= ts->handle_vect; break;
                        case TH_HANDLE_ALIGN:
@@ -328,11 +333,13 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                cp= ts->handle_sel_free; break;
                        case TH_HANDLE_SEL_AUTO:
                                cp= ts->handle_sel_auto; break;
+                       case TH_HANDLE_SEL_AUTOCLAMP:
+                               cp= ts->handle_sel_auto_clamped; break;
                        case TH_HANDLE_SEL_VECT:
                                cp= ts->handle_sel_vect; break;
                        case TH_HANDLE_SEL_ALIGN:
                                cp= ts->handle_sel_align; break;
-
+               
                        case TH_SYNTAX_B:
                                cp= ts->syntaxb; break;
                        case TH_SYNTAX_V:
@@ -354,7 +361,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                cp= ts->syntaxv; break;
                        case TH_NODE_GROUP:
                                cp= ts->syntaxc; break;
-                               
+                       case TH_NODE_CURVING:
+                               cp= &ts->noodle_curving; break;
+
                        case TH_SEQ_MOVIE:
                                cp= ts->movie; break;
                        case TH_SEQ_IMAGE:
@@ -403,6 +412,27 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                        case TH_PREVIEW_BACK:
                                cp= ts->preview_back;
                                break;  
+
+                       case TH_MARKER_OUTLINE:
+                               cp= ts->marker_outline; break;
+                       case TH_MARKER:
+                               cp= ts->marker; break;
+                       case TH_ACT_MARKER:
+                               cp= ts->act_marker; break;
+                       case TH_SEL_MARKER:
+                               cp= ts->sel_marker; break;
+                       case TH_BUNDLE_SOLID:
+                               cp= ts->bundle_solid; break;
+                       case TH_DIS_MARKER:
+                               cp= ts->dis_marker; break;
+                       case TH_PATH_BEFORE:
+                               cp= ts->path_before; break;
+                       case TH_PATH_AFTER:
+                               cp= ts->path_after; break;
+                       case TH_CAMERA_PATH:
+                               cp= ts->camera_path; break;
+                       case TH_LOCK_MARKER:
+                               cp= ts->lock_marker; break;
                        }
                }
        }
@@ -410,8 +440,83 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
        return (unsigned char *)cp;
 }
 
+
+#define SETCOL(col, r, g, b, a)  col[0]=r; col[1]=g; col[2]= b; col[3]= a;
+#define SETCOLF(col, r, g, b, a)  col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255;
 #define SETCOLTEST(col, r, g, b, a)  if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;}
 
+/* use this call to init new bone color sets in Theme */
+static void ui_theme_init_boneColorSets(bTheme *btheme)
+{
+       int i;
+       
+       /* define default color sets - currently we only define 15 of these, though that should be ample */
+               /* set 1 */
+       SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
+       SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
+       SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
+               /* set 2 */
+       SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
+       SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
+       SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
+               /* set 3 */
+       SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
+       SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
+       SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
+               /* set 4 */
+       SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
+       SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
+       SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
+               /* set 5 */
+       SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
+       SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
+       SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
+               /* set 6 */
+       SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
+       SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
+       SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
+               /* set 7 */
+       SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
+       SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
+       SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
+               /* set 8 */
+       SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
+       SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
+       SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
+               /* set 9 */
+       SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
+       SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
+       SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
+               /* set 10 */
+       SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
+       SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
+       SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
+               /* set 11 */
+       SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
+       SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
+       SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
+               /* set 12 */
+       SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
+       SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
+       SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
+               /* set 13 */
+       SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
+       SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
+       SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
+               /* set 14 */
+       SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
+       SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
+       SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
+               /* set 15 */
+       SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
+       SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
+       SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
+       
+       /* reset flags too */
+       for (i = 0; i < 20; i++)
+               btheme->tarm[i].flag = 0;
+}
+
 /* use this call to init new variables in themespace, if they're same for all */
 static void ui_theme_init_new_do(ThemeSpace *ts)
 {
@@ -441,12 +546,10 @@ static void ui_theme_init_new(bTheme *btheme)
        ui_theme_init_new_do(&btheme->tfile);
        ui_theme_init_new_do(&btheme->tipo);
        ui_theme_init_new_do(&btheme->tinfo);
-       ui_theme_init_new_do(&btheme->tsnd);
        ui_theme_init_new_do(&btheme->tact);
        ui_theme_init_new_do(&btheme->tnla);
        ui_theme_init_new_do(&btheme->tseq);
        ui_theme_init_new_do(&btheme->tima);
-       ui_theme_init_new_do(&btheme->timasel);
        ui_theme_init_new_do(&btheme->text);
        ui_theme_init_new_do(&btheme->toops);
        ui_theme_init_new_do(&btheme->ttime);
@@ -454,11 +557,10 @@ static void ui_theme_init_new(bTheme *btheme)
        ui_theme_init_new_do(&btheme->tlogic);
        ui_theme_init_new_do(&btheme->tuserpref);
        ui_theme_init_new_do(&btheme->tconsole);
+       ui_theme_init_new_do(&btheme->tclip);
        
 }
 
-#define SETCOL(col, r, g, b, a)  col[0]=r; col[1]=g; col[2]= b; col[3]= a;
-#define SETCOLF(col, r, g, b, a)  col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255;
 
 /* initialize default theme
    Note: when you add new colors, created & saved themes need initialized
@@ -483,7 +585,11 @@ void ui_theme_init_default(void)
 
        /* UI buttons */
        ui_widget_color_init(&btheme->tui);
-
+       btheme->tui.iconfile[0]= 0;
+       
+       /* Bone Color Sets */
+       ui_theme_init_boneColorSets(btheme);
+       
        /* common (new) variables */
        ui_theme_init_new(btheme);
        
@@ -502,14 +608,16 @@ void ui_theme_init_default(void)
        SETCOLF(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
        SETCOL(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
        SETCOL(btheme->tv3d.lamp,       0, 0, 0, 40);
+       SETCOL(btheme->tv3d.speaker,    0, 0, 0, 255);
        SETCOL(btheme->tv3d.select, 241, 88, 0, 255);
-       SETCOL(btheme->tv3d.active, 255, 140, 25, 255);
+       SETCOL(btheme->tv3d.active, 255, 170, 64, 255);
        SETCOL(btheme->tv3d.group,      8, 48, 8, 255);
        SETCOL(btheme->tv3d.group_active, 85, 187, 85, 255);
        SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
        SETCOL(btheme->tv3d.vertex, 0, 0, 0, 255);
        SETCOL(btheme->tv3d.vertex_select, 255, 133, 0, 255);
        btheme->tv3d.vertex_size= 3;
+       btheme->tv3d.outline_width= 1;
        SETCOL(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
        SETCOL(btheme->tv3d.edge_select, 255, 160, 0, 255);
        SETCOL(btheme->tv3d.edge_seam, 219, 37, 18, 255);
@@ -519,6 +627,16 @@ void ui_theme_init_default(void)
        SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
        SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
        SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255);
+       SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
+       SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
+       SETCOL(btheme->tv3d.edge_sharp, 0, 255, 255, 255);
+       SETCOL(btheme->tv3d.header_text, 0, 0, 0, 255);
+       SETCOL(btheme->tv3d.header_text_hi, 255, 255, 255, 255);
+       SETCOL(btheme->tv3d.button_text, 0, 0, 0, 255);
+       SETCOL(btheme->tv3d.button_text_hi, 255, 255, 255, 255);
+       SETCOL(btheme->tv3d.button_title, 0, 0, 0, 255);
+       SETCOL(btheme->tv3d.title, 0, 0, 0, 255);
+
        btheme->tv3d.facedot_size= 4;
 
        SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
@@ -546,7 +664,9 @@ void ui_theme_init_default(void)
 
        SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
        SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);               // alpha 80 is not meant editable, used for wire+action draw
-       
+
+       SETCOL(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
+       SETCOL(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
        
        /* space buttons */
        /* to have something initialized */
@@ -570,7 +690,9 @@ void ui_theme_init_default(void)
 
        SETCOL(btheme->tipo.handle_vertex,              0, 0, 0, 255);
        SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
-       btheme->tipo.handle_vertex_size= 3;
+       SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
+       SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
+       btheme->tipo.handle_vertex_size= 4;
        
        SETCOL(btheme->tipo.ds_channel,         82, 96, 110, 255);
        SETCOL(btheme->tipo.ds_subchannel,      124, 137, 150, 255);
@@ -628,18 +750,6 @@ void ui_theme_init_default(void)
        SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
        SETCOLF(btheme->tima.preview_back,      0.45, 0.45, 0.45, 1.0);
 
-       /* space imageselect */
-       btheme->timasel= btheme->tv3d;
-       SETCOL(btheme->timasel.active,  195, 195, 195, 255); /* active tile */
-       SETCOL(btheme->timasel.grid,  94, 94, 94, 255); /* active file text */
-       SETCOL(btheme->timasel.back,    110, 110, 110, 255);
-       SETCOL(btheme->timasel.shade1,  94, 94, 94, 255);       /* bar */
-       SETCOL(btheme->timasel.shade2,  172, 172, 172, 255); /* sliders */
-       SETCOL(btheme->timasel.hilite,  17, 27, 60, 100);       /* selected tile */
-       SETCOL(btheme->timasel.text,    0, 0, 0, 255);
-       SETCOL(btheme->timasel.text_hi, 255, 255, 255, 255);
-       SETCOL(btheme->timasel.panel,   132, 132, 132, 255);
-
        /* space text */
        btheme->text= btheme->tv3d;
        SETCOL(btheme->text.back,       153, 153, 153, 255);
@@ -675,15 +785,11 @@ void ui_theme_init_default(void)
        SETCOL(btheme->tconsole.console_error, 220, 96, 96, 255);
        SETCOL(btheme->tconsole.console_cursor, 220, 96, 96, 255);
        
-
-       /* space sound */
-       btheme->tsnd= btheme->tv3d;
-       SETCOLF(btheme->tsnd.back,      0.45, 0.45, 0.45, 1.0);
-       SETCOLF(btheme->tsnd.grid,      0.36, 0.36, 0.36, 1.0);
-       SETCOL(btheme->tsnd.shade1,  173, 173, 173, 255);               // sliders
-       
        /* space time */
-       btheme->ttime= btheme->tsnd;    // same as sound space
+       btheme->ttime= btheme->tv3d;
+       SETCOLF(btheme->ttime.back,     0.45, 0.45, 0.45, 1.0);
+       SETCOLF(btheme->ttime.grid,     0.36, 0.36, 0.36, 1.0);
+       SETCOL(btheme->ttime.shade1,  173, 173, 173, 255);              // sliders
        
        /* space node, re-uses syntax color storage */
        btheme->tnode= btheme->tv3d;
@@ -693,11 +799,28 @@ void ui_theme_init_default(void)
        SETCOL(btheme->tnode.syntaxb, 108, 105, 111, 255);      /* operator */
        SETCOL(btheme->tnode.syntaxv, 104, 106, 117, 255);      /* generator */
        SETCOL(btheme->tnode.syntaxc, 105, 117, 110, 255);      /* group */
+       btheme->tnode.noodle_curving = 5;
 
        /* space logic */
        btheme->tlogic= btheme->tv3d;
        SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
        
+       /* space clip */
+       btheme->tclip= btheme->tv3d;
+
+       SETCOL(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
+       SETCOL(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
+       SETCOL(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
+       SETCOL(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
+       SETCOL(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
+       SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
+       SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
+       SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
+       SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
+       SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
+       SETCOL(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
+       SETCOL(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
+       btheme->tclip.handle_vertex_size= 4;
 }
 
 
@@ -778,10 +901,10 @@ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
        cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
        cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
 
-       if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
-       r= floor((1.0-fac)*cp1[0] + fac*cp2[0]);
-       g= floor((1.0-fac)*cp1[1] + fac*cp2[1]);
-       b= floor((1.0-fac)*cp1[2] + fac*cp2[2]);
+       CLAMP(fac, 0.0f, 1.0f);
+       r= floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
+       g= floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
+       b= floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
        
        glColor3ub(r, g, b);
 }
@@ -795,10 +918,10 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
        cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
        cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
 
-       if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
-       r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
-       g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
-       b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
+       CLAMP(fac, 0.0f, 1.0f);
+       r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
+       g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
+       b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
        
        CLAMP(r, 0, 255);
        CLAMP(g, 0, 255);
@@ -816,11 +939,11 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
        cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
        cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
 
-       if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
-       r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
-       g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
-       b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
-       a= alphaoffset+floor((1.0-fac)*cp1[3] + fac*cp2[3]);
+       CLAMP(fac, 0.0f, 1.0f);
+       r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
+       g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
+       b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
+       a= alphaoffset + floorf((1.0f-fac)*cp1[3] + fac*cp2[3]);
        
        CLAMP(r, 0, 255);
        CLAMP(g, 0, 255);
@@ -858,9 +981,9 @@ void UI_GetThemeColor3fv(int colorid, float *col)
        const unsigned char *cp;
        
        cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
-       col[0]= ((float)cp[0])/255.0;
-       col[1]= ((float)cp[1])/255.0;
-       col[2]= ((float)cp[2])/255.0;
+       col[0]= ((float)cp[0])/255.0f;
+       col[1]= ((float)cp[1])/255.0f;
+       col[2]= ((float)cp[2])/255.0f;
 }
 
 // get the color, range 0.0-1.0, complete with shading offset
@@ -878,9 +1001,9 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
        b= offset + (int) cp[2];
        CLAMP(b, 0, 255);
        
-       col[0]= ((float)r)/255.0;
-       col[1]= ((float)g)/255.0;
-       col[2]= ((float)b)/255.0;
+       col[0]= ((float)r)/255.0f;
+       col[1]= ((float)g)/255.0f;
+       col[2]= ((float)b)/255.0f;
 }
 
 // get the color, in char pointer
@@ -921,11 +1044,10 @@ void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
 void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
 {
        int r, g, b;
-       
-       if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
-       r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
-       g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
-       b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
+       CLAMP(fac, 0.0f, 1.0f);
+       r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
+       g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
+       b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
        
        r= r<0?0:(r>255?255:r);
        g= g<0?0:(g>255?255:g);
@@ -934,20 +1056,37 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c
        glColor3ub(r, g, b);
 }
 
+void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], int offset)
+{
+       int r, g, b;
+
+       r= offset+(int)cp[0];
+       g= offset+(int)cp[1];
+       b= offset+(int)cp[2];
+
+       CLAMP(r, 0, 255);
+       CLAMP(g, 0, 255);
+       CLAMP(b, 0, 255);
+
+       col[0] = r;
+       col[1] = g;
+       col[2] = b;
+}
+
 // get a 3 byte color, blended and shaded between two other char color pointers
 void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset)
 {
        int r, g, b;
-       
-       if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
-       r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
-       g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
-       b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
-       
-       r= r<0?0:(r>255?255:r);
-       g= g<0?0:(g>255?255:g);
-       b= b<0?0:(b>255?255:b);
-       
+
+       CLAMP(fac, 0.0f, 1.0f);
+       r= offset+floor((1.0f-fac)*cp1[0] + fac*cp2[0]);
+       g= offset+floor((1.0f-fac)*cp1[1] + fac*cp2[1]);
+       b= offset+floor((1.0f-fac)*cp1[2] + fac*cp2[2]);
+
+       CLAMP(r, 0, 255);
+       CLAMP(g, 0, 255);
+       CLAMP(b, 0, 255);
+
        col[0] = r;
        col[1] = g;
        col[2] = b;
@@ -1004,10 +1143,8 @@ void init_userdef_do_versions(void)
                U.tb_rightmouse= 5;
        }
        if(U.mixbufsize==0) U.mixbufsize= 2048;
-       if (BLI_streq(U.tempdir, "/")) {
-               char *tmp= getenv("TEMP");
-               
-               strcpy(U.tempdir, tmp?tmp:"/tmp/");
+       if (strcmp(U.tempdir, "/") == 0) {
+               BLI_system_temporary_dir(U.tempdir);
        }
        if (U.autokey_mode == 0) {
                /* 'add/replace' but not on */
@@ -1025,12 +1162,13 @@ void init_userdef_do_versions(void)
        }
        if(U.pad_rot_angle==0)
                U.pad_rot_angle= 15;
-       
-       if(U.flag & USER_CUSTOM_RANGE) 
-               vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */
-       
+
+       /* signal for derivedmesh to use colorband */
+       /* run incase this was on and is now off in the user prefs [#28096] */
+       vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight):NULL);
+
        if (bmain->versionfile <= 191) {
-               strcpy(U.plugtexdir, U.textudir);
+               BLI_strncpy(U.plugtexdir, U.textudir, sizeof(U.plugtexdir));
                strcpy(U.sounddir, "/");
        }
        
@@ -1074,7 +1212,11 @@ void init_userdef_do_versions(void)
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
                        /* check for alpha==0 is safe, then color was never set */
                        if(btheme->ttime.back[3]==0) {
-                               btheme->ttime = btheme->tsnd;   // copy from sound
+                               // copied from ui_theme_init_default
+                               btheme->ttime= btheme->tv3d;
+                               SETCOLF(btheme->ttime.back,     0.45, 0.45, 0.45, 1.0);
+                               SETCOLF(btheme->ttime.grid,     0.36, 0.36, 0.36, 1.0);
+                               SETCOL(btheme->ttime.shade1,  173, 173, 173, 255);              // sliders
                        }
                        if(btheme->text.syntaxn[3]==0) {
                                SETCOL(btheme->text.syntaxn,    0, 0, 200, 255);        /* Numbers  Blue*/
@@ -1201,7 +1343,7 @@ void init_userdef_do_versions(void)
                        SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
                        SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
                        SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
-                       SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255);
+                       //SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); Not needed anymore
                        SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
                }
        }
@@ -1213,69 +1355,8 @@ void init_userdef_do_versions(void)
                        SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
                        
                        /* bone custom-color sets */
-                       // FIXME: this check for initialised colors is bad
-                       if (btheme->tarm[0].solid[3] == 0) {
-                                       /* set 1 */
-                               SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
-                               SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
-                               SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
-                                       /* set 2 */
-                               SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
-                               SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
-                               SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
-                                       /* set 3 */
-                               SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
-                               SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
-                               SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
-                                       /* set 4 */
-                               SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
-                               SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
-                               SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
-                                       /* set 5 */
-                               SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
-                               SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
-                               SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
-                                       /* set 6 */
-                               SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
-                               SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
-                               SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
-                                       /* set 7 */
-                               SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
-                               SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
-                               SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
-                                       /* set 8 */
-                               SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
-                               SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
-                               SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
-                                       /* set 9 */
-                               SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
-                               SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
-                               SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
-                                       /* set 10 */
-                               SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
-                               SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
-                               SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
-                                       /* set 11 */
-                               SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
-                               SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
-                               SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
-                                       /* set 12 */
-                               SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
-                               SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
-                               SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
-                                       /* set 13 */
-                               SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
-                               SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
-                               SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
-                                       /* set 14 */
-                               SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
-                               SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
-                               SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
-                                       /* set 15 */
-                               SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
-                               SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
-                               SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
-                       }
+                       if (btheme->tarm[0].solid[3] == 0)
+                               ui_theme_init_boneColorSets(btheme);
                }
        }
        if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
@@ -1391,7 +1472,7 @@ void init_userdef_do_versions(void)
        if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
                wmKeyMap *km;
                
-               for(km=U.keymaps.first; km; km=km->next) {
+               for(km=U.user_keymaps.first; km; km=km->next) {
                        if (strcmp(km->idname, "Armature_Sketch")==0)
                                strcpy(km->idname, "Armature Sketch");
                        else if (strcmp(km->idname, "View3D")==0)
@@ -1511,11 +1592,85 @@ void init_userdef_do_versions(void)
                }
        }
        
+       if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) {
+               bTheme *btheme;
+               for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+                       if((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width= 1;
+               }
+       }
+
        if (bmain->versionfile < 257) {
                /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs, so that it doesn't linger around from old configs like a ghost */
                U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
        }
+
+       if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 2)) {
+               bTheme *btheme;
+               for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+                       btheme->tnode.noodle_curving = 5;
+               }
+       }
+
+       if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
+               bTheme *btheme;
+               
+               /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead */
+               if (U.keyhandles_new == HD_AUTO) 
+                       U.keyhandles_new = HD_AUTO_ANIM;
+                       
+               /* theme color additions */
+               for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+                       /* auto-clamped handles -> based on auto */
+                       SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
+                       SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
+               }
+       }
        
+       if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
+               bTheme *btheme;
+
+               for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+                       btheme->tv3d.speaker[3] = 255;
+               }
+       }
+
+       if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 3)) {
+               bTheme *btheme;
+
+               for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+                       if(btheme->tv3d.bundle_solid[3] == 0)
+                               SETCOL(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
+
+                       if(btheme->tv3d.camera_path[3] == 0)
+                               SETCOL(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
+
+                       if((btheme->tclip.back[3]) == 0) {
+                               btheme->tclip= btheme->tv3d;
+
+                               SETCOL(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
+                               SETCOL(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
+                               SETCOL(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
+                               SETCOL(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
+                               SETCOL(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
+                               SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
+                               SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
+                               SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
+                               SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
+                               SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
+                               SETCOL(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
+                               SETCOL(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
+                               btheme->tclip.handle_vertex_size= 4;
+                       }
+               }
+
+               /* enable addon by default */
+               if(!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) {
+                       bAddon *baddon= MEM_callocN(sizeof(bAddon), "bAddon");
+                       BLI_strncpy(baddon->module, "cycles", sizeof(baddon->module));
+                       BLI_addtail(&U.addons, baddon);
+               }
+       }
+
        /* GL Texture Garbage Collection (variable abused above!) */
        if (U.textimeout == 0) {
                U.texcollectrate = 60;
@@ -1542,6 +1697,16 @@ void init_userdef_do_versions(void)
        }
        if (U.dragthreshold == 0 )
                U.dragthreshold= 5;
+       if (U.widget_unit==0)
+               U.widget_unit= (U.dpi * 20 + 36)/72;
+       if (U.anisotropic_filter <= 0)
+               U.anisotropic_filter = 1;
+
+       if (U.ndof_sensitivity == 0.0f) {
+               U.ndof_sensitivity = 1.0f;
+               U.ndof_flag = NDOF_LOCK_HORIZON |
+                       NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
+       }
 
        /* funny name, but it is GE stuff, moves userdef stuff to engine */
 // XXX space_set_commmandline_options();