patch [#26495] Adjustable outline width for selected objects
[blender-staging.git] / source / blender / editors / interface / resources.c
1 /** \file blender/editors/interface/resources.c
2  *  \ingroup edinterface
3  */
4 /*
5  * $Id$
6  *
7  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version. The Blender
13  * Foundation also sells licenses for use in proprietary software under
14  * the Blender License.  See http://www.blender.org/BL/ for information
15  * about this.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25  *
26  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
27  * All rights reserved.
28  *
29  * The Original Code is: all of this file.
30  *
31  * Contributor(s): none yet.
32  *
33  * ***** END GPL/BL DUAL LICENSE BLOCK *****
34  */
35
36 #include <math.h>
37 #include <stdlib.h>
38 #include <string.h>
39
40 #include "MEM_guardedalloc.h"
41
42 #include "DNA_curve_types.h"
43 #include "DNA_userdef_types.h"
44 #include "DNA_screen_types.h"
45 #include "DNA_space_types.h"
46 #include "DNA_windowmanager_types.h"
47
48 #include "BLI_blenlib.h"
49 #include "BLI_utildefines.h"
50
51 #include "BKE_DerivedMesh.h"
52 #include "BKE_global.h"
53 #include "BKE_main.h"
54 #include "BKE_texture.h"
55
56
57 #include "BIF_gl.h"
58
59 #include "UI_interface.h"
60 #include "UI_interface_icons.h"
61
62 #include "interface_intern.h"
63
64 /* global for themes */
65 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
66
67 static bTheme *theme_active=NULL;
68 static int theme_spacetype= SPACE_VIEW3D;
69 static int theme_regionid= RGN_TYPE_WINDOW;
70
71 void ui_resources_init(void)
72 {
73         UI_icons_init(BIFICONID_LAST);
74 }
75
76 void ui_resources_free(void)
77 {
78         UI_icons_free();
79 }
80
81
82 /* ******************************************************** */
83 /*    THEMES */
84 /* ******************************************************** */
85
86 const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
87 {
88         ThemeSpace *ts= NULL;
89         static char error[4]={240, 0, 240, 255};
90         static char alert[4]={240, 60, 60, 255};
91         static char headerdesel[4]={0,0,0,255};
92         
93         const char *cp= error;
94         
95         if(btheme) {
96         
97                 // first check for ui buttons theme
98                 if(colorid < TH_THEMEUI) {
99                 
100                         switch(colorid) {
101
102                         case TH_REDALERT:
103                                 cp= alert; break;
104                         }
105                 }
106                 else {
107                 
108                         switch(spacetype) {
109                         case SPACE_BUTS:
110                                 ts= &btheme->tbuts;
111                                 break;
112                         case SPACE_VIEW3D:
113                                 ts= &btheme->tv3d;
114                                 break;
115                         case SPACE_IPO:
116                                 ts= &btheme->tipo;
117                                 break;
118                         case SPACE_FILE:
119                                 ts= &btheme->tfile;
120                                 break;
121                         case SPACE_NLA:
122                                 ts= &btheme->tnla;
123                                 break;
124                         case SPACE_ACTION:
125                                 ts= &btheme->tact;
126                                 break;
127                         case SPACE_SEQ:
128                                 ts= &btheme->tseq;
129                                 break;
130                         case SPACE_IMAGE:
131                                 ts= &btheme->tima;
132                                 break;
133                         case SPACE_IMASEL:
134                                 ts= &btheme->timasel;
135                                 break;
136                         case SPACE_TEXT:
137                                 ts= &btheme->text;
138                                 break;
139                         case SPACE_OUTLINER:
140                                 ts= &btheme->toops;
141                                 break;
142                         case SPACE_SOUND:
143                                 ts= &btheme->tsnd;
144                                 break;
145                         case SPACE_INFO:
146                                 ts= &btheme->tinfo;
147                                 break;
148                         case SPACE_USERPREF:
149                                 ts= &btheme->tuserpref;
150                                 break;
151                         case SPACE_CONSOLE:
152                                 ts= &btheme->tconsole;
153                                 break;
154                         case SPACE_TIME:
155                                 ts= &btheme->ttime;
156                                 break;
157                         case SPACE_NODE:
158                                 ts= &btheme->tnode;
159                                 break;
160                         case SPACE_LOGIC:
161                                 ts= &btheme->tlogic;
162                                 break;
163                         default:
164                                 ts= &btheme->tv3d;
165                                 break;
166                         }
167                         
168                         switch(colorid) {
169                         case TH_BACK:
170                                 if(theme_regionid==RGN_TYPE_WINDOW)
171                                         cp= ts->back;
172                                 else if(theme_regionid==RGN_TYPE_CHANNELS)
173                                         cp= ts->list;
174                                 else if(theme_regionid==RGN_TYPE_HEADER)
175                                         cp= ts->header;
176                                 else
177                                         cp= ts->button; 
178                                 break;
179                         case TH_TEXT:
180                                 if(theme_regionid==RGN_TYPE_WINDOW)
181                                         cp= ts->text; 
182                                 else if(theme_regionid==RGN_TYPE_CHANNELS)
183                                         cp= ts->list_text;
184                                 else if(theme_regionid==RGN_TYPE_HEADER)
185                                         cp= ts->header_text;
186                                 else
187                                         cp= ts->button_text; 
188                                 break;
189                         case TH_TEXT_HI:
190                                 if(theme_regionid==RGN_TYPE_WINDOW)
191                                         cp= ts->text_hi;
192                                 else if(theme_regionid==RGN_TYPE_CHANNELS)
193                                         cp= ts->list_text_hi;
194                                 else if(theme_regionid==RGN_TYPE_HEADER)
195                                         cp= ts->header_text_hi;
196                                 else
197                                         cp= ts->button_text_hi; 
198                                 break;
199                         case TH_TITLE:
200                                 if(theme_regionid==RGN_TYPE_WINDOW)
201                                         cp= ts->title;
202                                 else if(theme_regionid==RGN_TYPE_CHANNELS)
203                                         cp= ts->list_title;
204                                 else if(theme_regionid==RGN_TYPE_HEADER)
205                                         cp= ts->header_title;
206                                 else
207                                         cp= ts->button_title; 
208                                 break;
209                                 
210                         case TH_HEADER:
211                                 cp= ts->header; break;
212                         case TH_HEADERDESEL:
213                                 /* we calculate a dynamic builtin header deselect color, also for pulldowns... */
214                                 cp= ts->header; 
215                                 headerdesel[0]= cp[0]>10?cp[0]-10:0;
216                                 headerdesel[1]= cp[1]>10?cp[1]-10:0;
217                                 headerdesel[2]= cp[2]>10?cp[2]-10:0;
218                                 cp= headerdesel;
219                                 break;
220                         case TH_HEADER_TEXT:
221                                 cp= ts->header_text; break;
222                         case TH_HEADER_TEXT_HI:
223                                 cp= ts->header_text_hi; break;
224                                 
225                         case TH_PANEL:
226                                 cp= ts->panel; break;
227                         case TH_PANEL_TEXT:
228                                 cp= ts->panel_text; break;
229                         case TH_PANEL_TEXT_HI:
230                                 cp= ts->panel_text_hi; break;
231                                 
232                         case TH_BUTBACK:
233                                 cp= ts->button; break;
234                         case TH_BUTBACK_TEXT:
235                                 cp= ts->button_text; break;
236                         case TH_BUTBACK_TEXT_HI:
237                                 cp= ts->button_text_hi; break;
238                                 
239                         case TH_SHADE1:
240                                 cp= ts->shade1; break;
241                         case TH_SHADE2:
242                                 cp= ts->shade2; break;
243                         case TH_HILITE:
244                                 cp= ts->hilite; break;
245                                 
246                         case TH_GRID:
247                                 cp= ts->grid; break;
248                         case TH_WIRE:
249                                 cp= ts->wire; break;
250                         case TH_LAMP:
251                                 cp= ts->lamp; break;
252                         case TH_SELECT:
253                                 cp= ts->select; break;
254                         case TH_ACTIVE:
255                                 cp= ts->active; break;
256                         case TH_GROUP:
257                                 cp= ts->group; break;
258                         case TH_GROUP_ACTIVE:
259                                 cp= ts->group_active; break;
260                         case TH_TRANSFORM:
261                                 cp= ts->transform; break;
262                         case TH_VERTEX:
263                                 cp= ts->vertex; break;
264                         case TH_VERTEX_SELECT:
265                                 cp= ts->vertex_select; break;
266                         case TH_VERTEX_SIZE:
267                                 cp= &ts->vertex_size; break;
268                         case TH_OUTLINE_WIDTH:
269                                 cp= &ts->outline_width; break;
270                         case TH_EDGE:
271                                 cp= ts->edge; break;
272                         case TH_EDGE_SELECT:
273                                 cp= ts->edge_select; break;
274                         case TH_EDGE_SEAM:
275                                 cp= ts->edge_seam; break;
276                         case TH_EDGE_SHARP:
277                                 cp= ts->edge_sharp; break;
278                         case TH_EDGE_CREASE:
279                                 cp= ts->edge_crease; break;
280                         case TH_EDITMESH_ACTIVE:
281                                 cp= ts->editmesh_active; break;
282                         case TH_EDGE_FACESEL:
283                                 cp= ts->edge_facesel; break;
284                         case TH_FACE:
285                                 cp= ts->face; break;
286                         case TH_FACE_SELECT:
287                                 cp= ts->face_select; break;
288                         case TH_FACE_DOT:
289                                 cp= ts->face_dot; break;
290                         case TH_FACEDOT_SIZE:
291                                 cp= &ts->facedot_size; break;
292                         case TH_DRAWEXTRA_EDGELEN:
293                                 cp= ts->extra_edge_len; break;
294                         case TH_DRAWEXTRA_FACEAREA:
295                                 cp= ts->extra_face_area; break;
296                         case TH_DRAWEXTRA_FACEANG:
297                                 cp= ts->extra_face_angle; break;
298                         case TH_NORMAL:
299                                 cp= ts->normal; break;
300                         case TH_VNORMAL:
301                                 cp= ts->vertex_normal; break;
302                         case TH_BONE_SOLID:
303                                 cp= ts->bone_solid; break;
304                         case TH_BONE_POSE:
305                                 cp= ts->bone_pose; break;
306                         case TH_STRIP:
307                                 cp= ts->strip; break;
308                         case TH_STRIP_SELECT:
309                                 cp= ts->strip_select; break;
310                         case TH_CFRAME:
311                                 cp= ts->cframe; break;
312                         case TH_NURB_ULINE:
313                                 cp= ts->nurb_uline; break;
314                         case TH_NURB_VLINE:
315                                 cp= ts->nurb_vline; break;
316                         case TH_NURB_SEL_ULINE:
317                                 cp= ts->nurb_sel_uline; break;
318                         case TH_NURB_SEL_VLINE:
319                                 cp= ts->nurb_sel_vline; break;
320                         case TH_ACTIVE_SPLINE:
321                                 cp= ts->act_spline; break;
322                         case TH_LASTSEL_POINT:
323                                 cp= ts->lastsel_point; break;
324                         case TH_HANDLE_FREE:
325                                 cp= ts->handle_free; break;
326                         case TH_HANDLE_AUTO:
327                                 cp= ts->handle_auto; break;
328                         case TH_HANDLE_VECT:
329                                 cp= ts->handle_vect; break;
330                         case TH_HANDLE_ALIGN:
331                                 cp= ts->handle_align; break;
332                         case TH_HANDLE_SEL_FREE:
333                                 cp= ts->handle_sel_free; break;
334                         case TH_HANDLE_SEL_AUTO:
335                                 cp= ts->handle_sel_auto; break;
336                         case TH_HANDLE_SEL_VECT:
337                                 cp= ts->handle_sel_vect; break;
338                         case TH_HANDLE_SEL_ALIGN:
339                                 cp= ts->handle_sel_align; break;
340
341                         case TH_SYNTAX_B:
342                                 cp= ts->syntaxb; break;
343                         case TH_SYNTAX_V:
344                                 cp= ts->syntaxv; break;
345                         case TH_SYNTAX_C:
346                                 cp= ts->syntaxc; break;
347                         case TH_SYNTAX_L:
348                                 cp= ts->syntaxl; break;
349                         case TH_SYNTAX_N:
350                                 cp= ts->syntaxn; break;
351
352                         case TH_NODE:
353                                 cp= ts->syntaxl; break;
354                         case TH_NODE_IN_OUT:
355                                 cp= ts->syntaxn; break;
356                         case TH_NODE_OPERATOR:
357                                 cp= ts->syntaxb; break;
358                         case TH_NODE_CONVERTOR:
359                                 cp= ts->syntaxv; break;
360                         case TH_NODE_GROUP:
361                                 cp= ts->syntaxc; break;
362                                 
363                         case TH_SEQ_MOVIE:
364                                 cp= ts->movie; break;
365                         case TH_SEQ_IMAGE:
366                                 cp= ts->image; break;
367                         case TH_SEQ_SCENE:
368                                 cp= ts->scene; break;
369                         case TH_SEQ_AUDIO:
370                                 cp= ts->audio; break;
371                         case TH_SEQ_EFFECT:
372                                 cp= ts->effect; break;
373                         case TH_SEQ_PLUGIN:
374                                 cp= ts->plugin; break;
375                         case TH_SEQ_TRANSITION:
376                                 cp= ts->transition; break;
377                         case TH_SEQ_META:
378                                 cp= ts->meta; break;
379                                 
380                         case TH_CONSOLE_OUTPUT:
381                                 cp= ts->console_output; break;
382                         case TH_CONSOLE_INPUT:
383                                 cp= ts-> console_input; break;
384                         case TH_CONSOLE_INFO:
385                                 cp= ts->console_info; break;
386                         case TH_CONSOLE_ERROR:
387                                 cp= ts->console_error; break;
388                         case TH_CONSOLE_CURSOR:
389                                 cp= ts->console_cursor; break;
390
391                         case TH_HANDLE_VERTEX:
392                                 cp= ts->handle_vertex;
393                                 break;
394                         case TH_HANDLE_VERTEX_SELECT:
395                                 cp= ts->handle_vertex_select;
396                                 break;
397                         case TH_HANDLE_VERTEX_SIZE:
398                                 cp= &ts->handle_vertex_size;
399                                 break;
400                                 
401                         case TH_DOPESHEET_CHANNELOB:
402                                 cp= ts->ds_channel;
403                                 break;
404                         case TH_DOPESHEET_CHANNELSUBOB:
405                                 cp= ts->ds_subchannel;
406                                 break;  
407                                         
408                         case TH_PREVIEW_BACK:
409                                 cp= ts->preview_back;
410                                 break;  
411                         }
412                 }
413         }
414         
415         return (unsigned char *)cp;
416 }
417
418 #define SETCOLTEST(col, r, g, b, a)  if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;}
419
420 /* use this call to init new variables in themespace, if they're same for all */
421 static void ui_theme_init_new_do(ThemeSpace *ts)
422 {
423         SETCOLTEST(ts->header_text,             0, 0, 0, 255);
424         SETCOLTEST(ts->header_title,    0, 0, 0, 255);
425         SETCOLTEST(ts->header_text_hi,  255, 255, 255, 255);
426         
427         SETCOLTEST(ts->panel_text,              0, 0, 0, 255);
428         SETCOLTEST(ts->panel_title,             0, 0, 0, 255);
429         SETCOLTEST(ts->panel_text_hi,   255, 255, 255, 255);
430         
431         SETCOLTEST(ts->button,                  145, 145, 145, 245);
432         SETCOLTEST(ts->button_title,    0, 0, 0, 255);
433         SETCOLTEST(ts->button_text,             0, 0, 0, 255);
434         SETCOLTEST(ts->button_text_hi,  255, 255, 255, 255);
435         
436         SETCOLTEST(ts->list,                    165, 165, 165, 255);
437         SETCOLTEST(ts->list_title,              0, 0, 0, 255);
438         SETCOLTEST(ts->list_text,               0, 0, 0, 255);
439         SETCOLTEST(ts->list_text_hi,    255, 255, 255, 255);
440 }
441
442 static void ui_theme_init_new(bTheme *btheme)
443 {
444         ui_theme_init_new_do(&btheme->tbuts);
445         ui_theme_init_new_do(&btheme->tv3d);
446         ui_theme_init_new_do(&btheme->tfile);
447         ui_theme_init_new_do(&btheme->tipo);
448         ui_theme_init_new_do(&btheme->tinfo);
449         ui_theme_init_new_do(&btheme->tsnd);
450         ui_theme_init_new_do(&btheme->tact);
451         ui_theme_init_new_do(&btheme->tnla);
452         ui_theme_init_new_do(&btheme->tseq);
453         ui_theme_init_new_do(&btheme->tima);
454         ui_theme_init_new_do(&btheme->timasel);
455         ui_theme_init_new_do(&btheme->text);
456         ui_theme_init_new_do(&btheme->toops);
457         ui_theme_init_new_do(&btheme->ttime);
458         ui_theme_init_new_do(&btheme->tnode);
459         ui_theme_init_new_do(&btheme->tlogic);
460         ui_theme_init_new_do(&btheme->tuserpref);
461         ui_theme_init_new_do(&btheme->tconsole);
462         
463 }
464
465 #define SETCOL(col, r, g, b, a)  col[0]=r; col[1]=g; col[2]= b; col[3]= a;
466 #define SETCOLF(col, r, g, b, a)  col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255;
467
468 /* initialize default theme
469    Note: when you add new colors, created & saved themes need initialized
470    use function below, init_userdef_do_versions() 
471 */
472 void ui_theme_init_default(void)
473 {
474         bTheme *btheme;
475         
476         /* we search for the theme with name Default */
477         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
478                 if(strcmp("Default", btheme->name)==0) break;
479         }
480         
481         if(btheme==NULL) {
482                 btheme= MEM_callocN(sizeof(bTheme), "theme");
483                 BLI_addtail(&U.themes, btheme);
484                 strcpy(btheme->name, "Default");
485         }
486         
487         UI_SetTheme(0, 0);      // make sure the global used in this file is set
488
489         /* UI buttons */
490         ui_widget_color_init(&btheme->tui);
491
492         /* common (new) variables */
493         ui_theme_init_new(btheme);
494         
495         /* space view3d */
496         SETCOLF(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
497         SETCOL(btheme->tv3d.text,       0, 0, 0, 255);
498         SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255);
499         
500         SETCOLF(btheme->tv3d.header,    0.45, 0.45, 0.45, 1.0);
501         SETCOLF(btheme->tv3d.button,    0.45, 0.45, 0.45, 1.0);
502         SETCOL(btheme->tv3d.panel,      165, 165, 165, 127);
503         
504         SETCOL(btheme->tv3d.shade1,  160, 160, 160, 100);
505         SETCOL(btheme->tv3d.shade2,  0x7f, 0x70, 0x70, 100);
506
507         SETCOLF(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
508         SETCOL(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
509         SETCOL(btheme->tv3d.lamp,       0, 0, 0, 40);
510         SETCOL(btheme->tv3d.select, 241, 88, 0, 255);
511         SETCOL(btheme->tv3d.active, 255, 140, 25, 255);
512         SETCOL(btheme->tv3d.group,      8, 48, 8, 255);
513         SETCOL(btheme->tv3d.group_active, 85, 187, 85, 255);
514         SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
515         SETCOL(btheme->tv3d.vertex, 0, 0, 0, 255);
516         SETCOL(btheme->tv3d.vertex_select, 255, 133, 0, 255);
517         btheme->tv3d.vertex_size= 3;
518         btheme->tv3d.outline_width= 1;
519         SETCOL(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
520         SETCOL(btheme->tv3d.edge_select, 255, 160, 0, 255);
521         SETCOL(btheme->tv3d.edge_seam, 219, 37, 18, 255);
522         SETCOL(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
523         SETCOL(btheme->tv3d.face,       0, 0, 0, 18);
524         SETCOL(btheme->tv3d.face_select, 255, 133, 0, 60);
525         SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
526         SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
527         SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255);
528         btheme->tv3d.facedot_size= 4;
529
530         SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
531         SETCOL(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
532         SETCOL(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
533
534         SETCOL(btheme->tv3d.cframe, 0x60, 0xc0,  0x40, 255);
535
536         SETCOL(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
537         SETCOL(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
538         SETCOL(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255);
539         SETCOL(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255);
540
541         SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
542         SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
543         SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
544         SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
545         SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
546         SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
547         SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
548         SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
549
550         SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
551         SETCOL(btheme->tv3d.lastsel_point,  0xff, 0xff, 0xff, 255);
552
553         SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
554         SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);               // alpha 80 is not meant editable, used for wire+action draw
555         
556         
557         /* space buttons */
558         /* to have something initialized */
559         btheme->tbuts= btheme->tv3d;
560
561         SETCOLF(btheme->tbuts.back,     0.45, 0.45, 0.45, 1.0);
562         SETCOL(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255);
563
564         /* graph editor */
565         btheme->tipo= btheme->tv3d;
566         SETCOLF(btheme->tipo.back,      0.42, 0.42, 0.42, 1.0);
567         SETCOLF(btheme->tipo.list,      0.4, 0.4, 0.4, 1.0);
568         SETCOL(btheme->tipo.grid,       94, 94, 94, 255);
569         SETCOL(btheme->tipo.panel,  255, 255, 255, 150);
570         SETCOL(btheme->tipo.shade1,             150, 150, 150, 100);    /* scrollbars */
571         SETCOL(btheme->tipo.shade2,             0x70, 0x70, 0x70, 100);
572         SETCOL(btheme->tipo.vertex,             0, 0, 0, 255);
573         SETCOL(btheme->tipo.vertex_select, 255, 133, 0, 255);
574         SETCOL(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255); 
575         btheme->tipo.vertex_size= 3;
576
577         SETCOL(btheme->tipo.handle_vertex,              0, 0, 0, 255);
578         SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
579         btheme->tipo.handle_vertex_size= 3;
580         
581         SETCOL(btheme->tipo.ds_channel,         82, 96, 110, 255);
582         SETCOL(btheme->tipo.ds_subchannel,      124, 137, 150, 255);
583         SETCOL(btheme->tipo.group, 79, 101, 73, 255);
584         SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
585
586         /* dopesheet */
587         btheme->tact= btheme->tipo;
588         SETCOL(btheme->tact.strip,                      12, 10, 10, 128); 
589         SETCOL(btheme->tact.strip_select,       255, 140, 0, 255); 
590         
591         /* space nla */
592         btheme->tnla= btheme->tact;
593         
594         /* space file */
595         /* to have something initialized */
596         btheme->tfile= btheme->tv3d;
597         SETCOLF(btheme->tfile.back, 0.3, 0.3, 0.3, 1);
598         SETCOLF(btheme->tfile.panel, 0.3, 0.3, 0.3, 1);
599         SETCOLF(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
600         SETCOL(btheme->tfile.text,      250, 250, 250, 255);
601         SETCOL(btheme->tfile.text_hi, 15, 15, 15, 255);
602         SETCOL(btheme->tfile.panel, 145, 145, 145, 255);        // bookmark/ui regions
603         SETCOL(btheme->tfile.active, 130, 130, 130, 255); // selected files
604         SETCOL(btheme->tfile.hilite, 255, 140, 25, 255); // selected files
605         
606         SETCOL(btheme->tfile.grid,      250, 250, 250, 255);
607         SETCOL(btheme->tfile.image,     250, 250, 250, 255);
608         SETCOL(btheme->tfile.movie,     250, 250, 250, 255);
609         SETCOL(btheme->tfile.scene,     250, 250, 250, 255);
610
611         
612         /* space seq */
613         btheme->tseq= btheme->tv3d;
614         SETCOL(btheme->tseq.back,       116, 116, 116, 255);
615         SETCOL(btheme->tseq.movie,      81, 105, 135, 255);
616         SETCOL(btheme->tseq.image,      109, 88, 129, 255);
617         SETCOL(btheme->tseq.scene,      78, 152, 62, 255);
618         SETCOL(btheme->tseq.audio,      46, 143, 143, 255);
619         SETCOL(btheme->tseq.effect,     169, 84, 124, 255);
620         SETCOL(btheme->tseq.plugin,     126, 126, 80, 255);
621         SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
622         SETCOL(btheme->tseq.meta,       109, 145, 131, 255);
623         
624
625         /* space image */
626         btheme->tima= btheme->tv3d;
627         SETCOL(btheme->tima.back,       53, 53, 53, 255);
628         SETCOL(btheme->tima.vertex, 0, 0, 0, 255);
629         SETCOL(btheme->tima.vertex_select, 255, 133, 0, 255);
630         btheme->tima.vertex_size= 3;
631         btheme->tima.facedot_size= 3;
632         SETCOL(btheme->tima.face,   255, 255, 255, 10);
633         SETCOL(btheme->tima.face_select, 255, 133, 0, 60);
634         SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
635         SETCOLF(btheme->tima.preview_back,      0.45, 0.45, 0.45, 1.0);
636
637         /* space imageselect */
638         btheme->timasel= btheme->tv3d;
639         SETCOL(btheme->timasel.active,  195, 195, 195, 255); /* active tile */
640         SETCOL(btheme->timasel.grid,  94, 94, 94, 255); /* active file text */
641         SETCOL(btheme->timasel.back,    110, 110, 110, 255);
642         SETCOL(btheme->timasel.shade1,  94, 94, 94, 255);       /* bar */
643         SETCOL(btheme->timasel.shade2,  172, 172, 172, 255); /* sliders */
644         SETCOL(btheme->timasel.hilite,  17, 27, 60, 100);       /* selected tile */
645         SETCOL(btheme->timasel.text,    0, 0, 0, 255);
646         SETCOL(btheme->timasel.text_hi, 255, 255, 255, 255);
647         SETCOL(btheme->timasel.panel,   132, 132, 132, 255);
648
649         /* space text */
650         btheme->text= btheme->tv3d;
651         SETCOL(btheme->text.back,       153, 153, 153, 255);
652         SETCOL(btheme->text.shade1,     143, 143, 143, 255);
653         SETCOL(btheme->text.shade2,     0xc6, 0x77, 0x77, 255);
654         SETCOL(btheme->text.hilite,     255, 0, 0, 255);
655         
656         /* syntax highlighting */
657         SETCOL(btheme->text.syntaxn,    0, 0, 200, 255);        /* Numbers  Blue*/
658         SETCOL(btheme->text.syntaxl,    100, 0, 0, 255);        /* Strings  red */
659         SETCOL(btheme->text.syntaxc,    0, 100, 50, 255);       /* Comments greenish */
660         SETCOL(btheme->text.syntaxv,    95, 95, 0, 255);        /* Special */
661         SETCOL(btheme->text.syntaxb,    128, 0, 80, 255);       /* Builtin, red-purple */
662         
663         /* space oops */
664         btheme->toops= btheme->tv3d;
665         SETCOLF(btheme->toops.back,     0.45, 0.45, 0.45, 1.0);
666         
667         /* space info */
668         btheme->tinfo= btheme->tv3d;
669         SETCOLF(btheme->tinfo.back,     0.45, 0.45, 0.45, 1.0);
670
671         /* space user preferences */
672         btheme->tuserpref= btheme->tv3d;
673         SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
674         
675         /* space console */
676         btheme->tconsole= btheme->tv3d;
677         SETCOL(btheme->tconsole.back, 0, 0, 0, 255);
678         SETCOL(btheme->tconsole.console_output, 96, 128, 255, 255);
679         SETCOL(btheme->tconsole.console_input, 255, 255, 255, 255);
680         SETCOL(btheme->tconsole.console_info, 0, 170, 0, 255);
681         SETCOL(btheme->tconsole.console_error, 220, 96, 96, 255);
682         SETCOL(btheme->tconsole.console_cursor, 220, 96, 96, 255);
683         
684
685         /* space sound */
686         btheme->tsnd= btheme->tv3d;
687         SETCOLF(btheme->tsnd.back,      0.45, 0.45, 0.45, 1.0);
688         SETCOLF(btheme->tsnd.grid,      0.36, 0.36, 0.36, 1.0);
689         SETCOL(btheme->tsnd.shade1,  173, 173, 173, 255);               // sliders
690         
691         /* space time */
692         btheme->ttime= btheme->tsnd;    // same as sound space
693         
694         /* space node, re-uses syntax color storage */
695         btheme->tnode= btheme->tv3d;
696         SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
697         SETCOL(btheme->tnode.syntaxl, 155, 155, 155, 160);      /* TH_NODE, backdrop */
698         SETCOL(btheme->tnode.syntaxn, 100, 100, 100, 255);      /* in/output */
699         SETCOL(btheme->tnode.syntaxb, 108, 105, 111, 255);      /* operator */
700         SETCOL(btheme->tnode.syntaxv, 104, 106, 117, 255);      /* generator */
701         SETCOL(btheme->tnode.syntaxc, 105, 117, 110, 255);      /* group */
702
703         /* space logic */
704         btheme->tlogic= btheme->tv3d;
705         SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
706         
707 }
708
709
710 void UI_SetTheme(int spacetype, int regionid)
711 {
712         if(spacetype==0) {      // called for safety, when delete themes
713                 theme_active= U.themes.first;
714                 theme_spacetype= SPACE_VIEW3D;
715                 theme_regionid= RGN_TYPE_WINDOW;
716         }
717         else {
718                 // later on, a local theme can be found too
719                 theme_active= U.themes.first;
720                 theme_spacetype= spacetype;
721                 theme_regionid= regionid;
722         }
723 }
724
725 // for space windows only
726 void UI_ThemeColor(int colorid)
727 {
728         const unsigned char *cp;
729         
730         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
731         glColor3ubv(cp);
732
733 }
734
735 // plus alpha
736 void UI_ThemeColor4(int colorid)
737 {
738         const unsigned char *cp;
739         
740         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
741         glColor4ubv(cp);
742
743 }
744
745 // set the color with offset for shades
746 void UI_ThemeColorShade(int colorid, int offset)
747 {
748         int r, g, b;
749         const unsigned char *cp;
750         
751         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
752         r= offset + (int) cp[0];
753         CLAMP(r, 0, 255);
754         g= offset + (int) cp[1];
755         CLAMP(g, 0, 255);
756         b= offset + (int) cp[2];
757         CLAMP(b, 0, 255);
758         //glColor3ub(r, g, b);
759         glColor4ub(r, g, b, cp[3]);
760 }
761 void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
762 {
763         int r, g, b, a;
764         const unsigned char *cp;
765         
766         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
767         r= coloffset + (int) cp[0];
768         CLAMP(r, 0, 255);
769         g= coloffset + (int) cp[1];
770         CLAMP(g, 0, 255);
771         b= coloffset + (int) cp[2];
772         CLAMP(b, 0, 255);
773         a= alphaoffset + (int) cp[3];
774         CLAMP(a, 0, 255);
775         glColor4ub(r, g, b, a);
776 }
777
778 // blend between to theme colors, and set it
779 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
780 {
781         int r, g, b;
782         const unsigned char *cp1, *cp2;
783         
784         cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
785         cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
786
787         if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
788         r= floor((1.0-fac)*cp1[0] + fac*cp2[0]);
789         g= floor((1.0-fac)*cp1[1] + fac*cp2[1]);
790         b= floor((1.0-fac)*cp1[2] + fac*cp2[2]);
791         
792         glColor3ub(r, g, b);
793 }
794
795 // blend between to theme colors, shade it, and set it
796 void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
797 {
798         int r, g, b;
799         const unsigned char *cp1, *cp2;
800         
801         cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
802         cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
803
804         if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
805         r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
806         g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
807         b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
808         
809         CLAMP(r, 0, 255);
810         CLAMP(g, 0, 255);
811         CLAMP(b, 0, 255);
812         
813         glColor3ub(r, g, b);
814 }
815
816 // blend between to theme colors, shade it, and set it
817 void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
818 {
819         int r, g, b, a;
820         const unsigned char *cp1, *cp2;
821         
822         cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
823         cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
824
825         if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
826         r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
827         g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
828         b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
829         a= alphaoffset+floor((1.0-fac)*cp1[3] + fac*cp2[3]);
830         
831         CLAMP(r, 0, 255);
832         CLAMP(g, 0, 255);
833         CLAMP(b, 0, 255);
834         CLAMP(a, 0, 255);
835
836         glColor4ub(r, g, b, a);
837 }
838
839
840 // get individual values, not scaled
841 float UI_GetThemeValuef(int colorid)
842 {
843         const unsigned char *cp;
844         
845         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
846         return ((float)cp[0]);
847
848 }
849
850 // get individual values, not scaled
851 int UI_GetThemeValue(int colorid)
852 {
853         const unsigned char *cp;
854         
855         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
856         return ((int) cp[0]);
857
858 }
859
860
861 // get the color, range 0.0-1.0
862 void UI_GetThemeColor3fv(int colorid, float *col)
863 {
864         const unsigned char *cp;
865         
866         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
867         col[0]= ((float)cp[0])/255.0;
868         col[1]= ((float)cp[1])/255.0;
869         col[2]= ((float)cp[2])/255.0;
870 }
871
872 // get the color, range 0.0-1.0, complete with shading offset
873 void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
874 {
875         int r, g, b;
876         const unsigned char *cp;
877         
878         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
879         
880         r= offset + (int) cp[0];
881         CLAMP(r, 0, 255);
882         g= offset + (int) cp[1];
883         CLAMP(g, 0, 255);
884         b= offset + (int) cp[2];
885         CLAMP(b, 0, 255);
886         
887         col[0]= ((float)r)/255.0;
888         col[1]= ((float)g)/255.0;
889         col[2]= ((float)b)/255.0;
890 }
891
892 // get the color, in char pointer
893 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
894 {
895         const unsigned char *cp;
896         
897         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
898         col[0]= cp[0];
899         col[1]= cp[1];
900         col[2]= cp[2];
901 }
902
903 // get the color, in char pointer
904 void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
905 {
906         const unsigned char *cp;
907         
908         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
909         col[0]= cp[0];
910         col[1]= cp[1];
911         col[2]= cp[2];
912         col[3]= cp[3];
913 }
914
915 void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
916 {
917         const unsigned char *cp;
918         
919         cp= UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
920         col[0]= cp[0];
921         col[1]= cp[1];
922         col[2]= cp[2];
923         col[3]= cp[3];
924 }
925
926 // blends and shades between two char color pointers
927 void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
928 {
929         int r, g, b;
930         
931         if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
932         r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
933         g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
934         b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
935         
936         r= r<0?0:(r>255?255:r);
937         g= g<0?0:(g>255?255:g);
938         b= b<0?0:(b>255?255:b);
939         
940         glColor3ub(r, g, b);
941 }
942
943 // get a 3 byte color, blended and shaded between two other char color pointers
944 void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset)
945 {
946         int r, g, b;
947         
948         if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
949         r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
950         g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
951         b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
952         
953         r= r<0?0:(r>255?255:r);
954         g= g<0?0:(g>255?255:g);
955         b= b<0?0:(b>255?255:b);
956         
957         col[0] = r;
958         col[1] = g;
959         col[2] = b;
960 }
961
962 void UI_ThemeClearColor(int colorid)
963 {
964         float col[3];
965         
966         UI_GetThemeColor3fv(colorid, col);
967         glClearColor(col[0], col[1], col[2], 0.0);
968 }
969
970 void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
971 {
972         switch(axis)
973         {
974                 case 'X':
975                         dst_col[0]= src_col[0]>219?255:src_col[0]+36;
976                         dst_col[1]= src_col[1]<26?0:src_col[1]-26;
977                         dst_col[2]= src_col[2]<26?0:src_col[2]-26;
978                         break;
979                 case 'Y':
980                         dst_col[0]= src_col[0]<46?0:src_col[0]-36;
981                         dst_col[1]= src_col[1]>189?255:src_col[1]+66;
982                         dst_col[2]= src_col[2]<46?0:src_col[2]-36;
983                         break;
984                 case 'Z':
985                         dst_col[0]= src_col[0]<26?0:src_col[0]-26; 
986                         dst_col[1]= src_col[1]<26?0:src_col[1]-26; 
987                         dst_col[2]= src_col[2]>209?255:src_col[2]+46;
988                         break;
989                 default:
990                         BLI_assert(!"invalid axis arg");
991         }
992 }
993
994 /* ************************************************************* */
995
996 /* patching UserDef struct and Themes */
997 void init_userdef_do_versions(void)
998 {
999         Main *bmain= G.main;
1000 //      countall();
1001         
1002         /* the UserDef struct is not corrected with do_versions() .... ugh! */
1003         if(U.wheellinescroll == 0) U.wheellinescroll = 3;
1004         if(U.menuthreshold1==0) {
1005                 U.menuthreshold1= 5;
1006                 U.menuthreshold2= 2;
1007         }
1008         if(U.tb_leftmouse==0) {
1009                 U.tb_leftmouse= 5;
1010                 U.tb_rightmouse= 5;
1011         }
1012         if(U.mixbufsize==0) U.mixbufsize= 2048;
1013         if (strcmp(U.tempdir, "/") == 0) {
1014                 BLI_where_is_temp(U.tempdir, sizeof(U.tempdir), FALSE);
1015         }
1016         if (U.autokey_mode == 0) {
1017                 /* 'add/replace' but not on */
1018                 U.autokey_mode = 2;
1019         }
1020         if (U.savetime <= 0) {
1021                 U.savetime = 1;
1022 // XXX          error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
1023         }
1024         /* transform widget settings */
1025         if(U.tw_hotspot==0) {
1026                 U.tw_hotspot= 14;
1027                 U.tw_size= 20;                  // percentage of window size
1028                 U.tw_handlesize= 16;    // percentage of widget radius
1029         }
1030         if(U.pad_rot_angle==0)
1031                 U.pad_rot_angle= 15;
1032         
1033         if(U.flag & USER_CUSTOM_RANGE) 
1034                 vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */
1035         
1036         if (bmain->versionfile <= 191) {
1037                 strcpy(U.plugtexdir, U.textudir);
1038                 strcpy(U.sounddir, "/");
1039         }
1040         
1041         /* patch to set Dupli Armature */
1042         if (bmain->versionfile < 220) {
1043                 U.dupflag |= USER_DUP_ARM;
1044         }
1045         
1046         /* added seam, normal color, undo */
1047         if (bmain->versionfile <= 234) {
1048                 bTheme *btheme;
1049                 
1050                 U.uiflag |= USER_GLOBALUNDO;
1051                 if (U.undosteps==0) U.undosteps=32;
1052                 
1053                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1054                         /* check for alpha==0 is safe, then color was never set */
1055                         if(btheme->tv3d.edge_seam[3]==0) {
1056                                 SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255);
1057                         }
1058                         if(btheme->tv3d.normal[3]==0) {
1059                                 SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
1060                         }
1061                         if(btheme->tv3d.vertex_normal[3]==0) {
1062                                 SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
1063                         }
1064                         if(btheme->tv3d.face_dot[3]==0) {
1065                                 SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255);
1066                                 btheme->tv3d.facedot_size= 4;
1067                         }
1068                 }
1069         }
1070         if (bmain->versionfile <= 235) {
1071                 /* illegal combo... */
1072                 if (U.flag & USER_LMOUSESELECT) 
1073                         U.flag &= ~USER_TWOBUTTONMOUSE;
1074         }
1075         if (bmain->versionfile <= 236) {
1076                 bTheme *btheme;
1077                 /* new space type */
1078                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1079                         /* check for alpha==0 is safe, then color was never set */
1080                         if(btheme->ttime.back[3]==0) {
1081                                 btheme->ttime = btheme->tsnd;   // copy from sound
1082                         }
1083                         if(btheme->text.syntaxn[3]==0) {
1084                                 SETCOL(btheme->text.syntaxn,    0, 0, 200, 255);        /* Numbers  Blue*/
1085                                 SETCOL(btheme->text.syntaxl,    100, 0, 0, 255);        /* Strings  red */
1086                                 SETCOL(btheme->text.syntaxc,    0, 100, 50, 255);       /* Comments greenish */
1087                                 SETCOL(btheme->text.syntaxv,    95, 95, 0, 255);        /* Special */
1088                                 SETCOL(btheme->text.syntaxb,    128, 0, 80, 255);       /* Builtin, red-purple */
1089                         }
1090                 }
1091         }
1092         if (bmain->versionfile <= 237) {
1093                 bTheme *btheme;
1094                 /* bone colors */
1095                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1096                         /* check for alpha==0 is safe, then color was never set */
1097                         if(btheme->tv3d.bone_solid[3]==0) {
1098                                 SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
1099                                 SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);
1100                         }
1101                 }
1102         }
1103         if (bmain->versionfile <= 238) {
1104                 bTheme *btheme;
1105                 /* bone colors */
1106                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1107                         /* check for alpha==0 is safe, then color was never set */
1108                         if(btheme->tnla.strip[3]==0) {
1109                                 SETCOL(btheme->tnla.strip_select,       0xff, 0xff, 0xaa, 255);
1110                                 SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
1111                         }
1112                 }
1113         }
1114         if (bmain->versionfile <= 239) {
1115                 bTheme *btheme;
1116                 
1117                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1118                         /* Lamp theme, check for alpha==0 is safe, then color was never set */
1119                         if(btheme->tv3d.lamp[3]==0) {
1120                                 SETCOL(btheme->tv3d.lamp,       0, 0, 0, 40);
1121 /* TEMPORAL, remove me! (ton) */                                
1122                                 U.uiflag |= USER_PLAINMENUS;
1123                         }
1124                         
1125                 }
1126                 if(U.obcenter_dia==0) U.obcenter_dia= 6;
1127         }
1128         if (bmain->versionfile <= 241) {
1129                 bTheme *btheme;
1130                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1131                         /* Node editor theme, check for alpha==0 is safe, then color was never set */
1132                         if(btheme->tnode.syntaxn[3]==0) {
1133                                 /* re-uses syntax color storage */
1134                                 btheme->tnode= btheme->tv3d;
1135                                 SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
1136                                 SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255);      /* TH_NODE, backdrop */
1137                                 SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255);      /* in/output */
1138                                 SETCOL(btheme->tnode.syntaxb, 127,127,127, 255);        /* operator */
1139                                 SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255);      /* generator */
1140                                 SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255);      /* group */
1141                         }
1142                         /* Group theme colors */
1143                         if(btheme->tv3d.group[3]==0) {
1144                                 SETCOL(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255);
1145                                 SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
1146                         }
1147                         /* Sequence editor theme*/
1148                         if(btheme->tseq.movie[3]==0) {
1149                                 SETCOL(btheme->tseq.movie,      81, 105, 135, 255);
1150                                 SETCOL(btheme->tseq.image,      109, 88, 129, 255);
1151                                 SETCOL(btheme->tseq.scene,      78, 152, 62, 255);
1152                                 SETCOL(btheme->tseq.audio,      46, 143, 143, 255);
1153                                 SETCOL(btheme->tseq.effect,     169, 84, 124, 255);
1154                                 SETCOL(btheme->tseq.plugin,     126, 126, 80, 255);
1155                                 SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
1156                                 SETCOL(btheme->tseq.meta,       109, 145, 131, 255);
1157                         }
1158                 }
1159                 
1160                 /* set defaults for 3D View rotating axis indicator */ 
1161                 /* since size can't be set to 0, this indicates it's not saved in startup.blend */
1162                 if (U.rvisize == 0) {
1163                         U.rvisize = 15;
1164                         U.rvibright = 8;
1165                         U.uiflag |= USER_SHOW_ROTVIEWICON;
1166                 }
1167                 
1168         }
1169         if (bmain->versionfile <= 242) {
1170                 bTheme *btheme;
1171                 
1172                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1173                         /* long keyframe color */
1174                         /* check for alpha==0 is safe, then color was never set */
1175                         if(btheme->tact.strip[3]==0) {
1176                                 SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
1177                                 SETCOL(btheme->tact.strip_select,       0xff, 0xff, 0xaa, 204);
1178                                 SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
1179                         }
1180                         
1181                         /* IPO-Editor - Vertex Size*/
1182                         if(btheme->tipo.vertex_size == 0) {
1183                                 btheme->tipo.vertex_size= 3;
1184                         }
1185                 }
1186         }
1187         if (bmain->versionfile <= 243) {
1188                 /* set default number of recently-used files (if not set) */
1189                 if (U.recent_files == 0) U.recent_files = 10;
1190         }
1191         if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
1192                 bTheme *btheme;
1193                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1194                         SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
1195                 }
1196                 if(U.coba_weight.tot==0)
1197                         init_colorband(&U.coba_weight, 1);
1198         }
1199         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
1200                 bTheme *btheme;
1201                 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1202                         /* these should all use the same color */
1203                         SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
1204                         SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
1205                         SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
1206                         SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
1207                         SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
1208                         SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255);
1209                         SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
1210                 }
1211         }
1212         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
1213                 bTheme *btheme;
1214                 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1215                         /* action channel groups (recolor anyway) */
1216                         SETCOL(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
1217                         SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
1218                         
1219                         /* bone custom-color sets */
1220                         // FIXME: this check for initialised colors is bad
1221                         if (btheme->tarm[0].solid[3] == 0) {
1222                                         /* set 1 */
1223                                 SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
1224                                 SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
1225                                 SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
1226                                         /* set 2 */
1227                                 SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
1228                                 SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
1229                                 SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
1230                                         /* set 3 */
1231                                 SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
1232                                 SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
1233                                 SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
1234                                         /* set 4 */
1235                                 SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
1236                                 SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
1237                                 SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
1238                                         /* set 5 */
1239                                 SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
1240                                 SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
1241                                 SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
1242                                         /* set 6 */
1243                                 SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
1244                                 SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
1245                                 SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
1246                                         /* set 7 */
1247                                 SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
1248                                 SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
1249                                 SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
1250                                         /* set 8 */
1251                                 SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
1252                                 SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
1253                                 SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
1254                                         /* set 9 */
1255                                 SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
1256                                 SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
1257                                 SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
1258                                         /* set 10 */
1259                                 SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
1260                                 SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
1261                                 SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
1262                                         /* set 11 */
1263                                 SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
1264                                 SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
1265                                 SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
1266                                         /* set 12 */
1267                                 SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
1268                                 SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
1269                                 SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
1270                                         /* set 13 */
1271                                 SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
1272                                 SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
1273                                 SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
1274                                         /* set 14 */
1275                                 SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
1276                                 SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
1277                                 SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
1278                                         /* set 15 */
1279                                 SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
1280                                 SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
1281                                 SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
1282                         }
1283                 }
1284         }
1285         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
1286                 U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE;
1287         }
1288         if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
1289                 bTheme *btheme;
1290                 
1291                 /* adjust themes */
1292                 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1293                         char *col;
1294                         
1295                         /* IPO Editor: Handles/Vertices */
1296                         col = btheme->tipo.vertex;
1297                         SETCOL(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
1298                         col = btheme->tipo.vertex_select;
1299                         SETCOL(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
1300                         btheme->tipo.handle_vertex_size= btheme->tipo.vertex_size;
1301                         
1302                         /* Sequence/Image Editor: colors for GPencil text */
1303                         col = btheme->tv3d.bone_pose;
1304                         SETCOL(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
1305                         SETCOL(btheme->tima.bone_pose, col[0], col[1], col[2], 255);
1306                         col = btheme->tv3d.vertex_select;
1307                         SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
1308                 }
1309         }
1310         if (bmain->versionfile < 250) {
1311                 bTheme *btheme;
1312                 
1313                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1314                         /* this was not properly initialized in 2.45 */
1315                         if(btheme->tima.face_dot[3]==0) {
1316                                 SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
1317                                 SETCOL(btheme->tima.face_dot, 255, 133, 0, 255);
1318                                 btheme->tima.facedot_size= 2;
1319                         }
1320                         
1321                         /* DopeSheet - (Object) Channel color */
1322                         SETCOL(btheme->tact.ds_channel,         82, 96, 110, 255);
1323                         SETCOL(btheme->tact.ds_subchannel,      124, 137, 150, 255);
1324                         /* DopeSheet - Group Channel color (saner version) */
1325                         SETCOL(btheme->tact.group, 79, 101, 73, 255);
1326                         SETCOL(btheme->tact.group_active, 135, 177, 125, 255);
1327                         
1328                         /* Graph Editor - (Object) Channel color */
1329                         SETCOL(btheme->tipo.ds_channel,         82, 96, 110, 255);
1330                         SETCOL(btheme->tipo.ds_subchannel,      124, 137, 150, 255);
1331                         /* Graph Editor - Group Channel color */
1332                         SETCOL(btheme->tipo.group, 79, 101, 73, 255);
1333                         SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
1334                         
1335                         /* Nla Editor - (Object) Channel color */
1336                         SETCOL(btheme->tnla.ds_channel,         82, 96, 110, 255);
1337                         SETCOL(btheme->tnla.ds_subchannel,      124, 137, 150, 255);
1338                         /* NLA Editor - New Strip colors */
1339                         SETCOL(btheme->tnla.strip,                      12, 10, 10, 128); 
1340                         SETCOL(btheme->tnla.strip_select,       255, 140, 0, 255);
1341                 }
1342                 
1343                 /* adjust grease-pencil distances */
1344                 U.gp_manhattendist= 1;
1345                 U.gp_euclideandist= 2;
1346                 
1347                 /* adjust default interpolation for new IPO-curves */
1348                 U.ipo_new= BEZT_IPO_BEZ;
1349         }
1350         
1351         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
1352                 bTheme *btheme;
1353
1354                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1355                         
1356                         /* common (new) variables, it checks for alpha==0 */
1357                         ui_theme_init_new(btheme);
1358
1359                         if(btheme->tui.wcol_num.outline[3]==0)
1360                                 ui_widget_color_init(&btheme->tui);
1361                         
1362                         /* Logic editor theme, check for alpha==0 is safe, then color was never set */
1363                         if(btheme->tlogic.syntaxn[3]==0) {
1364                                 /* re-uses syntax color storage */
1365                                 btheme->tlogic= btheme->tv3d;
1366                                 SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
1367                         }
1368
1369                         SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
1370                         SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
1371                 }
1372         }
1373
1374         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
1375                 /* new audio system */
1376                 if(U.audiochannels == 0)
1377                         U.audiochannels = 2;
1378                 if(U.audiodevice == 0) {
1379 #ifdef WITH_OPENAL
1380                         U.audiodevice = 2;
1381 #endif
1382 #ifdef WITH_SDL
1383                         U.audiodevice = 1;
1384 #endif
1385                 }
1386                 if(U.audioformat == 0)
1387                         U.audioformat = 0x24;
1388                 if(U.audiorate == 0)
1389                         U.audiorate = 44100;
1390         }
1391
1392         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
1393                 U.gameflags |= USER_DISABLE_VBO;
1394         
1395         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
1396                 wmKeyMap *km;
1397                 
1398                 for(km=U.keymaps.first; km; km=km->next) {
1399                         if (strcmp(km->idname, "Armature_Sketch")==0)
1400                                 strcpy(km->idname, "Armature Sketch");
1401                         else if (strcmp(km->idname, "View3D")==0)
1402                                 strcpy(km->idname, "3D View");
1403                         else if (strcmp(km->idname, "View3D Generic")==0)
1404                                 strcpy(km->idname, "3D View Generic");
1405                         else if (strcmp(km->idname, "EditMesh")==0)
1406                                 strcpy(km->idname, "Mesh");
1407                         else if (strcmp(km->idname, "TimeLine")==0)
1408                                 strcpy(km->idname, "Timeline");
1409                         else if (strcmp(km->idname, "UVEdit")==0)
1410                                 strcpy(km->idname, "UV Editor");
1411                         else if (strcmp(km->idname, "Animation_Channels")==0)
1412                                 strcpy(km->idname, "Animation Channels");
1413                         else if (strcmp(km->idname, "GraphEdit Keys")==0)
1414                                 strcpy(km->idname, "Graph Editor");
1415                         else if (strcmp(km->idname, "GraphEdit Generic")==0)
1416                                 strcpy(km->idname, "Graph Editor Generic");
1417                         else if (strcmp(km->idname, "Action_Keys")==0)
1418                                 strcpy(km->idname, "Dopesheet");
1419                         else if (strcmp(km->idname, "NLA Data")==0)
1420                                 strcpy(km->idname, "NLA Editor");
1421                         else if (strcmp(km->idname, "Node Generic")==0)
1422                                 strcpy(km->idname, "Node Editor");
1423                         else if (strcmp(km->idname, "Logic Generic")==0)
1424                                 strcpy(km->idname, "Logic Editor");
1425                         else if (strcmp(km->idname, "File")==0)
1426                                 strcpy(km->idname, "File Browser");
1427                         else if (strcmp(km->idname, "FileMain")==0)
1428                                 strcpy(km->idname, "File Browser Main");
1429                         else if (strcmp(km->idname, "FileButtons")==0)
1430                                 strcpy(km->idname, "File Browser Buttons");
1431                         else if (strcmp(km->idname, "Buttons Generic")==0)
1432                                 strcpy(km->idname, "Property Editor");
1433                 }
1434         }
1435         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
1436                 if(U.wmdrawmethod == USER_DRAW_TRIPLE)
1437                         U.wmdrawmethod = USER_DRAW_AUTOMATIC;
1438         }
1439         
1440         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
1441                 if (U.flag & USER_LMOUSESELECT) 
1442                         U.flag &= ~USER_TWOBUTTONMOUSE;
1443         }
1444         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
1445                 bTheme *btheme;
1446                 
1447                 /* default new handle type is auto handles */
1448                 U.keyhandles_new = HD_AUTO;
1449                 
1450                 /* init new curve colors */
1451                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1452                         /* init colors used for handles in 3D-View  */
1453                         SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
1454                         SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
1455                         SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
1456                         SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
1457                         SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
1458                         SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1459                         SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1460                         SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1461                         SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
1462                         
1463                         /* same colors again for Graph Editor... */
1464                         SETCOL(btheme->tipo.handle_free, 0, 0, 0, 255);
1465                         SETCOL(btheme->tipo.handle_auto, 0x90, 0x90, 0x00, 255);
1466                         SETCOL(btheme->tipo.handle_vect, 0x40, 0x90, 0x30, 255);
1467                         SETCOL(btheme->tipo.handle_align, 0x80, 0x30, 0x60, 255);
1468                         SETCOL(btheme->tipo.handle_sel_free, 0, 0, 0, 255);
1469                         SETCOL(btheme->tipo.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1470                         SETCOL(btheme->tipo.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1471                         SETCOL(btheme->tipo.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1472                         
1473                         /* edge crease */
1474                         SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
1475                 }
1476         }
1477         if (bmain->versionfile <= 252) {
1478                 bTheme *btheme;
1479
1480                 /* init new curve colors */
1481                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1482                         if (btheme->tv3d.lastsel_point[3] == 0)
1483                                 SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
1484                 }
1485         }
1486         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
1487                 bTheme *btheme;
1488                 
1489                 /* interface_widgets.c */
1490                 struct uiWidgetColors wcol_progress= {
1491                         {0, 0, 0, 255},
1492                         {190, 190, 190, 255},
1493                         {100, 100, 100, 180},
1494                         {68, 68, 68, 255},
1495                         
1496                         {0, 0, 0, 255},
1497                         {255, 255, 255, 255},
1498                         
1499                         0,
1500                         5, -5
1501                 };
1502                 
1503                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1504                         /* init progress bar theme */
1505                         btheme->tui.wcol_progress= wcol_progress;
1506                 }
1507         }
1508
1509         if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
1510                 bTheme *btheme;
1511                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1512                         SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
1513                         SETCOL(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
1514                         SETCOL(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
1515                 }
1516         }
1517         
1518         if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) {
1519                 bTheme *btheme;
1520                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1521                         if((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width= 1;
1522                 }
1523         }
1524
1525         if (bmain->versionfile < 257) {
1526                 /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs, so that it doesn't linger around from old configs like a ghost */
1527                 U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
1528         }
1529         
1530         /* GL Texture Garbage Collection (variable abused above!) */
1531         if (U.textimeout == 0) {
1532                 U.texcollectrate = 60;
1533                 U.textimeout = 120;
1534         }
1535         if (U.memcachelimit <= 0) {
1536                 U.memcachelimit = 32;
1537         }
1538         if (U.frameserverport == 0) {
1539                 U.frameserverport = 8080;
1540         }
1541         if (U.dbl_click_time == 0) {
1542                 U.dbl_click_time = 350;
1543         }
1544         if (U.anim_player_preset == 0) {
1545                 U.anim_player_preset = 1 ;
1546         }
1547         if (U.scrcastfps == 0) {
1548                 U.scrcastfps = 10;
1549                 U.scrcastwait = 50;
1550         }
1551         if (U.v2d_min_gridsize == 0) {
1552                 U.v2d_min_gridsize= 35;
1553         }
1554         if (U.dragthreshold == 0 )
1555                 U.dragthreshold= 5;
1556
1557         /* funny name, but it is GE stuff, moves userdef stuff to engine */
1558 // XXX  space_set_commmandline_options();
1559         /* this timer uses U */
1560 // XXX  reset_autosave();
1561
1562 }