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