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