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