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