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