eaa3da8c3050391dc9e69c5ee41b316870084ac9
[blender.git] / source / blender / editors / interface / resources.c
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19
20 /** \file
21  * \ingroup edinterface
22  */
23
24 #include <math.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 #include "MEM_guardedalloc.h"
29
30 #include "DNA_screen_types.h"
31 #include "DNA_space_types.h"
32 #include "DNA_userdef_types.h"
33
34 #include "BLI_blenlib.h"
35 #include "BLI_utildefines.h"
36 #include "BLI_math.h"
37
38 #include "BKE_addon.h"
39 #include "BKE_appdir.h"
40 #include "BKE_main.h"
41 #include "BKE_mesh_runtime.h"
42
43 #include "BLO_readfile.h"  /* for UserDef version patching. */
44
45 #include "BLF_api.h"
46
47 #include "ED_screen.h"
48
49 #include "UI_interface.h"
50 #include "UI_interface_icons.h"
51
52 #include "interface_intern.h"
53 #include "GPU_framebuffer.h"
54
55 /* global for themes */
56 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
57
58 /* be sure to keep 'bThemeState' in sync */
59 static struct bThemeState g_theme_state = {
60     NULL,
61     SPACE_VIEW3D,
62     RGN_TYPE_WINDOW,
63 };
64
65 #define theme_active g_theme_state.theme
66 #define theme_spacetype g_theme_state.spacetype
67 #define theme_regionid g_theme_state.regionid
68
69 void ui_resources_init(void)
70 {
71         UI_icons_init();
72 }
73
74 void ui_resources_free(void)
75 {
76         UI_icons_free();
77 }
78
79
80 /* ******************************************************** */
81 /*    THEMES */
82 /* ******************************************************** */
83
84 const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
85 {
86         ThemeSpace *ts = NULL;
87         static char error[4] = {240, 0, 240, 255};
88         static char alert[4] = {240, 60, 60, 255};
89         static char headerdesel[4] = {0, 0, 0, 255};
90         static char back[4] = {0, 0, 0, 255};
91         static char setting = 0;
92         const char *cp = error;
93
94         /* ensure we're not getting a color after running BKE_blender_userdef_free */
95         BLI_assert(BLI_findindex(&U.themes, theme_active) != -1);
96         BLI_assert(colorid != TH_UNDEFINED);
97
98         if (btheme) {
99
100                 /* first check for ui buttons theme */
101                 if (colorid < TH_THEMEUI) {
102
103                         switch (colorid) {
104
105                                 case TH_REDALERT:
106                                         cp = alert; break;
107                         }
108                 }
109                 else {
110
111                         switch (spacetype) {
112                                 case SPACE_PROPERTIES:
113                                         ts = &btheme->space_properties;
114                                         break;
115                                 case SPACE_VIEW3D:
116                                         ts = &btheme->space_view3d;
117                                         break;
118                                 case SPACE_GRAPH:
119                                         ts = &btheme->space_graph;
120                                         break;
121                                 case SPACE_FILE:
122                                         ts = &btheme->space_file;
123                                         break;
124                                 case SPACE_NLA:
125                                         ts = &btheme->space_nla;
126                                         break;
127                                 case SPACE_ACTION:
128                                         ts = &btheme->space_action;
129                                         break;
130                                 case SPACE_SEQ:
131                                         ts = &btheme->space_sequencer;
132                                         break;
133                                 case SPACE_IMAGE:
134                                         ts = &btheme->space_image;
135                                         break;
136                                 case SPACE_TEXT:
137                                         ts = &btheme->space_text;
138                                         break;
139                                 case SPACE_OUTLINER:
140                                         ts = &btheme->space_outliner;
141                                         break;
142                                 case SPACE_INFO:
143                                         ts = &btheme->space_info;
144                                         break;
145                                 case SPACE_USERPREF:
146                                         ts = &btheme->space_preferences;
147                                         break;
148                                 case SPACE_CONSOLE:
149                                         ts = &btheme->space_console;
150                                         break;
151                                 case SPACE_NODE:
152                                         ts = &btheme->space_node;
153                                         break;
154                                 case SPACE_CLIP:
155                                         ts = &btheme->space_clip;
156                                         break;
157                                 case SPACE_TOPBAR:
158                                         ts = &btheme->space_topbar;
159                                         break;
160                                 case SPACE_STATUSBAR:
161                                         ts = &btheme->space_statusbar;
162                                         break;
163                                 default:
164                                         ts = &btheme->space_view3d;
165                                         break;
166                         }
167
168                         switch (colorid) {
169                                 case TH_BACK:
170                                         if (ELEM(theme_regionid, RGN_TYPE_WINDOW, RGN_TYPE_PREVIEW))
171                                                 cp = ts->back;
172                                         else if (theme_regionid == RGN_TYPE_CHANNELS)
173                                                 cp = ts->list;
174                                         else if (theme_regionid == RGN_TYPE_HEADER)
175                                                 cp = ts->header;
176                                         else if (theme_regionid == RGN_TYPE_NAV_BAR)
177                                                 cp = ts->navigation_bar;
178                                         else if (theme_regionid == RGN_TYPE_EXECUTE)
179                                                 cp = ts->execution_buts;
180                                         else
181                                                 cp = ts->button;
182
183                                         copy_v4_v4_char(back, cp);
184                                         if (!ED_region_is_overlap(spacetype, theme_regionid)) {
185                                                 back[3] = 255;
186                                         }
187                                         cp = back;
188                                         break;
189                                 case TH_BACK_GRAD:
190                                         cp = ts->back_grad;
191                                         break;
192
193                                 case TH_SHOW_BACK_GRAD:
194                                         cp = &setting;
195                                         setting = ts->show_back_grad;
196                                         break;
197                                 case TH_TEXT:
198                                         if (theme_regionid == RGN_TYPE_WINDOW)
199                                                 cp = ts->text;
200                                         else if (theme_regionid == RGN_TYPE_CHANNELS)
201                                                 cp = ts->list_text;
202                                         else if (theme_regionid == RGN_TYPE_HEADER)
203                                                 cp = ts->header_text;
204                                         else
205                                                 cp = ts->button_text;
206                                         break;
207                                 case TH_TEXT_HI:
208                                         if (theme_regionid == RGN_TYPE_WINDOW)
209                                                 cp = ts->text_hi;
210                                         else if (theme_regionid == RGN_TYPE_CHANNELS)
211                                                 cp = ts->list_text_hi;
212                                         else if (theme_regionid == RGN_TYPE_HEADER)
213                                                 cp = ts->header_text_hi;
214                                         else
215                                                 cp = ts->button_text_hi;
216                                         break;
217                                 case TH_TITLE:
218                                         if (theme_regionid == RGN_TYPE_WINDOW)
219                                                 cp = ts->title;
220                                         else if (theme_regionid == RGN_TYPE_CHANNELS)
221                                                 cp = ts->list_title;
222                                         else if (theme_regionid == RGN_TYPE_HEADER)
223                                                 cp = ts->header_title;
224                                         else
225                                                 cp = ts->button_title;
226                                         break;
227
228                                 case TH_HEADER:
229                                         cp = ts->header; break;
230                                 case TH_HEADERDESEL:
231                                         /* we calculate a dynamic builtin header deselect color,
232                                          * also for pulldowns... */
233                                         cp = ts->header;
234                                         headerdesel[0] = cp[0] > 10 ? cp[0] - 10 : 0;
235                                         headerdesel[1] = cp[1] > 10 ? cp[1] - 10 : 0;
236                                         headerdesel[2] = cp[2] > 10 ? cp[2] - 10 : 0;
237                                         headerdesel[3] = cp[3];
238                                         cp = headerdesel;
239                                         break;
240                                 case TH_HEADER_TEXT:
241                                         cp = ts->header_text; break;
242                                 case TH_HEADER_TEXT_HI:
243                                         cp = ts->header_text_hi; break;
244
245                                 case TH_PANEL_HEADER:
246                                         cp = ts->panelcolors.header; break;
247                                 case TH_PANEL_BACK:
248                                         cp = ts->panelcolors.back; break;
249                                 case TH_PANEL_SUB_BACK:
250                                         cp = ts->panelcolors.sub_back; break;
251
252                                 case TH_BUTBACK:
253                                         cp = ts->button; break;
254                                 case TH_BUTBACK_TEXT:
255                                         cp = ts->button_text; break;
256                                 case TH_BUTBACK_TEXT_HI:
257                                         cp = ts->button_text_hi; break;
258
259                                 case TH_TAB_ACTIVE:
260                                         cp = ts->tab_active; break;
261                                 case TH_TAB_INACTIVE:
262                                         cp = ts->tab_inactive; break;
263                                 case TH_TAB_BACK:
264                                         cp = ts->tab_back; break;
265                                 case TH_TAB_OUTLINE:
266                                         cp = ts->tab_outline; break;
267
268                                 case TH_SHADE1:
269                                         cp = ts->shade1; break;
270                                 case TH_SHADE2:
271                                         cp = ts->shade2; break;
272                                 case TH_HILITE:
273                                         cp = ts->hilite; break;
274
275                                 case TH_GRID:
276                                         cp = ts->grid; break;
277                                 case TH_VIEW_OVERLAY:
278                                         cp = ts->view_overlay; break;
279                                 case TH_WIRE:
280                                         cp = ts->wire; break;
281                                 case TH_WIRE_INNER:
282                                         cp = ts->syntaxr; break;
283                                 case TH_WIRE_EDIT:
284                                         cp = ts->wire_edit; break;
285                                 case TH_LIGHT:
286                                         cp = ts->lamp; break;
287                                 case TH_SPEAKER:
288                                         cp = ts->speaker; break;
289                                 case TH_CAMERA:
290                                         cp = ts->camera; break;
291                                 case TH_EMPTY:
292                                         cp = ts->empty; break;
293                                 case TH_SELECT:
294                                         cp = ts->select; break;
295                                 case TH_ACTIVE:
296                                         cp = ts->active; break;
297                                 case TH_GROUP:
298                                         cp = ts->group; break;
299                                 case TH_GROUP_ACTIVE:
300                                         cp = ts->group_active; break;
301                                 case TH_TRANSFORM:
302                                         cp = ts->transform; break;
303                                 case TH_VERTEX:
304                                         cp = ts->vertex; break;
305                                 case TH_VERTEX_SELECT:
306                                         cp = ts->vertex_select; break;
307                                 case TH_VERTEX_BEVEL:
308                                         cp = ts->vertex_bevel; break;
309                                 case TH_VERTEX_UNREFERENCED:
310                                         cp = ts->vertex_unreferenced; break;
311                                 case TH_VERTEX_SIZE:
312                                         cp = &ts->vertex_size; break;
313                                 case TH_OUTLINE_WIDTH:
314                                         cp = &ts->outline_width; break;
315                                 case TH_EDGE:
316                                         cp = ts->edge; break;
317                                 case TH_EDGE_SELECT:
318                                         cp = ts->edge_select; break;
319                                 case TH_EDGE_SEAM:
320                                         cp = ts->edge_seam; break;
321                                 case TH_EDGE_SHARP:
322                                         cp = ts->edge_sharp; break;
323                                 case TH_EDGE_CREASE:
324                                         cp = ts->edge_crease; break;
325                                 case TH_EDGE_BEVEL:
326                                         cp = ts->edge_bevel; break;
327                                 case TH_EDITMESH_ACTIVE:
328                                         cp = ts->editmesh_active; break;
329                                 case TH_EDGE_FACESEL:
330                                         cp = ts->edge_facesel; break;
331                                 case TH_FACE:
332                                         cp = ts->face; break;
333                                 case TH_FACE_SELECT:
334                                         cp = ts->face_select; break;
335                                 case TH_FACE_DOT:
336                                         cp = ts->face_dot; break;
337                                 case TH_FACEDOT_SIZE:
338                                         cp = &ts->facedot_size; break;
339                                 case TH_DRAWEXTRA_EDGELEN:
340                                         cp = ts->extra_edge_len; break;
341                                 case TH_DRAWEXTRA_EDGEANG:
342                                         cp = ts->extra_edge_angle; break;
343                                 case TH_DRAWEXTRA_FACEAREA:
344                                         cp = ts->extra_face_area; break;
345                                 case TH_DRAWEXTRA_FACEANG:
346                                         cp = ts->extra_face_angle; break;
347                                 case TH_NORMAL:
348                                         cp = ts->normal; break;
349                                 case TH_VNORMAL:
350                                         cp = ts->vertex_normal; break;
351                                 case TH_LNORMAL:
352                                         cp = ts->loop_normal; break;
353                                 case TH_BONE_SOLID:
354                                         cp = ts->bone_solid; break;
355                                 case TH_BONE_POSE:
356                                         cp = ts->bone_pose; break;
357                                 case TH_BONE_POSE_ACTIVE:
358                                         cp = ts->bone_pose_active; break;
359                                 case TH_STRIP:
360                                         cp = ts->strip; break;
361                                 case TH_STRIP_SELECT:
362                                         cp = ts->strip_select; break;
363                                 case TH_KEYTYPE_KEYFRAME:
364                                         cp = ts->keytype_keyframe; break;
365                                 case TH_KEYTYPE_KEYFRAME_SELECT:
366                                         cp = ts->keytype_keyframe_select; break;
367                                 case TH_KEYTYPE_EXTREME:
368                                         cp = ts->keytype_extreme; break;
369                                 case TH_KEYTYPE_EXTREME_SELECT:
370                                         cp = ts->keytype_extreme_select; break;
371                                 case TH_KEYTYPE_BREAKDOWN:
372                                         cp = ts->keytype_breakdown; break;
373                                 case TH_KEYTYPE_BREAKDOWN_SELECT:
374                                         cp = ts->keytype_breakdown_select; break;
375                                 case TH_KEYTYPE_JITTER:
376                                         cp = ts->keytype_jitter; break;
377                                 case TH_KEYTYPE_JITTER_SELECT:
378                                         cp = ts->keytype_jitter_select; break;
379                                 case TH_KEYTYPE_MOVEHOLD:
380                                         cp = ts->keytype_movehold; break;
381                                 case TH_KEYTYPE_MOVEHOLD_SELECT:
382                                         cp = ts->keytype_movehold_select; break;
383                                 case TH_KEYBORDER:
384                                         cp = ts->keyborder; break;
385                                 case TH_KEYBORDER_SELECT:
386                                         cp = ts->keyborder_select; break;
387                                 case TH_CFRAME:
388                                         cp = ts->cframe; break;
389                                 case TH_TIME_KEYFRAME:
390                                         cp = ts->time_keyframe; break;
391                                 case TH_TIME_GP_KEYFRAME:
392                                         cp = ts->time_gp_keyframe; break;
393                                 case TH_NURB_ULINE:
394                                         cp = ts->nurb_uline; break;
395                                 case TH_NURB_VLINE:
396                                         cp = ts->nurb_vline; break;
397                                 case TH_NURB_SEL_ULINE:
398                                         cp = ts->nurb_sel_uline; break;
399                                 case TH_NURB_SEL_VLINE:
400                                         cp = ts->nurb_sel_vline; break;
401                                 case TH_ACTIVE_SPLINE:
402                                         cp = ts->act_spline; break;
403                                 case TH_ACTIVE_VERT:
404                                         cp = ts->lastsel_point; break;
405                                 case TH_HANDLE_FREE:
406                                         cp = ts->handle_free; break;
407                                 case TH_HANDLE_AUTO:
408                                         cp = ts->handle_auto; break;
409                                 case TH_HANDLE_AUTOCLAMP:
410                                         cp = ts->handle_auto_clamped; break;
411                                 case TH_HANDLE_VECT:
412                                         cp = ts->handle_vect; break;
413                                 case TH_HANDLE_ALIGN:
414                                         cp = ts->handle_align; break;
415                                 case TH_HANDLE_SEL_FREE:
416                                         cp = ts->handle_sel_free; break;
417                                 case TH_HANDLE_SEL_AUTO:
418                                         cp = ts->handle_sel_auto; break;
419                                 case TH_HANDLE_SEL_AUTOCLAMP:
420                                         cp = ts->handle_sel_auto_clamped; break;
421                                 case TH_HANDLE_SEL_VECT:
422                                         cp = ts->handle_sel_vect; break;
423                                 case TH_HANDLE_SEL_ALIGN:
424                                         cp = ts->handle_sel_align; break;
425                                 case TH_FREESTYLE_EDGE_MARK:
426                                         cp = ts->freestyle_edge_mark; break;
427                                 case TH_FREESTYLE_FACE_MARK:
428                                         cp = ts->freestyle_face_mark; break;
429
430                                 case TH_SYNTAX_B:
431                                         cp = ts->syntaxb; break;
432                                 case TH_SYNTAX_V:
433                                         cp = ts->syntaxv; break;
434                                 case TH_SYNTAX_C:
435                                         cp = ts->syntaxc; break;
436                                 case TH_SYNTAX_L:
437                                         cp = ts->syntaxl; break;
438                                 case TH_SYNTAX_D:
439                                         cp = ts->syntaxd; break;
440                                 case TH_SYNTAX_R:
441                                         cp = ts->syntaxr; break;
442                                 case TH_SYNTAX_N:
443                                         cp = ts->syntaxn; break;
444                                 case TH_SYNTAX_S:
445                                         cp = ts->syntaxs; break;
446
447                                 case TH_NODE:
448                                         cp = ts->syntaxl; break;
449                                 case TH_NODE_INPUT:
450                                         cp = ts->syntaxn; break;
451                                 case TH_NODE_OUTPUT:
452                                         cp = ts->nodeclass_output; break;
453                                 case TH_NODE_COLOR:
454                                         cp = ts->syntaxb; break;
455                                 case TH_NODE_FILTER:
456                                         cp = ts->nodeclass_filter; break;
457                                 case TH_NODE_VECTOR:
458                                         cp = ts->nodeclass_vector; break;
459                                 case TH_NODE_TEXTURE:
460                                         cp = ts->nodeclass_texture; break;
461                                 case TH_NODE_PATTERN:
462                                         cp = ts->nodeclass_pattern; break;
463                                 case TH_NODE_SCRIPT:
464                                         cp = ts->nodeclass_script; break;
465                                 case TH_NODE_LAYOUT:
466                                         cp = ts->nodeclass_layout; break;
467                                 case TH_NODE_SHADER:
468                                         cp = ts->nodeclass_shader; break;
469                                 case TH_NODE_CONVERTOR:
470                                         cp = ts->syntaxv; break;
471                                 case TH_NODE_GROUP:
472                                         cp = ts->syntaxc; break;
473                                 case TH_NODE_INTERFACE:
474                                         cp = ts->console_output; break;
475                                 case TH_NODE_FRAME:
476                                         cp = ts->movie; break;
477                                 case TH_NODE_MATTE:
478                                         cp = ts->syntaxs; break;
479                                 case TH_NODE_DISTORT:
480                                         cp = ts->syntaxd; break;
481                                 case TH_NODE_CURVING:
482                                         cp = &ts->noodle_curving; break;
483
484                                 case TH_SEQ_MOVIE:
485                                         cp = ts->movie; break;
486                                 case TH_SEQ_MOVIECLIP:
487                                         cp = ts->movieclip; break;
488                                 case TH_SEQ_MASK:
489                                         cp = ts->mask; break;
490                                 case TH_SEQ_IMAGE:
491                                         cp = ts->image; break;
492                                 case TH_SEQ_SCENE:
493                                         cp = ts->scene; break;
494                                 case TH_SEQ_AUDIO:
495                                         cp = ts->audio; break;
496                                 case TH_SEQ_EFFECT:
497                                         cp = ts->effect; break;
498                                 case TH_SEQ_TRANSITION:
499                                         cp = ts->transition; break;
500                                 case TH_SEQ_META:
501                                         cp = ts->meta; break;
502                                 case TH_SEQ_TEXT:
503                                         cp = ts->text_strip; break;
504                                 case TH_SEQ_PREVIEW:
505                                         cp = ts->preview_back; break;
506
507                                 case TH_CONSOLE_OUTPUT:
508                                         cp = ts->console_output; break;
509                                 case TH_CONSOLE_INPUT:
510                                         cp = ts->console_input; break;
511                                 case TH_CONSOLE_INFO:
512                                         cp = ts->console_info; break;
513                                 case TH_CONSOLE_ERROR:
514                                         cp = ts->console_error; break;
515                                 case TH_CONSOLE_CURSOR:
516                                         cp = ts->console_cursor; break;
517                                 case TH_CONSOLE_SELECT:
518                                         cp = ts->console_select; break;
519
520                                 case TH_HANDLE_VERTEX:
521                                         cp = ts->handle_vertex;
522                                         break;
523                                 case TH_HANDLE_VERTEX_SELECT:
524                                         cp = ts->handle_vertex_select;
525                                         break;
526                                 case TH_HANDLE_VERTEX_SIZE:
527                                         cp = &ts->handle_vertex_size;
528                                         break;
529
530                                 case TH_GP_VERTEX:
531                                         cp = ts->gp_vertex;
532                                         break;
533                                 case TH_GP_VERTEX_SELECT:
534                                         cp = ts->gp_vertex_select;
535                                         break;
536                                 case TH_GP_VERTEX_SIZE:
537                                         cp = &ts->gp_vertex_size;
538                                         break;
539
540                                 case TH_DOPESHEET_CHANNELOB:
541                                         cp = ts->ds_channel;
542                                         break;
543                                 case TH_DOPESHEET_CHANNELSUBOB:
544                                         cp = ts->ds_subchannel;
545                                         break;
546                                 case TH_DOPESHEET_IPOLINE:
547                                         cp = ts->ds_ipoline;
548                                         break;
549
550                                 case TH_PREVIEW_BACK:
551                                         cp = ts->preview_back;
552                                         break;
553
554                                 case TH_STITCH_PREVIEW_FACE:
555                                         cp = ts->preview_stitch_face;
556                                         break;
557
558                                 case TH_STITCH_PREVIEW_EDGE:
559                                         cp = ts->preview_stitch_edge;
560                                         break;
561
562                                 case TH_STITCH_PREVIEW_VERT:
563                                         cp = ts->preview_stitch_vert;
564                                         break;
565
566                                 case TH_STITCH_PREVIEW_STITCHABLE:
567                                         cp = ts->preview_stitch_stitchable;
568                                         break;
569
570                                 case TH_STITCH_PREVIEW_UNSTITCHABLE:
571                                         cp = ts->preview_stitch_unstitchable;
572                                         break;
573                                 case TH_STITCH_PREVIEW_ACTIVE:
574                                         cp = ts->preview_stitch_active;
575                                         break;
576
577                                 case TH_PAINT_CURVE_HANDLE:
578                                         cp = ts->paint_curve_handle;
579                                         break;
580                                 case TH_PAINT_CURVE_PIVOT:
581                                         cp = ts->paint_curve_pivot;
582                                         break;
583
584                                 case TH_METADATA_BG:
585                                         cp = ts->metadatabg;
586                                         break;
587                                 case TH_METADATA_TEXT:
588                                         cp = ts->metadatatext;
589                                         break;
590
591                                 case TH_UV_OTHERS:
592                                         cp = ts->uv_others;
593                                         break;
594                                 case TH_UV_SHADOW:
595                                         cp = ts->uv_shadow;
596                                         break;
597
598                                 case TH_MARKER_OUTLINE:
599                                         cp = ts->marker_outline; break;
600                                 case TH_MARKER:
601                                         cp = ts->marker; break;
602                                 case TH_ACT_MARKER:
603                                         cp = ts->act_marker; break;
604                                 case TH_SEL_MARKER:
605                                         cp = ts->sel_marker; break;
606                                 case TH_BUNDLE_SOLID:
607                                         cp = ts->bundle_solid; break;
608                                 case TH_DIS_MARKER:
609                                         cp = ts->dis_marker; break;
610                                 case TH_PATH_BEFORE:
611                                         cp = ts->path_before; break;
612                                 case TH_PATH_AFTER:
613                                         cp = ts->path_after; break;
614                                 case TH_CAMERA_PATH:
615                                         cp = ts->camera_path; break;
616                                 case TH_LOCK_MARKER:
617                                         cp = ts->lock_marker; break;
618
619                                 case TH_MATCH:
620                                         cp = ts->match;
621                                         break;
622
623                                 case TH_SELECT_HIGHLIGHT:
624                                         cp = ts->selected_highlight;
625                                         break;
626
627                                 case TH_SKIN_ROOT:
628                                         cp = ts->skin_root;
629                                         break;
630
631                                 case TH_ANIM_ACTIVE:
632                                         cp = ts->anim_active;
633                                         break;
634                                 case TH_ANIM_INACTIVE:
635                                         cp = ts->anim_non_active;
636                                         break;
637                                 case TH_ANIM_PREVIEW_RANGE:
638                                         cp = ts->anim_preview_range;
639                                         break;
640
641                                 case TH_NLA_TWEAK:
642                                         cp = ts->nla_tweaking;
643                                         break;
644                                 case TH_NLA_TWEAK_DUPLI:
645                                         cp = ts->nla_tweakdupli;
646                                         break;
647
648                                 case TH_NLA_TRANSITION:
649                                         cp = ts->nla_transition;
650                                         break;
651                                 case TH_NLA_TRANSITION_SEL:
652                                         cp = ts->nla_transition_sel;
653                                         break;
654                                 case TH_NLA_META:
655                                         cp = ts->nla_meta;
656                                         break;
657                                 case TH_NLA_META_SEL:
658                                         cp = ts->nla_meta_sel;
659                                         break;
660                                 case TH_NLA_SOUND:
661                                         cp = ts->nla_sound;
662                                         break;
663                                 case TH_NLA_SOUND_SEL:
664                                         cp = ts->nla_sound_sel;
665                                         break;
666
667                                 case TH_WIDGET_EMBOSS:
668                                         cp = btheme->tui.widget_emboss; break;
669
670                                 case TH_EDITOR_OUTLINE:
671                                         cp = btheme->tui.editor_outline;
672                                         break;
673                                 case TH_AXIS_X:
674                                         cp = btheme->tui.xaxis; break;
675                                 case TH_AXIS_Y:
676                                         cp = btheme->tui.yaxis; break;
677                                 case TH_AXIS_Z:
678                                         cp = btheme->tui.zaxis; break;
679
680                                 case TH_GIZMO_HI:
681                                         cp = btheme->tui.gizmo_hi; break;
682                                 case TH_GIZMO_PRIMARY:
683                                         cp = btheme->tui.gizmo_primary; break;
684                                 case TH_GIZMO_SECONDARY:
685                                         cp = btheme->tui.gizmo_secondary; break;
686                                 case TH_GIZMO_A:
687                                         cp = btheme->tui.gizmo_a; break;
688                                 case TH_GIZMO_B:
689                                         cp = btheme->tui.gizmo_b; break;
690
691                                 case TH_ICON_COLLECTION:
692                                         cp = btheme->tui.icon_collection; break;
693                                 case TH_ICON_OBJECT:
694                                         cp = btheme->tui.icon_object; break;
695                                 case TH_ICON_OBJECT_DATA:
696                                         cp = btheme->tui.icon_object_data; break;
697                                 case TH_ICON_MODIFIER:
698                                         cp = btheme->tui.icon_modifier; break;
699                                 case TH_ICON_SHADING:
700                                         cp = btheme->tui.icon_shading; break;
701
702                                 case TH_INFO_SELECTED:
703                                         cp = ts->info_selected;
704                                         break;
705                                 case TH_INFO_SELECTED_TEXT:
706                                         cp = ts->info_selected_text;
707                                         break;
708                                 case TH_INFO_ERROR:
709                                         cp = ts->info_error;
710                                         break;
711                                 case TH_INFO_ERROR_TEXT:
712                                         cp = ts->info_error_text;
713                                         break;
714                                 case TH_INFO_WARNING:
715                                         cp = ts->info_warning;
716                                         break;
717                                 case TH_INFO_WARNING_TEXT:
718                                         cp = ts->info_warning_text;
719                                         break;
720                                 case TH_INFO_INFO:
721                                         cp = ts->info_info;
722                                         break;
723                                 case TH_INFO_INFO_TEXT:
724                                         cp = ts->info_info_text;
725                                         break;
726                                 case TH_INFO_DEBUG:
727                                         cp = ts->info_debug;
728                                         break;
729                                 case TH_INFO_DEBUG_TEXT:
730                                         cp = ts->info_debug_text;
731                                         break;
732                                 case TH_V3D_CLIPPING_BORDER:
733                                         cp = ts->clipping_border_3d;
734                                         break;
735                         }
736                 }
737         }
738
739         return (const uchar *)cp;
740 }
741
742 /**
743  * initialize default theme
744  * \note: when you add new colors, created & saved themes need initialized
745  * use function below, init_userdef_do_versions()
746  */
747 void ui_theme_init_default(void)
748 {
749
750         /* we search for the theme with name Default */
751         bTheme *btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
752         if (btheme == NULL) {
753                 btheme = MEM_callocN(sizeof(bTheme), __func__);
754                 BLI_addtail(&U.themes, btheme);
755         }
756
757         UI_SetTheme(0, 0);  /* make sure the global used in this file is set */
758
759         const int active_theme_area = btheme->active_theme_area;
760         memcpy(btheme, &U_theme_default, sizeof(*btheme));
761         btheme->active_theme_area = active_theme_area;
762 }
763
764 void ui_style_init_default(void)
765 {
766         BLI_freelistN(&U.uistyles);
767         /* gets automatically re-allocated */
768         uiStyleInit();
769 }
770
771
772 void UI_SetTheme(int spacetype, int regionid)
773 {
774         if (spacetype) {
775                 /* later on, a local theme can be found too */
776                 theme_active = U.themes.first;
777                 theme_spacetype = spacetype;
778                 theme_regionid = regionid;
779         }
780         else if (regionid) {
781                 /* popups */
782                 theme_active = U.themes.first;
783                 theme_spacetype = SPACE_PROPERTIES;
784                 theme_regionid = regionid;
785         }
786         else {
787                 /* for safety, when theme was deleted */
788                 theme_active = U.themes.first;
789                 theme_spacetype = SPACE_VIEW3D;
790                 theme_regionid = RGN_TYPE_WINDOW;
791         }
792 }
793
794 bTheme *UI_GetTheme(void)
795 {
796         return U.themes.first;
797 }
798
799 /**
800  * for the rare case we need to temp swap in a different theme (offscreen render)
801  */
802 void UI_Theme_Store(struct bThemeState *theme_state)
803 {
804         *theme_state = g_theme_state;
805 }
806 void UI_Theme_Restore(struct bThemeState *theme_state)
807 {
808         g_theme_state = *theme_state;
809 }
810
811 void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, uchar col[4])
812 {
813         int r, g, b, a;
814         const uchar *cp;
815
816         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
817         r = coloffset + (int) cp[0];
818         CLAMP(r, 0, 255);
819         g = coloffset + (int) cp[1];
820         CLAMP(g, 0, 255);
821         b = coloffset + (int) cp[2];
822         CLAMP(b, 0, 255);
823         a = alphaoffset + (int) cp[3];
824         CLAMP(a, 0, 255);
825
826         col[0] = r;
827         col[1] = g;
828         col[2] = b;
829         col[3] = a;
830 }
831
832 void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, uchar col[3])
833 {
834         const uchar *cp1, *cp2;
835
836         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
837         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
838
839         CLAMP(fac, 0.0f, 1.0f);
840         col[0] = floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
841         col[1] = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
842         col[2] = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
843 }
844
845 void UI_GetThemeColorBlend3f(int colorid1, int colorid2, float fac, float r_col[3])
846 {
847         const uchar *cp1, *cp2;
848
849         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
850         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
851
852         CLAMP(fac, 0.0f, 1.0f);
853         r_col[0] = ((1.0f - fac) * cp1[0] + fac * cp2[0]) / 255.0f;
854         r_col[1] = ((1.0f - fac) * cp1[1] + fac * cp2[1]) / 255.0f;
855         r_col[2] = ((1.0f - fac) * cp1[2] + fac * cp2[2]) / 255.0f;
856 }
857
858 void UI_GetThemeColorBlend4f(int colorid1, int colorid2, float fac, float r_col[4])
859 {
860         const uchar *cp1, *cp2;
861
862         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
863         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
864
865         CLAMP(fac, 0.0f, 1.0f);
866         r_col[0] = ((1.0f - fac) * cp1[0] + fac * cp2[0]) / 255.0f;
867         r_col[1] = ((1.0f - fac) * cp1[1] + fac * cp2[1]) / 255.0f;
868         r_col[2] = ((1.0f - fac) * cp1[2] + fac * cp2[2]) / 255.0f;
869         r_col[3] = ((1.0f - fac) * cp1[3] + fac * cp2[3]) / 255.0f;
870 }
871
872 void UI_FontThemeColor(int fontid, int colorid)
873 {
874         uchar color[4];
875         UI_GetThemeColor4ubv(colorid, color);
876         BLF_color4ubv(fontid, color);
877 }
878
879 /* get individual values, not scaled */
880 float UI_GetThemeValuef(int colorid)
881 {
882         const uchar *cp;
883
884         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
885         return ((float)cp[0]);
886 }
887
888 /* get individual values, not scaled */
889 int UI_GetThemeValue(int colorid)
890 {
891         const uchar *cp;
892
893         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
894         return ((int) cp[0]);
895 }
896
897 /* versions of the function above, which take a space-type */
898 float UI_GetThemeValueTypef(int colorid, int spacetype)
899 {
900         const uchar *cp;
901
902         cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
903         return ((float)cp[0]);
904 }
905
906 int UI_GetThemeValueType(int colorid, int spacetype)
907 {
908         const uchar *cp;
909
910         cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
911         return ((int)cp[0]);
912 }
913
914
915 /* get the color, range 0.0-1.0 */
916 void UI_GetThemeColor3fv(int colorid, float col[3])
917 {
918         const uchar *cp;
919
920         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
921         col[0] = ((float)cp[0]) / 255.0f;
922         col[1] = ((float)cp[1]) / 255.0f;
923         col[2] = ((float)cp[2]) / 255.0f;
924 }
925
926 void UI_GetThemeColor4fv(int colorid, float col[4])
927 {
928         const uchar *cp;
929
930         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
931         col[0] = ((float)cp[0]) / 255.0f;
932         col[1] = ((float)cp[1]) / 255.0f;
933         col[2] = ((float)cp[2]) / 255.0f;
934         col[3] = ((float)cp[3]) / 255.0f;
935 }
936
937 void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4])
938 {
939         const unsigned char *cp;
940
941         cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
942         col[0] = ((float)cp[0]) / 255.0f;
943         col[1] = ((float)cp[1]) / 255.0f;
944         col[2] = ((float)cp[2]) / 255.0f;
945         col[3] = ((float)cp[3]) / 255.0f;
946 }
947
948 /* get the color, range 0.0-1.0, complete with shading offset */
949 void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
950 {
951         int r, g, b;
952         const uchar *cp;
953
954         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
955
956         r = offset + (int) cp[0];
957         CLAMP(r, 0, 255);
958         g = offset + (int) cp[1];
959         CLAMP(g, 0, 255);
960         b = offset + (int) cp[2];
961         CLAMP(b, 0, 255);
962
963         col[0] = ((float)r) / 255.0f;
964         col[1] = ((float)g) / 255.0f;
965         col[2] = ((float)b) / 255.0f;
966 }
967
968 void UI_GetThemeColorShade3ubv(int colorid, int offset, uchar col[3])
969 {
970         int r, g, b;
971         const uchar *cp;
972
973         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
974
975         r = offset + (int) cp[0];
976         CLAMP(r, 0, 255);
977         g = offset + (int) cp[1];
978         CLAMP(g, 0, 255);
979         b = offset + (int) cp[2];
980         CLAMP(b, 0, 255);
981
982         col[0] = r;
983         col[1] = g;
984         col[2] = b;
985 }
986
987 void UI_GetThemeColorBlendShade3ubv(int colorid1, int colorid2, float fac, int offset, uchar col[3])
988 {
989         const uchar *cp1, *cp2;
990
991         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
992         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
993
994         CLAMP(fac, 0.0f, 1.0f);
995
996         float blend[3];
997         blend[0] = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
998         blend[1] = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
999         blend[2] = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1000
1001         unit_float_to_uchar_clamp_v3(col, blend);
1002 }
1003
1004 void UI_GetThemeColorShade4ubv(int colorid, int offset, uchar col[4])
1005 {
1006         int r, g, b;
1007         const uchar *cp;
1008
1009         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1010         r = offset + (int) cp[0];
1011         CLAMP(r, 0, 255);
1012         g = offset + (int) cp[1];
1013         CLAMP(g, 0, 255);
1014         b = offset + (int) cp[2];
1015         CLAMP(b, 0, 255);
1016
1017         col[0] = r;
1018         col[1] = g;
1019         col[2] = b;
1020         col[3] = cp[3];
1021 }
1022
1023 void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4])
1024 {
1025         int r, g, b, a;
1026         const uchar *cp;
1027
1028         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1029
1030         r = coloffset + (int) cp[0];
1031         CLAMP(r, 0, 255);
1032         g = coloffset + (int) cp[1];
1033         CLAMP(g, 0, 255);
1034         b = coloffset + (int) cp[2];
1035         CLAMP(b, 0, 255);
1036         a = alphaoffset + (int) cp[3];
1037         CLAMP(b, 0, 255);
1038
1039         col[0] = ((float)r) / 255.0f;
1040         col[1] = ((float)g) / 255.0f;
1041         col[2] = ((float)b) / 255.0f;
1042         col[3] = ((float)a) / 255.0f;
1043 }
1044
1045 void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int offset, float col[3])
1046 {
1047         int r, g, b;
1048         const uchar *cp1, *cp2;
1049
1050         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
1051         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
1052
1053         CLAMP(fac, 0.0f, 1.0f);
1054
1055         r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1056         CLAMP(r, 0, 255);
1057         g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1058         CLAMP(g, 0, 255);
1059         b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1060         CLAMP(b, 0, 255);
1061
1062         col[0] = ((float)r) / 255.0f;
1063         col[1] = ((float)g) / 255.0f;
1064         col[2] = ((float)b) / 255.0f;
1065 }
1066
1067 void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
1068 {
1069         int r, g, b, a;
1070         const uchar *cp1, *cp2;
1071
1072         cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
1073         cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
1074
1075         CLAMP(fac, 0.0f, 1.0f);
1076
1077         r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
1078         CLAMP(r, 0, 255);
1079         g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
1080         CLAMP(g, 0, 255);
1081         b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
1082         CLAMP(b, 0, 255);
1083         a = offset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
1084         CLAMP(a, 0, 255);
1085
1086         col[0] = ((float)r) / 255.0f;
1087         col[1] = ((float)g) / 255.0f;
1088         col[2] = ((float)b) / 255.0f;
1089         col[3] = ((float)a) / 255.0f;
1090 }
1091
1092 /* get the color, in char pointer */
1093 void UI_GetThemeColor3ubv(int colorid, uchar col[3])
1094 {
1095         const uchar *cp;
1096
1097         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1098         col[0] = cp[0];
1099         col[1] = cp[1];
1100         col[2] = cp[2];
1101 }
1102
1103 /* get the color, range 0.0-1.0, complete with shading offset */
1104 void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
1105 {
1106         int r, g, b, a;
1107         const uchar *cp;
1108
1109         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1110
1111         r = offset + (int) cp[0];
1112         CLAMP(r, 0, 255);
1113         g = offset + (int) cp[1];
1114         CLAMP(g, 0, 255);
1115         b = offset + (int) cp[2];
1116         CLAMP(b, 0, 255);
1117
1118         a = (int) cp[3]; /* no shading offset... */
1119         CLAMP(a, 0, 255);
1120
1121         col[0] = ((float)r) / 255.0f;
1122         col[1] = ((float)g) / 255.0f;
1123         col[2] = ((float)b) / 255.0f;
1124         col[3] = ((float)a) / 255.0f;
1125 }
1126
1127 /* get the color, in char pointer */
1128 void UI_GetThemeColor4ubv(int colorid, uchar col[4])
1129 {
1130         const uchar *cp;
1131
1132         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1133         col[0] = cp[0];
1134         col[1] = cp[1];
1135         col[2] = cp[2];
1136         col[3] = cp[3];
1137 }
1138
1139 void UI_GetThemeColorType3ubv(int colorid, int spacetype, uchar col[3])
1140 {
1141         const uchar *cp;
1142
1143         cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
1144         col[0] = cp[0];
1145         col[1] = cp[1];
1146         col[2] = cp[2];
1147 }
1148
1149 void UI_GetThemeColorType4ubv(int colorid, int spacetype, uchar col[4])
1150 {
1151         const uchar *cp;
1152
1153         cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
1154         col[0] = cp[0];
1155         col[1] = cp[1];
1156         col[2] = cp[2];
1157         col[3] = cp[3];
1158 }
1159
1160 bool UI_GetIconThemeColor4fv(int colorid, float col[4])
1161 {
1162         if (colorid == 0) {
1163                 return false;
1164         }
1165
1166         /* Only colored icons in outliner and popups, overall UI is intended
1167          * to stay monochrome and out of the way except a few places where it
1168          * is important to communicate different data types. */
1169         if (!((theme_spacetype == SPACE_OUTLINER) ||
1170               (theme_regionid == RGN_TYPE_TEMPORARY)))
1171         {
1172                 return false;
1173         }
1174
1175         const uchar *cp;
1176         cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1177         col[0] = ((float)cp[0]) / 255.0f;
1178         col[1] = ((float)cp[1]) / 255.0f;
1179         col[2] = ((float)cp[2]) / 255.0f;
1180         col[3] = ((float)cp[3]) / 255.0f;
1181
1182         return true;
1183 }
1184
1185 void UI_GetColorPtrShade3ubv(const uchar cp[3], uchar col[3], int offset)
1186 {
1187         int r, g, b;
1188
1189         r = offset + (int)cp[0];
1190         g = offset + (int)cp[1];
1191         b = offset + (int)cp[2];
1192
1193         CLAMP(r, 0, 255);
1194         CLAMP(g, 0, 255);
1195         CLAMP(b, 0, 255);
1196
1197         col[0] = r;
1198         col[1] = g;
1199         col[2] = b;
1200 }
1201
1202 /* get a 3 byte color, blended and shaded between two other char color pointers */
1203 void UI_GetColorPtrBlendShade3ubv(
1204         const uchar cp1[3], const uchar cp2[3], uchar col[3],
1205         float fac, int offset)
1206 {
1207         int r, g, b;
1208
1209         CLAMP(fac, 0.0f, 1.0f);
1210         r = offset + floor((1.0f - fac) * cp1[0] + fac * cp2[0]);
1211         g = offset + floor((1.0f - fac) * cp1[1] + fac * cp2[1]);
1212         b = offset + floor((1.0f - fac) * cp1[2] + fac * cp2[2]);
1213
1214         CLAMP(r, 0, 255);
1215         CLAMP(g, 0, 255);
1216         CLAMP(b, 0, 255);
1217
1218         col[0] = r;
1219         col[1] = g;
1220         col[2] = b;
1221 }
1222
1223 void UI_ThemeClearColor(int colorid)
1224 {
1225         float col[3];
1226
1227         UI_GetThemeColor3fv(colorid, col);
1228         GPU_clear_color(col[0], col[1], col[2], 0.0f);
1229 }
1230
1231 void UI_ThemeClearColorAlpha(int colorid, float alpha)
1232 {
1233         float col[3];
1234         UI_GetThemeColor3fv(colorid, col);
1235         GPU_clear_color(col[0], col[1], col[2], alpha);
1236 }
1237
1238
1239 int UI_ThemeMenuShadowWidth(void)
1240 {
1241         bTheme *btheme = UI_GetTheme();
1242         return (int)(btheme->tui.menu_shadow_width * UI_DPI_FAC);
1243 }
1244
1245 void UI_make_axis_color(const uchar src_col[3], uchar dst_col[3], const char axis)
1246 {
1247         uchar col[3];
1248
1249         switch (axis) {
1250                 case 'X':
1251                         UI_GetThemeColor3ubv(TH_AXIS_X, col);
1252                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1253                         break;
1254                 case 'Y':
1255                         UI_GetThemeColor3ubv(TH_AXIS_Y, col);
1256                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1257                         break;
1258                 case 'Z':
1259                         UI_GetThemeColor3ubv(TH_AXIS_Z, col);
1260                         UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
1261                         break;
1262                 default:
1263                         BLI_assert(0);
1264                         break;
1265         }
1266 }
1267
1268 /* patching UserDef struct and Themes */
1269 void init_userdef_do_versions(Main *bmain)
1270 {
1271         BLO_version_defaults_userpref_blend(bmain, &U);
1272
1273         if (STREQ(U.tempdir, "/")) {
1274                 BKE_tempdir_system_init(U.tempdir);
1275         }
1276
1277         /* Not versioning, just avoid errors. */
1278 #ifndef WITH_CYCLES
1279         BKE_addon_remove_safe(&U.addons, "cycles");
1280 #endif
1281
1282 }