Make options for background gradient more organized.
[blender.git] / source / blender / editors / interface / resources.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL/BL DUAL LICENSE BLOCK *****
26  */
27
28 /** \file blender/editors/interface/resources.c
29  *  \ingroup edinterface
30  */
31
32 #include <math.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 #include "MEM_guardedalloc.h"
37
38 #include "DNA_curve_types.h"
39 #include "DNA_userdef_types.h"
40 #include "DNA_screen_types.h"
41 #include "DNA_space_types.h"
42 #include "DNA_windowmanager_types.h"
43
44 #include "BLI_blenlib.h"
45 #include "BLI_utildefines.h"
46 #include "BLI_math.h"
47
48 #include "BKE_DerivedMesh.h"
49 #include "BKE_global.h"
50 #include "BKE_main.h"
51 #include "BKE_texture.h"
52
53
54 #include "BIF_gl.h"
55
56 #include "UI_interface.h"
57 #include "UI_interface_icons.h"
58
59 #include "interface_intern.h"
60
61 /* global for themes */
62 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
63
64 static bTheme *theme_active = NULL;
65 static int theme_spacetype = SPACE_VIEW3D;
66 static int theme_regionid = RGN_TYPE_WINDOW;
67
68 void ui_resources_init(void)
69 {
70         UI_icons_init(BIFICONID_LAST);
71 }
72
73 void ui_resources_free(void)
74 {
75         UI_icons_free();
76 }
77
78
79 /* ******************************************************** */
80 /*    THEMES */
81 /* ******************************************************** */
82
83 const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
84 {
85         ThemeSpace *ts = NULL;
86         static char error[4] = {240, 0, 240, 255};
87         static char alert[4] = {240, 60, 60, 255};
88         static char headerdesel[4] = {0, 0, 0, 255};
89         static char setting = 0;
90         const char *cp = error;
91         
92         if (btheme) {
93         
94                 /* first check for ui buttons theme */
95                 if (colorid < TH_THEMEUI) {
96                 
97                         switch (colorid) {
98
99                                 case TH_REDALERT:
100                                         cp = alert; break;
101                         }
102                 }
103                 else {
104                 
105                         switch (spacetype) {
106                                 case SPACE_BUTS:
107                                         ts = &btheme->tbuts;
108                                         break;
109                                 case SPACE_VIEW3D:
110                                         ts = &btheme->tv3d;
111                                         break;
112                                 case SPACE_IPO:
113                                         ts = &btheme->tipo;
114                                         break;
115                                 case SPACE_FILE:
116                                         ts = &btheme->tfile;
117                                         break;
118                                 case SPACE_NLA:
119                                         ts = &btheme->tnla;
120                                         break;
121                                 case SPACE_ACTION:
122                                         ts = &btheme->tact;
123                                         break;
124                                 case SPACE_SEQ:
125                                         ts = &btheme->tseq;
126                                         break;
127                                 case SPACE_IMAGE:
128                                         ts = &btheme->tima;
129                                         break;
130                                 case SPACE_TEXT:
131                                         ts = &btheme->text;
132                                         break;
133                                 case SPACE_OUTLINER:
134                                         ts = &btheme->toops;
135                                         break;
136                                 case SPACE_INFO:
137                                         ts = &btheme->tinfo;
138                                         break;
139                                 case SPACE_USERPREF:
140                                         ts = &btheme->tuserpref;
141                                         break;
142                                 case SPACE_CONSOLE:
143                                         ts = &btheme->tconsole;
144                                         break;
145                                 case SPACE_TIME:
146                                         ts = &btheme->ttime;
147                                         break;
148                                 case SPACE_NODE:
149                                         ts = &btheme->tnode;
150                                         break;
151                                 case SPACE_LOGIC:
152                                         ts = &btheme->tlogic;
153                                         break;
154                                 case SPACE_CLIP:
155                                         ts = &btheme->tclip;
156                                         break;
157                                 default:
158                                         ts = &btheme->tv3d;
159                                         break;
160                         }
161
162                         switch (colorid) {
163                                 case TH_BACK:
164                                         if (theme_regionid == RGN_TYPE_WINDOW)
165                                                 cp = ts->back;
166                                         else if (theme_regionid == RGN_TYPE_CHANNELS)
167                                                 cp = ts->list;
168                                         else if (theme_regionid == RGN_TYPE_HEADER)
169                                                 cp = ts->header;
170                                         else
171                                                 cp = ts->button;
172                                         break;
173                                 case TH_LOW_GRAD:
174                                         cp = ts->gradients.gradient;
175                                         break;
176                                 case TH_HIGH_GRAD:
177                                         cp = ts->gradients.high_gradient;
178                                         break;
179                                 case TH_SHOW_BACK_GRAD:
180                                         cp = &setting;
181                                         setting = ts->gradients.show_grad;
182                                         break;
183                                 case TH_TEXT:
184                                         if (theme_regionid == RGN_TYPE_WINDOW)
185                                                 cp = ts->text;
186                                         else if (theme_regionid == RGN_TYPE_CHANNELS)
187                                                 cp = ts->list_text;
188                                         else if (theme_regionid == RGN_TYPE_HEADER)
189                                                 cp = ts->header_text;
190                                         else
191                                                 cp = ts->button_text;
192                                         break;
193                                 case TH_TEXT_HI:
194                                         if (theme_regionid == RGN_TYPE_WINDOW)
195                                                 cp = ts->text_hi;
196                                         else if (theme_regionid == RGN_TYPE_CHANNELS)
197                                                 cp = ts->list_text_hi;
198                                         else if (theme_regionid == RGN_TYPE_HEADER)
199                                                 cp = ts->header_text_hi;
200                                         else
201                                                 cp = ts->button_text_hi;
202                                         break;
203                                 case TH_TITLE:
204                                         if (theme_regionid == RGN_TYPE_WINDOW)
205                                                 cp = ts->title;
206                                         else if (theme_regionid == RGN_TYPE_CHANNELS)
207                                                 cp = ts->list_title;
208                                         else if (theme_regionid == RGN_TYPE_HEADER)
209                                                 cp = ts->header_title;
210                                         else
211                                                 cp = ts->button_title;
212                                         break;
213
214                                 case TH_HEADER:
215                                         cp = ts->header; break;
216                                 case TH_HEADERDESEL:
217                                         /* we calculate a dynamic builtin header deselect color, also for pulldowns... */
218                                         cp = ts->header;
219                                         headerdesel[0] = cp[0] > 10 ? cp[0] - 10 : 0;
220                                         headerdesel[1] = cp[1] > 10 ? cp[1] - 10 : 0;
221                                         headerdesel[2] = cp[2] > 10 ? cp[2] - 10 : 0;
222                                         cp = headerdesel;
223                                         break;
224                                 case TH_HEADER_TEXT:
225                                         cp = ts->header_text; break;
226                                 case TH_HEADER_TEXT_HI:
227                                         cp = ts->header_text_hi; break;
228
229                                 case TH_PANEL_HEADER:
230                                         cp = ts->panelcolors.header; break;
231                                 case TH_PANEL_BACK:
232                                         cp = ts->panelcolors.back; break;
233                                 case TH_PANEL_SHOW_HEADER:
234                                         cp = &setting;
235                                         setting = ts->panelcolors.show_header;
236                                         break;
237                                 case TH_PANEL_SHOW_BACK:
238                                         cp = &setting;
239                                         setting = ts->panelcolors.show_back;
240                                         break;
241                                         
242                                 case TH_BUTBACK:
243                                         cp = ts->button; break;
244                                 case TH_BUTBACK_TEXT:
245                                         cp = ts->button_text; break;
246                                 case TH_BUTBACK_TEXT_HI:
247                                         cp = ts->button_text_hi; break;
248
249                                 case TH_SHADE1:
250                                         cp = ts->shade1; break;
251                                 case TH_SHADE2:
252                                         cp = ts->shade2; break;
253                                 case TH_HILITE:
254                                         cp = ts->hilite; break;
255                                 
256                                 case TH_GRID:
257                                         cp = ts->grid; break;
258                                 case TH_WIRE:
259                                         cp = ts->wire; break;
260                                 case TH_LAMP:
261                                         cp = ts->lamp; break;
262                                 case TH_SPEAKER:
263                                         cp = ts->speaker; break;
264                                 case TH_CAMERA:
265                                         cp = ts->camera; break;
266                                 case TH_EMPTY:
267                                         cp = ts->empty; break;
268                                 case TH_SELECT:
269                                         cp = ts->select; break;
270                                 case TH_ACTIVE:
271                                         cp = ts->active; break;
272                                 case TH_GROUP:
273                                         cp = ts->group; break;
274                                 case TH_GROUP_ACTIVE:
275                                         cp = ts->group_active; break;
276                                 case TH_TRANSFORM:
277                                         cp = ts->transform; break;
278                                 case TH_VERTEX:
279                                         cp = ts->vertex; break;
280                                 case TH_VERTEX_SELECT:
281                                         cp = ts->vertex_select; break;
282                                 case TH_VERTEX_SIZE:
283                                         cp = &ts->vertex_size; break;
284                                 case TH_OUTLINE_WIDTH:
285                                         cp = &ts->outline_width; break;
286                                 case TH_EDGE:
287                                         cp = ts->edge; break;
288                                 case TH_EDGE_SELECT:
289                                         cp = ts->edge_select; break;
290                                 case TH_EDGE_SEAM:
291                                         cp = ts->edge_seam; break;
292                                 case TH_EDGE_SHARP:
293                                         cp = ts->edge_sharp; break;
294                                 case TH_EDGE_CREASE:
295                                         cp = ts->edge_crease; break;
296                                 case TH_EDITMESH_ACTIVE:
297                                         cp = ts->editmesh_active; break;
298                                 case TH_EDGE_FACESEL:
299                                         cp = ts->edge_facesel; break;
300                                 case TH_FACE:
301                                         cp = ts->face; break;
302                                 case TH_FACE_SELECT:
303                                         cp = ts->face_select; break;
304                                 case TH_FACE_DOT:
305                                         cp = ts->face_dot; break;
306                                 case TH_FACEDOT_SIZE:
307                                         cp = &ts->facedot_size; break;
308                                 case TH_DRAWEXTRA_EDGELEN:
309                                         cp = ts->extra_edge_len; break;
310                                 case TH_DRAWEXTRA_FACEAREA:
311                                         cp = ts->extra_face_area; break;
312                                 case TH_DRAWEXTRA_FACEANG:
313                                         cp = ts->extra_face_angle; break;
314                                 case TH_NORMAL:
315                                         cp = ts->normal; break;
316                                 case TH_VNORMAL:
317                                         cp = ts->vertex_normal; break;
318                                 case TH_BONE_SOLID:
319                                         cp = ts->bone_solid; break;
320                                 case TH_BONE_POSE:
321                                         cp = ts->bone_pose; break;
322                                 case TH_BONE_POSE_ACTIVE:
323                                         cp = ts->bone_pose_active; break;
324                                 case TH_STRIP:
325                                         cp = ts->strip; break;
326                                 case TH_STRIP_SELECT:
327                                         cp = ts->strip_select; break;
328                                 case TH_CFRAME:
329                                         cp = ts->cframe; break;
330                                 case TH_NURB_ULINE:
331                                         cp = ts->nurb_uline; break;
332                                 case TH_NURB_VLINE:
333                                         cp = ts->nurb_vline; break;
334                                 case TH_NURB_SEL_ULINE:
335                                         cp = ts->nurb_sel_uline; break;
336                                 case TH_NURB_SEL_VLINE:
337                                         cp = ts->nurb_sel_vline; break;
338                                 case TH_ACTIVE_SPLINE:
339                                         cp = ts->act_spline; break;
340                                 case TH_LASTSEL_POINT:
341                                         cp = ts->lastsel_point; break;
342                                 case TH_HANDLE_FREE:
343                                         cp = ts->handle_free; break;
344                                 case TH_HANDLE_AUTO:
345                                         cp = ts->handle_auto; break;
346                                 case TH_HANDLE_AUTOCLAMP:
347                                         cp = ts->handle_auto_clamped; break;
348                                 case TH_HANDLE_VECT:
349                                         cp = ts->handle_vect; break;
350                                 case TH_HANDLE_ALIGN:
351                                         cp = ts->handle_align; break;
352                                 case TH_HANDLE_SEL_FREE:
353                                         cp = ts->handle_sel_free; break;
354                                 case TH_HANDLE_SEL_AUTO:
355                                         cp = ts->handle_sel_auto; break;
356                                 case TH_HANDLE_SEL_AUTOCLAMP:
357                                         cp = ts->handle_sel_auto_clamped; break;
358                                 case TH_HANDLE_SEL_VECT:
359                                         cp = ts->handle_sel_vect; break;
360                                 case TH_HANDLE_SEL_ALIGN:
361                                         cp = ts->handle_sel_align; break;
362
363                                 case TH_SYNTAX_B:
364                                         cp = ts->syntaxb; break;
365                                 case TH_SYNTAX_V:
366                                         cp = ts->syntaxv; break;
367                                 case TH_SYNTAX_C:
368                                         cp = ts->syntaxc; break;
369                                 case TH_SYNTAX_L:
370                                         cp = ts->syntaxl; break;
371                                 case TH_SYNTAX_D:
372                                         cp = ts->syntaxd; break;
373                                 case TH_SYNTAX_R:
374                                         cp = ts->syntaxr; break;
375                                 case TH_SYNTAX_N:
376                                         cp = ts->syntaxn; break;
377                                 case TH_SYNTAX_S:
378                                         cp = ts->syntaxs; break;
379
380                                 case TH_NODE:
381                                         cp = ts->syntaxl; break;
382                                 case TH_NODE_IN_OUT:
383                                         cp = ts->syntaxn; break;
384                                 case TH_NODE_OPERATOR:
385                                         cp = ts->syntaxb; break;
386                                 case TH_NODE_CONVERTOR:
387                                         cp = ts->syntaxv; break;
388                                 case TH_NODE_GROUP:
389                                         cp = ts->syntaxc; break;
390                                 case TH_NODE_FRAME:
391                                         cp = ts->movie; break;
392                                 case TH_NODE_CURVING:
393                                         cp = &ts->noodle_curving; break;
394
395                                 case TH_SEQ_MOVIE:
396                                         cp = ts->movie; break;
397                                 case TH_SEQ_MOVIECLIP:
398                                         cp = ts->movieclip; break;
399                                 case TH_SEQ_MASK:
400                                         cp = ts->mask; break;
401                                 case TH_SEQ_IMAGE:
402                                         cp = ts->image; break;
403                                 case TH_SEQ_SCENE:
404                                         cp = ts->scene; break;
405                                 case TH_SEQ_AUDIO:
406                                         cp = ts->audio; break;
407                                 case TH_SEQ_EFFECT:
408                                         cp = ts->effect; break;
409                                 case TH_SEQ_TRANSITION:
410                                         cp = ts->transition; break;
411                                 case TH_SEQ_META:
412                                         cp = ts->meta; break;
413                                 case TH_SEQ_PREVIEW:
414                                         cp = ts->preview_back; break;
415
416                                 case TH_CONSOLE_OUTPUT:
417                                         cp = ts->console_output; break;
418                                 case TH_CONSOLE_INPUT:
419                                         cp = ts->console_input; break;
420                                 case TH_CONSOLE_INFO:
421                                         cp = ts->console_info; break;
422                                 case TH_CONSOLE_ERROR:
423                                         cp = ts->console_error; break;
424                                 case TH_CONSOLE_CURSOR:
425                                         cp = ts->console_cursor; break;
426
427                                 case TH_HANDLE_VERTEX:
428                                         cp = ts->handle_vertex;
429                                         break;
430                                 case TH_HANDLE_VERTEX_SELECT:
431                                         cp = ts->handle_vertex_select;
432                                         break;
433                                 case TH_HANDLE_VERTEX_SIZE:
434                                         cp = &ts->handle_vertex_size;
435                                         break;
436
437                                 case TH_DOPESHEET_CHANNELOB:
438                                         cp = ts->ds_channel;
439                                         break;
440                                 case TH_DOPESHEET_CHANNELSUBOB:
441                                         cp = ts->ds_subchannel;
442                                         break;
443
444                                 case TH_PREVIEW_BACK:
445                                         cp = ts->preview_back;
446                                         break;
447
448                                 case TH_STITCH_PREVIEW_FACE:
449                                         cp = ts->preview_stitch_face;
450                                         break;
451
452                                 case TH_STITCH_PREVIEW_EDGE:
453                                         cp = ts->preview_stitch_edge;
454                                         break;
455
456                                 case TH_STITCH_PREVIEW_VERT:
457                                         cp = ts->preview_stitch_vert;
458                                         break;
459
460                                 case TH_STITCH_PREVIEW_STITCHABLE:
461                                         cp = ts->preview_stitch_stitchable;
462                                         break;
463
464                                 case TH_STITCH_PREVIEW_UNSTITCHABLE:
465                                         cp = ts->preview_stitch_unstitchable;
466                                         break;
467                                 case TH_STITCH_PREVIEW_ACTIVE:
468                                         cp = ts->preview_stitch_active;
469                                         break;
470                                 case TH_MARKER_OUTLINE:
471                                         cp = ts->marker_outline; break;
472                                 case TH_MARKER:
473                                         cp = ts->marker; break;
474                                 case TH_ACT_MARKER:
475                                         cp = ts->act_marker; break;
476                                 case TH_SEL_MARKER:
477                                         cp = ts->sel_marker; break;
478                                 case TH_BUNDLE_SOLID:
479                                         cp = ts->bundle_solid; break;
480                                 case TH_DIS_MARKER:
481                                         cp = ts->dis_marker; break;
482                                 case TH_PATH_BEFORE:
483                                         cp = ts->path_before; break;
484                                 case TH_PATH_AFTER:
485                                         cp = ts->path_after; break;
486                                 case TH_CAMERA_PATH:
487                                         cp = ts->camera_path; break;
488                                 case TH_LOCK_MARKER:
489                                         cp = ts->lock_marker; break;
490
491                                 case TH_MATCH:
492                                         cp = ts->match;
493                                         break;
494
495                                 case TH_SELECT_HIGHLIGHT:
496                                         cp = ts->selected_highlight;
497                                         break;
498
499                                 case TH_SKIN_ROOT:
500                                         cp = ts->skin_root;
501                                         break;
502                                         
503                                 case TH_ANIM_ACTIVE:
504                                         cp = ts->anim_active;
505                                         break;
506                                 case TH_ANIM_INACTIVE:
507                                         cp = ts->anim_non_active;
508                                         break;
509                                 
510                                 case TH_NLA_TWEAK:
511                                         cp = ts->nla_tweaking;
512                                         break;
513                                 case TH_NLA_TWEAK_DUPLI:
514                                         cp = ts->nla_tweakdupli;
515                                         break;
516                                 
517                                 case TH_NLA_TRANSITION:
518                                         cp = ts->nla_transition;
519                                         break;
520                                 case TH_NLA_TRANSITION_SEL:
521                                         cp = ts->nla_transition_sel;
522                                         break;
523                                 case TH_NLA_META:
524                                         cp = ts->nla_meta;
525                                         break;
526                                 case TH_NLA_META_SEL:
527                                         cp = ts->nla_meta_sel;
528                                         break;
529                                 case TH_NLA_SOUND:
530                                         cp = ts->nla_sound;
531                                         break;
532                                 case TH_NLA_SOUND_SEL:
533                                         cp = ts->nla_sound_sel;
534                                         break;
535                                         
536                                 case TH_AXIS_X:
537                                         cp = btheme->tui.xaxis; break;
538                                 case TH_AXIS_Y:
539                                         cp = btheme->tui.yaxis; break;
540                                 case TH_AXIS_Z:
541                                         cp = btheme->tui.zaxis; break;
542                         }
543                 }
544         }
545         
546         return (unsigned char *)cp;
547 }
548
549 /* use this call to init new bone color sets in Theme */
550 static void ui_theme_init_boneColorSets(bTheme *btheme)
551 {
552         int i;
553         
554         /* define default color sets - currently we only define 15 of these, though that should be ample */
555         /* set 1 */
556         rgba_char_args_set(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
557         rgba_char_args_set(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
558         rgba_char_args_set(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
559         /* set 2 */
560         rgba_char_args_set(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
561         rgba_char_args_set(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
562         rgba_char_args_set(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
563         /* set 3 */
564         rgba_char_args_set(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
565         rgba_char_args_set(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
566         rgba_char_args_set(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
567         /* set 4 */
568         rgba_char_args_set(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
569         rgba_char_args_set(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
570         rgba_char_args_set(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
571         /* set 5 */
572         rgba_char_args_set(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
573         rgba_char_args_set(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
574         rgba_char_args_set(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
575         /* set 6 */
576         rgba_char_args_set(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
577         rgba_char_args_set(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
578         rgba_char_args_set(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
579         /* set 7 */
580         rgba_char_args_set(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
581         rgba_char_args_set(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
582         rgba_char_args_set(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
583         /* set 8 */
584         rgba_char_args_set(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
585         rgba_char_args_set(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
586         rgba_char_args_set(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
587         /* set 9 */
588         rgba_char_args_set(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
589         rgba_char_args_set(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
590         rgba_char_args_set(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
591         /* set 10 */
592         rgba_char_args_set(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
593         rgba_char_args_set(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
594         rgba_char_args_set(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
595         /* set 11 */
596         rgba_char_args_set(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
597         rgba_char_args_set(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
598         rgba_char_args_set(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
599         /* set 12 */
600         rgba_char_args_set(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
601         rgba_char_args_set(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
602         rgba_char_args_set(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
603         /* set 13 */
604         rgba_char_args_set(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
605         rgba_char_args_set(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
606         rgba_char_args_set(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
607         /* set 14 */
608         rgba_char_args_set(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
609         rgba_char_args_set(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
610         rgba_char_args_set(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
611         /* set 15 */
612         rgba_char_args_set(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
613         rgba_char_args_set(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
614         rgba_char_args_set(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
615         
616         /* reset flags too */
617         for (i = 0; i < 20; i++)
618                 btheme->tarm[i].flag = 0;
619 }
620
621 /* use this call to init new variables in themespace, if they're same for all */
622 static void ui_theme_init_new_do(ThemeSpace *ts)
623 {
624         rgba_char_args_test_set(ts->header_text,        0, 0, 0, 255);
625         rgba_char_args_test_set(ts->header_title,   0, 0, 0, 255);
626         rgba_char_args_test_set(ts->header_text_hi, 255, 255, 255, 255);
627
628 //      rgba_char_args_test_set(ts->panel_text,     0, 0, 0, 255);
629 //      rgba_char_args_test_set(ts->panel_title,        0, 0, 0, 255);
630 //      rgba_char_args_test_set(ts->panel_text_hi,  255, 255, 255, 255);
631
632         rgba_char_args_test_set(ts->button,         145, 145, 145, 245);
633         rgba_char_args_test_set(ts->button_title,   0, 0, 0, 255);
634         rgba_char_args_test_set(ts->button_text,        0, 0, 0, 255);
635         rgba_char_args_test_set(ts->button_text_hi, 255, 255, 255, 255);
636
637         rgba_char_args_test_set(ts->list,           165, 165, 165, 255);
638         rgba_char_args_test_set(ts->list_title,     0, 0, 0, 255);
639         rgba_char_args_test_set(ts->list_text,      0, 0, 0, 255);
640         rgba_char_args_test_set(ts->list_text_hi,   255, 255, 255, 255);
641 }
642
643 static void ui_theme_init_new(bTheme *btheme)
644 {
645         ui_theme_init_new_do(&btheme->tbuts);
646         ui_theme_init_new_do(&btheme->tv3d);
647         ui_theme_init_new_do(&btheme->tfile);
648         ui_theme_init_new_do(&btheme->tipo);
649         ui_theme_init_new_do(&btheme->tinfo);
650         ui_theme_init_new_do(&btheme->tact);
651         ui_theme_init_new_do(&btheme->tnla);
652         ui_theme_init_new_do(&btheme->tseq);
653         ui_theme_init_new_do(&btheme->tima);
654         ui_theme_init_new_do(&btheme->text);
655         ui_theme_init_new_do(&btheme->toops);
656         ui_theme_init_new_do(&btheme->ttime);
657         ui_theme_init_new_do(&btheme->tnode);
658         ui_theme_init_new_do(&btheme->tlogic);
659         ui_theme_init_new_do(&btheme->tuserpref);
660         ui_theme_init_new_do(&btheme->tconsole);
661         ui_theme_init_new_do(&btheme->tclip);
662         
663 }
664
665
666 /* initialize default theme
667  * Note: when you add new colors, created & saved themes need initialized
668  * use function below, init_userdef_do_versions()
669  */
670 void ui_theme_init_default(void)
671 {
672         bTheme *btheme;
673         
674         /* we search for the theme with name Default */
675         btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
676         
677         if (btheme == NULL) {
678                 btheme = MEM_callocN(sizeof(bTheme), "theme");
679                 BLI_addtail(&U.themes, btheme);
680                 strcpy(btheme->name, "Default");
681         }
682         
683         UI_SetTheme(0, 0);  /* make sure the global used in this file is set */
684
685         /* UI buttons */
686         ui_widget_color_init(&btheme->tui);
687         
688         btheme->tui.iconfile[0] = 0;
689         btheme->tui.panel.show_header = FALSE;
690         rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
691         
692         rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
693         rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
694         rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
695
696         btheme->tui.menu_shadow_fac = 0.5f;
697         btheme->tui.menu_shadow_width = 12;
698         
699         /* Bone Color Sets */
700         ui_theme_init_boneColorSets(btheme);
701         
702         /* common (new) variables */
703         ui_theme_init_new(btheme);
704         
705         /* space view3d */
706         rgba_char_args_set_fl(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
707         rgba_char_args_set(btheme->tv3d.text,       0, 0, 0, 255);
708         rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255);
709         
710         rgba_char_args_set_fl(btheme->tv3d.header,  0.45, 0.45, 0.45, 1.0);
711         rgba_char_args_set_fl(btheme->tv3d.button,  0.45, 0.45, 0.45, 0.5);
712 //      rgba_char_args_set(btheme->tv3d.panel,      165, 165, 165, 127);
713         
714         rgba_char_args_set(btheme->tv3d.shade1,  160, 160, 160, 100);
715         rgba_char_args_set(btheme->tv3d.shade2,  0x7f, 0x70, 0x70, 100);
716
717         rgba_char_args_set_fl(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
718         rgba_char_args_set(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
719         rgba_char_args_set(btheme->tv3d.lamp,       0, 0, 0, 40);
720         rgba_char_args_set(btheme->tv3d.speaker,    0, 0, 0, 255);
721         rgba_char_args_set(btheme->tv3d.camera,    0, 0, 0, 255);
722         rgba_char_args_set(btheme->tv3d.empty,    0, 0, 0, 255);
723         rgba_char_args_set(btheme->tv3d.select, 241, 88, 0, 255);
724         rgba_char_args_set(btheme->tv3d.active, 255, 170, 64, 255);
725         rgba_char_args_set(btheme->tv3d.group,      8, 48, 8, 255);
726         rgba_char_args_set(btheme->tv3d.group_active, 85, 187, 85, 255);
727         rgba_char_args_set(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
728         rgba_char_args_set(btheme->tv3d.vertex, 0, 0, 0, 255);
729         rgba_char_args_set(btheme->tv3d.vertex_select, 255, 133, 0, 255);
730         btheme->tv3d.vertex_size = 3;
731         btheme->tv3d.outline_width = 1;
732         rgba_char_args_set(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
733         rgba_char_args_set(btheme->tv3d.edge_select, 255, 160, 0, 255);
734         rgba_char_args_set(btheme->tv3d.edge_seam, 219, 37, 18, 255);
735         rgba_char_args_set(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
736         rgba_char_args_set(btheme->tv3d.face,       0, 0, 0, 18);
737         rgba_char_args_set(btheme->tv3d.face_select, 255, 133, 0, 60);
738         rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
739         rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
740         rgba_char_args_set(btheme->tv3d.face_dot, 255, 133, 0, 255);
741         rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
742         rgba_char_args_set_fl(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
743         rgba_char_args_set(btheme->tv3d.edge_sharp, 0, 255, 255, 255);
744         rgba_char_args_set(btheme->tv3d.header_text, 0, 0, 0, 255);
745         rgba_char_args_set(btheme->tv3d.header_text_hi, 255, 255, 255, 255);
746         rgba_char_args_set(btheme->tv3d.button_text, 0, 0, 0, 255);
747         rgba_char_args_set(btheme->tv3d.button_text_hi, 255, 255, 255, 255);
748         rgba_char_args_set(btheme->tv3d.button_title, 0, 0, 0, 255);
749         rgba_char_args_set(btheme->tv3d.title, 0, 0, 0, 255);
750
751         btheme->tv3d.facedot_size = 4;
752
753         rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
754         rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
755         rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
756
757         rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0,  0x40, 255);
758
759         rgba_char_args_set(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
760         rgba_char_args_set(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
761         rgba_char_args_set(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255);
762         rgba_char_args_set(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255);
763
764         rgba_char_args_set(btheme->tv3d.handle_free, 0, 0, 0, 255);
765         rgba_char_args_set(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
766         rgba_char_args_set(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
767         rgba_char_args_set(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
768         rgba_char_args_set(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
769         rgba_char_args_set(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
770         rgba_char_args_set(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
771         rgba_char_args_set(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
772
773         rgba_char_args_set(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
774         rgba_char_args_set(btheme->tv3d.lastsel_point,  0xff, 0xff, 0xff, 255);
775
776         rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255);
777         /* alpha 80 is not meant editable, used for wire+action draw */
778         rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80);
779         rgba_char_args_set(btheme->tv3d.bone_pose_active, 140, 255, 255, 80);
780
781         rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
782         rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
783
784         rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
785         rgba_char_args_set(btheme->tv3d.gradients.gradient, 0, 0, 0, 0);
786         rgba_char_args_set(btheme->tv3d.gradients.high_gradient, 0.225, 0.225, 0.225, 1.0);
787         btheme->tv3d.gradients.show_grad = FALSE;
788
789         /* space buttons */
790         /* to have something initialized */
791         btheme->tbuts = btheme->tv3d;
792
793         rgba_char_args_set_fl(btheme->tbuts.back,   0.45, 0.45, 0.45, 1.0);
794 //      rgba_char_args_set(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255);
795
796         /* graph editor */
797         btheme->tipo = btheme->tv3d;
798         rgba_char_args_set_fl(btheme->tipo.back,    0.42, 0.42, 0.42, 1.0);
799         rgba_char_args_set_fl(btheme->tipo.list,    0.4, 0.4, 0.4, 1.0);
800         rgba_char_args_set(btheme->tipo.grid,   94, 94, 94, 255);
801 //      rgba_char_args_set(btheme->tipo.panel,  255, 255, 255, 150);
802         rgba_char_args_set(btheme->tipo.shade1,     150, 150, 150, 100);    /* scrollbars */
803         rgba_char_args_set(btheme->tipo.shade2,     0x70, 0x70, 0x70, 100);
804         rgba_char_args_set(btheme->tipo.vertex,     0, 0, 0, 255);
805         rgba_char_args_set(btheme->tipo.vertex_select, 255, 133, 0, 255);
806         rgba_char_args_set(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255);
807         btheme->tipo.vertex_size = 3;
808
809         rgba_char_args_set(btheme->tipo.handle_vertex,      0, 0, 0, 255);
810         rgba_char_args_set(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
811         rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
812         rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
813         btheme->tipo.handle_vertex_size = 4;
814         
815         rgba_char_args_set(btheme->tipo.ds_channel,      82, 96, 110, 255);
816         rgba_char_args_set(btheme->tipo.ds_subchannel,  124, 137, 150, 255);
817         rgba_char_args_set(btheme->tipo.group,           79, 101, 73, 255);
818         rgba_char_args_set(btheme->tipo.group_active,   135, 177, 125, 255);
819
820         /* dopesheet */
821         btheme->tact = btheme->tipo;
822         rgba_char_args_set(btheme->tact.strip,          12, 10, 10, 128);
823         rgba_char_args_set(btheme->tact.strip_select,   255, 140, 0, 255);
824         
825         rgba_char_args_set(btheme->tact.anim_active,    204, 112, 26, 102);
826         
827         /* space nla */
828         btheme->tnla = btheme->tact;
829         
830         rgba_char_args_set(btheme->tnla.anim_active,     204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */
831         rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
832         
833         rgba_char_args_set(btheme->tnla.nla_tweaking,   77, 243, 26, 77);
834         rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
835         
836         rgba_char_args_set(btheme->tnla.nla_transition,     28, 38, 48, 255);
837         rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
838         rgba_char_args_set(btheme->tnla.nla_meta,           51, 38, 66, 255);
839         rgba_char_args_set(btheme->tnla.nla_meta_sel,       105, 33, 150, 255);
840         rgba_char_args_set(btheme->tnla.nla_sound,          43, 61, 61, 255);
841         rgba_char_args_set(btheme->tnla.nla_sound_sel,      31, 122, 122, 255);
842         
843         /* space file */
844         /* to have something initialized */
845         btheme->tfile = btheme->tv3d;
846         rgba_char_args_set_fl(btheme->tfile.back, 0.3, 0.3, 0.3, 1);
847 //      rgba_char_args_set_fl(btheme->tfile.panel, 0.3, 0.3, 0.3, 1);
848         rgba_char_args_set_fl(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
849         rgba_char_args_set(btheme->tfile.text,  250, 250, 250, 255);
850         rgba_char_args_set(btheme->tfile.text_hi, 15, 15, 15, 255);
851 //      rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255);  /* bookmark/ui regions */
852         rgba_char_args_set(btheme->tfile.active, 130, 130, 130, 255); /* selected files */
853         rgba_char_args_set(btheme->tfile.hilite, 255, 140, 25, 255);  /* selected files */
854         
855         rgba_char_args_set(btheme->tfile.grid,  250, 250, 250, 255);
856         rgba_char_args_set(btheme->tfile.image, 250, 250, 250, 255);
857         rgba_char_args_set(btheme->tfile.movie, 250, 250, 250, 255);
858         rgba_char_args_set(btheme->tfile.scene, 250, 250, 250, 255);
859
860         
861         /* space seq */
862         btheme->tseq = btheme->tv3d;
863         rgba_char_args_set(btheme->tseq.back,   116, 116, 116, 255);
864         rgba_char_args_set(btheme->tseq.movie,  81, 105, 135, 255);
865         rgba_char_args_set(btheme->tseq.movieclip,  32, 32, 143, 255);
866         rgba_char_args_set(btheme->tseq.mask,   152, 78, 62, 255);
867         rgba_char_args_set(btheme->tseq.image,  109, 88, 129, 255);
868         rgba_char_args_set(btheme->tseq.scene,  78, 152, 62, 255);
869         rgba_char_args_set(btheme->tseq.audio,  46, 143, 143, 255);
870         rgba_char_args_set(btheme->tseq.effect,     169, 84, 124, 255);
871         rgba_char_args_set(btheme->tseq.transition, 162, 95, 111, 255);
872         rgba_char_args_set(btheme->tseq.meta,   109, 145, 131, 255);
873         rgba_char_args_set(btheme->tseq.preview_back,   0, 0, 0, 255);
874
875         /* space image */
876         btheme->tima = btheme->tv3d;
877         rgba_char_args_set(btheme->tima.back,   53, 53, 53, 255);
878         rgba_char_args_set(btheme->tima.vertex, 0, 0, 0, 255);
879         rgba_char_args_set(btheme->tima.vertex_select, 255, 133, 0, 255);
880         btheme->tima.vertex_size = 3;
881         btheme->tima.facedot_size = 3;
882         rgba_char_args_set(btheme->tima.face,   255, 255, 255, 10);
883         rgba_char_args_set(btheme->tima.face_select, 255, 133, 0, 60);
884         rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128);
885         rgba_char_args_set_fl(btheme->tima.preview_back,    0.45, 0.45, 0.45, 1.0);
886         rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.5, 0.5, 0.0, 0.2);
887         rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.0, 1.0, 0.2);
888         rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 0.0, 0.0, 1.0, 0.2);
889         rgba_char_args_set_fl(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0);
890         rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0);
891         rgba_char_args_set_fl(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140);
892
893         /* space text */
894         btheme->text = btheme->tv3d;
895         rgba_char_args_set(btheme->text.back,   153, 153, 153, 255);
896         rgba_char_args_set(btheme->text.shade1,     143, 143, 143, 255);
897         rgba_char_args_set(btheme->text.shade2,     0xc6, 0x77, 0x77, 255);
898         rgba_char_args_set(btheme->text.hilite,     255, 0, 0, 255);
899         
900         /* syntax highlighting */
901         rgba_char_args_set(btheme->text.syntaxn,    0, 0, 200, 255);    /* Numbers  Blue*/
902         rgba_char_args_set(btheme->text.syntaxl,    100, 0, 0, 255);    /* Strings  Red */
903         rgba_char_args_set(btheme->text.syntaxc,    0, 100, 50, 255);   /* Comments  Greenish */
904         rgba_char_args_set(btheme->text.syntaxv,    95, 95, 0, 255);    /* Special  Yellow*/
905         rgba_char_args_set(btheme->text.syntaxd,    50, 0, 140, 255);   /* Decorator/Preprocessor Dir.  Blue-purple */
906         rgba_char_args_set(btheme->text.syntaxr,    140, 60, 0, 255);   /* Reserved  Orange*/
907         rgba_char_args_set(btheme->text.syntaxb,    128, 0, 80, 255);   /* Builtin  Red-purple */
908         rgba_char_args_set(btheme->text.syntaxs,    76, 76, 76, 255);   /* Grey (mix between fg/bg) */
909         
910         /* space oops */
911         btheme->toops = btheme->tv3d;
912         rgba_char_args_set_fl(btheme->toops.back,   0.45, 0.45, 0.45, 1.0);
913         
914         rgba_char_args_set_fl(btheme->toops.match,  0.2, 0.5, 0.2, 0.3);    /* highlighting search match - soft green*/
915         rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
916
917         /* space info */
918         btheme->tinfo = btheme->tv3d;
919         rgba_char_args_set_fl(btheme->tinfo.back,   0.45, 0.45, 0.45, 1.0);
920
921         /* space user preferences */
922         btheme->tuserpref = btheme->tv3d;
923         rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
924         
925         /* space console */
926         btheme->tconsole = btheme->tv3d;
927         rgba_char_args_set(btheme->tconsole.back, 0, 0, 0, 255);
928         rgba_char_args_set(btheme->tconsole.console_output, 96, 128, 255, 255);
929         rgba_char_args_set(btheme->tconsole.console_input, 255, 255, 255, 255);
930         rgba_char_args_set(btheme->tconsole.console_info, 0, 170, 0, 255);
931         rgba_char_args_set(btheme->tconsole.console_error, 220, 96, 96, 255);
932         rgba_char_args_set(btheme->tconsole.console_cursor, 220, 96, 96, 255);
933         
934         /* space time */
935         btheme->ttime = btheme->tv3d;
936         rgba_char_args_set_fl(btheme->ttime.back,   0.45, 0.45, 0.45, 1.0);
937         rgba_char_args_set_fl(btheme->ttime.grid,   0.36, 0.36, 0.36, 1.0);
938         rgba_char_args_set(btheme->ttime.shade1,  173, 173, 173, 255);      /* sliders */
939         
940         /* space node, re-uses syntax color storage */
941         btheme->tnode = btheme->tv3d;
942         rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255);      /* wire selected */
943         rgba_char_args_set(btheme->tnode.syntaxl, 155, 155, 155, 160);  /* TH_NODE, backdrop */
944         rgba_char_args_set(btheme->tnode.syntaxn, 100, 100, 100, 255);  /* in/output */
945         rgba_char_args_set(btheme->tnode.syntaxb, 108, 105, 111, 255);  /* operator */
946         rgba_char_args_set(btheme->tnode.syntaxv, 104, 106, 117, 255);  /* generator */
947         rgba_char_args_set(btheme->tnode.syntaxc, 105, 117, 110, 255);  /* group */
948         rgba_char_args_set(btheme->tnode.movie, 155, 155, 155, 160);  /* frame */
949         btheme->tnode.noodle_curving = 5;
950
951         /* space logic */
952         btheme->tlogic = btheme->tv3d;
953         rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
954         
955         /* space clip */
956         btheme->tclip = btheme->tv3d;
957
958         rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
959         rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
960         rgba_char_args_set(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
961         rgba_char_args_set(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
962         rgba_char_args_set(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
963         rgba_char_args_set(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
964         rgba_char_args_set(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
965         rgba_char_args_set(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
966         rgba_char_args_set(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
967         rgba_char_args_set(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
968         rgba_char_args_set(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
969         rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
970         rgba_char_args_set(btheme->tclip.list, 0x66, 0x66, 0x66, 0xff);
971         rgba_char_args_set(btheme->tclip.strip, 0x0c, 0x0a, 0x0a, 0x80);
972         rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff);
973         btheme->tclip.handle_vertex_size = 4;
974 }
975
976
977 void UI_SetTheme(int spacetype, int regionid)
978 {
979         if (spacetype == 0) {  /* called for safety, when delete themes */
980                 theme_active = U.themes.first;
981                 theme_spacetype = SPACE_VIEW3D;
982                 theme_regionid = RGN_TYPE_WINDOW;
983         }
984         else {
985                 /* later on, a local theme can be found too */
986                 theme_active = U.themes.first;
987                 theme_spacetype = spacetype;
988                 theme_regionid = regionid;
989         }
990 }
991
992 bTheme *UI_GetTheme(void)
993 {
994         return U.themes.first;
995 }
996
997 /* for space windows only */
998 void UI_ThemeColor(int colorid)
999 {
1000         const unsigned char *cp;
1001         
1002         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1003         glColor3ubv(cp);
1004
1005 }
1006
1007 /* plus alpha */
1008 void UI_ThemeColor4(int colorid)
1009 {
1010         const unsigned char *cp;
1011         
1012         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1013         glColor4ubv(cp);
1014
1015 }
1016
1017 /* set the color with offset for shades */
1018 void UI_ThemeColorShade(int colorid, int offset)
1019 {
1020         int r, g, b;
1021         const unsigned char *cp;
1022         
1023         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1024         r = offset + (int) cp[0];
1025         CLAMP(r, 0, 255);
1026         g = offset + (int) cp[1];
1027         CLAMP(g, 0, 255);
1028         b = offset + (int) cp[2];
1029         CLAMP(b, 0, 255);
1030         //glColor3ub(r, g, b);
1031         glColor4ub(r, g, b, cp[3]);
1032 }
1033 void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
1034 {
1035         int r, g, b, a;
1036         const unsigned char *cp;
1037         
1038         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1039         r = coloffset + (int) cp[0];
1040         CLAMP(r, 0, 255);
1041         g = coloffset + (int) cp[1];
1042         CLAMP(g, 0, 255);
1043         b = coloffset + (int) cp[2];
1044         CLAMP(b, 0, 255);
1045         a = alphaoffset + (int) cp[3];
1046         CLAMP(a, 0, 255);
1047         glColor4ub(r, g, b, a);
1048 }
1049
1050 /* blend between to theme colors, and set it */
1051 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
1052 {
1053         int r, g, b;
1054         const unsigned char *cp1, *cp2;
1055         
1056         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
1057         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
1058
1059         CLAMP(fac, 0.0f, 1.0f);
1060         r = floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1061         g = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1062         b = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1063         
1064         glColor3ub(r, g, b);
1065 }
1066
1067 /* blend between to theme colors, shade it, and set it */
1068 void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
1069 {
1070         int r, g, b;
1071         const unsigned char *cp1, *cp2;
1072         
1073         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
1074         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
1075
1076         CLAMP(fac, 0.0f, 1.0f);
1077         r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1078         g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1079         b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1080         
1081         CLAMP(r, 0, 255);
1082         CLAMP(g, 0, 255);
1083         CLAMP(b, 0, 255);
1084         
1085         glColor3ub(r, g, b);
1086 }
1087
1088 /* blend between to theme colors, shade it, and set it */
1089 void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
1090 {
1091         int r, g, b, a;
1092         const unsigned char *cp1, *cp2;
1093         
1094         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
1095         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
1096
1097         CLAMP(fac, 0.0f, 1.0f);
1098         r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1099         g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1100         b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1101         a = alphaoffset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
1102         
1103         CLAMP(r, 0, 255);
1104         CLAMP(g, 0, 255);
1105         CLAMP(b, 0, 255);
1106         CLAMP(a, 0, 255);
1107
1108         glColor4ub(r, g, b, a);
1109 }
1110
1111
1112 /* get individual values, not scaled */
1113 float UI_GetThemeValuef(int colorid)
1114 {
1115         const unsigned char *cp;
1116         
1117         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1118         return ((float)cp[0]);
1119 }
1120
1121 /* get individual values, not scaled */
1122 int UI_GetThemeValue(int colorid)
1123 {
1124         const unsigned char *cp;
1125         
1126         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1127         return ((int) cp[0]);
1128 }
1129
1130
1131 /* get the color, range 0.0-1.0 */
1132 void UI_GetThemeColor3fv(int colorid, float col[3])
1133 {
1134         const unsigned char *cp;
1135         
1136         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1137         col[0] = ((float)cp[0]) / 255.0f;
1138         col[1] = ((float)cp[1]) / 255.0f;
1139         col[2] = ((float)cp[2]) / 255.0f;
1140 }
1141
1142 void UI_GetThemeColor4fv(int colorid, float col[4])
1143 {
1144         const unsigned char *cp;
1145         
1146         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1147         col[0] = ((float)cp[0]) / 255.0f;
1148         col[1] = ((float)cp[1]) / 255.0f;
1149         col[2] = ((float)cp[2]) / 255.0f;
1150         col[3] = ((float)cp[3]) / 255.0f;
1151 }
1152
1153 /* get the color, range 0.0-1.0, complete with shading offset */
1154 void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
1155 {
1156         int r, g, b;
1157         const unsigned char *cp;
1158         
1159         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1160         
1161         r = offset + (int) cp[0];
1162         CLAMP(r, 0, 255);
1163         g = offset + (int) cp[1];
1164         CLAMP(g, 0, 255);
1165         b = offset + (int) cp[2];
1166         CLAMP(b, 0, 255);
1167         
1168         col[0] = ((float)r) / 255.0f;
1169         col[1] = ((float)g) / 255.0f;
1170         col[2] = ((float)b) / 255.0f;
1171 }
1172
1173 void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3])
1174 {
1175         int r, g, b;
1176         const unsigned char *cp;
1177
1178         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1179
1180         r = offset + (int) cp[0];
1181         CLAMP(r, 0, 255);
1182         g = offset + (int) cp[1];
1183         CLAMP(g, 0, 255);
1184         b = offset + (int) cp[2];
1185         CLAMP(b, 0, 255);
1186
1187         col[0] = r;
1188         col[1] = g;
1189         col[2] = b;
1190 }
1191
1192 /* get the color, in char pointer */
1193 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
1194 {
1195         const unsigned char *cp;
1196         
1197         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1198         col[0] = cp[0];
1199         col[1] = cp[1];
1200         col[2] = cp[2];
1201 }
1202
1203 /* get the color, in char pointer */
1204 void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
1205 {
1206         const unsigned char *cp;
1207         
1208         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1209         col[0] = cp[0];
1210         col[1] = cp[1];
1211         col[2] = cp[2];
1212         col[3] = cp[3];
1213 }
1214
1215 void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
1216 {
1217         const unsigned char *cp;
1218         
1219         cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
1220         col[0] = cp[0];
1221         col[1] = cp[1];
1222         col[2] = cp[2];
1223         col[3] = cp[3];
1224 }
1225
1226 /* blends and shades between two char color pointers */
1227 void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
1228 {
1229         int r, g, b;
1230         CLAMP(fac, 0.0f, 1.0f);
1231         r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1232         g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1233         b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1234
1235         r = r < 0 ? 0 : (r > 255 ? 255 : r);
1236         g = g < 0 ? 0 : (g > 255 ? 255 : g);
1237         b = b < 0 ? 0 : (b > 255 ? 255 : b);
1238         
1239         glColor3ub(r, g, b);
1240 }
1241
1242 void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], int offset)
1243 {
1244         int r, g, b;
1245
1246         r = offset + (int)cp[0];
1247         g = offset + (int)cp[1];
1248         b = offset + (int)cp[2];
1249
1250         CLAMP(r, 0, 255);
1251         CLAMP(g, 0, 255);
1252         CLAMP(b, 0, 255);
1253
1254         col[0] = r;
1255         col[1] = g;
1256         col[2] = b;
1257 }
1258
1259 /* get a 3 byte color, blended and shaded between two other char color pointers */
1260 void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3],
1261                                   float fac, int offset)
1262 {
1263         int r, g, b;
1264
1265         CLAMP(fac, 0.0f, 1.0f);
1266         r = offset + floor((1.0f - fac) * cp1[0] + fac * cp2[0]);
1267         g = offset + floor((1.0f - fac) * cp1[1] + fac * cp2[1]);
1268         b = offset + floor((1.0f - fac) * cp1[2] + fac * cp2[2]);
1269
1270         CLAMP(r, 0, 255);
1271         CLAMP(g, 0, 255);
1272         CLAMP(b, 0, 255);
1273
1274         col[0] = r;
1275         col[1] = g;
1276         col[2] = b;
1277 }
1278
1279 void UI_ThemeClearColor(int colorid)
1280 {
1281         float col[3];
1282         
1283         UI_GetThemeColor3fv(colorid, col);
1284         glClearColor(col[0], col[1], col[2], 0.0);
1285 }
1286
1287 int UI_ThemeMenuShadowWidth(void)
1288 {
1289         bTheme *btheme = UI_GetTheme();
1290         return (int)(btheme->tui.menu_shadow_width * UI_DPI_FAC);
1291 }
1292
1293 void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
1294 {
1295         unsigned char col[3];
1296         
1297         switch (axis) {
1298                 case 'X':
1299                         UI_GetThemeColor3ubv(TH_AXIS_X, col);
1300                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1301                         break;
1302                 case 'Y':
1303                         UI_GetThemeColor3ubv(TH_AXIS_Y, col);
1304                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1305                         break;
1306                 case 'Z':
1307                         UI_GetThemeColor3ubv(TH_AXIS_Z, col);
1308                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1309                         break;
1310                 default:
1311                         BLI_assert(!"invalid axis arg");
1312         }
1313 }
1314
1315 /* ************************************************************* */
1316
1317 /* patching UserDef struct and Themes */
1318 void init_userdef_do_versions(void)
1319 {
1320         Main *bmain = G.main;
1321 //      countall();
1322         
1323         /* the UserDef struct is not corrected with do_versions() .... ugh! */
1324         if (U.wheellinescroll == 0) U.wheellinescroll = 3;
1325         if (U.menuthreshold1 == 0) {
1326                 U.menuthreshold1 = 5;
1327                 U.menuthreshold2 = 2;
1328         }
1329         if (U.tb_leftmouse == 0) {
1330                 U.tb_leftmouse = 5;
1331                 U.tb_rightmouse = 5;
1332         }
1333         if (U.mixbufsize == 0) U.mixbufsize = 2048;
1334         if (strcmp(U.tempdir, "/") == 0) {
1335                 BLI_system_temporary_dir(U.tempdir);
1336         }
1337         if (U.autokey_mode == 0) {
1338                 /* 'add/replace' but not on */
1339                 U.autokey_mode = 2;
1340         }
1341         if (U.savetime <= 0) {
1342                 U.savetime = 1;
1343 // XXX          error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
1344         }
1345         /* transform widget settings */
1346         if (U.tw_hotspot == 0) {
1347                 U.tw_hotspot = 14;
1348                 U.tw_size = 20;          /* percentage of window size */
1349                 U.tw_handlesize = 16;    /* percentage of widget radius */
1350         }
1351         if (U.pad_rot_angle == 0)
1352                 U.pad_rot_angle = 15;
1353         /* graph editor - unselected F-Curve visibility */
1354         if (U.fcu_inactive_alpha == 0) {
1355                 U.fcu_inactive_alpha = 0.25f;
1356         }
1357         
1358         /* signal for derivedmesh to use colorband */
1359         /* run in case this was on and is now off in the user prefs [#28096] */
1360         vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL);
1361
1362         if (bmain->versionfile <= 191) {
1363                 strcpy(U.sounddir, "/");
1364         }
1365         
1366         /* patch to set Dupli Armature */
1367         if (bmain->versionfile < 220) {
1368                 U.dupflag |= USER_DUP_ARM;
1369         }
1370         
1371         /* added seam, normal color, undo */
1372         if (bmain->versionfile <= 234) {
1373                 bTheme *btheme;
1374                 
1375                 U.uiflag |= USER_GLOBALUNDO;
1376                 if (U.undosteps == 0) U.undosteps = 32;
1377                 
1378                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1379                         /* check for (alpha == 0) is safe, then color was never set */
1380                         if (btheme->tv3d.edge_seam[3] == 0) {
1381                                 rgba_char_args_set(btheme->tv3d.edge_seam, 230, 150, 50, 255);
1382                         }
1383                         if (btheme->tv3d.normal[3] == 0) {
1384                                 rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
1385                         }
1386                         if (btheme->tv3d.vertex_normal[3] == 0) {
1387                                 rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
1388                         }
1389                         if (btheme->tv3d.face_dot[3] == 0) {
1390                                 rgba_char_args_set(btheme->tv3d.face_dot, 255, 138, 48, 255);
1391                                 btheme->tv3d.facedot_size = 4;
1392                         }
1393                 }
1394         }
1395         if (bmain->versionfile <= 235) {
1396                 /* illegal combo... */
1397                 if (U.flag & USER_LMOUSESELECT) 
1398                         U.flag &= ~USER_TWOBUTTONMOUSE;
1399         }
1400         if (bmain->versionfile <= 236) {
1401                 bTheme *btheme;
1402                 /* new space type */
1403                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1404                         /* check for (alpha == 0) is safe, then color was never set */
1405                         if (btheme->ttime.back[3] == 0) {
1406                                 /* copied from ui_theme_init_default */
1407                                 btheme->ttime = btheme->tv3d;
1408                                 rgba_char_args_set_fl(btheme->ttime.back,   0.45, 0.45, 0.45, 1.0);
1409                                 rgba_char_args_set_fl(btheme->ttime.grid,   0.36, 0.36, 0.36, 1.0);
1410                                 rgba_char_args_set(btheme->ttime.shade1,  173, 173, 173, 255);  /* sliders */
1411                         }
1412                         if (btheme->text.syntaxn[3] == 0) {
1413                                 rgba_char_args_set(btheme->text.syntaxn,    0, 0, 200, 255);    /* Numbers  Blue*/
1414                                 rgba_char_args_set(btheme->text.syntaxl,    100, 0, 0, 255);    /* Strings  red */
1415                                 rgba_char_args_set(btheme->text.syntaxc,    0, 100, 50, 255);   /* Comments greenish */
1416                                 rgba_char_args_set(btheme->text.syntaxv,    95, 95, 0, 255);    /* Special */
1417                                 rgba_char_args_set(btheme->text.syntaxb,    128, 0, 80, 255);   /* Builtin, red-purple */
1418                         }
1419                 }
1420         }
1421         if (bmain->versionfile <= 237) {
1422                 bTheme *btheme;
1423                 /* bone colors */
1424                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1425                         /* check for alpha==0 is safe, then color was never set */
1426                         if (btheme->tv3d.bone_solid[3] == 0) {
1427                                 rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255);
1428                                 rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80);
1429                         }
1430                 }
1431         }
1432         if (bmain->versionfile <= 238) {
1433                 bTheme *btheme;
1434                 /* bone colors */
1435                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1436                         /* check for alpha==0 is safe, then color was never set */
1437                         if (btheme->tnla.strip[3] == 0) {
1438                                 rgba_char_args_set(btheme->tnla.strip_select,   0xff, 0xff, 0xaa, 255);
1439                                 rgba_char_args_set(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
1440                         }
1441                 }
1442         }
1443         if (bmain->versionfile <= 239) {
1444                 bTheme *btheme;
1445                 
1446                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1447                         /* Lamp theme, check for alpha==0 is safe, then color was never set */
1448                         if (btheme->tv3d.lamp[3] == 0) {
1449                                 rgba_char_args_set(btheme->tv3d.lamp,   0, 0, 0, 40);
1450 /* TEMPORAL, remove me! (ton) */                                
1451                                 U.uiflag |= USER_PLAINMENUS;
1452                         }
1453                         
1454                 }
1455                 if (U.obcenter_dia == 0) U.obcenter_dia = 6;
1456         }
1457         if (bmain->versionfile <= 241) {
1458                 bTheme *btheme;
1459                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1460                         /* Node editor theme, check for alpha==0 is safe, then color was never set */
1461                         if (btheme->tnode.syntaxn[3] == 0) {
1462                                 /* re-uses syntax color storage */
1463                                 btheme->tnode = btheme->tv3d;
1464                                 rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255);
1465                                 rgba_char_args_set(btheme->tnode.syntaxl, 150, 150, 150, 255);  /* TH_NODE, backdrop */
1466                                 rgba_char_args_set(btheme->tnode.syntaxn, 129, 131, 144, 255);  /* in/output */
1467                                 rgba_char_args_set(btheme->tnode.syntaxb, 127, 127, 127, 255);  /* operator */
1468                                 rgba_char_args_set(btheme->tnode.syntaxv, 142, 138, 145, 255);  /* generator */
1469                                 rgba_char_args_set(btheme->tnode.syntaxc, 120, 145, 120, 255);  /* group */
1470                         }
1471                         /* Group theme colors */
1472                         if (btheme->tv3d.group[3] == 0) {
1473                                 rgba_char_args_set(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255);
1474                                 rgba_char_args_set(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
1475                         }
1476                         /* Sequence editor theme*/
1477                         if (btheme->tseq.movie[3] == 0) {
1478                                 rgba_char_args_set(btheme->tseq.movie,  81, 105, 135, 255);
1479                                 rgba_char_args_set(btheme->tseq.image,  109, 88, 129, 255);
1480                                 rgba_char_args_set(btheme->tseq.scene,  78, 152, 62, 255);
1481                                 rgba_char_args_set(btheme->tseq.audio,  46, 143, 143, 255);
1482                                 rgba_char_args_set(btheme->tseq.effect,     169, 84, 124, 255);
1483                                 rgba_char_args_set(btheme->tseq.transition, 162, 95, 111, 255);
1484                                 rgba_char_args_set(btheme->tseq.meta,   109, 145, 131, 255);
1485                         }
1486                 }
1487                 
1488                 /* set defaults for 3D View rotating axis indicator */ 
1489                 /* since size can't be set to 0, this indicates it's not saved in startup.blend */
1490                 if (U.rvisize == 0) {
1491                         U.rvisize = 15;
1492                         U.rvibright = 8;
1493                         U.uiflag |= USER_SHOW_ROTVIEWICON;
1494                 }
1495                 
1496         }
1497         if (bmain->versionfile <= 242) {
1498                 bTheme *btheme;
1499                 
1500                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1501                         /* long keyframe color */
1502                         /* check for alpha==0 is safe, then color was never set */
1503                         if (btheme->tact.strip[3] == 0) {
1504                                 rgba_char_args_set(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
1505                                 rgba_char_args_set(btheme->tact.strip_select,   0xff, 0xff, 0xaa, 204);
1506                                 rgba_char_args_set(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
1507                         }
1508                         
1509                         /* IPO-Editor - Vertex Size*/
1510                         if (btheme->tipo.vertex_size == 0) {
1511                                 btheme->tipo.vertex_size = 3;
1512                         }
1513                 }
1514         }
1515         if (bmain->versionfile <= 243) {
1516                 /* set default number of recently-used files (if not set) */
1517                 if (U.recent_files == 0) U.recent_files = 10;
1518         }
1519         if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
1520                 bTheme *btheme;
1521                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1522                         rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
1523                 }
1524                 if (U.coba_weight.tot == 0)
1525                         init_colorband(&U.coba_weight, 1);
1526         }
1527         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
1528                 bTheme *btheme;
1529                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1530                         /* these should all use the same color */
1531                         rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
1532                         rgba_char_args_set(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
1533                         rgba_char_args_set(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
1534                         rgba_char_args_set(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
1535                         rgba_char_args_set(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
1536                         //rgba_char_args_set(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); Not needed anymore
1537                         rgba_char_args_set(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
1538                 }
1539         }
1540         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
1541                 bTheme *btheme;
1542                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1543                         /* action channel groups (recolor anyway) */
1544                         rgba_char_args_set(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
1545                         rgba_char_args_set(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
1546                         
1547                         /* bone custom-color sets */
1548                         if (btheme->tarm[0].solid[3] == 0)
1549                                 ui_theme_init_boneColorSets(btheme);
1550                 }
1551         }
1552         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
1553                 U.flag |= USER_ADD_VIEWALIGNED | USER_ADD_EDITMODE;
1554         }
1555         if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
1556                 bTheme *btheme;
1557                 
1558                 /* adjust themes */
1559                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1560                         char *col;
1561                         
1562                         /* IPO Editor: Handles/Vertices */
1563                         col = btheme->tipo.vertex;
1564                         rgba_char_args_set(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
1565                         col = btheme->tipo.vertex_select;
1566                         rgba_char_args_set(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
1567                         btheme->tipo.handle_vertex_size = btheme->tipo.vertex_size;
1568                         
1569                         /* Sequence/Image Editor: colors for GPencil text */
1570                         col = btheme->tv3d.bone_pose;
1571                         rgba_char_args_set(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
1572                         rgba_char_args_set(btheme->tima.bone_pose, col[0], col[1], col[2], 255);
1573                         col = btheme->tv3d.vertex_select;
1574                         rgba_char_args_set(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
1575                 }
1576         }
1577         if (bmain->versionfile < 250) {
1578                 bTheme *btheme;
1579                 
1580                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1581                         /* this was not properly initialized in 2.45 */
1582                         if (btheme->tima.face_dot[3] == 0) {
1583                                 rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128);
1584                                 rgba_char_args_set(btheme->tima.face_dot, 255, 133, 0, 255);
1585                                 btheme->tima.facedot_size = 2;
1586                         }
1587                         
1588                         /* DopeSheet - (Object) Channel color */
1589                         rgba_char_args_set(btheme->tact.ds_channel,     82, 96, 110, 255);
1590                         rgba_char_args_set(btheme->tact.ds_subchannel,  124, 137, 150, 255);
1591                         /* DopeSheet - Group Channel color (saner version) */
1592                         rgba_char_args_set(btheme->tact.group, 79, 101, 73, 255);
1593                         rgba_char_args_set(btheme->tact.group_active, 135, 177, 125, 255);
1594                         
1595                         /* Graph Editor - (Object) Channel color */
1596                         rgba_char_args_set(btheme->tipo.ds_channel,     82, 96, 110, 255);
1597                         rgba_char_args_set(btheme->tipo.ds_subchannel,  124, 137, 150, 255);
1598                         /* Graph Editor - Group Channel color */
1599                         rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255);
1600                         rgba_char_args_set(btheme->tipo.group_active, 135, 177, 125, 255);
1601                         
1602                         /* Nla Editor - (Object) Channel color */
1603                         rgba_char_args_set(btheme->tnla.ds_channel,     82, 96, 110, 255);
1604                         rgba_char_args_set(btheme->tnla.ds_subchannel,  124, 137, 150, 255);
1605                         /* NLA Editor - New Strip colors */
1606                         rgba_char_args_set(btheme->tnla.strip,          12, 10, 10, 128);
1607                         rgba_char_args_set(btheme->tnla.strip_select,   255, 140, 0, 255);
1608                 }
1609                 
1610                 /* adjust grease-pencil distances */
1611                 U.gp_manhattendist = 1;
1612                 U.gp_euclideandist = 2;
1613                 
1614                 /* adjust default interpolation for new IPO-curves */
1615                 U.ipo_new = BEZT_IPO_BEZ;
1616         }
1617         
1618         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
1619                 bTheme *btheme;
1620
1621                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1622                         
1623                         /* common (new) variables, it checks for alpha==0 */
1624                         ui_theme_init_new(btheme);
1625
1626                         if (btheme->tui.wcol_num.outline[3] == 0)
1627                                 ui_widget_color_init(&btheme->tui);
1628                         
1629                         /* Logic editor theme, check for alpha==0 is safe, then color was never set */
1630                         if (btheme->tlogic.syntaxn[3] == 0) {
1631                                 /* re-uses syntax color storage */
1632                                 btheme->tlogic = btheme->tv3d;
1633                                 rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
1634                         }
1635
1636                         rgba_char_args_set_fl(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
1637                         rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
1638                 }
1639         }
1640
1641         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
1642                 /* new audio system */
1643                 if (U.audiochannels == 0)
1644                         U.audiochannels = 2;
1645                 if (U.audiodevice == 0) {
1646 #ifdef WITH_OPENAL
1647                         U.audiodevice = 2;
1648 #endif
1649 #ifdef WITH_SDL
1650                         U.audiodevice = 1;
1651 #endif
1652                 }
1653                 if (U.audioformat == 0)
1654                         U.audioformat = 0x24;
1655                 if (U.audiorate == 0)
1656                         U.audiorate = 44100;
1657         }
1658
1659         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
1660                 U.gameflags |= USER_DISABLE_VBO;
1661         
1662         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
1663                 wmKeyMap *km;
1664                 
1665                 for (km = U.user_keymaps.first; km; km = km->next) {
1666                         if (strcmp(km->idname, "Armature_Sketch") == 0)
1667                                 strcpy(km->idname, "Armature Sketch");
1668                         else if (strcmp(km->idname, "View3D") == 0)
1669                                 strcpy(km->idname, "3D View");
1670                         else if (strcmp(km->idname, "View3D Generic") == 0)
1671                                 strcpy(km->idname, "3D View Generic");
1672                         else if (strcmp(km->idname, "EditMesh") == 0)
1673                                 strcpy(km->idname, "Mesh");
1674                         else if (strcmp(km->idname, "TimeLine") == 0)
1675                                 strcpy(km->idname, "Timeline");
1676                         else if (strcmp(km->idname, "UVEdit") == 0)
1677                                 strcpy(km->idname, "UV Editor");
1678                         else if (strcmp(km->idname, "Animation_Channels") == 0)
1679                                 strcpy(km->idname, "Animation Channels");
1680                         else if (strcmp(km->idname, "GraphEdit Keys") == 0)
1681                                 strcpy(km->idname, "Graph Editor");
1682                         else if (strcmp(km->idname, "GraphEdit Generic") == 0)
1683                                 strcpy(km->idname, "Graph Editor Generic");
1684                         else if (strcmp(km->idname, "Action_Keys") == 0)
1685                                 strcpy(km->idname, "Dopesheet");
1686                         else if (strcmp(km->idname, "NLA Data") == 0)
1687                                 strcpy(km->idname, "NLA Editor");
1688                         else if (strcmp(km->idname, "Node Generic") == 0)
1689                                 strcpy(km->idname, "Node Editor");
1690                         else if (strcmp(km->idname, "Logic Generic") == 0)
1691                                 strcpy(km->idname, "Logic Editor");
1692                         else if (strcmp(km->idname, "File") == 0)
1693                                 strcpy(km->idname, "File Browser");
1694                         else if (strcmp(km->idname, "FileMain") == 0)
1695                                 strcpy(km->idname, "File Browser Main");
1696                         else if (strcmp(km->idname, "FileButtons") == 0)
1697                                 strcpy(km->idname, "File Browser Buttons");
1698                         else if (strcmp(km->idname, "Buttons Generic") == 0)
1699                                 strcpy(km->idname, "Property Editor");
1700                 }
1701         }
1702         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
1703                 if (U.wmdrawmethod == USER_DRAW_TRIPLE)
1704                         U.wmdrawmethod = USER_DRAW_AUTOMATIC;
1705         }
1706         
1707         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
1708                 if (U.flag & USER_LMOUSESELECT) 
1709                         U.flag &= ~USER_TWOBUTTONMOUSE;
1710         }
1711         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
1712                 bTheme *btheme;
1713                 
1714                 /* default new handle type is auto handles */
1715                 U.keyhandles_new = HD_AUTO;
1716                 
1717                 /* init new curve colors */
1718                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1719                         /* init colors used for handles in 3D-View  */
1720                         rgba_char_args_set(btheme->tv3d.handle_free, 0, 0, 0, 255);
1721                         rgba_char_args_set(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
1722                         rgba_char_args_set(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
1723                         rgba_char_args_set(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
1724                         rgba_char_args_set(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
1725                         rgba_char_args_set(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1726                         rgba_char_args_set(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1727                         rgba_char_args_set(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1728                         rgba_char_args_set(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
1729                         
1730                         /* same colors again for Graph Editor... */
1731                         rgba_char_args_set(btheme->tipo.handle_free, 0, 0, 0, 255);
1732                         rgba_char_args_set(btheme->tipo.handle_auto, 0x90, 0x90, 0x00, 255);
1733                         rgba_char_args_set(btheme->tipo.handle_vect, 0x40, 0x90, 0x30, 255);
1734                         rgba_char_args_set(btheme->tipo.handle_align, 0x80, 0x30, 0x60, 255);
1735                         rgba_char_args_set(btheme->tipo.handle_sel_free, 0, 0, 0, 255);
1736                         rgba_char_args_set(btheme->tipo.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1737                         rgba_char_args_set(btheme->tipo.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1738                         rgba_char_args_set(btheme->tipo.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1739                         
1740                         /* edge crease */
1741                         rgba_char_args_set_fl(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
1742                 }
1743         }
1744         if (bmain->versionfile <= 252) {
1745                 bTheme *btheme;
1746
1747                 /* init new curve colors */
1748                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1749                         if (btheme->tv3d.lastsel_point[3] == 0)
1750                                 rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
1751                 }
1752         }
1753         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
1754                 bTheme *btheme;
1755                 
1756                 /* interface_widgets.c */
1757                 struct uiWidgetColors wcol_progress = {
1758                         {0, 0, 0, 255},
1759                         {190, 190, 190, 255},
1760                         {100, 100, 100, 180},
1761                         {68, 68, 68, 255},
1762                         
1763                         {0, 0, 0, 255},
1764                         {255, 255, 255, 255},
1765                         
1766                         0,
1767                         5, -5
1768                 };
1769                 
1770                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1771                         /* init progress bar theme */
1772                         btheme->tui.wcol_progress = wcol_progress;
1773                 }
1774         }
1775
1776         if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
1777                 bTheme *btheme;
1778                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1779                         rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
1780                         rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
1781                         rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
1782                 }
1783         }
1784         
1785         if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) {
1786                 bTheme *btheme;
1787                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1788                         if ((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width = 1;
1789                 }
1790         }
1791
1792         if (bmain->versionfile < 257) {
1793                 /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs,
1794                  * so that it doesn't linger around from old configs like a ghost */
1795                 U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
1796         }
1797
1798         if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 2)) {
1799                 bTheme *btheme;
1800                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1801                         btheme->tnode.noodle_curving = 5;
1802                 }
1803         }
1804
1805         if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
1806                 bTheme *btheme;
1807                 
1808                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1809                         btheme->tv3d.speaker[3] = 255;
1810                 }
1811         }
1812
1813         if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 3)) {
1814                 bTheme *btheme;
1815                 
1816                 /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead 
1817                  * was changed in 260 as part of GSoC11, but version patch was wrong
1818                  */
1819                 if (U.keyhandles_new == HD_AUTO) 
1820                         U.keyhandles_new = HD_AUTO_ANIM;
1821                 
1822                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1823                         if (btheme->tv3d.bundle_solid[3] == 0)
1824                                 rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
1825                         
1826                         if (btheme->tv3d.camera_path[3] == 0)
1827                                 rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
1828                                 
1829                         if ((btheme->tclip.back[3]) == 0) {
1830                                 btheme->tclip = btheme->tv3d;
1831                                 
1832                                 rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
1833                                 rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
1834                                 rgba_char_args_set(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
1835                                 rgba_char_args_set(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
1836                                 rgba_char_args_set(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
1837                                 rgba_char_args_set(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
1838                                 rgba_char_args_set(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
1839                                 rgba_char_args_set(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
1840                                 rgba_char_args_set(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
1841                                 rgba_char_args_set(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
1842                                 rgba_char_args_set(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
1843                                 rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
1844                                 btheme->tclip.handle_vertex_size = 4;
1845                         }
1846                         
1847                         /* auto-clamped handles -> based on auto */
1848                         if (btheme->tipo.handle_auto_clamped[3] == 0)
1849                                 rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
1850                         if (btheme->tipo.handle_sel_auto_clamped[3] == 0)
1851                                 rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
1852                 }
1853                 
1854                 /* enable (Cycles) addon by default */
1855                 if (!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) {
1856                         bAddon *baddon = MEM_callocN(sizeof(bAddon), "bAddon");
1857                         BLI_strncpy(baddon->module, "cycles", sizeof(baddon->module));
1858                         BLI_addtail(&U.addons, baddon);
1859                 }
1860         }
1861         
1862         if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) {
1863                 bTheme *btheme;
1864                 
1865                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1866                         rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
1867                         btheme->tui.icon_alpha = 1.0;
1868                 }
1869         }
1870         
1871         if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 4)) {
1872                 bTheme *btheme;
1873                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1874                         rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.071, 0.259, 0.694, 0.150);
1875                         rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.522, 0.0, 0.7);
1876                         rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 1.0, 0.522, 0.0, 0.5);
1877                         rgba_char_args_set_fl(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0);
1878                         rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0);
1879                         rgba_char_args_set_fl(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140);
1880                         
1881                         rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3);
1882                         rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
1883                 }
1884                 
1885                 U.use_16bit_textures = TRUE;
1886         }
1887
1888         if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
1889                 bTheme *btheme;
1890                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1891                         if (btheme->tui.wcol_menu_item.item[3] == 255)
1892                                 rgba_char_args_set(btheme->tui.wcol_menu_item.item, 172, 172, 172, 128);
1893                 }
1894         }
1895
1896         if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
1897                 bTheme *btheme;
1898                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1899                         if (btheme->tui.wcol_tooltip.inner[3] == 0) {
1900                                 btheme->tui.wcol_tooltip = btheme->tui.wcol_menu_back;
1901                         }
1902                         if (btheme->tui.wcol_tooltip.text[0] == 160) { /* hrmf */
1903                                 rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255);
1904                         }
1905                 }
1906         }
1907
1908         if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
1909                 bTheme *btheme;
1910                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1911                         if (btheme->tseq.movieclip[0] == 0) {
1912                                 rgba_char_args_set(btheme->tseq.movieclip,  32, 32, 143, 255);
1913                         }
1914                 }
1915         }
1916
1917         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) {
1918                 bTheme *btheme;
1919                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1920                         if (btheme->tclip.strip[0] == 0) {
1921                                 rgba_char_args_set(btheme->tclip.list, 0x66, 0x66, 0x66, 0xff);
1922                                 rgba_char_args_set(btheme->tclip.strip, 0x0c, 0x0a, 0x0a, 0x80);
1923                                 rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff);
1924                         }
1925                 }
1926         }
1927
1928         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 6)) {
1929                 bTheme *btheme;
1930                 for (btheme = U.themes.first; btheme; btheme = btheme->next)
1931                         rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
1932         }
1933         
1934         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
1935                 bTheme *btheme;
1936                 
1937                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1938                         /* DopeSheet Summary */
1939                         rgba_char_args_set(btheme->tact.anim_active,    204, 112, 26, 102); 
1940                         
1941                         /* NLA Colors */
1942                         rgba_char_args_set(btheme->tnla.anim_active,     204, 112, 26, 102); /* same as dopesheet above */
1943                         rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
1944                         
1945                         rgba_char_args_set(btheme->tnla.nla_tweaking,   77, 243, 26, 77);
1946                         rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
1947                         
1948                         rgba_char_args_set(btheme->tnla.nla_transition,     28, 38, 48, 255);
1949                         rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
1950                         rgba_char_args_set(btheme->tnla.nla_meta,           51, 38, 66, 255);
1951                         rgba_char_args_set(btheme->tnla.nla_meta_sel,       105, 33, 150, 255);
1952                         rgba_char_args_set(btheme->tnla.nla_sound,          43, 61, 61, 255);
1953                         rgba_char_args_set(btheme->tnla.nla_sound_sel,      31, 122, 122, 255);
1954                 }
1955         }
1956
1957         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
1958                 bTheme *btheme;
1959                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1960                         if (btheme->tseq.movieclip[0] == 0) {
1961                                 rgba_char_args_set(btheme->tseq.mask,  152, 78, 62, 255);
1962                         }
1963                 }
1964         }
1965
1966         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 15)) {
1967                 bTheme *btheme;
1968                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1969                         rgba_char_args_set(btheme->tv3d.bone_pose_active, 140, 255, 255, 80);
1970                 }
1971         }
1972
1973         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 16)) {
1974                 bTheme *btheme;
1975
1976                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1977                         if (btheme->tact.anim_active[3] == 0)
1978                                 rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102);
1979
1980                         if (btheme->tnla.anim_active[3] == 0)
1981                                 rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102);
1982                 }
1983         }
1984
1985         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 22)) {
1986                 bTheme *btheme;
1987
1988                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1989                         if (btheme->tipo.lastsel_point[3] == 0)
1990                                 rgba_char_args_set(btheme->tipo.lastsel_point, 0xff, 0xff, 0xff, 255);
1991
1992                         if (btheme->tv3d.skin_root[3] == 0)
1993                                 rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
1994                 }
1995         }
1996         
1997         if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 9)) {
1998                 bTheme *btheme;
1999                 
2000                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2001                         rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
2002                         rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
2003                         rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
2004                 }
2005         }
2006
2007         /* GL Texture Garbage Collection (variable abused above!) */
2008         if (U.textimeout == 0) {
2009                 U.texcollectrate = 60;
2010                 U.textimeout = 120;
2011         }
2012         if (U.memcachelimit <= 0) {
2013                 U.memcachelimit = 32;
2014         }
2015         if (U.frameserverport == 0) {
2016                 U.frameserverport = 8080;
2017         }
2018         if (U.dbl_click_time == 0) {
2019                 U.dbl_click_time = 350;
2020         }
2021         if (U.scrcastfps == 0) {
2022                 U.scrcastfps = 10;
2023                 U.scrcastwait = 50;
2024         }
2025         if (U.v2d_min_gridsize == 0) {
2026                 U.v2d_min_gridsize = 35;
2027         }
2028         if (U.dragthreshold == 0)
2029                 U.dragthreshold = 5;
2030         if (U.widget_unit == 0)
2031                 U.widget_unit = 20;
2032         if (U.anisotropic_filter <= 0)
2033                 U.anisotropic_filter = 1;
2034
2035         if (U.ndof_sensitivity == 0.0f) {
2036                 U.ndof_sensitivity = 1.0f;
2037                 U.ndof_flag = NDOF_LOCK_HORIZON |
2038                               NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
2039         }
2040         
2041         if (U.ndof_orbit_sensitivity == 0.0f) {
2042                 U.ndof_orbit_sensitivity = U.ndof_sensitivity;
2043
2044                 if (!(U.flag & USER_TRACKBALL))
2045                         U.ndof_flag |= NDOF_TURNTABLE;
2046         }
2047         if (U.tweak_threshold == 0)
2048                 U.tweak_threshold = 10;
2049
2050         if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 1)) {
2051                 bTheme *btheme;
2052                 
2053                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2054                         /* note: the toggle operator for transparent backdrops limits to these spacetypes */
2055                         if (btheme->tnode.button[3] == 255) {
2056                                 btheme->tv3d.button[3] = 128;
2057                                 btheme->tnode.button[3] = 128;
2058                                 btheme->tima.button[3] = 128;
2059                                 btheme->tseq.button[3] = 128;
2060                                 btheme->tclip.button[3] = 128;
2061                         }
2062                 }
2063         }
2064         
2065         /* panel header/backdrop supported locally per editor now */
2066         if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 2)) {
2067                 bTheme *btheme;
2068                 
2069                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2070                         
2071                         /* new color, panel backdrop. Not used anywhere yet, until you enable it */
2072                         copy_v3_v3_char(btheme->tui.panel.back, btheme->tbuts.button);
2073                         btheme->tui.panel.back[3] = 128;
2074                         
2075                         btheme->tbuts.panelcolors = btheme->tui.panel;
2076                         btheme->tv3d.panelcolors = btheme->tui.panel;
2077                         btheme->tfile.panelcolors = btheme->tui.panel;
2078                         btheme->tipo.panelcolors = btheme->tui.panel;
2079                         btheme->tinfo.panelcolors = btheme->tui.panel;
2080                         btheme->tact.panelcolors = btheme->tui.panel;
2081                         btheme->tnla.panelcolors = btheme->tui.panel;
2082                         btheme->tseq.panelcolors = btheme->tui.panel;
2083                         btheme->tima.panelcolors = btheme->tui.panel;
2084                         btheme->text.panelcolors = btheme->tui.panel;
2085                         btheme->toops.panelcolors = btheme->tui.panel;
2086                         btheme->ttime.panelcolors = btheme->tui.panel;
2087                         btheme->tnode.panelcolors = btheme->tui.panel;
2088                         btheme->tlogic.panelcolors = btheme->tui.panel;
2089                         btheme->tuserpref.panelcolors = btheme->tui.panel;
2090                         btheme->tconsole.panelcolors = btheme->tui.panel;
2091                         btheme->tclip.panelcolors = btheme->tui.panel;
2092                 }
2093         }
2094         
2095         if (bmain->versionfile < 266) {
2096                 bTheme *btheme;
2097                 
2098                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2099                         /* rna definition limits fac to 0.01 */
2100                         if (btheme->tui.menu_shadow_fac == 0.0f) {
2101                                 btheme->tui.menu_shadow_fac = 0.5f;
2102                                 btheme->tui.menu_shadow_width = 12;
2103                         }
2104                 }
2105         }
2106
2107         if (!MAIN_VERSION_ATLEAST(bmain, 265, 4)) {
2108                 bTheme *btheme;
2109                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2110                         rgba_char_args_set(btheme->text.syntaxd,    50, 0, 140, 255);   /* Decorator/Preprocessor Dir.  Blue-purple */
2111                         rgba_char_args_set(btheme->text.syntaxr,    140, 60, 0, 255);   /* Reserved  Orange */
2112                         rgba_char_args_set(btheme->text.syntaxs,    76, 76, 76, 255);   /* Grey (mix between fg/bg) */
2113                 }
2114         }
2115
2116         if (!MAIN_VERSION_ATLEAST(bmain, 265, 6)) {
2117                 bTheme *btheme;
2118                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2119                         copy_v4_v4_char(btheme->tv3d.gradients.high_gradient, btheme->tv3d.back);
2120                 }
2121         }
2122
2123         if (U.pixelsize == 0.0f)
2124                 U.pixelsize = 1.0f;
2125         
2126         /* funny name, but it is GE stuff, moves userdef stuff to engine */
2127 // XXX  space_set_commmandline_options();
2128         /* this timer uses U */
2129 // XXX  reset_autosave();
2130
2131 }