4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version. The Blender
10 * Foundation also sells licenses for use in proprietary software under
11 * the Blender License. See http://www.blender.org/BL/ for information
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
33 /** \file blender/editors/interface/resources.c
34 * \ingroup edinterface
41 #include "MEM_guardedalloc.h"
43 #include "DNA_curve_types.h"
44 #include "DNA_userdef_types.h"
45 #include "DNA_screen_types.h"
46 #include "DNA_space_types.h"
47 #include "DNA_windowmanager_types.h"
49 #include "BLI_blenlib.h"
50 #include "BLI_utildefines.h"
52 #include "BKE_DerivedMesh.h"
53 #include "BKE_global.h"
55 #include "BKE_texture.h"
60 #include "UI_interface.h"
61 #include "UI_interface_icons.h"
63 #include "interface_intern.h"
65 /* global for themes */
66 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
68 static bTheme *theme_active=NULL;
69 static int theme_spacetype= SPACE_VIEW3D;
70 static int theme_regionid= RGN_TYPE_WINDOW;
72 void ui_resources_init(void)
74 UI_icons_init(BIFICONID_LAST);
77 void ui_resources_free(void)
83 /* ******************************************************** */
85 /* ******************************************************** */
87 const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
90 static char error[4]={240, 0, 240, 255};
91 static char alert[4]={240, 60, 60, 255};
92 static char headerdesel[4]={0,0,0,255};
94 const char *cp= error;
98 // first check for ui buttons theme
99 if(colorid < TH_THEMEUI) {
135 ts= &btheme->timasel;
150 ts= &btheme->tuserpref;
153 ts= &btheme->tconsole;
171 if(theme_regionid==RGN_TYPE_WINDOW)
173 else if(theme_regionid==RGN_TYPE_CHANNELS)
175 else if(theme_regionid==RGN_TYPE_HEADER)
181 if(theme_regionid==RGN_TYPE_WINDOW)
183 else if(theme_regionid==RGN_TYPE_CHANNELS)
185 else if(theme_regionid==RGN_TYPE_HEADER)
191 if(theme_regionid==RGN_TYPE_WINDOW)
193 else if(theme_regionid==RGN_TYPE_CHANNELS)
194 cp= ts->list_text_hi;
195 else if(theme_regionid==RGN_TYPE_HEADER)
196 cp= ts->header_text_hi;
198 cp= ts->button_text_hi;
201 if(theme_regionid==RGN_TYPE_WINDOW)
203 else if(theme_regionid==RGN_TYPE_CHANNELS)
205 else if(theme_regionid==RGN_TYPE_HEADER)
206 cp= ts->header_title;
208 cp= ts->button_title;
212 cp= ts->header; break;
214 /* we calculate a dynamic builtin header deselect color, also for pulldowns... */
216 headerdesel[0]= cp[0]>10?cp[0]-10:0;
217 headerdesel[1]= cp[1]>10?cp[1]-10:0;
218 headerdesel[2]= cp[2]>10?cp[2]-10:0;
222 cp= ts->header_text; break;
223 case TH_HEADER_TEXT_HI:
224 cp= ts->header_text_hi; break;
227 cp= ts->panel; break;
229 cp= ts->panel_text; break;
230 case TH_PANEL_TEXT_HI:
231 cp= ts->panel_text_hi; break;
234 cp= ts->button; break;
235 case TH_BUTBACK_TEXT:
236 cp= ts->button_text; break;
237 case TH_BUTBACK_TEXT_HI:
238 cp= ts->button_text_hi; break;
241 cp= ts->shade1; break;
243 cp= ts->shade2; break;
245 cp= ts->hilite; break;
254 cp= ts->speaker; break;
256 cp= ts->select; break;
258 cp= ts->active; break;
260 cp= ts->group; break;
261 case TH_GROUP_ACTIVE:
262 cp= ts->group_active; break;
264 cp= ts->transform; break;
266 cp= ts->vertex; break;
267 case TH_VERTEX_SELECT:
268 cp= ts->vertex_select; break;
270 cp= &ts->vertex_size; break;
271 case TH_OUTLINE_WIDTH:
272 cp= &ts->outline_width; break;
276 cp= ts->edge_select; break;
278 cp= ts->edge_seam; break;
280 cp= ts->edge_sharp; break;
282 cp= ts->edge_crease; break;
283 case TH_EDITMESH_ACTIVE:
284 cp= ts->editmesh_active; break;
285 case TH_EDGE_FACESEL:
286 cp= ts->edge_facesel; break;
290 cp= ts->face_select; break;
292 cp= ts->face_dot; break;
293 case TH_FACEDOT_SIZE:
294 cp= &ts->facedot_size; break;
295 case TH_DRAWEXTRA_EDGELEN:
296 cp= ts->extra_edge_len; break;
297 case TH_DRAWEXTRA_FACEAREA:
298 cp= ts->extra_face_area; break;
299 case TH_DRAWEXTRA_FACEANG:
300 cp= ts->extra_face_angle; break;
302 cp= ts->normal; break;
304 cp= ts->vertex_normal; break;
306 cp= ts->bone_solid; break;
308 cp= ts->bone_pose; break;
310 cp= ts->strip; break;
311 case TH_STRIP_SELECT:
312 cp= ts->strip_select; break;
314 cp= ts->cframe; break;
316 cp= ts->nurb_uline; break;
318 cp= ts->nurb_vline; break;
319 case TH_NURB_SEL_ULINE:
320 cp= ts->nurb_sel_uline; break;
321 case TH_NURB_SEL_VLINE:
322 cp= ts->nurb_sel_vline; break;
323 case TH_ACTIVE_SPLINE:
324 cp= ts->act_spline; break;
325 case TH_LASTSEL_POINT:
326 cp= ts->lastsel_point; break;
328 cp= ts->handle_free; break;
330 cp= ts->handle_auto; break;
331 case TH_HANDLE_AUTOCLAMP:
332 cp= ts->handle_auto_clamped; break;
334 cp= ts->handle_vect; break;
335 case TH_HANDLE_ALIGN:
336 cp= ts->handle_align; break;
337 case TH_HANDLE_SEL_FREE:
338 cp= ts->handle_sel_free; break;
339 case TH_HANDLE_SEL_AUTO:
340 cp= ts->handle_sel_auto; break;
341 case TH_HANDLE_SEL_AUTOCLAMP:
342 cp= ts->handle_sel_auto_clamped; break;
343 case TH_HANDLE_SEL_VECT:
344 cp= ts->handle_sel_vect; break;
345 case TH_HANDLE_SEL_ALIGN:
346 cp= ts->handle_sel_align; break;
349 cp= ts->syntaxb; break;
351 cp= ts->syntaxv; break;
353 cp= ts->syntaxc; break;
355 cp= ts->syntaxl; break;
357 cp= ts->syntaxn; break;
360 cp= ts->syntaxl; break;
362 cp= ts->syntaxn; break;
363 case TH_NODE_OPERATOR:
364 cp= ts->syntaxb; break;
365 case TH_NODE_CONVERTOR:
366 cp= ts->syntaxv; break;
368 cp= ts->syntaxc; break;
369 case TH_NODE_CURVING:
370 cp= &ts->noodle_curving; break;
373 cp= ts->movie; break;
375 cp= ts->image; break;
377 cp= ts->scene; break;
379 cp= ts->audio; break;
381 cp= ts->effect; break;
383 cp= ts->plugin; break;
384 case TH_SEQ_TRANSITION:
385 cp= ts->transition; break;
389 case TH_CONSOLE_OUTPUT:
390 cp= ts->console_output; break;
391 case TH_CONSOLE_INPUT:
392 cp= ts-> console_input; break;
393 case TH_CONSOLE_INFO:
394 cp= ts->console_info; break;
395 case TH_CONSOLE_ERROR:
396 cp= ts->console_error; break;
397 case TH_CONSOLE_CURSOR:
398 cp= ts->console_cursor; break;
400 case TH_HANDLE_VERTEX:
401 cp= ts->handle_vertex;
403 case TH_HANDLE_VERTEX_SELECT:
404 cp= ts->handle_vertex_select;
406 case TH_HANDLE_VERTEX_SIZE:
407 cp= &ts->handle_vertex_size;
410 case TH_DOPESHEET_CHANNELOB:
413 case TH_DOPESHEET_CHANNELSUBOB:
414 cp= ts->ds_subchannel;
417 case TH_PREVIEW_BACK:
418 cp= ts->preview_back;
424 return (unsigned char *)cp;
428 #define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a;
429 #define SETCOLF(col, r, g, b, a) col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255;
430 #define SETCOLTEST(col, r, g, b, a) if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;}
432 /* use this call to init new bone color sets in Theme */
433 static void ui_theme_init_boneColorSets(bTheme *btheme)
437 /* define default color sets - currently we only define 15 of these, though that should be ample */
439 SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
440 SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
441 SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
443 SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
444 SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
445 SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
447 SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
448 SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
449 SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
451 SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
452 SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
453 SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
455 SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
456 SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
457 SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
459 SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
460 SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
461 SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
463 SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
464 SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
465 SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
467 SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
468 SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
469 SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
471 SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
472 SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
473 SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
475 SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
476 SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
477 SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
479 SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
480 SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
481 SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
483 SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
484 SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
485 SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
487 SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
488 SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
489 SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
491 SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
492 SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
493 SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
495 SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
496 SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
497 SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
499 /* reset flags too */
500 for (i = 0; i < 20; i++)
501 btheme->tarm[i].flag = 0;
504 /* use this call to init new variables in themespace, if they're same for all */
505 static void ui_theme_init_new_do(ThemeSpace *ts)
507 SETCOLTEST(ts->header_text, 0, 0, 0, 255);
508 SETCOLTEST(ts->header_title, 0, 0, 0, 255);
509 SETCOLTEST(ts->header_text_hi, 255, 255, 255, 255);
511 SETCOLTEST(ts->panel_text, 0, 0, 0, 255);
512 SETCOLTEST(ts->panel_title, 0, 0, 0, 255);
513 SETCOLTEST(ts->panel_text_hi, 255, 255, 255, 255);
515 SETCOLTEST(ts->button, 145, 145, 145, 245);
516 SETCOLTEST(ts->button_title, 0, 0, 0, 255);
517 SETCOLTEST(ts->button_text, 0, 0, 0, 255);
518 SETCOLTEST(ts->button_text_hi, 255, 255, 255, 255);
520 SETCOLTEST(ts->list, 165, 165, 165, 255);
521 SETCOLTEST(ts->list_title, 0, 0, 0, 255);
522 SETCOLTEST(ts->list_text, 0, 0, 0, 255);
523 SETCOLTEST(ts->list_text_hi, 255, 255, 255, 255);
526 static void ui_theme_init_new(bTheme *btheme)
528 ui_theme_init_new_do(&btheme->tbuts);
529 ui_theme_init_new_do(&btheme->tv3d);
530 ui_theme_init_new_do(&btheme->tfile);
531 ui_theme_init_new_do(&btheme->tipo);
532 ui_theme_init_new_do(&btheme->tinfo);
533 ui_theme_init_new_do(&btheme->tsnd);
534 ui_theme_init_new_do(&btheme->tact);
535 ui_theme_init_new_do(&btheme->tnla);
536 ui_theme_init_new_do(&btheme->tseq);
537 ui_theme_init_new_do(&btheme->tima);
538 ui_theme_init_new_do(&btheme->timasel);
539 ui_theme_init_new_do(&btheme->text);
540 ui_theme_init_new_do(&btheme->toops);
541 ui_theme_init_new_do(&btheme->ttime);
542 ui_theme_init_new_do(&btheme->tnode);
543 ui_theme_init_new_do(&btheme->tlogic);
544 ui_theme_init_new_do(&btheme->tuserpref);
545 ui_theme_init_new_do(&btheme->tconsole);
550 /* initialize default theme
551 Note: when you add new colors, created & saved themes need initialized
552 use function below, init_userdef_do_versions()
554 void ui_theme_init_default(void)
558 /* we search for the theme with name Default */
559 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
560 if(strcmp("Default", btheme->name)==0) break;
564 btheme= MEM_callocN(sizeof(bTheme), "theme");
565 BLI_addtail(&U.themes, btheme);
566 strcpy(btheme->name, "Default");
569 UI_SetTheme(0, 0); // make sure the global used in this file is set
572 ui_widget_color_init(&btheme->tui);
573 btheme->tui.iconfile[0]= 0;
575 /* Bone Color Sets */
576 ui_theme_init_boneColorSets(btheme);
578 /* common (new) variables */
579 ui_theme_init_new(btheme);
582 SETCOLF(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0);
583 SETCOL(btheme->tv3d.text, 0, 0, 0, 255);
584 SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255);
586 SETCOLF(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0);
587 SETCOLF(btheme->tv3d.button, 0.45, 0.45, 0.45, 1.0);
588 SETCOL(btheme->tv3d.panel, 165, 165, 165, 127);
590 SETCOL(btheme->tv3d.shade1, 160, 160, 160, 100);
591 SETCOL(btheme->tv3d.shade2, 0x7f, 0x70, 0x70, 100);
593 SETCOLF(btheme->tv3d.grid, 0.251, 0.251, 0.251, 1.0);
594 SETCOL(btheme->tv3d.wire, 0x0, 0x0, 0x0, 255);
595 SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40);
596 SETCOL(btheme->tv3d.speaker, 0, 0, 0, 255);
597 SETCOL(btheme->tv3d.select, 241, 88, 0, 255);
598 SETCOL(btheme->tv3d.active, 255, 170, 64, 255);
599 SETCOL(btheme->tv3d.group, 8, 48, 8, 255);
600 SETCOL(btheme->tv3d.group_active, 85, 187, 85, 255);
601 SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
602 SETCOL(btheme->tv3d.vertex, 0, 0, 0, 255);
603 SETCOL(btheme->tv3d.vertex_select, 255, 133, 0, 255);
604 btheme->tv3d.vertex_size= 3;
605 btheme->tv3d.outline_width= 1;
606 SETCOL(btheme->tv3d.edge, 0x0, 0x0, 0x0, 255);
607 SETCOL(btheme->tv3d.edge_select, 255, 160, 0, 255);
608 SETCOL(btheme->tv3d.edge_seam, 219, 37, 18, 255);
609 SETCOL(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
610 SETCOL(btheme->tv3d.face, 0, 0, 0, 18);
611 SETCOL(btheme->tv3d.face_select, 255, 133, 0, 60);
612 SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
613 SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
614 SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255);
615 SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
616 SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
617 SETCOL(btheme->tv3d.edge_sharp, 0, 255, 255, 255);
618 SETCOL(btheme->tv3d.header_text, 0, 0, 0, 255);
619 SETCOL(btheme->tv3d.header_text_hi, 255, 255, 255, 255);
620 SETCOL(btheme->tv3d.button_text, 0, 0, 0, 255);
621 SETCOL(btheme->tv3d.button_text_hi, 255, 255, 255, 255);
622 SETCOL(btheme->tv3d.button_title, 0, 0, 0, 255);
623 SETCOL(btheme->tv3d.title, 0, 0, 0, 255);
625 btheme->tv3d.facedot_size= 4;
627 SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
628 SETCOL(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
629 SETCOL(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
631 SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
633 SETCOL(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
634 SETCOL(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
635 SETCOL(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255);
636 SETCOL(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255);
638 SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
639 SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
640 SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
641 SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
642 SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
643 SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
644 SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
645 SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
647 SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
648 SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
650 SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
651 SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw
655 /* to have something initialized */
656 btheme->tbuts= btheme->tv3d;
658 SETCOLF(btheme->tbuts.back, 0.45, 0.45, 0.45, 1.0);
659 SETCOL(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255);
662 btheme->tipo= btheme->tv3d;
663 SETCOLF(btheme->tipo.back, 0.42, 0.42, 0.42, 1.0);
664 SETCOLF(btheme->tipo.list, 0.4, 0.4, 0.4, 1.0);
665 SETCOL(btheme->tipo.grid, 94, 94, 94, 255);
666 SETCOL(btheme->tipo.panel, 255, 255, 255, 150);
667 SETCOL(btheme->tipo.shade1, 150, 150, 150, 100); /* scrollbars */
668 SETCOL(btheme->tipo.shade2, 0x70, 0x70, 0x70, 100);
669 SETCOL(btheme->tipo.vertex, 0, 0, 0, 255);
670 SETCOL(btheme->tipo.vertex_select, 255, 133, 0, 255);
671 SETCOL(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255);
672 btheme->tipo.vertex_size= 3;
674 SETCOL(btheme->tipo.handle_vertex, 0, 0, 0, 255);
675 SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
676 SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
677 SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
678 btheme->tipo.handle_vertex_size= 4;
680 SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255);
681 SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
682 SETCOL(btheme->tipo.group, 79, 101, 73, 255);
683 SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
686 btheme->tact= btheme->tipo;
687 SETCOL(btheme->tact.strip, 12, 10, 10, 128);
688 SETCOL(btheme->tact.strip_select, 255, 140, 0, 255);
691 btheme->tnla= btheme->tact;
694 /* to have something initialized */
695 btheme->tfile= btheme->tv3d;
696 SETCOLF(btheme->tfile.back, 0.3, 0.3, 0.3, 1);
697 SETCOLF(btheme->tfile.panel, 0.3, 0.3, 0.3, 1);
698 SETCOLF(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
699 SETCOL(btheme->tfile.text, 250, 250, 250, 255);
700 SETCOL(btheme->tfile.text_hi, 15, 15, 15, 255);
701 SETCOL(btheme->tfile.panel, 145, 145, 145, 255); // bookmark/ui regions
702 SETCOL(btheme->tfile.active, 130, 130, 130, 255); // selected files
703 SETCOL(btheme->tfile.hilite, 255, 140, 25, 255); // selected files
705 SETCOL(btheme->tfile.grid, 250, 250, 250, 255);
706 SETCOL(btheme->tfile.image, 250, 250, 250, 255);
707 SETCOL(btheme->tfile.movie, 250, 250, 250, 255);
708 SETCOL(btheme->tfile.scene, 250, 250, 250, 255);
712 btheme->tseq= btheme->tv3d;
713 SETCOL(btheme->tseq.back, 116, 116, 116, 255);
714 SETCOL(btheme->tseq.movie, 81, 105, 135, 255);
715 SETCOL(btheme->tseq.image, 109, 88, 129, 255);
716 SETCOL(btheme->tseq.scene, 78, 152, 62, 255);
717 SETCOL(btheme->tseq.audio, 46, 143, 143, 255);
718 SETCOL(btheme->tseq.effect, 169, 84, 124, 255);
719 SETCOL(btheme->tseq.plugin, 126, 126, 80, 255);
720 SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
721 SETCOL(btheme->tseq.meta, 109, 145, 131, 255);
725 btheme->tima= btheme->tv3d;
726 SETCOL(btheme->tima.back, 53, 53, 53, 255);
727 SETCOL(btheme->tima.vertex, 0, 0, 0, 255);
728 SETCOL(btheme->tima.vertex_select, 255, 133, 0, 255);
729 btheme->tima.vertex_size= 3;
730 btheme->tima.facedot_size= 3;
731 SETCOL(btheme->tima.face, 255, 255, 255, 10);
732 SETCOL(btheme->tima.face_select, 255, 133, 0, 60);
733 SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
734 SETCOLF(btheme->tima.preview_back, 0.45, 0.45, 0.45, 1.0);
736 /* space imageselect */
737 btheme->timasel= btheme->tv3d;
738 SETCOL(btheme->timasel.active, 195, 195, 195, 255); /* active tile */
739 SETCOL(btheme->timasel.grid, 94, 94, 94, 255); /* active file text */
740 SETCOL(btheme->timasel.back, 110, 110, 110, 255);
741 SETCOL(btheme->timasel.shade1, 94, 94, 94, 255); /* bar */
742 SETCOL(btheme->timasel.shade2, 172, 172, 172, 255); /* sliders */
743 SETCOL(btheme->timasel.hilite, 17, 27, 60, 100); /* selected tile */
744 SETCOL(btheme->timasel.text, 0, 0, 0, 255);
745 SETCOL(btheme->timasel.text_hi, 255, 255, 255, 255);
746 SETCOL(btheme->timasel.panel, 132, 132, 132, 255);
749 btheme->text= btheme->tv3d;
750 SETCOL(btheme->text.back, 153, 153, 153, 255);
751 SETCOL(btheme->text.shade1, 143, 143, 143, 255);
752 SETCOL(btheme->text.shade2, 0xc6, 0x77, 0x77, 255);
753 SETCOL(btheme->text.hilite, 255, 0, 0, 255);
755 /* syntax highlighting */
756 SETCOL(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
757 SETCOL(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
758 SETCOL(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
759 SETCOL(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
760 SETCOL(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
763 btheme->toops= btheme->tv3d;
764 SETCOLF(btheme->toops.back, 0.45, 0.45, 0.45, 1.0);
767 btheme->tinfo= btheme->tv3d;
768 SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
770 /* space user preferences */
771 btheme->tuserpref= btheme->tv3d;
772 SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
775 btheme->tconsole= btheme->tv3d;
776 SETCOL(btheme->tconsole.back, 0, 0, 0, 255);
777 SETCOL(btheme->tconsole.console_output, 96, 128, 255, 255);
778 SETCOL(btheme->tconsole.console_input, 255, 255, 255, 255);
779 SETCOL(btheme->tconsole.console_info, 0, 170, 0, 255);
780 SETCOL(btheme->tconsole.console_error, 220, 96, 96, 255);
781 SETCOL(btheme->tconsole.console_cursor, 220, 96, 96, 255);
785 btheme->tsnd= btheme->tv3d;
786 SETCOLF(btheme->tsnd.back, 0.45, 0.45, 0.45, 1.0);
787 SETCOLF(btheme->tsnd.grid, 0.36, 0.36, 0.36, 1.0);
788 SETCOL(btheme->tsnd.shade1, 173, 173, 173, 255); // sliders
791 btheme->ttime= btheme->tsnd; // same as sound space
793 /* space node, re-uses syntax color storage */
794 btheme->tnode= btheme->tv3d;
795 SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
796 SETCOL(btheme->tnode.syntaxl, 155, 155, 155, 160); /* TH_NODE, backdrop */
797 SETCOL(btheme->tnode.syntaxn, 100, 100, 100, 255); /* in/output */
798 SETCOL(btheme->tnode.syntaxb, 108, 105, 111, 255); /* operator */
799 SETCOL(btheme->tnode.syntaxv, 104, 106, 117, 255); /* generator */
800 SETCOL(btheme->tnode.syntaxc, 105, 117, 110, 255); /* group */
801 btheme->tnode.noodle_curving = 5;
804 btheme->tlogic= btheme->tv3d;
805 SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
810 void UI_SetTheme(int spacetype, int regionid)
812 if(spacetype==0) { // called for safety, when delete themes
813 theme_active= U.themes.first;
814 theme_spacetype= SPACE_VIEW3D;
815 theme_regionid= RGN_TYPE_WINDOW;
818 // later on, a local theme can be found too
819 theme_active= U.themes.first;
820 theme_spacetype= spacetype;
821 theme_regionid= regionid;
825 // for space windows only
826 void UI_ThemeColor(int colorid)
828 const unsigned char *cp;
830 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
836 void UI_ThemeColor4(int colorid)
838 const unsigned char *cp;
840 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
845 // set the color with offset for shades
846 void UI_ThemeColorShade(int colorid, int offset)
849 const unsigned char *cp;
851 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
852 r= offset + (int) cp[0];
854 g= offset + (int) cp[1];
856 b= offset + (int) cp[2];
858 //glColor3ub(r, g, b);
859 glColor4ub(r, g, b, cp[3]);
861 void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
864 const unsigned char *cp;
866 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
867 r= coloffset + (int) cp[0];
869 g= coloffset + (int) cp[1];
871 b= coloffset + (int) cp[2];
873 a= alphaoffset + (int) cp[3];
875 glColor4ub(r, g, b, a);
878 // blend between to theme colors, and set it
879 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
882 const unsigned char *cp1, *cp2;
884 cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
885 cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
887 CLAMP(fac, 0.0f, 1.0f);
888 r= floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
889 g= floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
890 b= floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
895 // blend between to theme colors, shade it, and set it
896 void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
899 const unsigned char *cp1, *cp2;
901 cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
902 cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
904 CLAMP(fac, 0.0f, 1.0f);
905 r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
906 g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
907 b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
916 // blend between to theme colors, shade it, and set it
917 void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
920 const unsigned char *cp1, *cp2;
922 cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
923 cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
925 CLAMP(fac, 0.0f, 1.0f);
926 r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
927 g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
928 b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
929 a= alphaoffset + floorf((1.0f-fac)*cp1[3] + fac*cp2[3]);
936 glColor4ub(r, g, b, a);
940 // get individual values, not scaled
941 float UI_GetThemeValuef(int colorid)
943 const unsigned char *cp;
945 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
946 return ((float)cp[0]);
950 // get individual values, not scaled
951 int UI_GetThemeValue(int colorid)
953 const unsigned char *cp;
955 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
956 return ((int) cp[0]);
961 // get the color, range 0.0-1.0
962 void UI_GetThemeColor3fv(int colorid, float *col)
964 const unsigned char *cp;
966 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
967 col[0]= ((float)cp[0])/255.0f;
968 col[1]= ((float)cp[1])/255.0f;
969 col[2]= ((float)cp[2])/255.0f;
972 // get the color, range 0.0-1.0, complete with shading offset
973 void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
976 const unsigned char *cp;
978 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
980 r= offset + (int) cp[0];
982 g= offset + (int) cp[1];
984 b= offset + (int) cp[2];
987 col[0]= ((float)r)/255.0f;
988 col[1]= ((float)g)/255.0f;
989 col[2]= ((float)b)/255.0f;
992 // get the color, in char pointer
993 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
995 const unsigned char *cp;
997 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1003 // get the color, in char pointer
1004 void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
1006 const unsigned char *cp;
1008 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
1015 void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
1017 const unsigned char *cp;
1019 cp= UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
1026 // blends and shades between two char color pointers
1027 void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
1030 CLAMP(fac, 0.0f, 1.0f);
1031 r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
1032 g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
1033 b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
1035 r= r<0?0:(r>255?255:r);
1036 g= g<0?0:(g>255?255:g);
1037 b= b<0?0:(b>255?255:b);
1039 glColor3ub(r, g, b);
1042 // get a 3 byte color, blended and shaded between two other char color pointers
1043 void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset)
1047 CLAMP(fac, 0.0f, 1.0f);
1048 r= offset+floor((1.0f-fac)*cp1[0] + fac*cp2[0]);
1049 g= offset+floor((1.0f-fac)*cp1[1] + fac*cp2[1]);
1050 b= offset+floor((1.0f-fac)*cp1[2] + fac*cp2[2]);
1061 void UI_ThemeClearColor(int colorid)
1065 UI_GetThemeColor3fv(colorid, col);
1066 glClearColor(col[0], col[1], col[2], 0.0);
1069 void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
1074 dst_col[0]= src_col[0]>219?255:src_col[0]+36;
1075 dst_col[1]= src_col[1]<26?0:src_col[1]-26;
1076 dst_col[2]= src_col[2]<26?0:src_col[2]-26;
1079 dst_col[0]= src_col[0]<46?0:src_col[0]-36;
1080 dst_col[1]= src_col[1]>189?255:src_col[1]+66;
1081 dst_col[2]= src_col[2]<46?0:src_col[2]-36;
1084 dst_col[0]= src_col[0]<26?0:src_col[0]-26;
1085 dst_col[1]= src_col[1]<26?0:src_col[1]-26;
1086 dst_col[2]= src_col[2]>209?255:src_col[2]+46;
1089 BLI_assert(!"invalid axis arg");
1093 /* ************************************************************* */
1095 /* patching UserDef struct and Themes */
1096 void init_userdef_do_versions(void)
1098 Main *bmain= G.main;
1101 /* the UserDef struct is not corrected with do_versions() .... ugh! */
1102 if(U.wheellinescroll == 0) U.wheellinescroll = 3;
1103 if(U.menuthreshold1==0) {
1104 U.menuthreshold1= 5;
1105 U.menuthreshold2= 2;
1107 if(U.tb_leftmouse==0) {
1111 if(U.mixbufsize==0) U.mixbufsize= 2048;
1112 if (strcmp(U.tempdir, "/") == 0) {
1113 BLI_where_is_temp(U.tempdir, sizeof(U.tempdir), FALSE);
1115 if (U.autokey_mode == 0) {
1116 /* 'add/replace' but not on */
1119 if (U.savetime <= 0) {
1121 // XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
1123 /* transform widget settings */
1124 if(U.tw_hotspot==0) {
1126 U.tw_size= 20; // percentage of window size
1127 U.tw_handlesize= 16; // percentage of widget radius
1129 if(U.pad_rot_angle==0)
1130 U.pad_rot_angle= 15;
1132 /* signal for derivedmesh to use colorband */
1133 /* run incase this was on and is now off in the user prefs [#28096] */
1134 vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight):NULL);
1136 if (bmain->versionfile <= 191) {
1137 strcpy(U.plugtexdir, U.textudir);
1138 strcpy(U.sounddir, "/");
1141 /* patch to set Dupli Armature */
1142 if (bmain->versionfile < 220) {
1143 U.dupflag |= USER_DUP_ARM;
1146 /* added seam, normal color, undo */
1147 if (bmain->versionfile <= 234) {
1150 U.uiflag |= USER_GLOBALUNDO;
1151 if (U.undosteps==0) U.undosteps=32;
1153 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1154 /* check for alpha==0 is safe, then color was never set */
1155 if(btheme->tv3d.edge_seam[3]==0) {
1156 SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255);
1158 if(btheme->tv3d.normal[3]==0) {
1159 SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
1161 if(btheme->tv3d.vertex_normal[3]==0) {
1162 SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
1164 if(btheme->tv3d.face_dot[3]==0) {
1165 SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255);
1166 btheme->tv3d.facedot_size= 4;
1170 if (bmain->versionfile <= 235) {
1171 /* illegal combo... */
1172 if (U.flag & USER_LMOUSESELECT)
1173 U.flag &= ~USER_TWOBUTTONMOUSE;
1175 if (bmain->versionfile <= 236) {
1177 /* new space type */
1178 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1179 /* check for alpha==0 is safe, then color was never set */
1180 if(btheme->ttime.back[3]==0) {
1181 btheme->ttime = btheme->tsnd; // copy from sound
1183 if(btheme->text.syntaxn[3]==0) {
1184 SETCOL(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
1185 SETCOL(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
1186 SETCOL(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
1187 SETCOL(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
1188 SETCOL(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
1192 if (bmain->versionfile <= 237) {
1195 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1196 /* check for alpha==0 is safe, then color was never set */
1197 if(btheme->tv3d.bone_solid[3]==0) {
1198 SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
1199 SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);
1203 if (bmain->versionfile <= 238) {
1206 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1207 /* check for alpha==0 is safe, then color was never set */
1208 if(btheme->tnla.strip[3]==0) {
1209 SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255);
1210 SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
1214 if (bmain->versionfile <= 239) {
1217 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1218 /* Lamp theme, check for alpha==0 is safe, then color was never set */
1219 if(btheme->tv3d.lamp[3]==0) {
1220 SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40);
1221 /* TEMPORAL, remove me! (ton) */
1222 U.uiflag |= USER_PLAINMENUS;
1226 if(U.obcenter_dia==0) U.obcenter_dia= 6;
1228 if (bmain->versionfile <= 241) {
1230 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1231 /* Node editor theme, check for alpha==0 is safe, then color was never set */
1232 if(btheme->tnode.syntaxn[3]==0) {
1233 /* re-uses syntax color storage */
1234 btheme->tnode= btheme->tv3d;
1235 SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
1236 SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */
1237 SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */
1238 SETCOL(btheme->tnode.syntaxb, 127,127,127, 255); /* operator */
1239 SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */
1240 SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */
1242 /* Group theme colors */
1243 if(btheme->tv3d.group[3]==0) {
1244 SETCOL(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255);
1245 SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
1247 /* Sequence editor theme*/
1248 if(btheme->tseq.movie[3]==0) {
1249 SETCOL(btheme->tseq.movie, 81, 105, 135, 255);
1250 SETCOL(btheme->tseq.image, 109, 88, 129, 255);
1251 SETCOL(btheme->tseq.scene, 78, 152, 62, 255);
1252 SETCOL(btheme->tseq.audio, 46, 143, 143, 255);
1253 SETCOL(btheme->tseq.effect, 169, 84, 124, 255);
1254 SETCOL(btheme->tseq.plugin, 126, 126, 80, 255);
1255 SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
1256 SETCOL(btheme->tseq.meta, 109, 145, 131, 255);
1260 /* set defaults for 3D View rotating axis indicator */
1261 /* since size can't be set to 0, this indicates it's not saved in startup.blend */
1262 if (U.rvisize == 0) {
1265 U.uiflag |= USER_SHOW_ROTVIEWICON;
1269 if (bmain->versionfile <= 242) {
1272 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1273 /* long keyframe color */
1274 /* check for alpha==0 is safe, then color was never set */
1275 if(btheme->tact.strip[3]==0) {
1276 SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
1277 SETCOL(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204);
1278 SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
1281 /* IPO-Editor - Vertex Size*/
1282 if(btheme->tipo.vertex_size == 0) {
1283 btheme->tipo.vertex_size= 3;
1287 if (bmain->versionfile <= 243) {
1288 /* set default number of recently-used files (if not set) */
1289 if (U.recent_files == 0) U.recent_files = 10;
1291 if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
1293 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1294 SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
1296 if(U.coba_weight.tot==0)
1297 init_colorband(&U.coba_weight, 1);
1299 if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
1301 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1302 /* these should all use the same color */
1303 SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
1304 SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
1305 SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
1306 SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
1307 SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
1308 SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255);
1309 SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
1312 if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
1314 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1315 /* action channel groups (recolor anyway) */
1316 SETCOL(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
1317 SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
1319 /* bone custom-color sets */
1320 if (btheme->tarm[0].solid[3] == 0)
1321 ui_theme_init_boneColorSets(btheme);
1324 if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
1325 U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE;
1327 if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
1331 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1334 /* IPO Editor: Handles/Vertices */
1335 col = btheme->tipo.vertex;
1336 SETCOL(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
1337 col = btheme->tipo.vertex_select;
1338 SETCOL(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
1339 btheme->tipo.handle_vertex_size= btheme->tipo.vertex_size;
1341 /* Sequence/Image Editor: colors for GPencil text */
1342 col = btheme->tv3d.bone_pose;
1343 SETCOL(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
1344 SETCOL(btheme->tima.bone_pose, col[0], col[1], col[2], 255);
1345 col = btheme->tv3d.vertex_select;
1346 SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
1349 if (bmain->versionfile < 250) {
1352 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1353 /* this was not properly initialized in 2.45 */
1354 if(btheme->tima.face_dot[3]==0) {
1355 SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
1356 SETCOL(btheme->tima.face_dot, 255, 133, 0, 255);
1357 btheme->tima.facedot_size= 2;
1360 /* DopeSheet - (Object) Channel color */
1361 SETCOL(btheme->tact.ds_channel, 82, 96, 110, 255);
1362 SETCOL(btheme->tact.ds_subchannel, 124, 137, 150, 255);
1363 /* DopeSheet - Group Channel color (saner version) */
1364 SETCOL(btheme->tact.group, 79, 101, 73, 255);
1365 SETCOL(btheme->tact.group_active, 135, 177, 125, 255);
1367 /* Graph Editor - (Object) Channel color */
1368 SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255);
1369 SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
1370 /* Graph Editor - Group Channel color */
1371 SETCOL(btheme->tipo.group, 79, 101, 73, 255);
1372 SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
1374 /* Nla Editor - (Object) Channel color */
1375 SETCOL(btheme->tnla.ds_channel, 82, 96, 110, 255);
1376 SETCOL(btheme->tnla.ds_subchannel, 124, 137, 150, 255);
1377 /* NLA Editor - New Strip colors */
1378 SETCOL(btheme->tnla.strip, 12, 10, 10, 128);
1379 SETCOL(btheme->tnla.strip_select, 255, 140, 0, 255);
1382 /* adjust grease-pencil distances */
1383 U.gp_manhattendist= 1;
1384 U.gp_euclideandist= 2;
1386 /* adjust default interpolation for new IPO-curves */
1387 U.ipo_new= BEZT_IPO_BEZ;
1390 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
1393 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1395 /* common (new) variables, it checks for alpha==0 */
1396 ui_theme_init_new(btheme);
1398 if(btheme->tui.wcol_num.outline[3]==0)
1399 ui_widget_color_init(&btheme->tui);
1401 /* Logic editor theme, check for alpha==0 is safe, then color was never set */
1402 if(btheme->tlogic.syntaxn[3]==0) {
1403 /* re-uses syntax color storage */
1404 btheme->tlogic= btheme->tv3d;
1405 SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
1408 SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
1409 SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
1413 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
1414 /* new audio system */
1415 if(U.audiochannels == 0)
1416 U.audiochannels = 2;
1417 if(U.audiodevice == 0) {
1425 if(U.audioformat == 0)
1426 U.audioformat = 0x24;
1427 if(U.audiorate == 0)
1428 U.audiorate = 44100;
1431 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
1432 U.gameflags |= USER_DISABLE_VBO;
1434 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
1437 for(km=U.user_keymaps.first; km; km=km->next) {
1438 if (strcmp(km->idname, "Armature_Sketch")==0)
1439 strcpy(km->idname, "Armature Sketch");
1440 else if (strcmp(km->idname, "View3D")==0)
1441 strcpy(km->idname, "3D View");
1442 else if (strcmp(km->idname, "View3D Generic")==0)
1443 strcpy(km->idname, "3D View Generic");
1444 else if (strcmp(km->idname, "EditMesh")==0)
1445 strcpy(km->idname, "Mesh");
1446 else if (strcmp(km->idname, "TimeLine")==0)
1447 strcpy(km->idname, "Timeline");
1448 else if (strcmp(km->idname, "UVEdit")==0)
1449 strcpy(km->idname, "UV Editor");
1450 else if (strcmp(km->idname, "Animation_Channels")==0)
1451 strcpy(km->idname, "Animation Channels");
1452 else if (strcmp(km->idname, "GraphEdit Keys")==0)
1453 strcpy(km->idname, "Graph Editor");
1454 else if (strcmp(km->idname, "GraphEdit Generic")==0)
1455 strcpy(km->idname, "Graph Editor Generic");
1456 else if (strcmp(km->idname, "Action_Keys")==0)
1457 strcpy(km->idname, "Dopesheet");
1458 else if (strcmp(km->idname, "NLA Data")==0)
1459 strcpy(km->idname, "NLA Editor");
1460 else if (strcmp(km->idname, "Node Generic")==0)
1461 strcpy(km->idname, "Node Editor");
1462 else if (strcmp(km->idname, "Logic Generic")==0)
1463 strcpy(km->idname, "Logic Editor");
1464 else if (strcmp(km->idname, "File")==0)
1465 strcpy(km->idname, "File Browser");
1466 else if (strcmp(km->idname, "FileMain")==0)
1467 strcpy(km->idname, "File Browser Main");
1468 else if (strcmp(km->idname, "FileButtons")==0)
1469 strcpy(km->idname, "File Browser Buttons");
1470 else if (strcmp(km->idname, "Buttons Generic")==0)
1471 strcpy(km->idname, "Property Editor");
1474 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
1475 if(U.wmdrawmethod == USER_DRAW_TRIPLE)
1476 U.wmdrawmethod = USER_DRAW_AUTOMATIC;
1479 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
1480 if (U.flag & USER_LMOUSESELECT)
1481 U.flag &= ~USER_TWOBUTTONMOUSE;
1483 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
1486 /* default new handle type is auto handles */
1487 U.keyhandles_new = HD_AUTO;
1489 /* init new curve colors */
1490 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1491 /* init colors used for handles in 3D-View */
1492 SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
1493 SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
1494 SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
1495 SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
1496 SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
1497 SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1498 SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1499 SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1500 SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
1502 /* same colors again for Graph Editor... */
1503 SETCOL(btheme->tipo.handle_free, 0, 0, 0, 255);
1504 SETCOL(btheme->tipo.handle_auto, 0x90, 0x90, 0x00, 255);
1505 SETCOL(btheme->tipo.handle_vect, 0x40, 0x90, 0x30, 255);
1506 SETCOL(btheme->tipo.handle_align, 0x80, 0x30, 0x60, 255);
1507 SETCOL(btheme->tipo.handle_sel_free, 0, 0, 0, 255);
1508 SETCOL(btheme->tipo.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1509 SETCOL(btheme->tipo.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1510 SETCOL(btheme->tipo.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1513 SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
1516 if (bmain->versionfile <= 252) {
1519 /* init new curve colors */
1520 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1521 if (btheme->tv3d.lastsel_point[3] == 0)
1522 SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
1525 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
1528 /* interface_widgets.c */
1529 struct uiWidgetColors wcol_progress= {
1531 {190, 190, 190, 255},
1532 {100, 100, 100, 180},
1536 {255, 255, 255, 255},
1542 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1543 /* init progress bar theme */
1544 btheme->tui.wcol_progress= wcol_progress;
1548 if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
1550 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1551 SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
1552 SETCOL(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
1553 SETCOL(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
1557 if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) {
1559 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1560 if((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width= 1;
1564 if (bmain->versionfile < 257) {
1565 /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs, so that it doesn't linger around from old configs like a ghost */
1566 U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
1569 if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 2)) {
1571 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1572 btheme->tnode.noodle_curving = 5;
1576 if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
1579 /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead */
1580 if (U.keyhandles_new == HD_AUTO)
1581 U.keyhandles_new = HD_AUTO_ANIM;
1583 /* theme color additions */
1584 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1585 /* auto-clamped handles -> based on auto */
1586 SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
1587 SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
1591 if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
1594 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1595 btheme->tv3d.speaker[3] = 255;
1599 /* GL Texture Garbage Collection (variable abused above!) */
1600 if (U.textimeout == 0) {
1601 U.texcollectrate = 60;
1604 if (U.memcachelimit <= 0) {
1605 U.memcachelimit = 32;
1607 if (U.frameserverport == 0) {
1608 U.frameserverport = 8080;
1610 if (U.dbl_click_time == 0) {
1611 U.dbl_click_time = 350;
1613 if (U.anim_player_preset == 0) {
1614 U.anim_player_preset = 1 ;
1616 if (U.scrcastfps == 0) {
1620 if (U.v2d_min_gridsize == 0) {
1621 U.v2d_min_gridsize= 35;
1623 if (U.dragthreshold == 0 )
1625 if (U.widget_unit==0)
1626 U.widget_unit= (U.dpi * 20 + 36)/72;
1627 if (U.anisotropic_filter <= 0)
1628 U.anisotropic_filter = 1;
1630 if (U.ndof_sensitivity == 0.0f) {
1631 U.ndof_sensitivity = 1.0f;
1632 U.ndof_flag = NDOF_LOCK_HORIZON |
1633 NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
1636 /* funny name, but it is GE stuff, moves userdef stuff to engine */
1637 // XXX space_set_commmandline_options();
1638 /* this timer uses U */
1639 // XXX reset_autosave();