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