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