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 *****
37 #include "MEM_guardedalloc.h"
39 #include "DNA_curve_types.h"
40 #include "DNA_userdef_types.h"
41 #include "DNA_screen_types.h"
42 #include "DNA_space_types.h"
43 #include "DNA_windowmanager_types.h"
45 #include "BLI_blenlib.h"
46 #include "BLI_utildefines.h"
48 #include "BKE_DerivedMesh.h"
49 #include "BKE_global.h"
51 #include "BKE_texture.h"
56 #include "UI_interface.h"
57 #include "UI_interface_icons.h"
59 #include "interface_intern.h"
61 /* global for themes */
62 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
64 static bTheme *theme_active=NULL;
65 static int theme_spacetype= SPACE_VIEW3D;
66 static int theme_regionid= RGN_TYPE_WINDOW;
68 void ui_resources_init(void)
70 UI_icons_init(BIFICONID_LAST);
73 void ui_resources_free(void)
79 /* ******************************************************** */
81 /* ******************************************************** */
83 const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
86 static char error[4]={240, 0, 240, 255};
87 static char alert[4]={240, 60, 60, 255};
88 static char headerdesel[4]={0,0,0,255};
90 const char *cp= error;
94 // first check for ui buttons theme
95 if(colorid < TH_THEMEUI) {
131 ts= &btheme->timasel;
146 ts= &btheme->tuserpref;
149 ts= &btheme->tconsole;
167 if(theme_regionid==RGN_TYPE_WINDOW)
169 else if(theme_regionid==RGN_TYPE_CHANNELS)
171 else if(theme_regionid==RGN_TYPE_HEADER)
177 if(theme_regionid==RGN_TYPE_WINDOW)
179 else if(theme_regionid==RGN_TYPE_CHANNELS)
181 else if(theme_regionid==RGN_TYPE_HEADER)
187 if(theme_regionid==RGN_TYPE_WINDOW)
189 else if(theme_regionid==RGN_TYPE_CHANNELS)
190 cp= ts->list_text_hi;
191 else if(theme_regionid==RGN_TYPE_HEADER)
192 cp= ts->header_text_hi;
194 cp= ts->button_text_hi;
197 if(theme_regionid==RGN_TYPE_WINDOW)
199 else if(theme_regionid==RGN_TYPE_CHANNELS)
201 else if(theme_regionid==RGN_TYPE_HEADER)
202 cp= ts->header_title;
204 cp= ts->button_title;
208 cp= ts->header; break;
210 /* we calculate a dynamic builtin header deselect color, also for pulldowns... */
212 headerdesel[0]= cp[0]>10?cp[0]-10:0;
213 headerdesel[1]= cp[1]>10?cp[1]-10:0;
214 headerdesel[2]= cp[2]>10?cp[2]-10:0;
218 cp= ts->header_text; break;
219 case TH_HEADER_TEXT_HI:
220 cp= ts->header_text_hi; break;
223 cp= ts->panel; break;
225 cp= ts->panel_text; break;
226 case TH_PANEL_TEXT_HI:
227 cp= ts->panel_text_hi; break;
230 cp= ts->button; break;
231 case TH_BUTBACK_TEXT:
232 cp= ts->button_text; break;
233 case TH_BUTBACK_TEXT_HI:
234 cp= ts->button_text_hi; break;
237 cp= ts->shade1; break;
239 cp= ts->shade2; break;
241 cp= ts->hilite; break;
250 cp= ts->select; break;
252 cp= ts->active; break;
254 cp= ts->group; break;
255 case TH_GROUP_ACTIVE:
256 cp= ts->group_active; break;
258 cp= ts->transform; break;
260 cp= ts->vertex; break;
261 case TH_VERTEX_SELECT:
262 cp= ts->vertex_select; break;
264 cp= &ts->vertex_size; break;
268 cp= ts->edge_select; break;
270 cp= ts->edge_seam; break;
272 cp= ts->edge_sharp; break;
274 cp= ts->edge_crease; break;
275 case TH_EDITMESH_ACTIVE:
276 cp= ts->editmesh_active; break;
277 case TH_EDGE_FACESEL:
278 cp= ts->edge_facesel; break;
282 cp= ts->face_select; break;
284 cp= ts->face_dot; break;
285 case TH_FACEDOT_SIZE:
286 cp= &ts->facedot_size; break;
287 case TH_DRAWEXTRA_EDGELEN:
288 cp= ts->extra_edge_len; break;
289 case TH_DRAWEXTRA_FACEAREA:
290 cp= ts->extra_face_area; break;
291 case TH_DRAWEXTRA_FACEANG:
292 cp= ts->extra_face_angle; break;
294 cp= ts->normal; break;
296 cp= ts->vertex_normal; break;
298 cp= ts->bone_solid; break;
300 cp= ts->bone_pose; break;
302 cp= ts->strip; break;
303 case TH_STRIP_SELECT:
304 cp= ts->strip_select; break;
306 cp= ts->cframe; break;
308 cp= ts->nurb_uline; break;
310 cp= ts->nurb_vline; break;
311 case TH_NURB_SEL_ULINE:
312 cp= ts->nurb_sel_uline; break;
313 case TH_NURB_SEL_VLINE:
314 cp= ts->nurb_sel_vline; break;
315 case TH_ACTIVE_SPLINE:
316 cp= ts->act_spline; break;
317 case TH_LASTSEL_POINT:
318 cp= ts->lastsel_point; break;
320 cp= ts->handle_free; break;
322 cp= ts->handle_auto; break;
324 cp= ts->handle_vect; break;
325 case TH_HANDLE_ALIGN:
326 cp= ts->handle_align; break;
327 case TH_HANDLE_SEL_FREE:
328 cp= ts->handle_sel_free; break;
329 case TH_HANDLE_SEL_AUTO:
330 cp= ts->handle_sel_auto; break;
331 case TH_HANDLE_SEL_VECT:
332 cp= ts->handle_sel_vect; break;
333 case TH_HANDLE_SEL_ALIGN:
334 cp= ts->handle_sel_align; break;
337 cp= ts->syntaxb; break;
339 cp= ts->syntaxv; break;
341 cp= ts->syntaxc; break;
343 cp= ts->syntaxl; break;
345 cp= ts->syntaxn; break;
348 cp= ts->syntaxl; break;
350 cp= ts->syntaxn; break;
351 case TH_NODE_OPERATOR:
352 cp= ts->syntaxb; break;
353 case TH_NODE_CONVERTOR:
354 cp= ts->syntaxv; break;
356 cp= ts->syntaxc; break;
359 cp= ts->movie; break;
361 cp= ts->image; break;
363 cp= ts->scene; break;
365 cp= ts->audio; break;
367 cp= ts->effect; break;
369 cp= ts->plugin; break;
370 case TH_SEQ_TRANSITION:
371 cp= ts->transition; break;
375 case TH_CONSOLE_OUTPUT:
376 cp= ts->console_output; break;
377 case TH_CONSOLE_INPUT:
378 cp= ts-> console_input; break;
379 case TH_CONSOLE_INFO:
380 cp= ts->console_info; break;
381 case TH_CONSOLE_ERROR:
382 cp= ts->console_error; break;
383 case TH_CONSOLE_CURSOR:
384 cp= ts->console_cursor; break;
386 case TH_HANDLE_VERTEX:
387 cp= ts->handle_vertex;
389 case TH_HANDLE_VERTEX_SELECT:
390 cp= ts->handle_vertex_select;
392 case TH_HANDLE_VERTEX_SIZE:
393 cp= &ts->handle_vertex_size;
396 case TH_DOPESHEET_CHANNELOB:
399 case TH_DOPESHEET_CHANNELSUBOB:
400 cp= ts->ds_subchannel;
403 case TH_PREVIEW_BACK:
404 cp= ts->preview_back;
410 return (unsigned char *)cp;
413 #define SETCOLTEST(col, r, g, b, a) if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;}
415 /* use this call to init new variables in themespace, if they're same for all */
416 static void ui_theme_init_new_do(ThemeSpace *ts)
418 SETCOLTEST(ts->header_text, 0, 0, 0, 255);
419 SETCOLTEST(ts->header_title, 0, 0, 0, 255);
420 SETCOLTEST(ts->header_text_hi, 255, 255, 255, 255);
422 SETCOLTEST(ts->panel_text, 0, 0, 0, 255);
423 SETCOLTEST(ts->panel_title, 0, 0, 0, 255);
424 SETCOLTEST(ts->panel_text_hi, 255, 255, 255, 255);
426 SETCOLTEST(ts->button, 145, 145, 145, 245);
427 SETCOLTEST(ts->button_title, 0, 0, 0, 255);
428 SETCOLTEST(ts->button_text, 0, 0, 0, 255);
429 SETCOLTEST(ts->button_text_hi, 255, 255, 255, 255);
431 SETCOLTEST(ts->list, 165, 165, 165, 255);
432 SETCOLTEST(ts->list_title, 0, 0, 0, 255);
433 SETCOLTEST(ts->list_text, 0, 0, 0, 255);
434 SETCOLTEST(ts->list_text_hi, 255, 255, 255, 255);
437 static void ui_theme_init_new(bTheme *btheme)
439 ui_theme_init_new_do(&btheme->tbuts);
440 ui_theme_init_new_do(&btheme->tv3d);
441 ui_theme_init_new_do(&btheme->tfile);
442 ui_theme_init_new_do(&btheme->tipo);
443 ui_theme_init_new_do(&btheme->tinfo);
444 ui_theme_init_new_do(&btheme->tsnd);
445 ui_theme_init_new_do(&btheme->tact);
446 ui_theme_init_new_do(&btheme->tnla);
447 ui_theme_init_new_do(&btheme->tseq);
448 ui_theme_init_new_do(&btheme->tima);
449 ui_theme_init_new_do(&btheme->timasel);
450 ui_theme_init_new_do(&btheme->text);
451 ui_theme_init_new_do(&btheme->toops);
452 ui_theme_init_new_do(&btheme->ttime);
453 ui_theme_init_new_do(&btheme->tnode);
454 ui_theme_init_new_do(&btheme->tlogic);
455 ui_theme_init_new_do(&btheme->tuserpref);
456 ui_theme_init_new_do(&btheme->tconsole);
460 #define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a;
461 #define SETCOLF(col, r, g, b, a) col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255;
463 /* initialize default theme
464 Note: when you add new colors, created & saved themes need initialized
465 use function below, init_userdef_do_versions()
467 void ui_theme_init_default(void)
471 /* we search for the theme with name Default */
472 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
473 if(strcmp("Default", btheme->name)==0) break;
477 btheme= MEM_callocN(sizeof(bTheme), "theme");
478 BLI_addtail(&U.themes, btheme);
479 strcpy(btheme->name, "Default");
482 UI_SetTheme(0, 0); // make sure the global used in this file is set
485 ui_widget_color_init(&btheme->tui);
487 /* common (new) variables */
488 ui_theme_init_new(btheme);
491 SETCOLF(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0);
492 SETCOL(btheme->tv3d.text, 0, 0, 0, 255);
493 SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255);
495 SETCOLF(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0);
496 SETCOLF(btheme->tv3d.button, 0.45, 0.45, 0.45, 1.0);
497 SETCOL(btheme->tv3d.panel, 165, 165, 165, 127);
499 SETCOL(btheme->tv3d.shade1, 160, 160, 160, 100);
500 SETCOL(btheme->tv3d.shade2, 0x7f, 0x70, 0x70, 100);
502 SETCOLF(btheme->tv3d.grid, 0.251, 0.251, 0.251, 1.0);
503 SETCOL(btheme->tv3d.wire, 0x0, 0x0, 0x0, 255);
504 SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40);
505 SETCOL(btheme->tv3d.select, 241, 88, 0, 255);
506 SETCOL(btheme->tv3d.active, 255, 140, 25, 255);
507 SETCOL(btheme->tv3d.group, 8, 48, 8, 255);
508 SETCOL(btheme->tv3d.group_active, 85, 187, 85, 255);
509 SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
510 SETCOL(btheme->tv3d.vertex, 0, 0, 0, 255);
511 SETCOL(btheme->tv3d.vertex_select, 255, 133, 0, 255);
512 btheme->tv3d.vertex_size= 3;
513 SETCOL(btheme->tv3d.edge, 0x0, 0x0, 0x0, 255);
514 SETCOL(btheme->tv3d.edge_select, 255, 160, 0, 255);
515 SETCOL(btheme->tv3d.edge_seam, 219, 37, 18, 255);
516 SETCOL(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
517 SETCOL(btheme->tv3d.face, 0, 0, 0, 18);
518 SETCOL(btheme->tv3d.face_select, 255, 133, 0, 60);
519 SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
520 SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
521 SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255);
522 btheme->tv3d.facedot_size= 4;
524 SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
525 SETCOL(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
526 SETCOL(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
528 SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
530 SETCOL(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
531 SETCOL(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
532 SETCOL(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255);
533 SETCOL(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255);
535 SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
536 SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
537 SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
538 SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
539 SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
540 SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
541 SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
542 SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
544 SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
545 SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
547 SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
548 SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw
552 /* to have something initialized */
553 btheme->tbuts= btheme->tv3d;
555 SETCOLF(btheme->tbuts.back, 0.45, 0.45, 0.45, 1.0);
556 SETCOL(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255);
559 btheme->tipo= btheme->tv3d;
560 SETCOLF(btheme->tipo.back, 0.42, 0.42, 0.42, 1.0);
561 SETCOLF(btheme->tipo.list, 0.4, 0.4, 0.4, 1.0);
562 SETCOL(btheme->tipo.grid, 94, 94, 94, 255);
563 SETCOL(btheme->tipo.panel, 255, 255, 255, 150);
564 SETCOL(btheme->tipo.shade1, 150, 150, 150, 100); /* scrollbars */
565 SETCOL(btheme->tipo.shade2, 0x70, 0x70, 0x70, 100);
566 SETCOL(btheme->tipo.vertex, 0, 0, 0, 255);
567 SETCOL(btheme->tipo.vertex_select, 255, 133, 0, 255);
568 SETCOL(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255);
569 btheme->tipo.vertex_size= 3;
571 SETCOL(btheme->tipo.handle_vertex, 0, 0, 0, 255);
572 SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
573 btheme->tipo.handle_vertex_size= 3;
575 SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255);
576 SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
577 SETCOL(btheme->tipo.group, 79, 101, 73, 255);
578 SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
581 btheme->tact= btheme->tipo;
582 SETCOL(btheme->tact.strip, 12, 10, 10, 128);
583 SETCOL(btheme->tact.strip_select, 255, 140, 0, 255);
586 btheme->tnla= btheme->tact;
589 /* to have something initialized */
590 btheme->tfile= btheme->tv3d;
591 SETCOLF(btheme->tfile.back, 0.3, 0.3, 0.3, 1);
592 SETCOLF(btheme->tfile.panel, 0.3, 0.3, 0.3, 1);
593 SETCOLF(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
594 SETCOL(btheme->tfile.text, 250, 250, 250, 255);
595 SETCOL(btheme->tfile.text_hi, 15, 15, 15, 255);
596 SETCOL(btheme->tfile.panel, 145, 145, 145, 255); // bookmark/ui regions
597 SETCOL(btheme->tfile.active, 130, 130, 130, 255); // selected files
598 SETCOL(btheme->tfile.hilite, 255, 140, 25, 255); // selected files
600 SETCOL(btheme->tfile.grid, 250, 250, 250, 255);
601 SETCOL(btheme->tfile.image, 250, 250, 250, 255);
602 SETCOL(btheme->tfile.movie, 250, 250, 250, 255);
603 SETCOL(btheme->tfile.scene, 250, 250, 250, 255);
607 btheme->tseq= btheme->tv3d;
608 SETCOL(btheme->tseq.back, 116, 116, 116, 255);
609 SETCOL(btheme->tseq.movie, 81, 105, 135, 255);
610 SETCOL(btheme->tseq.image, 109, 88, 129, 255);
611 SETCOL(btheme->tseq.scene, 78, 152, 62, 255);
612 SETCOL(btheme->tseq.audio, 46, 143, 143, 255);
613 SETCOL(btheme->tseq.effect, 169, 84, 124, 255);
614 SETCOL(btheme->tseq.plugin, 126, 126, 80, 255);
615 SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
616 SETCOL(btheme->tseq.meta, 109, 145, 131, 255);
620 btheme->tima= btheme->tv3d;
621 SETCOL(btheme->tima.back, 53, 53, 53, 255);
622 SETCOL(btheme->tima.vertex, 0, 0, 0, 255);
623 SETCOL(btheme->tima.vertex_select, 255, 133, 0, 255);
624 btheme->tima.vertex_size= 3;
625 btheme->tima.facedot_size= 3;
626 SETCOL(btheme->tima.face, 255, 255, 255, 10);
627 SETCOL(btheme->tima.face_select, 255, 133, 0, 60);
628 SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
629 SETCOLF(btheme->tima.preview_back, 0.45, 0.45, 0.45, 1.0);
631 /* space imageselect */
632 btheme->timasel= btheme->tv3d;
633 SETCOL(btheme->timasel.active, 195, 195, 195, 255); /* active tile */
634 SETCOL(btheme->timasel.grid, 94, 94, 94, 255); /* active file text */
635 SETCOL(btheme->timasel.back, 110, 110, 110, 255);
636 SETCOL(btheme->timasel.shade1, 94, 94, 94, 255); /* bar */
637 SETCOL(btheme->timasel.shade2, 172, 172, 172, 255); /* sliders */
638 SETCOL(btheme->timasel.hilite, 17, 27, 60, 100); /* selected tile */
639 SETCOL(btheme->timasel.text, 0, 0, 0, 255);
640 SETCOL(btheme->timasel.text_hi, 255, 255, 255, 255);
641 SETCOL(btheme->timasel.panel, 132, 132, 132, 255);
644 btheme->text= btheme->tv3d;
645 SETCOL(btheme->text.back, 153, 153, 153, 255);
646 SETCOL(btheme->text.shade1, 143, 143, 143, 255);
647 SETCOL(btheme->text.shade2, 0xc6, 0x77, 0x77, 255);
648 SETCOL(btheme->text.hilite, 255, 0, 0, 255);
650 /* syntax highlighting */
651 SETCOL(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
652 SETCOL(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
653 SETCOL(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
654 SETCOL(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
655 SETCOL(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
658 btheme->toops= btheme->tv3d;
659 SETCOLF(btheme->toops.back, 0.45, 0.45, 0.45, 1.0);
662 btheme->tinfo= btheme->tv3d;
663 SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
665 /* space user preferences */
666 btheme->tuserpref= btheme->tv3d;
667 SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
670 btheme->tconsole= btheme->tv3d;
671 SETCOL(btheme->tconsole.back, 0, 0, 0, 255);
672 SETCOL(btheme->tconsole.console_output, 96, 128, 255, 255);
673 SETCOL(btheme->tconsole.console_input, 255, 255, 255, 255);
674 SETCOL(btheme->tconsole.console_info, 0, 170, 0, 255);
675 SETCOL(btheme->tconsole.console_error, 220, 96, 96, 255);
676 SETCOL(btheme->tconsole.console_cursor, 220, 96, 96, 255);
680 btheme->tsnd= btheme->tv3d;
681 SETCOLF(btheme->tsnd.back, 0.45, 0.45, 0.45, 1.0);
682 SETCOLF(btheme->tsnd.grid, 0.36, 0.36, 0.36, 1.0);
683 SETCOL(btheme->tsnd.shade1, 173, 173, 173, 255); // sliders
686 btheme->ttime= btheme->tsnd; // same as sound space
688 /* space node, re-uses syntax color storage */
689 btheme->tnode= btheme->tv3d;
690 SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
691 SETCOL(btheme->tnode.syntaxl, 155, 155, 155, 160); /* TH_NODE, backdrop */
692 SETCOL(btheme->tnode.syntaxn, 100, 100, 100, 255); /* in/output */
693 SETCOL(btheme->tnode.syntaxb, 108, 105, 111, 255); /* operator */
694 SETCOL(btheme->tnode.syntaxv, 104, 106, 117, 255); /* generator */
695 SETCOL(btheme->tnode.syntaxc, 105, 117, 110, 255); /* group */
698 btheme->tlogic= btheme->tv3d;
699 SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
704 void UI_SetTheme(int spacetype, int regionid)
706 if(spacetype==0) { // called for safety, when delete themes
707 theme_active= U.themes.first;
708 theme_spacetype= SPACE_VIEW3D;
709 theme_regionid= RGN_TYPE_WINDOW;
712 // later on, a local theme can be found too
713 theme_active= U.themes.first;
714 theme_spacetype= spacetype;
715 theme_regionid= regionid;
719 // for space windows only
720 void UI_ThemeColor(int colorid)
722 const unsigned char *cp;
724 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
730 void UI_ThemeColor4(int colorid)
732 const unsigned char *cp;
734 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
739 // set the color with offset for shades
740 void UI_ThemeColorShade(int colorid, int offset)
743 const unsigned char *cp;
745 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
746 r= offset + (int) cp[0];
748 g= offset + (int) cp[1];
750 b= offset + (int) cp[2];
752 //glColor3ub(r, g, b);
753 glColor4ub(r, g, b, cp[3]);
755 void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
758 const unsigned char *cp;
760 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
761 r= coloffset + (int) cp[0];
763 g= coloffset + (int) cp[1];
765 b= coloffset + (int) cp[2];
767 a= alphaoffset + (int) cp[3];
769 glColor4ub(r, g, b, a);
772 // blend between to theme colors, and set it
773 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
776 const unsigned char *cp1, *cp2;
778 cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
779 cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
781 if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
782 r= floor((1.0-fac)*cp1[0] + fac*cp2[0]);
783 g= floor((1.0-fac)*cp1[1] + fac*cp2[1]);
784 b= floor((1.0-fac)*cp1[2] + fac*cp2[2]);
789 // blend between to theme colors, shade it, and set it
790 void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
793 const unsigned char *cp1, *cp2;
795 cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
796 cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
798 if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
799 r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
800 g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
801 b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
810 // blend between to theme colors, shade it, and set it
811 void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
814 const unsigned char *cp1, *cp2;
816 cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
817 cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
819 if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
820 r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
821 g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
822 b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
823 a= alphaoffset+floor((1.0-fac)*cp1[3] + fac*cp2[3]);
830 glColor4ub(r, g, b, a);
834 // get individual values, not scaled
835 float UI_GetThemeValuef(int colorid)
837 const unsigned char *cp;
839 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
840 return ((float)cp[0]);
844 // get individual values, not scaled
845 int UI_GetThemeValue(int colorid)
847 const unsigned char *cp;
849 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
850 return ((int) cp[0]);
855 // get the color, range 0.0-1.0
856 void UI_GetThemeColor3fv(int colorid, float *col)
858 const unsigned char *cp;
860 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
861 col[0]= ((float)cp[0])/255.0;
862 col[1]= ((float)cp[1])/255.0;
863 col[2]= ((float)cp[2])/255.0;
866 // get the color, range 0.0-1.0, complete with shading offset
867 void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
870 const unsigned char *cp;
872 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
874 r= offset + (int) cp[0];
876 g= offset + (int) cp[1];
878 b= offset + (int) cp[2];
881 col[0]= ((float)r)/255.0;
882 col[1]= ((float)g)/255.0;
883 col[2]= ((float)b)/255.0;
886 // get the color, in char pointer
887 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
889 const unsigned char *cp;
891 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
897 // get the color, in char pointer
898 void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
900 const unsigned char *cp;
902 cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
909 void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
911 const unsigned char *cp;
913 cp= UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
920 // blends and shades between two char color pointers
921 void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
925 if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
926 r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
927 g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
928 b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
930 r= r<0?0:(r>255?255:r);
931 g= g<0?0:(g>255?255:g);
932 b= b<0?0:(b>255?255:b);
937 // get a 3 byte color, blended and shaded between two other char color pointers
938 void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset)
942 if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
943 r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
944 g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
945 b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
947 r= r<0?0:(r>255?255:r);
948 g= g<0?0:(g>255?255:g);
949 b= b<0?0:(b>255?255:b);
956 void UI_ThemeClearColor(int colorid)
960 UI_GetThemeColor3fv(colorid, col);
961 glClearColor(col[0], col[1], col[2], 0.0);
964 void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
969 dst_col[0]= src_col[0]>219?255:src_col[0]+36;
970 dst_col[1]= src_col[1]<26?0:src_col[1]-26;
971 dst_col[2]= src_col[2]<26?0:src_col[2]-26;
974 dst_col[0]= src_col[0]<46?0:src_col[0]-36;
975 dst_col[1]= src_col[1]>189?255:src_col[1]+66;
976 dst_col[2]= src_col[2]<46?0:src_col[2]-36;
979 dst_col[0]= src_col[0]<26?0:src_col[0]-26;
980 dst_col[1]= src_col[1]<26?0:src_col[1]-26;
981 dst_col[2]= src_col[2]>209?255:src_col[2]+46;
984 BLI_assert(!"invalid axis arg");
988 /* ************************************************************* */
990 /* patching UserDef struct and Themes */
991 void init_userdef_do_versions(void)
996 /* the UserDef struct is not corrected with do_versions() .... ugh! */
997 if(U.wheellinescroll == 0) U.wheellinescroll = 3;
998 if(U.menuthreshold1==0) {
1000 U.menuthreshold2= 2;
1002 if(U.tb_leftmouse==0) {
1006 if(U.mixbufsize==0) U.mixbufsize= 2048;
1007 if (strcmp(U.tempdir, "/") == 0) {
1008 BLI_where_is_temp(U.tempdir, sizeof(U.tempdir), FALSE);
1010 if (U.autokey_mode == 0) {
1011 /* 'add/replace' but not on */
1014 if (U.savetime <= 0) {
1016 // XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
1018 /* transform widget settings */
1019 if(U.tw_hotspot==0) {
1021 U.tw_size= 20; // percentage of window size
1022 U.tw_handlesize= 16; // percentage of widget radius
1024 if(U.pad_rot_angle==0)
1025 U.pad_rot_angle= 15;
1027 if(U.flag & USER_CUSTOM_RANGE)
1028 vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */
1030 if (bmain->versionfile <= 191) {
1031 strcpy(U.plugtexdir, U.textudir);
1032 strcpy(U.sounddir, "/");
1035 /* patch to set Dupli Armature */
1036 if (bmain->versionfile < 220) {
1037 U.dupflag |= USER_DUP_ARM;
1040 /* added seam, normal color, undo */
1041 if (bmain->versionfile <= 234) {
1044 U.uiflag |= USER_GLOBALUNDO;
1045 if (U.undosteps==0) U.undosteps=32;
1047 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1048 /* check for alpha==0 is safe, then color was never set */
1049 if(btheme->tv3d.edge_seam[3]==0) {
1050 SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255);
1052 if(btheme->tv3d.normal[3]==0) {
1053 SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
1055 if(btheme->tv3d.vertex_normal[3]==0) {
1056 SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
1058 if(btheme->tv3d.face_dot[3]==0) {
1059 SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255);
1060 btheme->tv3d.facedot_size= 4;
1064 if (bmain->versionfile <= 235) {
1065 /* illegal combo... */
1066 if (U.flag & USER_LMOUSESELECT)
1067 U.flag &= ~USER_TWOBUTTONMOUSE;
1069 if (bmain->versionfile <= 236) {
1071 /* new space type */
1072 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1073 /* check for alpha==0 is safe, then color was never set */
1074 if(btheme->ttime.back[3]==0) {
1075 btheme->ttime = btheme->tsnd; // copy from sound
1077 if(btheme->text.syntaxn[3]==0) {
1078 SETCOL(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
1079 SETCOL(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
1080 SETCOL(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
1081 SETCOL(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
1082 SETCOL(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
1086 if (bmain->versionfile <= 237) {
1089 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1090 /* check for alpha==0 is safe, then color was never set */
1091 if(btheme->tv3d.bone_solid[3]==0) {
1092 SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
1093 SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);
1097 if (bmain->versionfile <= 238) {
1100 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1101 /* check for alpha==0 is safe, then color was never set */
1102 if(btheme->tnla.strip[3]==0) {
1103 SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255);
1104 SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
1108 if (bmain->versionfile <= 239) {
1111 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1112 /* Lamp theme, check for alpha==0 is safe, then color was never set */
1113 if(btheme->tv3d.lamp[3]==0) {
1114 SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40);
1115 /* TEMPORAL, remove me! (ton) */
1116 U.uiflag |= USER_PLAINMENUS;
1120 if(U.obcenter_dia==0) U.obcenter_dia= 6;
1122 if (bmain->versionfile <= 241) {
1124 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1125 /* Node editor theme, check for alpha==0 is safe, then color was never set */
1126 if(btheme->tnode.syntaxn[3]==0) {
1127 /* re-uses syntax color storage */
1128 btheme->tnode= btheme->tv3d;
1129 SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
1130 SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */
1131 SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */
1132 SETCOL(btheme->tnode.syntaxb, 127,127,127, 255); /* operator */
1133 SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */
1134 SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */
1136 /* Group theme colors */
1137 if(btheme->tv3d.group[3]==0) {
1138 SETCOL(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255);
1139 SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
1141 /* Sequence editor theme*/
1142 if(btheme->tseq.movie[3]==0) {
1143 SETCOL(btheme->tseq.movie, 81, 105, 135, 255);
1144 SETCOL(btheme->tseq.image, 109, 88, 129, 255);
1145 SETCOL(btheme->tseq.scene, 78, 152, 62, 255);
1146 SETCOL(btheme->tseq.audio, 46, 143, 143, 255);
1147 SETCOL(btheme->tseq.effect, 169, 84, 124, 255);
1148 SETCOL(btheme->tseq.plugin, 126, 126, 80, 255);
1149 SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
1150 SETCOL(btheme->tseq.meta, 109, 145, 131, 255);
1154 /* set defaults for 3D View rotating axis indicator */
1155 /* since size can't be set to 0, this indicates it's not saved in startup.blend */
1156 if (U.rvisize == 0) {
1159 U.uiflag |= USER_SHOW_ROTVIEWICON;
1163 if (bmain->versionfile <= 242) {
1166 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1167 /* long keyframe color */
1168 /* check for alpha==0 is safe, then color was never set */
1169 if(btheme->tact.strip[3]==0) {
1170 SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
1171 SETCOL(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204);
1172 SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
1175 /* IPO-Editor - Vertex Size*/
1176 if(btheme->tipo.vertex_size == 0) {
1177 btheme->tipo.vertex_size= 3;
1181 if (bmain->versionfile <= 243) {
1182 /* set default number of recently-used files (if not set) */
1183 if (U.recent_files == 0) U.recent_files = 10;
1185 if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
1187 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1188 SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
1190 if(U.coba_weight.tot==0)
1191 init_colorband(&U.coba_weight, 1);
1193 if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
1195 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1196 /* these should all use the same color */
1197 SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
1198 SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
1199 SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
1200 SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
1201 SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
1202 SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255);
1203 SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
1206 if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
1208 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1209 /* action channel groups (recolor anyway) */
1210 SETCOL(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
1211 SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
1213 /* bone custom-color sets */
1214 // FIXME: this check for initialised colors is bad
1215 if (btheme->tarm[0].solid[3] == 0) {
1217 SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
1218 SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
1219 SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
1221 SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
1222 SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
1223 SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
1225 SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
1226 SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
1227 SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
1229 SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
1230 SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
1231 SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
1233 SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
1234 SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
1235 SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
1237 SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
1238 SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
1239 SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
1241 SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
1242 SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
1243 SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
1245 SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
1246 SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
1247 SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
1249 SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
1250 SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
1251 SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
1253 SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
1254 SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
1255 SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
1257 SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
1258 SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
1259 SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
1261 SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
1262 SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
1263 SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
1265 SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
1266 SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
1267 SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
1269 SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
1270 SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
1271 SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
1273 SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
1274 SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
1275 SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
1279 if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
1280 U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE;
1282 if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
1286 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1289 /* IPO Editor: Handles/Vertices */
1290 col = btheme->tipo.vertex;
1291 SETCOL(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
1292 col = btheme->tipo.vertex_select;
1293 SETCOL(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
1294 btheme->tipo.handle_vertex_size= btheme->tipo.vertex_size;
1296 /* Sequence/Image Editor: colors for GPencil text */
1297 col = btheme->tv3d.bone_pose;
1298 SETCOL(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
1299 SETCOL(btheme->tima.bone_pose, col[0], col[1], col[2], 255);
1300 col = btheme->tv3d.vertex_select;
1301 SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
1304 if (bmain->versionfile < 250) {
1307 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1308 /* this was not properly initialized in 2.45 */
1309 if(btheme->tima.face_dot[3]==0) {
1310 SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
1311 SETCOL(btheme->tima.face_dot, 255, 133, 0, 255);
1312 btheme->tima.facedot_size= 2;
1315 /* DopeSheet - (Object) Channel color */
1316 SETCOL(btheme->tact.ds_channel, 82, 96, 110, 255);
1317 SETCOL(btheme->tact.ds_subchannel, 124, 137, 150, 255);
1318 /* DopeSheet - Group Channel color (saner version) */
1319 SETCOL(btheme->tact.group, 79, 101, 73, 255);
1320 SETCOL(btheme->tact.group_active, 135, 177, 125, 255);
1322 /* Graph Editor - (Object) Channel color */
1323 SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255);
1324 SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
1325 /* Graph Editor - Group Channel color */
1326 SETCOL(btheme->tipo.group, 79, 101, 73, 255);
1327 SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
1329 /* Nla Editor - (Object) Channel color */
1330 SETCOL(btheme->tnla.ds_channel, 82, 96, 110, 255);
1331 SETCOL(btheme->tnla.ds_subchannel, 124, 137, 150, 255);
1332 /* NLA Editor - New Strip colors */
1333 SETCOL(btheme->tnla.strip, 12, 10, 10, 128);
1334 SETCOL(btheme->tnla.strip_select, 255, 140, 0, 255);
1337 /* adjust grease-pencil distances */
1338 U.gp_manhattendist= 1;
1339 U.gp_euclideandist= 2;
1341 /* adjust default interpolation for new IPO-curves */
1342 U.ipo_new= BEZT_IPO_BEZ;
1345 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
1348 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1350 /* common (new) variables, it checks for alpha==0 */
1351 ui_theme_init_new(btheme);
1353 if(btheme->tui.wcol_num.outline[3]==0)
1354 ui_widget_color_init(&btheme->tui);
1356 /* Logic editor theme, check for alpha==0 is safe, then color was never set */
1357 if(btheme->tlogic.syntaxn[3]==0) {
1358 /* re-uses syntax color storage */
1359 btheme->tlogic= btheme->tv3d;
1360 SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
1363 SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
1364 SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
1368 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
1369 /* new audio system */
1370 if(U.audiochannels == 0)
1371 U.audiochannels = 2;
1372 if(U.audiodevice == 0) {
1380 if(U.audioformat == 0)
1381 U.audioformat = 0x24;
1382 if(U.audiorate == 0)
1383 U.audiorate = 44100;
1386 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
1387 U.gameflags |= USER_DISABLE_VBO;
1389 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
1392 for(km=U.keymaps.first; km; km=km->next) {
1393 if (strcmp(km->idname, "Armature_Sketch")==0)
1394 strcpy(km->idname, "Armature Sketch");
1395 else if (strcmp(km->idname, "View3D")==0)
1396 strcpy(km->idname, "3D View");
1397 else if (strcmp(km->idname, "View3D Generic")==0)
1398 strcpy(km->idname, "3D View Generic");
1399 else if (strcmp(km->idname, "EditMesh")==0)
1400 strcpy(km->idname, "Mesh");
1401 else if (strcmp(km->idname, "TimeLine")==0)
1402 strcpy(km->idname, "Timeline");
1403 else if (strcmp(km->idname, "UVEdit")==0)
1404 strcpy(km->idname, "UV Editor");
1405 else if (strcmp(km->idname, "Animation_Channels")==0)
1406 strcpy(km->idname, "Animation Channels");
1407 else if (strcmp(km->idname, "GraphEdit Keys")==0)
1408 strcpy(km->idname, "Graph Editor");
1409 else if (strcmp(km->idname, "GraphEdit Generic")==0)
1410 strcpy(km->idname, "Graph Editor Generic");
1411 else if (strcmp(km->idname, "Action_Keys")==0)
1412 strcpy(km->idname, "Dopesheet");
1413 else if (strcmp(km->idname, "NLA Data")==0)
1414 strcpy(km->idname, "NLA Editor");
1415 else if (strcmp(km->idname, "Node Generic")==0)
1416 strcpy(km->idname, "Node Editor");
1417 else if (strcmp(km->idname, "Logic Generic")==0)
1418 strcpy(km->idname, "Logic Editor");
1419 else if (strcmp(km->idname, "File")==0)
1420 strcpy(km->idname, "File Browser");
1421 else if (strcmp(km->idname, "FileMain")==0)
1422 strcpy(km->idname, "File Browser Main");
1423 else if (strcmp(km->idname, "FileButtons")==0)
1424 strcpy(km->idname, "File Browser Buttons");
1425 else if (strcmp(km->idname, "Buttons Generic")==0)
1426 strcpy(km->idname, "Property Editor");
1429 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
1430 if(U.wmdrawmethod == USER_DRAW_TRIPLE)
1431 U.wmdrawmethod = USER_DRAW_AUTOMATIC;
1434 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
1435 if (U.flag & USER_LMOUSESELECT)
1436 U.flag &= ~USER_TWOBUTTONMOUSE;
1438 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
1441 /* default new handle type is auto handles */
1442 U.keyhandles_new = HD_AUTO;
1444 /* init new curve colors */
1445 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1446 /* init colors used for handles in 3D-View */
1447 SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
1448 SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
1449 SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
1450 SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
1451 SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
1452 SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1453 SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1454 SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1455 SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
1457 /* same colors again for Graph Editor... */
1458 SETCOL(btheme->tipo.handle_free, 0, 0, 0, 255);
1459 SETCOL(btheme->tipo.handle_auto, 0x90, 0x90, 0x00, 255);
1460 SETCOL(btheme->tipo.handle_vect, 0x40, 0x90, 0x30, 255);
1461 SETCOL(btheme->tipo.handle_align, 0x80, 0x30, 0x60, 255);
1462 SETCOL(btheme->tipo.handle_sel_free, 0, 0, 0, 255);
1463 SETCOL(btheme->tipo.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1464 SETCOL(btheme->tipo.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1465 SETCOL(btheme->tipo.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1468 SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
1471 if (bmain->versionfile <= 252) {
1474 /* init new curve colors */
1475 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1476 if (btheme->tv3d.lastsel_point[3] == 0)
1477 SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
1480 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
1483 /* interface_widgets.c */
1484 struct uiWidgetColors wcol_progress= {
1486 {190, 190, 190, 255},
1487 {100, 100, 100, 180},
1491 {255, 255, 255, 255},
1497 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1498 /* init progress bar theme */
1499 btheme->tui.wcol_progress= wcol_progress;
1503 if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
1505 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1506 SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
1507 SETCOL(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
1508 SETCOL(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
1512 if (bmain->versionfile < 257) {
1513 /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs, so that it doesn't linger around from old configs like a ghost */
1514 U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
1517 /* GL Texture Garbage Collection (variable abused above!) */
1518 if (U.textimeout == 0) {
1519 U.texcollectrate = 60;
1522 if (U.memcachelimit <= 0) {
1523 U.memcachelimit = 32;
1525 if (U.frameserverport == 0) {
1526 U.frameserverport = 8080;
1528 if (U.dbl_click_time == 0) {
1529 U.dbl_click_time = 350;
1531 if (U.anim_player_preset == 0) {
1532 U.anim_player_preset = 1 ;
1534 if (U.scrcastfps == 0) {
1538 if (U.v2d_min_gridsize == 0) {
1539 U.v2d_min_gridsize= 35;
1541 if (U.dragthreshold == 0 )
1544 /* funny name, but it is GE stuff, moves userdef stuff to engine */
1545 // XXX space_set_commmandline_options();
1546 /* this timer uses U */
1547 // XXX reset_autosave();