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