Implement asymmetric and free handles type for masks
[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 static void ui_theme_space_init_handles_color(ThemeSpace *theme_space)
767 {
768         rgba_char_args_set(theme_space->handle_free, 0, 0, 0, 255);
769         rgba_char_args_set(theme_space->handle_auto, 0x90, 0x90, 0x00, 255);
770         rgba_char_args_set(theme_space->handle_vect, 0x40, 0x90, 0x30, 255);
771         rgba_char_args_set(theme_space->handle_align, 0x80, 0x30, 0x60, 255);
772         rgba_char_args_set(theme_space->handle_sel_free, 0, 0, 0, 255);
773         rgba_char_args_set(theme_space->handle_sel_auto, 0xf0, 0xff, 0x40, 255);
774         rgba_char_args_set(theme_space->handle_sel_vect, 0x40, 0xc0, 0x30, 255);
775         rgba_char_args_set(theme_space->handle_sel_align, 0xf0, 0x90, 0xa0, 255);
776         rgba_char_args_set(theme_space->act_spline, 0xdb, 0x25, 0x12, 255);
777 }
778
779 /* initialize default theme
780  * Note: when you add new colors, created & saved themes need initialized
781  * use function below, init_userdef_do_versions()
782  */
783 void ui_theme_init_default(void)
784 {
785         bTheme *btheme;
786         
787         /* we search for the theme with name Default */
788         btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
789         
790         if (btheme == NULL) {
791                 btheme = MEM_callocN(sizeof(bTheme), "theme");
792                 BLI_addtail(&U.themes, btheme);
793                 strcpy(btheme->name, "Default");
794         }
795         
796         UI_SetTheme(0, 0);  /* make sure the global used in this file is set */
797
798         /* UI buttons */
799         ui_widget_color_init(&btheme->tui);
800         
801         btheme->tui.iconfile[0] = 0;
802         btheme->tui.panel.show_back = false;
803         btheme->tui.panel.show_header = false;
804         rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
805         
806         rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
807         rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
808         rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
809
810         btheme->tui.menu_shadow_fac = 0.5f;
811         btheme->tui.menu_shadow_width = 12;
812         
813         /* Bone Color Sets */
814         ui_theme_init_boneColorSets(btheme);
815         
816         /* common (new) variables */
817         ui_theme_init_new(btheme);
818         
819         /* space view3d */
820         btheme->tv3d.panelcolors.show_back = false;
821         btheme->tv3d.panelcolors.show_header = false;
822         rgba_char_args_set_fl(btheme->tv3d.panelcolors.back, 0.45, 0.45, 0.45, 0.5);
823         rgba_char_args_set_fl(btheme->tv3d.panelcolors.header, 0, 0, 0, 0.01);
824         rgba_char_args_set_fl(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
825         rgba_char_args_set(btheme->tv3d.text,       0, 0, 0, 255);
826         rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255);
827         
828         rgba_char_args_set_fl(btheme->tv3d.header,  0.45, 0.45, 0.45, 1.0);
829         rgba_char_args_set_fl(btheme->tv3d.button,  0.45, 0.45, 0.45, 0.5);
830 //      rgba_char_args_set(btheme->tv3d.panel,      165, 165, 165, 127);
831         
832         rgba_char_args_set(btheme->tv3d.shade1,  160, 160, 160, 100);
833         rgba_char_args_set(btheme->tv3d.shade2,  0x7f, 0x70, 0x70, 100);
834
835         rgba_char_args_set_fl(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
836         rgba_char_args_set(btheme->tv3d.view_overlay, 0, 0, 0, 255);
837         rgba_char_args_set(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
838         rgba_char_args_set(btheme->tv3d.wire_edit,  0x0, 0x0, 0x0, 255);
839         rgba_char_args_set(btheme->tv3d.lamp,       0, 0, 0, 40);
840         rgba_char_args_set(btheme->tv3d.speaker,    0, 0, 0, 255);
841         rgba_char_args_set(btheme->tv3d.camera,    0, 0, 0, 255);
842         rgba_char_args_set(btheme->tv3d.empty,    0, 0, 0, 255);
843         rgba_char_args_set(btheme->tv3d.select, 241, 88, 0, 255);
844         rgba_char_args_set(btheme->tv3d.active, 255, 170, 64, 255);
845         rgba_char_args_set(btheme->tv3d.group,      8, 48, 8, 255);
846         rgba_char_args_set(btheme->tv3d.group_active, 85, 187, 85, 255);
847         rgba_char_args_set(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
848         rgba_char_args_set(btheme->tv3d.vertex, 0, 0, 0, 255);
849         rgba_char_args_set(btheme->tv3d.vertex_select, 255, 133, 0, 255);
850         rgba_char_args_set(btheme->tv3d.vertex_unreferenced, 0, 0, 0, 255);
851         btheme->tv3d.vertex_size = 3;
852         btheme->tv3d.outline_width = 1;
853         rgba_char_args_set(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
854         rgba_char_args_set(btheme->tv3d.edge_select, 255, 160, 0, 255);
855         rgba_char_args_set(btheme->tv3d.edge_seam, 219, 37, 18, 255);
856         rgba_char_args_set(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
857         rgba_char_args_set(btheme->tv3d.face,       0, 0, 0, 18);
858         rgba_char_args_set(btheme->tv3d.face_select, 255, 133, 0, 60);
859         rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
860         rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
861         rgba_char_args_set(btheme->tv3d.face_dot, 255, 133, 0, 255);
862         rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
863         rgba_char_args_set_fl(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
864         rgba_char_args_set(btheme->tv3d.edge_sharp, 0, 255, 255, 255);
865         rgba_char_args_set(btheme->tv3d.header_text, 0, 0, 0, 255);
866         rgba_char_args_set(btheme->tv3d.header_text_hi, 255, 255, 255, 255);
867         rgba_char_args_set(btheme->tv3d.button_text, 0, 0, 0, 255);
868         rgba_char_args_set(btheme->tv3d.button_text_hi, 255, 255, 255, 255);
869         rgba_char_args_set(btheme->tv3d.button_title, 0, 0, 0, 255);
870         rgba_char_args_set(btheme->tv3d.title, 0, 0, 0, 255);
871         rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
872         rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
873
874         btheme->tv3d.facedot_size = 4;
875
876         rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
877         rgba_char_args_set(btheme->tv3d.extra_edge_angle, 32, 32, 0, 255);
878         rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
879         rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
880
881         rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0,  0x40, 255);
882
883         rgba_char_args_set(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
884         rgba_char_args_set(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
885         rgba_char_args_set(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255);
886         rgba_char_args_set(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255);
887
888         ui_theme_space_init_handles_color(&btheme->tv3d);
889
890         rgba_char_args_set(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
891         rgba_char_args_set(btheme->tv3d.lastsel_point,  0xff, 0xff, 0xff, 255);
892
893         rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255);
894         /* alpha 80 is not meant editable, used for wire+action draw */
895         rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80);
896         rgba_char_args_set(btheme->tv3d.bone_pose_active, 140, 255, 255, 80);
897
898         rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
899         rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
900
901         rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
902         rgba_char_args_set(btheme->tv3d.gradients.gradient, 0, 0, 0, 0);
903         rgba_char_args_set(btheme->tv3d.gradients.high_gradient, 58, 58, 58, 255);
904         btheme->tv3d.gradients.show_grad = false;
905
906         /* space buttons */
907         /* to have something initialized */
908         btheme->tbuts = btheme->tv3d;
909
910         rgba_char_args_set_fl(btheme->tbuts.back,   0.45, 0.45, 0.45, 1.0);
911 //      rgba_char_args_set(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255);
912
913         /* graph editor */
914         btheme->tipo = btheme->tv3d;
915         rgba_char_args_set_fl(btheme->tipo.back,    0.42, 0.42, 0.42, 1.0);
916         rgba_char_args_set_fl(btheme->tipo.list,    0.4, 0.4, 0.4, 1.0);
917         rgba_char_args_set(btheme->tipo.grid,   94, 94, 94, 255);
918 //      rgba_char_args_set(btheme->tipo.panel,  255, 255, 255, 150);
919         rgba_char_args_set(btheme->tipo.shade1,     150, 150, 150, 100);    /* scrollbars */
920         rgba_char_args_set(btheme->tipo.shade2,     0x70, 0x70, 0x70, 100);
921         rgba_char_args_set(btheme->tipo.vertex,     0, 0, 0, 255);
922         rgba_char_args_set(btheme->tipo.vertex_select, 255, 133, 0, 255);
923         rgba_char_args_set(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255);
924         btheme->tipo.vertex_size = 6;
925
926         rgba_char_args_set(btheme->tipo.handle_vertex,      0, 0, 0, 255);
927         rgba_char_args_set(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
928         rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
929         rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
930         btheme->tipo.handle_vertex_size = 5;
931         
932         rgba_char_args_set(btheme->tipo.ds_channel,      82, 96, 110, 255);
933         rgba_char_args_set(btheme->tipo.ds_subchannel,  124, 137, 150, 255);
934         rgba_char_args_set(btheme->tipo.group,           79, 101, 73, 255);
935         rgba_char_args_set(btheme->tipo.group_active,   135, 177, 125, 255);
936
937         /* dopesheet */
938         btheme->tact = btheme->tipo;
939         rgba_char_args_set(btheme->tact.strip,          12, 10, 10, 128);
940         rgba_char_args_set(btheme->tact.strip_select,   255, 140, 0, 255);
941         
942         rgba_char_args_set(btheme->tact.anim_active,    204, 112, 26, 102);
943         
944         rgba_char_args_set(btheme->tact.keytype_keyframe,           232, 232, 232, 255);
945         rgba_char_args_set(btheme->tact.keytype_keyframe_select,    255, 190,  50, 255);
946         rgba_char_args_set(btheme->tact.keytype_extreme,            232, 179, 204, 255);
947         rgba_char_args_set(btheme->tact.keytype_extreme_select,     242, 128, 128, 255);
948         rgba_char_args_set(btheme->tact.keytype_breakdown,          179, 219, 232, 255);
949         rgba_char_args_set(btheme->tact.keytype_breakdown_select,    84, 191, 237, 255);
950         rgba_char_args_set(btheme->tact.keytype_jitter,             148, 229, 117, 255);
951         rgba_char_args_set(btheme->tact.keytype_jitter_select,       97, 192,  66, 255);
952         
953         rgba_char_args_set(btheme->tact.keyborder,                   0,   0,   0, 255);
954         rgba_char_args_set(btheme->tact.keyborder_select,        0,   0,   0, 255);
955         
956         /* space nla */
957         btheme->tnla = btheme->tact;
958         
959         rgba_char_args_set(btheme->tnla.anim_active,     204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */
960         rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
961         
962         rgba_char_args_set(btheme->tnla.nla_tweaking,   77, 243, 26, 77);
963         rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
964         
965         rgba_char_args_set(btheme->tnla.nla_transition,     28, 38, 48, 255);
966         rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
967         rgba_char_args_set(btheme->tnla.nla_meta,           51, 38, 66, 255);
968         rgba_char_args_set(btheme->tnla.nla_meta_sel,       105, 33, 150, 255);
969         rgba_char_args_set(btheme->tnla.nla_sound,          43, 61, 61, 255);
970         rgba_char_args_set(btheme->tnla.nla_sound_sel,      31, 122, 122, 255);
971         
972         rgba_char_args_set(btheme->tnla.keyborder,                   0,   0,   0, 255);
973         rgba_char_args_set(btheme->tnla.keyborder_select,        0,   0,   0, 255);
974         
975         /* space file */
976         /* to have something initialized */
977         btheme->tfile = btheme->tv3d;
978         rgba_char_args_set_fl(btheme->tfile.back, 0.3, 0.3, 0.3, 1);
979 //      rgba_char_args_set_fl(btheme->tfile.panel, 0.3, 0.3, 0.3, 1);
980         rgba_char_args_set_fl(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
981         rgba_char_args_set(btheme->tfile.text,  250, 250, 250, 255);
982         rgba_char_args_set(btheme->tfile.text_hi, 15, 15, 15, 255);
983 //      rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255);  /* bookmark/ui regions */
984         rgba_char_args_set(btheme->tfile.active, 130, 130, 130, 255); /* selected files */
985         rgba_char_args_set(btheme->tfile.hilite, 255, 140, 25, 255);  /* selected files */
986         
987         rgba_char_args_set(btheme->tfile.grid,  250, 250, 250, 255);
988         rgba_char_args_set(btheme->tfile.image, 250, 250, 250, 255);
989         rgba_char_args_set(btheme->tfile.movie, 250, 250, 250, 255);
990         rgba_char_args_set(btheme->tfile.scene, 250, 250, 250, 255);
991
992         
993         /* space seq */
994         btheme->tseq = btheme->tv3d;
995         rgba_char_args_set(btheme->tseq.back,   116, 116, 116, 255);
996         rgba_char_args_set(btheme->tseq.movie,  81, 105, 135, 255);
997         rgba_char_args_set(btheme->tseq.movieclip,  32, 32, 143, 255);
998         rgba_char_args_set(btheme->tseq.mask,   152, 78, 62, 255);
999         rgba_char_args_set(btheme->tseq.image,  109, 88, 129, 255);
1000         rgba_char_args_set(btheme->tseq.scene,  78, 152, 62, 255);
1001         rgba_char_args_set(btheme->tseq.audio,  46, 143, 143, 255);
1002         rgba_char_args_set(btheme->tseq.effect,     169, 84, 124, 255);
1003         rgba_char_args_set(btheme->tseq.transition, 162, 95, 111, 255);
1004         rgba_char_args_set(btheme->tseq.meta,   109, 145, 131, 255);
1005         rgba_char_args_set(btheme->tseq.preview_back,   0, 0, 0, 255);
1006         rgba_char_args_set(btheme->tseq.grid,   64, 64, 64, 255);
1007
1008         /* space image */
1009         btheme->tima = btheme->tv3d;
1010         rgba_char_args_set(btheme->tima.back,   53, 53, 53, 255);
1011         rgba_char_args_set(btheme->tima.vertex, 0, 0, 0, 255);
1012         rgba_char_args_set(btheme->tima.vertex_select, 255, 133, 0, 255);
1013         rgba_char_args_set(btheme->tima.wire_edit, 192, 192, 192, 255);
1014         rgba_char_args_set(btheme->tima.edge_select, 255, 133, 0, 255);
1015         btheme->tima.vertex_size = 3;
1016         btheme->tima.facedot_size = 3;
1017         rgba_char_args_set(btheme->tima.face,   255, 255, 255, 10);
1018         rgba_char_args_set(btheme->tima.face_select, 255, 133, 0, 60);
1019         rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128);
1020         rgba_char_args_set_fl(btheme->tima.preview_back,    0.45, 0.45, 0.45, 1.0);
1021         rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.5, 0.5, 0.0, 0.2);
1022         rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.0, 1.0, 0.2);
1023         rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 0.0, 0.0, 1.0, 0.2);
1024         rgba_char_args_set_fl(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0);
1025         rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0);
1026         rgba_char_args_set_fl(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140);
1027
1028         rgba_char_args_test_set(btheme->tima.uv_others, 96, 96, 96, 255);
1029         rgba_char_args_test_set(btheme->tima.uv_shadow, 112, 112, 112, 255);
1030
1031         ui_theme_space_init_handles_color(&btheme->tima);
1032         btheme->tima.handle_vertex_size = 5;
1033
1034         /* space text */
1035         btheme->text = btheme->tv3d;
1036         rgba_char_args_set(btheme->text.back,   153, 153, 153, 255);
1037         rgba_char_args_set(btheme->text.shade1,     143, 143, 143, 255);
1038         rgba_char_args_set(btheme->text.shade2,     0xc6, 0x77, 0x77, 255);
1039         rgba_char_args_set(btheme->text.hilite,     255, 0, 0, 255);
1040         
1041         /* syntax highlighting */
1042         rgba_char_args_set(btheme->text.syntaxn,    0, 0, 200, 255);    /* Numbers  Blue*/
1043         rgba_char_args_set(btheme->text.syntaxl,    100, 0, 0, 255);    /* Strings  Red */
1044         rgba_char_args_set(btheme->text.syntaxc,    0, 100, 50, 255);   /* Comments  Greenish */
1045         rgba_char_args_set(btheme->text.syntaxv,    95, 95, 0, 255);    /* Special  Yellow*/
1046         rgba_char_args_set(btheme->text.syntaxd,    50, 0, 140, 255);   /* Decorator/Preprocessor Dir.  Blue-purple */
1047         rgba_char_args_set(btheme->text.syntaxr,    140, 60, 0, 255);   /* Reserved  Orange*/
1048         rgba_char_args_set(btheme->text.syntaxb,    128, 0, 80, 255);   /* Builtin  Red-purple */
1049         rgba_char_args_set(btheme->text.syntaxs,    76, 76, 76, 255);   /* Grey (mix between fg/bg) */
1050         
1051         /* space oops */
1052         btheme->toops = btheme->tv3d;
1053         rgba_char_args_set_fl(btheme->toops.back,   0.45, 0.45, 0.45, 1.0);
1054         
1055         rgba_char_args_set_fl(btheme->toops.match,  0.2, 0.5, 0.2, 0.3);    /* highlighting search match - soft green*/
1056         rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
1057
1058         /* space info */
1059         btheme->tinfo = btheme->tv3d;
1060         rgba_char_args_set_fl(btheme->tinfo.back,   0.45, 0.45, 0.45, 1.0);
1061         rgba_char_args_set(btheme->tinfo.info_selected, 96, 128, 255, 255);
1062         rgba_char_args_set(btheme->tinfo.info_selected_text, 255, 255, 255, 255);
1063         rgba_char_args_set(btheme->tinfo.info_error, 220, 0, 0, 255);
1064         rgba_char_args_set(btheme->tinfo.info_error_text, 0, 0, 0, 255);
1065         rgba_char_args_set(btheme->tinfo.info_warning, 220, 128, 96, 255);
1066         rgba_char_args_set(btheme->tinfo.info_warning_text, 0, 0, 0, 255);
1067         rgba_char_args_set(btheme->tinfo.info_info, 0, 170, 0, 255);
1068         rgba_char_args_set(btheme->tinfo.info_info_text, 0, 0, 0, 255);
1069         rgba_char_args_set(btheme->tinfo.info_debug, 196, 196, 196, 255);
1070         rgba_char_args_set(btheme->tinfo.info_debug_text, 0, 0, 0, 255);
1071
1072         /* space user preferences */
1073         btheme->tuserpref = btheme->tv3d;
1074         rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
1075         
1076         /* space console */
1077         btheme->tconsole = btheme->tv3d;
1078         rgba_char_args_set(btheme->tconsole.back, 0, 0, 0, 255);
1079         rgba_char_args_set(btheme->tconsole.console_output, 96, 128, 255, 255);
1080         rgba_char_args_set(btheme->tconsole.console_input, 255, 255, 255, 255);
1081         rgba_char_args_set(btheme->tconsole.console_info, 0, 170, 0, 255);
1082         rgba_char_args_set(btheme->tconsole.console_error, 220, 96, 96, 255);
1083         rgba_char_args_set(btheme->tconsole.console_cursor, 220, 96, 96, 255);
1084         rgba_char_args_set(btheme->tconsole.console_select, 255, 255, 255, 48);
1085         
1086         /* space time */
1087         btheme->ttime = btheme->tv3d;
1088         rgba_char_args_set_fl(btheme->ttime.back,   0.45, 0.45, 0.45, 1.0);
1089         rgba_char_args_set_fl(btheme->ttime.grid,   0.36, 0.36, 0.36, 1.0);
1090         rgba_char_args_set(btheme->ttime.shade1,  173, 173, 173, 255);      /* sliders */
1091         
1092         /* space node, re-uses syntax and console color storage */
1093         btheme->tnode = btheme->tv3d;
1094         rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255);      /* wire selected */
1095         rgba_char_args_set(btheme->tnode.syntaxl, 155, 155, 155, 160);  /* TH_NODE, backdrop */
1096         rgba_char_args_set(btheme->tnode.syntaxn, 100, 100, 100, 255);  /* in */
1097         rgba_char_args_set(btheme->tnode.nodeclass_output, 100, 100, 100, 255);  /* output */
1098         rgba_char_args_set(btheme->tnode.syntaxb, 108, 105, 111, 255);  /* operator */
1099         rgba_char_args_set(btheme->tnode.syntaxv, 104, 106, 117, 255);  /* generator */
1100         rgba_char_args_set(btheme->tnode.syntaxc, 105, 117, 110, 255);  /* group */
1101         rgba_char_args_set(btheme->tnode.nodeclass_texture, 108, 105, 111, 255);  /* operator */
1102         rgba_char_args_set(btheme->tnode.nodeclass_shader, 108, 105, 111, 255);  /* operator */
1103         rgba_char_args_set(btheme->tnode.nodeclass_filter, 108, 105, 111, 255);  /* operator */
1104         rgba_char_args_set(btheme->tnode.nodeclass_script, 108, 105, 111, 255);  /* operator */
1105         rgba_char_args_set(btheme->tnode.nodeclass_pattern, 108, 105, 111, 255);  /* operator */
1106         rgba_char_args_set(btheme->tnode.nodeclass_vector, 108, 105, 111, 255);  /* operator */
1107         rgba_char_args_set(btheme->tnode.nodeclass_layout, 108, 105, 111, 255);  /* operator */
1108         rgba_char_args_set(btheme->tnode.movie, 155, 155, 155, 160);  /* frame */
1109         rgba_char_args_set(btheme->tnode.syntaxs, 151, 116, 116, 255);  /* matte nodes */
1110         rgba_char_args_set(btheme->tnode.syntaxd, 116, 151, 151, 255);  /* distort nodes */
1111         rgba_char_args_set(btheme->tnode.console_output, 223, 202, 53, 255);  /* interface nodes */
1112         btheme->tnode.noodle_curving = 5;
1113
1114         /* space logic */
1115         btheme->tlogic = btheme->tv3d;
1116         rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
1117         
1118         /* space clip */
1119         btheme->tclip = btheme->tv3d;
1120
1121         rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
1122         rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
1123         rgba_char_args_set(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
1124         rgba_char_args_set(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
1125         rgba_char_args_set(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
1126         rgba_char_args_set(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
1127         rgba_char_args_set(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
1128         rgba_char_args_set(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
1129         rgba_char_args_set(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
1130         rgba_char_args_set(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
1131         rgba_char_args_set(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
1132         rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
1133         rgba_char_args_set(btheme->tclip.list, 0x66, 0x66, 0x66, 0xff);
1134         rgba_char_args_set(btheme->tclip.strip, 0x0c, 0x0a, 0x0a, 0x80);
1135         rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff);
1136         btheme->tclip.handle_vertex_size = 5;
1137         ui_theme_space_init_handles_color(&btheme->tclip);
1138 }
1139
1140 void ui_style_init_default(void)
1141 {
1142         BLI_freelistN(&U.uistyles);
1143         /* gets automatically re-allocated */
1144         uiStyleInit();
1145 }
1146
1147
1148 void UI_SetTheme(int spacetype, int regionid)
1149 {
1150         if (spacetype) {
1151                 /* later on, a local theme can be found too */
1152                 theme_active = U.themes.first;
1153                 theme_spacetype = spacetype;
1154                 theme_regionid = regionid;
1155         }
1156         else if (regionid) {
1157                 /* popups */
1158                 theme_active = U.themes.first;
1159                 theme_spacetype = SPACE_BUTS;
1160                 theme_regionid = regionid;
1161         }
1162         else {
1163                 /* for safety, when theme was deleted */
1164                 theme_active = U.themes.first;
1165                 theme_spacetype = SPACE_VIEW3D;
1166                 theme_regionid = RGN_TYPE_WINDOW;
1167         }
1168 }
1169
1170 bTheme *UI_GetTheme(void)
1171 {
1172         return U.themes.first;
1173 }
1174
1175 /* for space windows only */
1176 void UI_ThemeColor(int colorid)
1177 {
1178         const unsigned char *cp;
1179         
1180         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1181         glColor3ubv(cp);
1182
1183 }
1184
1185 /* plus alpha */
1186 void UI_ThemeColor4(int colorid)
1187 {
1188         const unsigned char *cp;
1189         
1190         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1191         glColor4ubv(cp);
1192
1193 }
1194
1195 /* set the color with offset for shades */
1196 void UI_ThemeColorShade(int colorid, int offset)
1197 {
1198         int r, g, b;
1199         const unsigned char *cp;
1200         
1201         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1202         r = offset + (int) cp[0];
1203         CLAMP(r, 0, 255);
1204         g = offset + (int) cp[1];
1205         CLAMP(g, 0, 255);
1206         b = offset + (int) cp[2];
1207         CLAMP(b, 0, 255);
1208         glColor4ub(r, g, b, cp[3]);
1209 }
1210 void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
1211 {
1212         int r, g, b, a;
1213         const unsigned char *cp;
1214         
1215         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1216         r = coloffset + (int) cp[0];
1217         CLAMP(r, 0, 255);
1218         g = coloffset + (int) cp[1];
1219         CLAMP(g, 0, 255);
1220         b = coloffset + (int) cp[2];
1221         CLAMP(b, 0, 255);
1222         a = alphaoffset + (int) cp[3];
1223         CLAMP(a, 0, 255);
1224         glColor4ub(r, g, b, a);
1225 }
1226
1227 /* blend between to theme colors, and set it */
1228 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
1229 {
1230         int r, g, b;
1231         const unsigned char *cp1, *cp2;
1232         
1233         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
1234         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
1235
1236         CLAMP(fac, 0.0f, 1.0f);
1237         r = floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1238         g = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1239         b = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1240         
1241         glColor3ub(r, g, b);
1242 }
1243
1244 /* blend between to theme colors, shade it, and set it */
1245 void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
1246 {
1247         int r, g, b;
1248         const unsigned char *cp1, *cp2;
1249         
1250         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
1251         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
1252
1253         CLAMP(fac, 0.0f, 1.0f);
1254         r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1255         g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1256         b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1257         
1258         CLAMP(r, 0, 255);
1259         CLAMP(g, 0, 255);
1260         CLAMP(b, 0, 255);
1261         
1262         glColor3ub(r, g, b);
1263 }
1264
1265 /* blend between to theme colors, shade it, and set it */
1266 void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
1267 {
1268         int r, g, b, a;
1269         const unsigned char *cp1, *cp2;
1270         
1271         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
1272         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
1273
1274         CLAMP(fac, 0.0f, 1.0f);
1275         r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1276         g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1277         b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1278         a = alphaoffset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
1279         
1280         CLAMP(r, 0, 255);
1281         CLAMP(g, 0, 255);
1282         CLAMP(b, 0, 255);
1283         CLAMP(a, 0, 255);
1284
1285         glColor4ub(r, g, b, a);
1286 }
1287
1288
1289 /* get individual values, not scaled */
1290 float UI_GetThemeValuef(int colorid)
1291 {
1292         const unsigned char *cp;
1293         
1294         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1295         return ((float)cp[0]);
1296 }
1297
1298 /* get individual values, not scaled */
1299 int UI_GetThemeValue(int colorid)
1300 {
1301         const unsigned char *cp;
1302         
1303         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1304         return ((int) cp[0]);
1305 }
1306
1307
1308 /* get the color, range 0.0-1.0 */
1309 void UI_GetThemeColor3fv(int colorid, float col[3])
1310 {
1311         const unsigned char *cp;
1312         
1313         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1314         col[0] = ((float)cp[0]) / 255.0f;
1315         col[1] = ((float)cp[1]) / 255.0f;
1316         col[2] = ((float)cp[2]) / 255.0f;
1317 }
1318
1319 void UI_GetThemeColor4fv(int colorid, float col[4])
1320 {
1321         const unsigned char *cp;
1322         
1323         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1324         col[0] = ((float)cp[0]) / 255.0f;
1325         col[1] = ((float)cp[1]) / 255.0f;
1326         col[2] = ((float)cp[2]) / 255.0f;
1327         col[3] = ((float)cp[3]) / 255.0f;
1328 }
1329
1330 /* get the color, range 0.0-1.0, complete with shading offset */
1331 void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
1332 {
1333         int r, g, b;
1334         const unsigned char *cp;
1335         
1336         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1337         
1338         r = offset + (int) cp[0];
1339         CLAMP(r, 0, 255);
1340         g = offset + (int) cp[1];
1341         CLAMP(g, 0, 255);
1342         b = offset + (int) cp[2];
1343         CLAMP(b, 0, 255);
1344         
1345         col[0] = ((float)r) / 255.0f;
1346         col[1] = ((float)g) / 255.0f;
1347         col[2] = ((float)b) / 255.0f;
1348 }
1349
1350 void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3])
1351 {
1352         int r, g, b;
1353         const unsigned char *cp;
1354
1355         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1356
1357         r = offset + (int) cp[0];
1358         CLAMP(r, 0, 255);
1359         g = offset + (int) cp[1];
1360         CLAMP(g, 0, 255);
1361         b = offset + (int) cp[2];
1362         CLAMP(b, 0, 255);
1363
1364         col[0] = r;
1365         col[1] = g;
1366         col[2] = b;
1367 }
1368
1369 /* get the color, in char pointer */
1370 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
1371 {
1372         const unsigned char *cp;
1373         
1374         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1375         col[0] = cp[0];
1376         col[1] = cp[1];
1377         col[2] = cp[2];
1378 }
1379
1380 /* get the color, in char pointer */
1381 void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
1382 {
1383         const unsigned char *cp;
1384         
1385         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1386         col[0] = cp[0];
1387         col[1] = cp[1];
1388         col[2] = cp[2];
1389         col[3] = cp[3];
1390 }
1391
1392 void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
1393 {
1394         const unsigned char *cp;
1395         
1396         cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
1397         col[0] = cp[0];
1398         col[1] = cp[1];
1399         col[2] = cp[2];
1400         col[3] = cp[3];
1401 }
1402
1403 /* blends and shades between two char color pointers */
1404 void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
1405 {
1406         int r, g, b;
1407         CLAMP(fac, 0.0f, 1.0f);
1408         r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1409         g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1410         b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1411
1412         r = r < 0 ? 0 : (r > 255 ? 255 : r);
1413         g = g < 0 ? 0 : (g > 255 ? 255 : g);
1414         b = b < 0 ? 0 : (b > 255 ? 255 : b);
1415         
1416         glColor3ub(r, g, b);
1417 }
1418
1419 void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], int offset)
1420 {
1421         int r, g, b;
1422
1423         r = offset + (int)cp[0];
1424         g = offset + (int)cp[1];
1425         b = offset + (int)cp[2];
1426
1427         CLAMP(r, 0, 255);
1428         CLAMP(g, 0, 255);
1429         CLAMP(b, 0, 255);
1430
1431         col[0] = r;
1432         col[1] = g;
1433         col[2] = b;
1434 }
1435
1436 /* get a 3 byte color, blended and shaded between two other char color pointers */
1437 void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3],
1438                                   float fac, int offset)
1439 {
1440         int r, g, b;
1441
1442         CLAMP(fac, 0.0f, 1.0f);
1443         r = offset + floor((1.0f - fac) * cp1[0] + fac * cp2[0]);
1444         g = offset + floor((1.0f - fac) * cp1[1] + fac * cp2[1]);
1445         b = offset + floor((1.0f - fac) * cp1[2] + fac * cp2[2]);
1446
1447         CLAMP(r, 0, 255);
1448         CLAMP(g, 0, 255);
1449         CLAMP(b, 0, 255);
1450
1451         col[0] = r;
1452         col[1] = g;
1453         col[2] = b;
1454 }
1455
1456 void UI_ThemeClearColor(int colorid)
1457 {
1458         float col[3];
1459         
1460         UI_GetThemeColor3fv(colorid, col);
1461         glClearColor(col[0], col[1], col[2], 0.0);
1462 }
1463
1464 int UI_ThemeMenuShadowWidth(void)
1465 {
1466         bTheme *btheme = UI_GetTheme();
1467         return (int)(btheme->tui.menu_shadow_width * UI_DPI_FAC);
1468 }
1469
1470 void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
1471 {
1472         unsigned char col[3];
1473         
1474         switch (axis) {
1475                 case 'X':
1476                         UI_GetThemeColor3ubv(TH_AXIS_X, col);
1477                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1478                         break;
1479                 case 'Y':
1480                         UI_GetThemeColor3ubv(TH_AXIS_Y, col);
1481                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1482                         break;
1483                 case 'Z':
1484                         UI_GetThemeColor3ubv(TH_AXIS_Z, col);
1485                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1486                         break;
1487                 default:
1488                         BLI_assert(0);
1489                         break;
1490         }
1491 }
1492
1493 /* ************************************************************* */
1494
1495 /* patching UserDef struct and Themes */
1496 void init_userdef_do_versions(void)
1497 {
1498         Main *bmain = G.main;
1499         
1500         /* the UserDef struct is not corrected with do_versions() .... ugh! */
1501         if (U.wheellinescroll == 0) U.wheellinescroll = 3;
1502         if (U.menuthreshold1 == 0) {
1503                 U.menuthreshold1 = 5;
1504                 U.menuthreshold2 = 2;
1505         }
1506         if (U.tb_leftmouse == 0) {
1507                 U.tb_leftmouse = 5;
1508                 U.tb_rightmouse = 5;
1509         }
1510         if (U.mixbufsize == 0) U.mixbufsize = 2048;
1511         if (strcmp(U.tempdir, "/") == 0) {
1512                 BLI_system_temporary_dir(U.tempdir);
1513         }
1514         if (U.autokey_mode == 0) {
1515                 /* 'add/replace' but not on */
1516                 U.autokey_mode = 2;
1517         }
1518         if (U.savetime <= 0) {
1519                 U.savetime = 1;
1520 // XXX          error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
1521         }
1522         /* transform widget settings */
1523         if (U.tw_hotspot == 0) {
1524                 U.tw_hotspot = 14;
1525                 U.tw_size = 25;          /* percentage of window size */
1526                 U.tw_handlesize = 16;    /* percentage of widget radius */
1527         }
1528         if (U.pad_rot_angle == 0)
1529                 U.pad_rot_angle = 15;
1530         
1531         /* graph editor - unselected F-Curve visibility */
1532         if (U.fcu_inactive_alpha == 0) {
1533                 U.fcu_inactive_alpha = 0.25f;
1534         }
1535         
1536         /* signal for derivedmesh to use colorband */
1537         /* run in case this was on and is now off in the user prefs [#28096] */
1538         vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced);
1539
1540         if (bmain->versionfile <= 191) {
1541                 strcpy(U.sounddir, "/");
1542         }
1543         
1544         /* patch to set Dupli Armature */
1545         if (bmain->versionfile < 220) {
1546                 U.dupflag |= USER_DUP_ARM;
1547         }
1548         
1549         /* added seam, normal color, undo */
1550         if (bmain->versionfile <= 234) {
1551                 bTheme *btheme;
1552                 
1553                 U.uiflag |= USER_GLOBALUNDO;
1554                 if (U.undosteps == 0) U.undosteps = 32;
1555                 
1556                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1557                         /* check for (alpha == 0) is safe, then color was never set */
1558                         if (btheme->tv3d.edge_seam[3] == 0) {
1559                                 rgba_char_args_set(btheme->tv3d.edge_seam, 230, 150, 50, 255);
1560                         }
1561                         if (btheme->tv3d.normal[3] == 0) {
1562                                 rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
1563                         }
1564                         if (btheme->tv3d.vertex_normal[3] == 0) {
1565                                 rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
1566                         }
1567                         if (btheme->tv3d.face_dot[3] == 0) {
1568                                 rgba_char_args_set(btheme->tv3d.face_dot, 255, 138, 48, 255);
1569                                 btheme->tv3d.facedot_size = 4;
1570                         }
1571                 }
1572         }
1573         if (bmain->versionfile <= 235) {
1574                 /* illegal combo... */
1575                 if (U.flag & USER_LMOUSESELECT) 
1576                         U.flag &= ~USER_TWOBUTTONMOUSE;
1577         }
1578         if (bmain->versionfile <= 236) {
1579                 bTheme *btheme;
1580                 /* new space type */
1581                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1582                         /* check for (alpha == 0) is safe, then color was never set */
1583                         if (btheme->ttime.back[3] == 0) {
1584                                 /* copied from ui_theme_init_default */
1585                                 btheme->ttime = btheme->tv3d;
1586                                 rgba_char_args_set_fl(btheme->ttime.back,   0.45, 0.45, 0.45, 1.0);
1587                                 rgba_char_args_set_fl(btheme->ttime.grid,   0.36, 0.36, 0.36, 1.0);
1588                                 rgba_char_args_set(btheme->ttime.shade1,  173, 173, 173, 255);  /* sliders */
1589                         }
1590                         if (btheme->text.syntaxn[3] == 0) {
1591                                 rgba_char_args_set(btheme->text.syntaxn,    0, 0, 200, 255);    /* Numbers  Blue*/
1592                                 rgba_char_args_set(btheme->text.syntaxl,    100, 0, 0, 255);    /* Strings  red */
1593                                 rgba_char_args_set(btheme->text.syntaxc,    0, 100, 50, 255);   /* Comments greenish */
1594                                 rgba_char_args_set(btheme->text.syntaxv,    95, 95, 0, 255);    /* Special */
1595                                 rgba_char_args_set(btheme->text.syntaxb,    128, 0, 80, 255);   /* Builtin, red-purple */
1596                         }
1597                 }
1598         }
1599         if (bmain->versionfile <= 237) {
1600                 bTheme *btheme;
1601                 /* bone colors */
1602                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1603                         /* check for alpha==0 is safe, then color was never set */
1604                         if (btheme->tv3d.bone_solid[3] == 0) {
1605                                 rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255);
1606                                 rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80);
1607                         }
1608                 }
1609         }
1610         if (bmain->versionfile <= 238) {
1611                 bTheme *btheme;
1612                 /* bone colors */
1613                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1614                         /* check for alpha==0 is safe, then color was never set */
1615                         if (btheme->tnla.strip[3] == 0) {
1616                                 rgba_char_args_set(btheme->tnla.strip_select,   0xff, 0xff, 0xaa, 255);
1617                                 rgba_char_args_set(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
1618                         }
1619                 }
1620         }
1621         if (bmain->versionfile <= 239) {
1622                 bTheme *btheme;
1623                 
1624                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1625                         /* Lamp theme, check for alpha==0 is safe, then color was never set */
1626                         if (btheme->tv3d.lamp[3] == 0) {
1627                                 rgba_char_args_set(btheme->tv3d.lamp,   0, 0, 0, 40);
1628 /* TEMPORAL, remove me! (ton) */                                
1629                                 U.uiflag |= USER_PLAINMENUS;
1630                         }
1631                         
1632                 }
1633                 if (U.obcenter_dia == 0) U.obcenter_dia = 6;
1634         }
1635         if (bmain->versionfile <= 241) {
1636                 bTheme *btheme;
1637                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1638                         /* Node editor theme, check for alpha==0 is safe, then color was never set */
1639                         if (btheme->tnode.syntaxn[3] == 0) {
1640                                 /* re-uses syntax color storage */
1641                                 btheme->tnode = btheme->tv3d;
1642                                 rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255);
1643                                 rgba_char_args_set(btheme->tnode.syntaxl, 150, 150, 150, 255);  /* TH_NODE, backdrop */
1644                                 rgba_char_args_set(btheme->tnode.syntaxn, 129, 131, 144, 255);  /* in/output */
1645                                 rgba_char_args_set(btheme->tnode.syntaxb, 127, 127, 127, 255);  /* operator */
1646                                 rgba_char_args_set(btheme->tnode.syntaxv, 142, 138, 145, 255);  /* generator */
1647                                 rgba_char_args_set(btheme->tnode.syntaxc, 120, 145, 120, 255);  /* group */
1648                         }
1649                         /* Group theme colors */
1650                         if (btheme->tv3d.group[3] == 0) {
1651                                 rgba_char_args_set(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255);
1652                                 rgba_char_args_set(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
1653                         }
1654                         /* Sequence editor theme*/
1655                         if (btheme->tseq.movie[3] == 0) {
1656                                 rgba_char_args_set(btheme->tseq.movie,  81, 105, 135, 255);
1657                                 rgba_char_args_set(btheme->tseq.image,  109, 88, 129, 255);
1658                                 rgba_char_args_set(btheme->tseq.scene,  78, 152, 62, 255);
1659                                 rgba_char_args_set(btheme->tseq.audio,  46, 143, 143, 255);
1660                                 rgba_char_args_set(btheme->tseq.effect,     169, 84, 124, 255);
1661                                 rgba_char_args_set(btheme->tseq.transition, 162, 95, 111, 255);
1662                                 rgba_char_args_set(btheme->tseq.meta,   109, 145, 131, 255);
1663                         }
1664                 }
1665                 
1666                 /* set defaults for 3D View rotating axis indicator */ 
1667                 /* since size can't be set to 0, this indicates it's not saved in startup.blend */
1668                 if (U.rvisize == 0) {
1669                         U.rvisize = 15;
1670                         U.rvibright = 8;
1671                         U.uiflag |= USER_SHOW_ROTVIEWICON;
1672                 }
1673                 
1674         }
1675         if (bmain->versionfile <= 242) {
1676                 bTheme *btheme;
1677                 
1678                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1679                         /* long keyframe color */
1680                         /* check for alpha==0 is safe, then color was never set */
1681                         if (btheme->tact.strip[3] == 0) {
1682                                 rgba_char_args_set(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
1683                                 rgba_char_args_set(btheme->tact.strip_select,   0xff, 0xff, 0xaa, 204);
1684                                 rgba_char_args_set(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
1685                         }
1686                         
1687                         /* IPO-Editor - Vertex Size*/
1688                         if (btheme->tipo.vertex_size == 0) {
1689                                 btheme->tipo.vertex_size = 3;
1690                         }
1691                 }
1692         }
1693         if (bmain->versionfile <= 243) {
1694                 /* set default number of recently-used files (if not set) */
1695                 if (U.recent_files == 0) U.recent_files = 10;
1696         }
1697         if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
1698                 bTheme *btheme;
1699                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1700                         rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
1701                 }
1702                 if (U.coba_weight.tot == 0)
1703                         init_colorband(&U.coba_weight, true);
1704         }
1705         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
1706                 bTheme *btheme;
1707                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1708                         /* these should all use the same color */
1709                         rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
1710                         rgba_char_args_set(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
1711                         rgba_char_args_set(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
1712                         rgba_char_args_set(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
1713                         rgba_char_args_set(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
1714                         //rgba_char_args_set(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); Not needed anymore
1715                         rgba_char_args_set(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
1716                 }
1717         }
1718         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
1719                 bTheme *btheme;
1720                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1721                         /* action channel groups (recolor anyway) */
1722                         rgba_char_args_set(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
1723                         rgba_char_args_set(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
1724                         
1725                         /* bone custom-color sets */
1726                         if (btheme->tarm[0].solid[3] == 0)
1727                                 ui_theme_init_boneColorSets(btheme);
1728                 }
1729         }
1730         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
1731                 U.flag |= USER_ADD_VIEWALIGNED | USER_ADD_EDITMODE;
1732         }
1733         if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
1734                 bTheme *btheme;
1735                 
1736                 /* adjust themes */
1737                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1738                         char *col;
1739                         
1740                         /* IPO Editor: Handles/Vertices */
1741                         col = btheme->tipo.vertex;
1742                         rgba_char_args_set(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
1743                         col = btheme->tipo.vertex_select;
1744                         rgba_char_args_set(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
1745                         btheme->tipo.handle_vertex_size = btheme->tipo.vertex_size;
1746                         
1747                         /* Sequence/Image Editor: colors for GPencil text */
1748                         col = btheme->tv3d.bone_pose;
1749                         rgba_char_args_set(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
1750                         rgba_char_args_set(btheme->tima.bone_pose, col[0], col[1], col[2], 255);
1751                         col = btheme->tv3d.vertex_select;
1752                         rgba_char_args_set(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
1753                 }
1754         }
1755         if (bmain->versionfile < 250) {
1756                 bTheme *btheme;
1757                 
1758                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1759                         /* this was not properly initialized in 2.45 */
1760                         if (btheme->tima.face_dot[3] == 0) {
1761                                 rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128);
1762                                 rgba_char_args_set(btheme->tima.face_dot, 255, 133, 0, 255);
1763                                 btheme->tima.facedot_size = 2;
1764                         }
1765                         
1766                         /* DopeSheet - (Object) Channel color */
1767                         rgba_char_args_set(btheme->tact.ds_channel,     82, 96, 110, 255);
1768                         rgba_char_args_set(btheme->tact.ds_subchannel,  124, 137, 150, 255);
1769                         /* DopeSheet - Group Channel color (saner version) */
1770                         rgba_char_args_set(btheme->tact.group, 79, 101, 73, 255);
1771                         rgba_char_args_set(btheme->tact.group_active, 135, 177, 125, 255);
1772                         
1773                         /* Graph Editor - (Object) Channel color */
1774                         rgba_char_args_set(btheme->tipo.ds_channel,     82, 96, 110, 255);
1775                         rgba_char_args_set(btheme->tipo.ds_subchannel,  124, 137, 150, 255);
1776                         /* Graph Editor - Group Channel color */
1777                         rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255);
1778                         rgba_char_args_set(btheme->tipo.group_active, 135, 177, 125, 255);
1779                         
1780                         /* Nla Editor - (Object) Channel color */
1781                         rgba_char_args_set(btheme->tnla.ds_channel,     82, 96, 110, 255);
1782                         rgba_char_args_set(btheme->tnla.ds_subchannel,  124, 137, 150, 255);
1783                         /* NLA Editor - New Strip colors */
1784                         rgba_char_args_set(btheme->tnla.strip,          12, 10, 10, 128);
1785                         rgba_char_args_set(btheme->tnla.strip_select,   255, 140, 0, 255);
1786                 }
1787                 
1788                 /* adjust grease-pencil distances */
1789                 U.gp_manhattendist = 1;
1790                 U.gp_euclideandist = 2;
1791                 
1792                 /* adjust default interpolation for new IPO-curves */
1793                 U.ipo_new = BEZT_IPO_BEZ;
1794         }
1795         
1796         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
1797                 bTheme *btheme;
1798
1799                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1800                         
1801                         /* common (new) variables, it checks for alpha==0 */
1802                         ui_theme_init_new(btheme);
1803
1804                         if (btheme->tui.wcol_num.outline[3] == 0)
1805                                 ui_widget_color_init(&btheme->tui);
1806                         
1807                         /* Logic editor theme, check for alpha==0 is safe, then color was never set */
1808                         if (btheme->tlogic.syntaxn[3] == 0) {
1809                                 /* re-uses syntax color storage */
1810                                 btheme->tlogic = btheme->tv3d;
1811                                 rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
1812                         }
1813
1814                         rgba_char_args_set_fl(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
1815                         rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
1816                 }
1817         }
1818
1819         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
1820                 /* new audio system */
1821                 if (U.audiochannels == 0)
1822                         U.audiochannels = 2;
1823                 if (U.audiodevice == 0) {
1824 #ifdef WITH_OPENAL
1825                         U.audiodevice = 2;
1826 #endif
1827 #ifdef WITH_SDL
1828                         U.audiodevice = 1;
1829 #endif
1830                 }
1831                 if (U.audioformat == 0)
1832                         U.audioformat = 0x24;
1833                 if (U.audiorate == 0)
1834                         U.audiorate = 44100;
1835         }
1836
1837         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
1838                 U.gameflags |= USER_DISABLE_VBO;
1839         
1840         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
1841                 wmKeyMap *km;
1842                 
1843                 for (km = U.user_keymaps.first; km; km = km->next) {
1844                         if (strcmp(km->idname, "Armature_Sketch") == 0)
1845                                 strcpy(km->idname, "Armature Sketch");
1846                         else if (strcmp(km->idname, "View3D") == 0)
1847                                 strcpy(km->idname, "3D View");
1848                         else if (strcmp(km->idname, "View3D Generic") == 0)
1849                                 strcpy(km->idname, "3D View Generic");
1850                         else if (strcmp(km->idname, "EditMesh") == 0)
1851                                 strcpy(km->idname, "Mesh");
1852                         else if (strcmp(km->idname, "TimeLine") == 0)
1853                                 strcpy(km->idname, "Timeline");
1854                         else if (strcmp(km->idname, "UVEdit") == 0)
1855                                 strcpy(km->idname, "UV Editor");
1856                         else if (strcmp(km->idname, "Animation_Channels") == 0)
1857                                 strcpy(km->idname, "Animation Channels");
1858                         else if (strcmp(km->idname, "GraphEdit Keys") == 0)
1859                                 strcpy(km->idname, "Graph Editor");
1860                         else if (strcmp(km->idname, "GraphEdit Generic") == 0)
1861                                 strcpy(km->idname, "Graph Editor Generic");
1862                         else if (strcmp(km->idname, "Action_Keys") == 0)
1863                                 strcpy(km->idname, "Dopesheet");
1864                         else if (strcmp(km->idname, "NLA Data") == 0)
1865                                 strcpy(km->idname, "NLA Editor");
1866                         else if (strcmp(km->idname, "Node Generic") == 0)
1867                                 strcpy(km->idname, "Node Editor");
1868                         else if (strcmp(km->idname, "Logic Generic") == 0)
1869                                 strcpy(km->idname, "Logic Editor");
1870                         else if (strcmp(km->idname, "File") == 0)
1871                                 strcpy(km->idname, "File Browser");
1872                         else if (strcmp(km->idname, "FileMain") == 0)
1873                                 strcpy(km->idname, "File Browser Main");
1874                         else if (strcmp(km->idname, "FileButtons") == 0)
1875                                 strcpy(km->idname, "File Browser Buttons");
1876                         else if (strcmp(km->idname, "Buttons Generic") == 0)
1877                                 strcpy(km->idname, "Property Editor");
1878                 }
1879         }
1880         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
1881                 if (U.wmdrawmethod == USER_DRAW_TRIPLE)
1882                         U.wmdrawmethod = USER_DRAW_AUTOMATIC;
1883         }
1884         
1885         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
1886                 if (U.flag & USER_LMOUSESELECT) 
1887                         U.flag &= ~USER_TWOBUTTONMOUSE;
1888         }
1889         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
1890                 bTheme *btheme;
1891                 
1892                 /* default new handle type is auto handles */
1893                 U.keyhandles_new = HD_AUTO;
1894                 
1895                 /* init new curve colors */
1896                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1897                         ui_theme_space_init_handles_color(&btheme->tv3d);
1898                         ui_theme_space_init_handles_color(&btheme->tipo);
1899
1900                         /* edge crease */
1901                         rgba_char_args_set_fl(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
1902                 }
1903         }
1904         if (bmain->versionfile <= 252) {
1905                 bTheme *btheme;
1906
1907                 /* init new curve colors */
1908                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1909                         if (btheme->tv3d.lastsel_point[3] == 0)
1910                                 rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
1911                 }
1912         }
1913         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
1914                 bTheme *btheme;
1915                 
1916                 /* interface_widgets.c */
1917                 struct uiWidgetColors wcol_progress = {
1918                         {0, 0, 0, 255},
1919                         {190, 190, 190, 255},
1920                         {100, 100, 100, 180},
1921                         {68, 68, 68, 255},
1922                         
1923                         {0, 0, 0, 255},
1924                         {255, 255, 255, 255},
1925                         
1926                         0,
1927                         5, -5
1928                 };
1929                 
1930                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1931                         /* init progress bar theme */
1932                         btheme->tui.wcol_progress = wcol_progress;
1933                 }
1934         }
1935
1936         if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
1937                 bTheme *btheme;
1938                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1939                         rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
1940                         rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
1941                         rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
1942                 }
1943         }
1944         
1945         if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) {
1946                 bTheme *btheme;
1947                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1948                         if ((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width = 1;
1949                 }
1950         }
1951
1952         if (bmain->versionfile < 257) {
1953                 /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs,
1954                  * so that it doesn't linger around from old configs like a ghost */
1955                 U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
1956         }
1957
1958         if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 2)) {
1959                 bTheme *btheme;
1960                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1961                         btheme->tnode.noodle_curving = 5;
1962                 }
1963         }
1964
1965         if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
1966                 bTheme *btheme;
1967                 
1968                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1969                         btheme->tv3d.speaker[3] = 255;
1970                 }
1971         }
1972
1973         if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 3)) {
1974                 bTheme *btheme;
1975                 
1976                 /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead 
1977                  * was changed in 260 as part of GSoC11, but version patch was wrong
1978                  */
1979                 if (U.keyhandles_new == HD_AUTO) 
1980                         U.keyhandles_new = HD_AUTO_ANIM;
1981                 
1982                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
1983                         if (btheme->tv3d.bundle_solid[3] == 0)
1984                                 rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
1985                         
1986                         if (btheme->tv3d.camera_path[3] == 0)
1987                                 rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
1988                                 
1989                         if ((btheme->tclip.back[3]) == 0) {
1990                                 btheme->tclip = btheme->tv3d;
1991                                 
1992                                 rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
1993                                 rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
1994                                 rgba_char_args_set(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
1995                                 rgba_char_args_set(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
1996                                 rgba_char_args_set(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
1997                                 rgba_char_args_set(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
1998                                 rgba_char_args_set(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
1999                                 rgba_char_args_set(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
2000                                 rgba_char_args_set(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
2001                                 rgba_char_args_set(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
2002                                 rgba_char_args_set(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
2003                                 rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
2004                                 btheme->tclip.handle_vertex_size = 5;
2005                         }
2006                         
2007                         /* auto-clamped handles -> based on auto */
2008                         if (btheme->tipo.handle_auto_clamped[3] == 0)
2009                                 rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
2010                         if (btheme->tipo.handle_sel_auto_clamped[3] == 0)
2011                                 rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
2012                 }
2013                 
2014                 /* enable (Cycles) addon by default */
2015                 if (!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) {
2016                         bAddon *baddon = MEM_callocN(sizeof(bAddon), "bAddon");
2017                         BLI_strncpy(baddon->module, "cycles", sizeof(baddon->module));
2018                         BLI_addtail(&U.addons, baddon);
2019                 }
2020         }
2021         
2022         if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) {
2023                 bTheme *btheme;
2024                 
2025                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2026                         rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
2027                         btheme->tui.icon_alpha = 1.0;
2028                 }
2029         }
2030         
2031         if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 4)) {
2032                 bTheme *btheme;
2033                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2034                         rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.071, 0.259, 0.694, 0.150);
2035                         rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.522, 0.0, 0.7);
2036                         rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 1.0, 0.522, 0.0, 0.5);
2037                         rgba_char_args_set_fl(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0);
2038                         rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0);
2039                         rgba_char_args_set_fl(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140);
2040                         
2041                         rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3);
2042                         rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
2043                 }
2044                 
2045                 U.use_16bit_textures = true;
2046         }
2047
2048         if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
2049                 bTheme *btheme;
2050                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2051                         if (btheme->tui.wcol_menu_item.item[3] == 255)
2052                                 rgba_char_args_set(btheme->tui.wcol_menu_item.item, 172, 172, 172, 128);
2053                 }
2054         }
2055
2056         if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
2057                 bTheme *btheme;
2058                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2059                         if (btheme->tui.wcol_tooltip.inner[3] == 0) {
2060                                 btheme->tui.wcol_tooltip = btheme->tui.wcol_menu_back;
2061                         }
2062                         if (btheme->tui.wcol_tooltip.text[0] == 160) { /* hrmf */
2063                                 rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255);
2064                         }
2065                 }
2066         }
2067
2068         if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
2069                 bTheme *btheme;
2070                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2071                         if (btheme->tseq.movieclip[3] == 0) {
2072                                 rgba_char_args_set(btheme->tseq.movieclip,  32, 32, 143, 255);
2073                         }
2074                 }
2075         }
2076
2077         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) {
2078                 bTheme *btheme;
2079                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2080                         if (btheme->tclip.strip[0] == 0) {
2081                                 rgba_char_args_set(btheme->tclip.list, 0x66, 0x66, 0x66, 0xff);
2082                                 rgba_char_args_set(btheme->tclip.strip, 0x0c, 0x0a, 0x0a, 0x80);
2083                                 rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff);
2084                         }
2085                 }
2086         }
2087
2088         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 6)) {
2089                 bTheme *btheme;
2090                 for (btheme = U.themes.first; btheme; btheme = btheme->next)
2091                         rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
2092         }
2093         
2094         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
2095                 bTheme *btheme;
2096                 
2097                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2098                         /* DopeSheet Summary */
2099                         rgba_char_args_set(btheme->tact.anim_active,    204, 112, 26, 102); 
2100                         
2101                         /* NLA Colors */
2102                         rgba_char_args_set(btheme->tnla.anim_active,     204, 112, 26, 102); /* same as dopesheet above */
2103                         rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
2104                         
2105                         rgba_char_args_set(btheme->tnla.nla_tweaking,   77, 243, 26, 77);
2106                         rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
2107                         
2108                         rgba_char_args_set(btheme->tnla.nla_transition,     28, 38, 48, 255);
2109                         rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
2110                         rgba_char_args_set(btheme->tnla.nla_meta,           51, 38, 66, 255);
2111                         rgba_char_args_set(btheme->tnla.nla_meta_sel,       105, 33, 150, 255);
2112                         rgba_char_args_set(btheme->tnla.nla_sound,          43, 61, 61, 255);
2113                         rgba_char_args_set(btheme->tnla.nla_sound_sel,      31, 122, 122, 255);
2114                 }
2115         }
2116
2117         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
2118                 bTheme *btheme;
2119                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2120                         if (btheme->tseq.mask[3] == 0) {
2121                                 rgba_char_args_set(btheme->tseq.mask,  152, 78, 62, 255);
2122                         }
2123                 }
2124         }
2125
2126         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 15)) {
2127                 bTheme *btheme;
2128                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2129                         rgba_char_args_set(btheme->tv3d.bone_pose_active, 140, 255, 255, 80);
2130                 }
2131         }
2132
2133         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 16)) {
2134                 bTheme *btheme;
2135
2136                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2137                         if (btheme->tact.anim_active[3] == 0)
2138                                 rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102);
2139
2140                         if (btheme->tnla.anim_active[3] == 0)
2141                                 rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102);
2142                 }
2143         }
2144
2145         if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 22)) {
2146                 bTheme *btheme;
2147
2148                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2149                         if (btheme->tipo.lastsel_point[3] == 0)
2150                                 rgba_char_args_set(btheme->tipo.lastsel_point, 0xff, 0xff, 0xff, 255);
2151
2152                         if (btheme->tv3d.skin_root[3] == 0)
2153                                 rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
2154                 }
2155         }
2156         
2157         if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 9)) {
2158                 bTheme *btheme;
2159                 
2160                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2161                         rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
2162                         rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
2163                         rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
2164                 }
2165         }
2166
2167         if (U.versionfile < 267) {
2168                 /* Freestyle color settings */
2169                 bTheme *btheme;
2170
2171                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2172                         /* check for alpha == 0 is safe, then color was never set */
2173                         if (btheme->tv3d.freestyle_edge_mark[3] == 0) {
2174                                 rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
2175                                 rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
2176                         }
2177
2178                         if (btheme->tv3d.wire_edit[3] == 0) {
2179                                 rgba_char_args_set(btheme->tv3d.wire_edit,  0x0, 0x0, 0x0, 255);
2180                         }
2181                 }
2182
2183                 /* GL Texture Garbage Collection */
2184                 if (U.textimeout == 0) {
2185                         U.texcollectrate = 60;
2186                         U.textimeout = 120;
2187                 }
2188                 if (U.memcachelimit <= 0) {
2189                         U.memcachelimit = 32;
2190                 }
2191                 if (U.frameserverport == 0) {
2192                         U.frameserverport = 8080;
2193                 }
2194                 if (U.dbl_click_time == 0) {
2195                         U.dbl_click_time = 350;
2196                 }
2197                 if (U.scrcastfps == 0) {
2198                         U.scrcastfps = 10;
2199                         U.scrcastwait = 50;
2200                 }
2201                 if (U.v2d_min_gridsize == 0) {
2202                         U.v2d_min_gridsize = 35;
2203                 }
2204                 if (U.dragthreshold == 0)
2205                         U.dragthreshold = 5;
2206                 if (U.widget_unit == 0)
2207                         U.widget_unit = 20;
2208                 if (U.anisotropic_filter <= 0)
2209                         U.anisotropic_filter = 1;
2210
2211                 if (U.ndof_sensitivity == 0.0f) {
2212                         U.ndof_sensitivity = 1.0f;
2213                         U.ndof_flag = (NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE);
2214                 }
2215                 
2216                 if (U.ndof_orbit_sensitivity == 0.0f) {
2217                         U.ndof_orbit_sensitivity = U.ndof_sensitivity;
2218
2219                         if (!(U.flag & USER_TRACKBALL))
2220                                 U.ndof_flag |= NDOF_TURNTABLE;
2221                 }
2222                 if (U.tweak_threshold == 0)
2223                         U.tweak_threshold = 10;
2224         }
2225
2226         if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 1)) {
2227                 bTheme *btheme;
2228                 
2229                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2230                         /* note: the toggle operator for transparent backdrops limits to these spacetypes */
2231                         if (btheme->tnode.button[3] == 255) {
2232                                 btheme->tv3d.button[3] = 128;
2233                                 btheme->tnode.button[3] = 128;
2234                                 btheme->tima.button[3] = 128;
2235                                 btheme->tseq.button[3] = 128;
2236                                 btheme->tclip.button[3] = 128;
2237                         }
2238                 }
2239         }
2240         
2241         /* panel header/backdrop supported locally per editor now */
2242         if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 2)) {
2243                 bTheme *btheme;
2244                 
2245                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2246                         ThemeSpace *ts;
2247                         
2248                         /* new color, panel backdrop. Not used anywhere yet, until you enable it */
2249                         copy_v3_v3_char(btheme->tui.panel.back, btheme->tbuts.button);
2250                         btheme->tui.panel.back[3] = 128;
2251                         
2252                         for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) {
2253                                 ts->panelcolors = btheme->tui.panel;
2254                         }
2255                 }
2256         }
2257
2258         /* NOTE!! from now on use U.versionfile and U.subversionfile */
2259         if (U.versionfile < 266) {
2260                 bTheme *btheme;
2261                 
2262                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2263                         /* rna definition limits fac to 0.01 */
2264                         if (btheme->tui.menu_shadow_fac == 0.0f) {
2265                                 btheme->tui.menu_shadow_fac = 0.5f;
2266                                 btheme->tui.menu_shadow_width = 12;
2267                         }
2268                 }
2269         }
2270
2271         if (U.versionfile < 265 || (U.versionfile == 265 && U.subversionfile < 4)) {
2272                 bTheme *btheme;
2273                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2274                         rgba_char_args_set(btheme->text.syntaxd,    50, 0, 140, 255);   /* Decorator/Preprocessor Dir.  Blue-purple */
2275                         rgba_char_args_set(btheme->text.syntaxr,    140, 60, 0, 255);   /* Reserved  Orange */
2276                         rgba_char_args_set(btheme->text.syntaxs,    76, 76, 76, 255);   /* Grey (mix between fg/bg) */
2277                 }
2278         }
2279
2280         if (U.versionfile < 265 || (U.versionfile == 265 && U.subversionfile < 6)) {
2281                 bTheme *btheme;
2282                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2283                         copy_v4_v4_char(btheme->tv3d.gradients.high_gradient, btheme->tv3d.back);
2284                 }
2285         }
2286
2287         if (U.versionfile < 265 || (U.versionfile == 265 && U.subversionfile < 9)) {
2288                 bTheme *btheme;
2289                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2290                         rgba_char_args_test_set(btheme->tnode.syntaxs, 151, 116, 116, 255);  /* matte nodes */
2291                         rgba_char_args_test_set(btheme->tnode.syntaxd, 116, 151, 151, 255);  /* distort nodes */
2292                 }
2293         }
2294
2295         if (U.versionfile < 265 || (U.versionfile == 265 && U.subversionfile < 11)) {
2296                 bTheme *btheme;
2297                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2298                         rgba_char_args_test_set(btheme->tconsole.console_select, 255, 255, 255, 48);
2299                 }
2300         }
2301
2302         if (U.versionfile < 266 || (U.versionfile == 266 && U.subversionfile < 2)) {
2303                 bTheme *btheme;
2304                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2305                         rgba_char_args_test_set(btheme->tnode.console_output, 223, 202, 53, 255);  /* interface nodes */
2306                 }
2307         }
2308
2309         /* NOTE!! from now on use U.versionfile and U.subversionfile */
2310
2311         if (U.versionfile < 268 || (U.versionfile == 268 && U.subversionfile < 3)) {
2312                 bTheme *btheme;
2313                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2314                         rgba_char_args_test_set(btheme->tima.uv_others, 96, 96, 96, 255);
2315                         rgba_char_args_test_set(btheme->tima.uv_shadow, 112, 112, 112, 255);
2316                 }
2317         }
2318
2319         if (U.versionfile < 269 || (U.versionfile == 269 && U.subversionfile < 5)) {
2320                 bTheme *btheme;
2321                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2322                         rgba_char_args_set(btheme->tima.wire_edit, 192, 192, 192, 255);
2323                         rgba_char_args_set(btheme->tima.edge_select, 255, 133, 0, 255);
2324                 }
2325         }
2326
2327         if (U.versionfile < 269 || (U.versionfile == 269 && U.subversionfile < 6)) {
2328                 bTheme *btheme;
2329                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2330                         char r, g, b;
2331                         r = btheme->tnode.syntaxn[0];
2332                         g = btheme->tnode.syntaxn[1];
2333                         b = btheme->tnode.syntaxn[2];
2334                         rgba_char_args_test_set(btheme->tnode.nodeclass_output, r, g, b, 255);
2335                         r = btheme->tnode.syntaxb[0];
2336                         g = btheme->tnode.syntaxb[1];
2337                         b = btheme->tnode.syntaxb[2];
2338                         rgba_char_args_test_set(btheme->tnode.nodeclass_filter, r, g, b, 255);
2339                         rgba_char_args_test_set(btheme->tnode.nodeclass_vector, r, g, b, 255);
2340                         rgba_char_args_test_set(btheme->tnode.nodeclass_texture, r, g, b, 255);
2341                         rgba_char_args_test_set(btheme->tnode.nodeclass_shader, r, g, b, 255);
2342                         rgba_char_args_test_set(btheme->tnode.nodeclass_script, r, g, b, 255);
2343                         rgba_char_args_test_set(btheme->tnode.nodeclass_pattern, r, g, b, 255);
2344                         rgba_char_args_test_set(btheme->tnode.nodeclass_layout, r, g, b, 255);
2345                 }
2346         }
2347
2348         if (U.versionfile < 269 || (U.versionfile == 269 && U.subversionfile < 8)) {
2349                 bTheme *btheme;
2350                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2351                         rgba_char_args_test_set(btheme->tinfo.info_selected, 96, 128, 255, 255);
2352                         rgba_char_args_test_set(btheme->tinfo.info_selected_text, 255, 255, 255, 255);
2353                         rgba_char_args_test_set(btheme->tinfo.info_error, 220, 0, 0, 255);
2354                         rgba_char_args_test_set(btheme->tinfo.info_error_text, 0, 0, 0, 255);
2355                         rgba_char_args_test_set(btheme->tinfo.info_warning, 220, 128, 96, 255);
2356                         rgba_char_args_test_set(btheme->tinfo.info_warning_text, 0, 0, 0, 255);
2357                         rgba_char_args_test_set(btheme->tinfo.info_info, 0, 170, 0, 255);
2358                         rgba_char_args_test_set(btheme->tinfo.info_info_text, 0, 0, 0, 255);
2359                         rgba_char_args_test_set(btheme->tinfo.info_debug, 196, 196, 196, 255);
2360                         rgba_char_args_test_set(btheme->tinfo.info_debug_text, 0, 0, 0, 255);
2361                 }
2362         }
2363         
2364         if (U.versionfile < 269 || (U.versionfile == 269 && U.subversionfile < 9)) {
2365                 bTheme *btheme;
2366                 
2367                 U.tw_size = U.tw_size * 5.0f;
2368                 
2369                 /* Action Editor (and NLA Editor) - Keyframe Colors */
2370                 /* Graph Editor - larger vertex size defaults */
2371                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2372                         /* Action Editor ................. */
2373                         /* key types */
2374                         rgba_char_args_set(btheme->tact.keytype_keyframe,           232, 232, 232, 255);
2375                         rgba_char_args_set(btheme->tact.keytype_keyframe_select,    255, 190,  50, 255);
2376                         rgba_char_args_set(btheme->tact.keytype_extreme,            232, 179, 204, 255);
2377                         rgba_char_args_set(btheme->tact.keytype_extreme_select,     242, 128, 128, 255);
2378                         rgba_char_args_set(btheme->tact.keytype_breakdown,          179, 219, 232, 255);
2379                         rgba_char_args_set(btheme->tact.keytype_breakdown_select,    84, 191, 237, 255);
2380                         rgba_char_args_set(btheme->tact.keytype_jitter,             148, 229, 117, 255);
2381                         rgba_char_args_set(btheme->tact.keytype_jitter_select,       97, 192,  66, 255);
2382                         
2383                         /* key border */
2384                         rgba_char_args_set(btheme->tact.keyborder,                   0,   0,   0, 255);
2385                         rgba_char_args_set(btheme->tact.keyborder_select,        0,   0,   0, 255);
2386                         
2387                         /* NLA ............................ */
2388                         /* key border */
2389                         rgba_char_args_set(btheme->tnla.keyborder,                   0,   0,   0, 255);
2390                         rgba_char_args_set(btheme->tnla.keyborder_select,        0,   0,   0, 255);
2391                         
2392                         /* Graph Editor ................... */
2393                         btheme->tipo.vertex_size = 6;
2394                         btheme->tipo.handle_vertex_size = 5;
2395                 }
2396                 
2397                 /* grease pencil - new layer color */
2398                 if (U.gpencil_new_layer_col[3] < 0.1f) {
2399                         /* defaults to black, but must at least be visible! */
2400                         U.gpencil_new_layer_col[3] = 0.9f;
2401                 }
2402         }
2403
2404         if (U.versionfile < 269 || (U.versionfile == 269 && U.subversionfile < 10)) {
2405                 bTheme *btheme;
2406                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2407                         ThemeSpace *ts;
2408
2409                         for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) {
2410                                 rgba_char_args_set(ts->tab_active, 114, 114, 114, 255);
2411                                 rgba_char_args_set(ts->tab_inactive, 83, 83, 83, 255);
2412                                 rgba_char_args_set(ts->tab_back, 64, 64, 64, 255);
2413                                 rgba_char_args_set(ts->tab_outline, 60, 60, 60, 255);
2414                         }
2415                 }
2416         }
2417
2418         {
2419                 bTheme *btheme;
2420                 for (btheme = U.themes.first; btheme; btheme = btheme->next) {
2421                         ui_theme_space_init_handles_color(&btheme->tclip);
2422                         ui_theme_space_init_handles_color(&btheme->tima);
2423                         btheme->tima.handle_vertex_size = 5;
2424                         btheme->tclip.handle_vertex_size = 5;
2425                 }
2426         }
2427
2428         if (U.pixelsize == 0.0f)
2429                 U.pixelsize = 1.0f;
2430         
2431         if (U.image_draw_method == 0)
2432                 U.image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
2433         
2434         /* funny name, but it is GE stuff, moves userdef stuff to engine */
2435 // XXX  space_set_commmandline_options();
2436         /* this timer uses U */
2437 // XXX  reset_autosave();
2438
2439 }
2440
2441 /**
2442  * Override values in in-memory startup.blend, avoids resaving for small changes.
2443  */
2444 void init_userdef_factory(void)
2445 {
2446         /* defaults from T37518 */
2447
2448         U.uiflag |= USER_AUTOPERSP;
2449         U.uiflag |= USER_ZBUF_CURSOR;
2450         U.uiflag |= USER_QUIT_PROMPT;
2451         U.uiflag |= USER_CONTINUOUS_MOUSE;
2452
2453         U.versions = 1;
2454         U.savetime = 2;
2455
2456         {
2457                 Mesh *me;
2458                 for (me = G.main->mesh.first; me; me = me->id.next) {
2459                         me->flag &= ~ME_TWOSIDED;
2460                 }
2461         }
2462 }