Blender V2.61 - r43446

resources.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL/BL DUAL LICENSE BLOCK *****
00026  */
00027 
00032 #include <math.h>
00033 #include <stdlib.h>
00034 #include <string.h>
00035 
00036 #include "MEM_guardedalloc.h"
00037 
00038 #include "DNA_curve_types.h"
00039 #include "DNA_userdef_types.h"
00040 #include "DNA_screen_types.h"
00041 #include "DNA_space_types.h"
00042 #include "DNA_windowmanager_types.h"
00043 
00044 #include "BLI_blenlib.h"
00045 #include "BLI_utildefines.h"
00046 
00047 #include "BKE_DerivedMesh.h"
00048 #include "BKE_global.h"
00049 #include "BKE_main.h"
00050 #include "BKE_texture.h"
00051 
00052 
00053 #include "BIF_gl.h"
00054 
00055 #include "UI_interface.h"
00056 #include "UI_interface_icons.h"
00057 
00058 #include "interface_intern.h"
00059 
00060 /* global for themes */
00061 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
00062 
00063 static bTheme *theme_active=NULL;
00064 static int theme_spacetype= SPACE_VIEW3D;
00065 static int theme_regionid= RGN_TYPE_WINDOW;
00066 
00067 void ui_resources_init(void)
00068 {
00069     UI_icons_init(BIFICONID_LAST);
00070 }
00071 
00072 void ui_resources_free(void)
00073 {
00074     UI_icons_free();
00075 }
00076 
00077 
00078 /* ******************************************************** */
00079 /*    THEMES */
00080 /* ******************************************************** */
00081 
00082 const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
00083 {
00084     ThemeSpace *ts= NULL;
00085     static char error[4]={240, 0, 240, 255};
00086     static char alert[4]={240, 60, 60, 255};
00087     static char headerdesel[4]={0,0,0,255};
00088     
00089     const char *cp= error;
00090     
00091     if(btheme) {
00092     
00093         // first check for ui buttons theme
00094         if(colorid < TH_THEMEUI) {
00095         
00096             switch(colorid) {
00097 
00098             case TH_REDALERT:
00099                 cp= alert; break;
00100             }
00101         }
00102         else {
00103         
00104             switch(spacetype) {
00105             case SPACE_BUTS:
00106                 ts= &btheme->tbuts;
00107                 break;
00108             case SPACE_VIEW3D:
00109                 ts= &btheme->tv3d;
00110                 break;
00111             case SPACE_IPO:
00112                 ts= &btheme->tipo;
00113                 break;
00114             case SPACE_FILE:
00115                 ts= &btheme->tfile;
00116                 break;
00117             case SPACE_NLA:
00118                 ts= &btheme->tnla;
00119                 break;
00120             case SPACE_ACTION:
00121                 ts= &btheme->tact;
00122                 break;
00123             case SPACE_SEQ:
00124                 ts= &btheme->tseq;
00125                 break;
00126             case SPACE_IMAGE:
00127                 ts= &btheme->tima;
00128                 break;
00129             case SPACE_TEXT:
00130                 ts= &btheme->text;
00131                 break;
00132             case SPACE_OUTLINER:
00133                 ts= &btheme->toops;
00134                 break;
00135             case SPACE_INFO:
00136                 ts= &btheme->tinfo;
00137                 break;
00138             case SPACE_USERPREF:
00139                 ts= &btheme->tuserpref;
00140                 break;
00141             case SPACE_CONSOLE:
00142                 ts= &btheme->tconsole;
00143                 break;
00144             case SPACE_TIME:
00145                 ts= &btheme->ttime;
00146                 break;
00147             case SPACE_NODE:
00148                 ts= &btheme->tnode;
00149                 break;
00150             case SPACE_LOGIC:
00151                 ts= &btheme->tlogic;
00152                 break;
00153             case SPACE_CLIP:
00154                 ts= &btheme->tclip;
00155                 break;
00156             default:
00157                 ts= &btheme->tv3d;
00158                 break;
00159             }
00160             
00161             switch(colorid) {
00162             case TH_BACK:
00163                 if(theme_regionid==RGN_TYPE_WINDOW)
00164                     cp= ts->back;
00165                 else if(theme_regionid==RGN_TYPE_CHANNELS)
00166                     cp= ts->list;
00167                 else if(theme_regionid==RGN_TYPE_HEADER)
00168                     cp= ts->header;
00169                 else
00170                     cp= ts->button; 
00171                 break;
00172             case TH_TEXT:
00173                 if(theme_regionid==RGN_TYPE_WINDOW)
00174                     cp= ts->text; 
00175                 else if(theme_regionid==RGN_TYPE_CHANNELS)
00176                     cp= ts->list_text;
00177                 else if(theme_regionid==RGN_TYPE_HEADER)
00178                     cp= ts->header_text;
00179                 else
00180                     cp= ts->button_text; 
00181                 break;
00182             case TH_TEXT_HI:
00183                 if(theme_regionid==RGN_TYPE_WINDOW)
00184                     cp= ts->text_hi;
00185                 else if(theme_regionid==RGN_TYPE_CHANNELS)
00186                     cp= ts->list_text_hi;
00187                 else if(theme_regionid==RGN_TYPE_HEADER)
00188                     cp= ts->header_text_hi;
00189                 else
00190                     cp= ts->button_text_hi; 
00191                 break;
00192             case TH_TITLE:
00193                 if(theme_regionid==RGN_TYPE_WINDOW)
00194                     cp= ts->title;
00195                 else if(theme_regionid==RGN_TYPE_CHANNELS)
00196                     cp= ts->list_title;
00197                 else if(theme_regionid==RGN_TYPE_HEADER)
00198                     cp= ts->header_title;
00199                 else
00200                     cp= ts->button_title; 
00201                 break;
00202                 
00203             case TH_HEADER:
00204                 cp= ts->header; break;
00205             case TH_HEADERDESEL:
00206                 /* we calculate a dynamic builtin header deselect color, also for pulldowns... */
00207                 cp= ts->header; 
00208                 headerdesel[0]= cp[0]>10?cp[0]-10:0;
00209                 headerdesel[1]= cp[1]>10?cp[1]-10:0;
00210                 headerdesel[2]= cp[2]>10?cp[2]-10:0;
00211                 cp= headerdesel;
00212                 break;
00213             case TH_HEADER_TEXT:
00214                 cp= ts->header_text; break;
00215             case TH_HEADER_TEXT_HI:
00216                 cp= ts->header_text_hi; break;
00217                 
00218             case TH_PANEL:
00219                 cp= ts->panel; break;
00220             case TH_PANEL_TEXT:
00221                 cp= ts->panel_text; break;
00222             case TH_PANEL_TEXT_HI:
00223                 cp= ts->panel_text_hi; break;
00224                 
00225             case TH_BUTBACK:
00226                 cp= ts->button; break;
00227             case TH_BUTBACK_TEXT:
00228                 cp= ts->button_text; break;
00229             case TH_BUTBACK_TEXT_HI:
00230                 cp= ts->button_text_hi; break;
00231                 
00232             case TH_SHADE1:
00233                 cp= ts->shade1; break;
00234             case TH_SHADE2:
00235                 cp= ts->shade2; break;
00236             case TH_HILITE:
00237                 cp= ts->hilite; break;
00238                 
00239             case TH_GRID:
00240                 cp= ts->grid; break;
00241             case TH_WIRE:
00242                 cp= ts->wire; break;
00243             case TH_LAMP:
00244                 cp= ts->lamp; break;
00245             case TH_SPEAKER:
00246                 cp= ts->speaker; break;
00247             case TH_SELECT:
00248                 cp= ts->select; break;
00249             case TH_ACTIVE:
00250                 cp= ts->active; break;
00251             case TH_GROUP:
00252                 cp= ts->group; break;
00253             case TH_GROUP_ACTIVE:
00254                 cp= ts->group_active; break;
00255             case TH_TRANSFORM:
00256                 cp= ts->transform; break;
00257             case TH_VERTEX:
00258                 cp= ts->vertex; break;
00259             case TH_VERTEX_SELECT:
00260                 cp= ts->vertex_select; break;
00261             case TH_VERTEX_SIZE:
00262                 cp= &ts->vertex_size; break;
00263             case TH_OUTLINE_WIDTH:
00264                 cp= &ts->outline_width; break;
00265             case TH_EDGE:
00266                 cp= ts->edge; break;
00267             case TH_EDGE_SELECT:
00268                 cp= ts->edge_select; break;
00269             case TH_EDGE_SEAM:
00270                 cp= ts->edge_seam; break;
00271             case TH_EDGE_SHARP:
00272                 cp= ts->edge_sharp; break;
00273             case TH_EDGE_CREASE:
00274                 cp= ts->edge_crease; break;
00275             case TH_EDITMESH_ACTIVE:
00276                 cp= ts->editmesh_active; break;
00277             case TH_EDGE_FACESEL:
00278                 cp= ts->edge_facesel; break;
00279             case TH_FACE:
00280                 cp= ts->face; break;
00281             case TH_FACE_SELECT:
00282                 cp= ts->face_select; break;
00283             case TH_FACE_DOT:
00284                 cp= ts->face_dot; break;
00285             case TH_FACEDOT_SIZE:
00286                 cp= &ts->facedot_size; break;
00287             case TH_DRAWEXTRA_EDGELEN:
00288                 cp= ts->extra_edge_len; break;
00289             case TH_DRAWEXTRA_FACEAREA:
00290                 cp= ts->extra_face_area; break;
00291             case TH_DRAWEXTRA_FACEANG:
00292                 cp= ts->extra_face_angle; break;
00293             case TH_NORMAL:
00294                 cp= ts->normal; break;
00295             case TH_VNORMAL:
00296                 cp= ts->vertex_normal; break;
00297             case TH_BONE_SOLID:
00298                 cp= ts->bone_solid; break;
00299             case TH_BONE_POSE:
00300                 cp= ts->bone_pose; break;
00301             case TH_STRIP:
00302                 cp= ts->strip; break;
00303             case TH_STRIP_SELECT:
00304                 cp= ts->strip_select; break;
00305             case TH_CFRAME:
00306                 cp= ts->cframe; break;
00307             case TH_NURB_ULINE:
00308                 cp= ts->nurb_uline; break;
00309             case TH_NURB_VLINE:
00310                 cp= ts->nurb_vline; break;
00311             case TH_NURB_SEL_ULINE:
00312                 cp= ts->nurb_sel_uline; break;
00313             case TH_NURB_SEL_VLINE:
00314                 cp= ts->nurb_sel_vline; break;
00315             case TH_ACTIVE_SPLINE:
00316                 cp= ts->act_spline; break;
00317             case TH_LASTSEL_POINT:
00318                 cp= ts->lastsel_point; break;
00319             case TH_HANDLE_FREE:
00320                 cp= ts->handle_free; break;
00321             case TH_HANDLE_AUTO:
00322                 cp= ts->handle_auto; break;
00323             case TH_HANDLE_AUTOCLAMP:
00324                 cp= ts->handle_auto_clamped; break;
00325             case TH_HANDLE_VECT:
00326                 cp= ts->handle_vect; break;
00327             case TH_HANDLE_ALIGN:
00328                 cp= ts->handle_align; break;
00329             case TH_HANDLE_SEL_FREE:
00330                 cp= ts->handle_sel_free; break;
00331             case TH_HANDLE_SEL_AUTO:
00332                 cp= ts->handle_sel_auto; break;
00333             case TH_HANDLE_SEL_AUTOCLAMP:
00334                 cp= ts->handle_sel_auto_clamped; break;
00335             case TH_HANDLE_SEL_VECT:
00336                 cp= ts->handle_sel_vect; break;
00337             case TH_HANDLE_SEL_ALIGN:
00338                 cp= ts->handle_sel_align; break;
00339         
00340             case TH_SYNTAX_B:
00341                 cp= ts->syntaxb; break;
00342             case TH_SYNTAX_V:
00343                 cp= ts->syntaxv; break;
00344             case TH_SYNTAX_C:
00345                 cp= ts->syntaxc; break;
00346             case TH_SYNTAX_L:
00347                 cp= ts->syntaxl; break;
00348             case TH_SYNTAX_N:
00349                 cp= ts->syntaxn; break;
00350 
00351             case TH_NODE:
00352                 cp= ts->syntaxl; break;
00353             case TH_NODE_IN_OUT:
00354                 cp= ts->syntaxn; break;
00355             case TH_NODE_OPERATOR:
00356                 cp= ts->syntaxb; break;
00357             case TH_NODE_CONVERTOR:
00358                 cp= ts->syntaxv; break;
00359             case TH_NODE_GROUP:
00360                 cp= ts->syntaxc; break;
00361             case TH_NODE_CURVING:
00362                 cp= &ts->noodle_curving; break;
00363 
00364             case TH_SEQ_MOVIE:
00365                 cp= ts->movie; break;
00366             case TH_SEQ_IMAGE:
00367                 cp= ts->image; break;
00368             case TH_SEQ_SCENE:
00369                 cp= ts->scene; break;
00370             case TH_SEQ_AUDIO:
00371                 cp= ts->audio; break;
00372             case TH_SEQ_EFFECT:
00373                 cp= ts->effect; break;
00374             case TH_SEQ_PLUGIN:
00375                 cp= ts->plugin; break;
00376             case TH_SEQ_TRANSITION:
00377                 cp= ts->transition; break;
00378             case TH_SEQ_META:
00379                 cp= ts->meta; break;
00380                 
00381             case TH_CONSOLE_OUTPUT:
00382                 cp= ts->console_output; break;
00383             case TH_CONSOLE_INPUT:
00384                 cp= ts-> console_input; break;
00385             case TH_CONSOLE_INFO:
00386                 cp= ts->console_info; break;
00387             case TH_CONSOLE_ERROR:
00388                 cp= ts->console_error; break;
00389             case TH_CONSOLE_CURSOR:
00390                 cp= ts->console_cursor; break;
00391 
00392             case TH_HANDLE_VERTEX:
00393                 cp= ts->handle_vertex;
00394                 break;
00395             case TH_HANDLE_VERTEX_SELECT:
00396                 cp= ts->handle_vertex_select;
00397                 break;
00398             case TH_HANDLE_VERTEX_SIZE:
00399                 cp= &ts->handle_vertex_size;
00400                 break;
00401                 
00402             case TH_DOPESHEET_CHANNELOB:
00403                 cp= ts->ds_channel;
00404                 break;
00405             case TH_DOPESHEET_CHANNELSUBOB:
00406                 cp= ts->ds_subchannel;
00407                 break;  
00408                     
00409             case TH_PREVIEW_BACK:
00410                 cp= ts->preview_back;
00411                 break;  
00412 
00413             case TH_MARKER_OUTLINE:
00414                 cp= ts->marker_outline; break;
00415             case TH_MARKER:
00416                 cp= ts->marker; break;
00417             case TH_ACT_MARKER:
00418                 cp= ts->act_marker; break;
00419             case TH_SEL_MARKER:
00420                 cp= ts->sel_marker; break;
00421             case TH_BUNDLE_SOLID:
00422                 cp= ts->bundle_solid; break;
00423             case TH_DIS_MARKER:
00424                 cp= ts->dis_marker; break;
00425             case TH_PATH_BEFORE:
00426                 cp= ts->path_before; break;
00427             case TH_PATH_AFTER:
00428                 cp= ts->path_after; break;
00429             case TH_CAMERA_PATH:
00430                 cp= ts->camera_path; break;
00431             case TH_LOCK_MARKER:
00432                 cp= ts->lock_marker; break;
00433             }
00434         }
00435     }
00436     
00437     return (unsigned char *)cp;
00438 }
00439 
00440 
00441 #define SETCOL(col, r, g, b, a)  col[0]=r; col[1]=g; col[2]= b; col[3]= a;
00442 #define SETCOLF(col, r, g, b, a)  col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255;
00443 #define SETCOLTEST(col, r, g, b, a)  if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;}
00444 
00445 /* use this call to init new bone color sets in Theme */
00446 static void ui_theme_init_boneColorSets(bTheme *btheme)
00447 {
00448     int i;
00449     
00450     /* define default color sets - currently we only define 15 of these, though that should be ample */
00451         /* set 1 */
00452     SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
00453     SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
00454     SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
00455         /* set 2 */
00456     SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
00457     SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
00458     SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
00459         /* set 3 */
00460     SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
00461     SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
00462     SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
00463         /* set 4 */
00464     SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
00465     SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
00466     SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
00467         /* set 5 */
00468     SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
00469     SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
00470     SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
00471         /* set 6 */
00472     SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
00473     SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
00474     SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
00475         /* set 7 */
00476     SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
00477     SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
00478     SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
00479         /* set 8 */
00480     SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
00481     SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
00482     SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
00483         /* set 9 */
00484     SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
00485     SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
00486     SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
00487         /* set 10 */
00488     SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
00489     SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
00490     SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
00491         /* set 11 */
00492     SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
00493     SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
00494     SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
00495         /* set 12 */
00496     SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
00497     SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
00498     SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
00499         /* set 13 */
00500     SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
00501     SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
00502     SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
00503         /* set 14 */
00504     SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
00505     SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
00506     SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
00507         /* set 15 */
00508     SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
00509     SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
00510     SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
00511     
00512     /* reset flags too */
00513     for (i = 0; i < 20; i++)
00514         btheme->tarm[i].flag = 0;
00515 }
00516 
00517 /* use this call to init new variables in themespace, if they're same for all */
00518 static void ui_theme_init_new_do(ThemeSpace *ts)
00519 {
00520     SETCOLTEST(ts->header_text,     0, 0, 0, 255);
00521     SETCOLTEST(ts->header_title,    0, 0, 0, 255);
00522     SETCOLTEST(ts->header_text_hi,  255, 255, 255, 255);
00523     
00524     SETCOLTEST(ts->panel_text,      0, 0, 0, 255);
00525     SETCOLTEST(ts->panel_title,     0, 0, 0, 255);
00526     SETCOLTEST(ts->panel_text_hi,   255, 255, 255, 255);
00527     
00528     SETCOLTEST(ts->button,          145, 145, 145, 245);
00529     SETCOLTEST(ts->button_title,    0, 0, 0, 255);
00530     SETCOLTEST(ts->button_text,     0, 0, 0, 255);
00531     SETCOLTEST(ts->button_text_hi,  255, 255, 255, 255);
00532     
00533     SETCOLTEST(ts->list,            165, 165, 165, 255);
00534     SETCOLTEST(ts->list_title,      0, 0, 0, 255);
00535     SETCOLTEST(ts->list_text,       0, 0, 0, 255);
00536     SETCOLTEST(ts->list_text_hi,    255, 255, 255, 255);
00537 }
00538 
00539 static void ui_theme_init_new(bTheme *btheme)
00540 {
00541     ui_theme_init_new_do(&btheme->tbuts);
00542     ui_theme_init_new_do(&btheme->tv3d);
00543     ui_theme_init_new_do(&btheme->tfile);
00544     ui_theme_init_new_do(&btheme->tipo);
00545     ui_theme_init_new_do(&btheme->tinfo);
00546     ui_theme_init_new_do(&btheme->tact);
00547     ui_theme_init_new_do(&btheme->tnla);
00548     ui_theme_init_new_do(&btheme->tseq);
00549     ui_theme_init_new_do(&btheme->tima);
00550     ui_theme_init_new_do(&btheme->text);
00551     ui_theme_init_new_do(&btheme->toops);
00552     ui_theme_init_new_do(&btheme->ttime);
00553     ui_theme_init_new_do(&btheme->tnode);
00554     ui_theme_init_new_do(&btheme->tlogic);
00555     ui_theme_init_new_do(&btheme->tuserpref);
00556     ui_theme_init_new_do(&btheme->tconsole);
00557     ui_theme_init_new_do(&btheme->tclip);
00558     
00559 }
00560 
00561 
00562 /* initialize default theme
00563    Note: when you add new colors, created & saved themes need initialized
00564    use function below, init_userdef_do_versions() 
00565 */
00566 void ui_theme_init_default(void)
00567 {
00568     bTheme *btheme;
00569     
00570     /* we search for the theme with name Default */
00571     for(btheme= U.themes.first; btheme; btheme= btheme->next) {
00572         if(strcmp("Default", btheme->name)==0) break;
00573     }
00574     
00575     if(btheme==NULL) {
00576         btheme= MEM_callocN(sizeof(bTheme), "theme");
00577         BLI_addtail(&U.themes, btheme);
00578         strcpy(btheme->name, "Default");
00579     }
00580     
00581     UI_SetTheme(0, 0);  // make sure the global used in this file is set
00582 
00583     /* UI buttons */
00584     ui_widget_color_init(&btheme->tui);
00585     btheme->tui.iconfile[0]= 0;
00586     
00587     /* Bone Color Sets */
00588     ui_theme_init_boneColorSets(btheme);
00589     
00590     /* common (new) variables */
00591     ui_theme_init_new(btheme);
00592     
00593     /* space view3d */
00594     SETCOLF(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
00595     SETCOL(btheme->tv3d.text,       0, 0, 0, 255);
00596     SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255);
00597     
00598     SETCOLF(btheme->tv3d.header,    0.45, 0.45, 0.45, 1.0);
00599     SETCOLF(btheme->tv3d.button,    0.45, 0.45, 0.45, 1.0);
00600     SETCOL(btheme->tv3d.panel,      165, 165, 165, 127);
00601     
00602     SETCOL(btheme->tv3d.shade1,  160, 160, 160, 100);
00603     SETCOL(btheme->tv3d.shade2,  0x7f, 0x70, 0x70, 100);
00604 
00605     SETCOLF(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
00606     SETCOL(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
00607     SETCOL(btheme->tv3d.lamp,       0, 0, 0, 40);
00608     SETCOL(btheme->tv3d.speaker,    0, 0, 0, 255);
00609     SETCOL(btheme->tv3d.select, 241, 88, 0, 255);
00610     SETCOL(btheme->tv3d.active, 255, 170, 64, 255);
00611     SETCOL(btheme->tv3d.group,      8, 48, 8, 255);
00612     SETCOL(btheme->tv3d.group_active, 85, 187, 85, 255);
00613     SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
00614     SETCOL(btheme->tv3d.vertex, 0, 0, 0, 255);
00615     SETCOL(btheme->tv3d.vertex_select, 255, 133, 0, 255);
00616     btheme->tv3d.vertex_size= 3;
00617     btheme->tv3d.outline_width= 1;
00618     SETCOL(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
00619     SETCOL(btheme->tv3d.edge_select, 255, 160, 0, 255);
00620     SETCOL(btheme->tv3d.edge_seam, 219, 37, 18, 255);
00621     SETCOL(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
00622     SETCOL(btheme->tv3d.face,       0, 0, 0, 18);
00623     SETCOL(btheme->tv3d.face_select, 255, 133, 0, 60);
00624     SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
00625     SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
00626     SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255);
00627     SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
00628     SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
00629     SETCOL(btheme->tv3d.edge_sharp, 0, 255, 255, 255);
00630     SETCOL(btheme->tv3d.header_text, 0, 0, 0, 255);
00631     SETCOL(btheme->tv3d.header_text_hi, 255, 255, 255, 255);
00632     SETCOL(btheme->tv3d.button_text, 0, 0, 0, 255);
00633     SETCOL(btheme->tv3d.button_text_hi, 255, 255, 255, 255);
00634     SETCOL(btheme->tv3d.button_title, 0, 0, 0, 255);
00635     SETCOL(btheme->tv3d.title, 0, 0, 0, 255);
00636 
00637     btheme->tv3d.facedot_size= 4;
00638 
00639     SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
00640     SETCOL(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
00641     SETCOL(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
00642 
00643     SETCOL(btheme->tv3d.cframe, 0x60, 0xc0,  0x40, 255);
00644 
00645     SETCOL(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
00646     SETCOL(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
00647     SETCOL(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255);
00648     SETCOL(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255);
00649 
00650     SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
00651     SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
00652     SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
00653     SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
00654     SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
00655     SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
00656     SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
00657     SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
00658 
00659     SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
00660     SETCOL(btheme->tv3d.lastsel_point,  0xff, 0xff, 0xff, 255);
00661 
00662     SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
00663     SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);               // alpha 80 is not meant editable, used for wire+action draw
00664 
00665     SETCOL(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
00666     SETCOL(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
00667     
00668     /* space buttons */
00669     /* to have something initialized */
00670     btheme->tbuts= btheme->tv3d;
00671 
00672     SETCOLF(btheme->tbuts.back,     0.45, 0.45, 0.45, 1.0);
00673     SETCOL(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255);
00674 
00675     /* graph editor */
00676     btheme->tipo= btheme->tv3d;
00677     SETCOLF(btheme->tipo.back,  0.42, 0.42, 0.42, 1.0);
00678     SETCOLF(btheme->tipo.list,  0.4, 0.4, 0.4, 1.0);
00679     SETCOL(btheme->tipo.grid,   94, 94, 94, 255);
00680     SETCOL(btheme->tipo.panel,  255, 255, 255, 150);
00681     SETCOL(btheme->tipo.shade1,     150, 150, 150, 100);    /* scrollbars */
00682     SETCOL(btheme->tipo.shade2,     0x70, 0x70, 0x70, 100);
00683     SETCOL(btheme->tipo.vertex,     0, 0, 0, 255);
00684     SETCOL(btheme->tipo.vertex_select, 255, 133, 0, 255);
00685     SETCOL(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255); 
00686     btheme->tipo.vertex_size= 3;
00687 
00688     SETCOL(btheme->tipo.handle_vertex,      0, 0, 0, 255);
00689     SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
00690     SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
00691     SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
00692     btheme->tipo.handle_vertex_size= 4;
00693     
00694     SETCOL(btheme->tipo.ds_channel,     82, 96, 110, 255);
00695     SETCOL(btheme->tipo.ds_subchannel,  124, 137, 150, 255);
00696     SETCOL(btheme->tipo.group, 79, 101, 73, 255);
00697     SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
00698 
00699     /* dopesheet */
00700     btheme->tact= btheme->tipo;
00701     SETCOL(btheme->tact.strip,          12, 10, 10, 128); 
00702     SETCOL(btheme->tact.strip_select,   255, 140, 0, 255); 
00703     
00704     /* space nla */
00705     btheme->tnla= btheme->tact;
00706     
00707     /* space file */
00708     /* to have something initialized */
00709     btheme->tfile= btheme->tv3d;
00710     SETCOLF(btheme->tfile.back, 0.3, 0.3, 0.3, 1);
00711     SETCOLF(btheme->tfile.panel, 0.3, 0.3, 0.3, 1);
00712     SETCOLF(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
00713     SETCOL(btheme->tfile.text,  250, 250, 250, 255);
00714     SETCOL(btheme->tfile.text_hi, 15, 15, 15, 255);
00715     SETCOL(btheme->tfile.panel, 145, 145, 145, 255);    // bookmark/ui regions
00716     SETCOL(btheme->tfile.active, 130, 130, 130, 255); // selected files
00717     SETCOL(btheme->tfile.hilite, 255, 140, 25, 255); // selected files
00718     
00719     SETCOL(btheme->tfile.grid,  250, 250, 250, 255);
00720     SETCOL(btheme->tfile.image, 250, 250, 250, 255);
00721     SETCOL(btheme->tfile.movie, 250, 250, 250, 255);
00722     SETCOL(btheme->tfile.scene, 250, 250, 250, 255);
00723 
00724     
00725     /* space seq */
00726     btheme->tseq= btheme->tv3d;
00727     SETCOL(btheme->tseq.back,   116, 116, 116, 255);
00728     SETCOL(btheme->tseq.movie,  81, 105, 135, 255);
00729     SETCOL(btheme->tseq.image,  109, 88, 129, 255);
00730     SETCOL(btheme->tseq.scene,  78, 152, 62, 255);
00731     SETCOL(btheme->tseq.audio,  46, 143, 143, 255);
00732     SETCOL(btheme->tseq.effect,     169, 84, 124, 255);
00733     SETCOL(btheme->tseq.plugin,     126, 126, 80, 255);
00734     SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
00735     SETCOL(btheme->tseq.meta,   109, 145, 131, 255);
00736     
00737 
00738     /* space image */
00739     btheme->tima= btheme->tv3d;
00740     SETCOL(btheme->tima.back,   53, 53, 53, 255);
00741     SETCOL(btheme->tima.vertex, 0, 0, 0, 255);
00742     SETCOL(btheme->tima.vertex_select, 255, 133, 0, 255);
00743     btheme->tima.vertex_size= 3;
00744     btheme->tima.facedot_size= 3;
00745     SETCOL(btheme->tima.face,   255, 255, 255, 10);
00746     SETCOL(btheme->tima.face_select, 255, 133, 0, 60);
00747     SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
00748     SETCOLF(btheme->tima.preview_back,  0.45, 0.45, 0.45, 1.0);
00749 
00750     /* space text */
00751     btheme->text= btheme->tv3d;
00752     SETCOL(btheme->text.back,   153, 153, 153, 255);
00753     SETCOL(btheme->text.shade1,     143, 143, 143, 255);
00754     SETCOL(btheme->text.shade2,     0xc6, 0x77, 0x77, 255);
00755     SETCOL(btheme->text.hilite,     255, 0, 0, 255);
00756     
00757     /* syntax highlighting */
00758     SETCOL(btheme->text.syntaxn,    0, 0, 200, 255);    /* Numbers  Blue*/
00759     SETCOL(btheme->text.syntaxl,    100, 0, 0, 255);    /* Strings  red */
00760     SETCOL(btheme->text.syntaxc,    0, 100, 50, 255);   /* Comments greenish */
00761     SETCOL(btheme->text.syntaxv,    95, 95, 0, 255);    /* Special */
00762     SETCOL(btheme->text.syntaxb,    128, 0, 80, 255);   /* Builtin, red-purple */
00763     
00764     /* space oops */
00765     btheme->toops= btheme->tv3d;
00766     SETCOLF(btheme->toops.back,     0.45, 0.45, 0.45, 1.0);
00767     
00768     /* space info */
00769     btheme->tinfo= btheme->tv3d;
00770     SETCOLF(btheme->tinfo.back,     0.45, 0.45, 0.45, 1.0);
00771 
00772     /* space user preferences */
00773     btheme->tuserpref= btheme->tv3d;
00774     SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
00775     
00776     /* space console */
00777     btheme->tconsole= btheme->tv3d;
00778     SETCOL(btheme->tconsole.back, 0, 0, 0, 255);
00779     SETCOL(btheme->tconsole.console_output, 96, 128, 255, 255);
00780     SETCOL(btheme->tconsole.console_input, 255, 255, 255, 255);
00781     SETCOL(btheme->tconsole.console_info, 0, 170, 0, 255);
00782     SETCOL(btheme->tconsole.console_error, 220, 96, 96, 255);
00783     SETCOL(btheme->tconsole.console_cursor, 220, 96, 96, 255);
00784     
00785     /* space time */
00786     btheme->ttime= btheme->tv3d;
00787     SETCOLF(btheme->ttime.back,     0.45, 0.45, 0.45, 1.0);
00788     SETCOLF(btheme->ttime.grid,     0.36, 0.36, 0.36, 1.0);
00789     SETCOL(btheme->ttime.shade1,  173, 173, 173, 255);      // sliders
00790     
00791     /* space node, re-uses syntax color storage */
00792     btheme->tnode= btheme->tv3d;
00793     SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
00794     SETCOL(btheme->tnode.syntaxl, 155, 155, 155, 160);  /* TH_NODE, backdrop */
00795     SETCOL(btheme->tnode.syntaxn, 100, 100, 100, 255);  /* in/output */
00796     SETCOL(btheme->tnode.syntaxb, 108, 105, 111, 255);  /* operator */
00797     SETCOL(btheme->tnode.syntaxv, 104, 106, 117, 255);  /* generator */
00798     SETCOL(btheme->tnode.syntaxc, 105, 117, 110, 255);  /* group */
00799     btheme->tnode.noodle_curving = 5;
00800 
00801     /* space logic */
00802     btheme->tlogic= btheme->tv3d;
00803     SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
00804     
00805     /* space clip */
00806     btheme->tclip= btheme->tv3d;
00807 
00808     SETCOL(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
00809     SETCOL(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
00810     SETCOL(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
00811     SETCOL(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
00812     SETCOL(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
00813     SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
00814     SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
00815     SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
00816     SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
00817     SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
00818     SETCOL(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
00819     SETCOL(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
00820     btheme->tclip.handle_vertex_size= 4;
00821 }
00822 
00823 
00824 void UI_SetTheme(int spacetype, int regionid)
00825 {
00826     if(spacetype==0) {  // called for safety, when delete themes
00827         theme_active= U.themes.first;
00828         theme_spacetype= SPACE_VIEW3D;
00829         theme_regionid= RGN_TYPE_WINDOW;
00830     }
00831     else {
00832         // later on, a local theme can be found too
00833         theme_active= U.themes.first;
00834         theme_spacetype= spacetype;
00835         theme_regionid= regionid;
00836     }
00837 }
00838 
00839 bTheme *UI_GetTheme()
00840 {
00841     return U.themes.first;
00842 }
00843 
00844 // for space windows only
00845 void UI_ThemeColor(int colorid)
00846 {
00847     const unsigned char *cp;
00848     
00849     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
00850     glColor3ubv(cp);
00851 
00852 }
00853 
00854 // plus alpha
00855 void UI_ThemeColor4(int colorid)
00856 {
00857     const unsigned char *cp;
00858     
00859     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
00860     glColor4ubv(cp);
00861 
00862 }
00863 
00864 // set the color with offset for shades
00865 void UI_ThemeColorShade(int colorid, int offset)
00866 {
00867     int r, g, b;
00868     const unsigned char *cp;
00869     
00870     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
00871     r= offset + (int) cp[0];
00872     CLAMP(r, 0, 255);
00873     g= offset + (int) cp[1];
00874     CLAMP(g, 0, 255);
00875     b= offset + (int) cp[2];
00876     CLAMP(b, 0, 255);
00877     //glColor3ub(r, g, b);
00878     glColor4ub(r, g, b, cp[3]);
00879 }
00880 void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
00881 {
00882     int r, g, b, a;
00883     const unsigned char *cp;
00884     
00885     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
00886     r= coloffset + (int) cp[0];
00887     CLAMP(r, 0, 255);
00888     g= coloffset + (int) cp[1];
00889     CLAMP(g, 0, 255);
00890     b= coloffset + (int) cp[2];
00891     CLAMP(b, 0, 255);
00892     a= alphaoffset + (int) cp[3];
00893     CLAMP(a, 0, 255);
00894     glColor4ub(r, g, b, a);
00895 }
00896 
00897 // blend between to theme colors, and set it
00898 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
00899 {
00900     int r, g, b;
00901     const unsigned char *cp1, *cp2;
00902     
00903     cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
00904     cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
00905 
00906     CLAMP(fac, 0.0f, 1.0f);
00907     r= floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
00908     g= floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
00909     b= floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
00910     
00911     glColor3ub(r, g, b);
00912 }
00913 
00914 // blend between to theme colors, shade it, and set it
00915 void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
00916 {
00917     int r, g, b;
00918     const unsigned char *cp1, *cp2;
00919     
00920     cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
00921     cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
00922 
00923     CLAMP(fac, 0.0f, 1.0f);
00924     r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
00925     g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
00926     b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
00927     
00928     CLAMP(r, 0, 255);
00929     CLAMP(g, 0, 255);
00930     CLAMP(b, 0, 255);
00931     
00932     glColor3ub(r, g, b);
00933 }
00934 
00935 // blend between to theme colors, shade it, and set it
00936 void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
00937 {
00938     int r, g, b, a;
00939     const unsigned char *cp1, *cp2;
00940     
00941     cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
00942     cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
00943 
00944     CLAMP(fac, 0.0f, 1.0f);
00945     r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
00946     g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
00947     b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
00948     a= alphaoffset + floorf((1.0f-fac)*cp1[3] + fac*cp2[3]);
00949     
00950     CLAMP(r, 0, 255);
00951     CLAMP(g, 0, 255);
00952     CLAMP(b, 0, 255);
00953     CLAMP(a, 0, 255);
00954 
00955     glColor4ub(r, g, b, a);
00956 }
00957 
00958 
00959 // get individual values, not scaled
00960 float UI_GetThemeValuef(int colorid)
00961 {
00962     const unsigned char *cp;
00963     
00964     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
00965     return ((float)cp[0]);
00966 
00967 }
00968 
00969 // get individual values, not scaled
00970 int UI_GetThemeValue(int colorid)
00971 {
00972     const unsigned char *cp;
00973     
00974     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
00975     return ((int) cp[0]);
00976 
00977 }
00978 
00979 
00980 // get the color, range 0.0-1.0
00981 void UI_GetThemeColor3fv(int colorid, float *col)
00982 {
00983     const unsigned char *cp;
00984     
00985     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
00986     col[0]= ((float)cp[0])/255.0f;
00987     col[1]= ((float)cp[1])/255.0f;
00988     col[2]= ((float)cp[2])/255.0f;
00989 }
00990 
00991 // get the color, range 0.0-1.0, complete with shading offset
00992 void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
00993 {
00994     int r, g, b;
00995     const unsigned char *cp;
00996     
00997     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
00998     
00999     r= offset + (int) cp[0];
01000     CLAMP(r, 0, 255);
01001     g= offset + (int) cp[1];
01002     CLAMP(g, 0, 255);
01003     b= offset + (int) cp[2];
01004     CLAMP(b, 0, 255);
01005     
01006     col[0]= ((float)r)/255.0f;
01007     col[1]= ((float)g)/255.0f;
01008     col[2]= ((float)b)/255.0f;
01009 }
01010 
01011 // get the color, in char pointer
01012 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
01013 {
01014     const unsigned char *cp;
01015     
01016     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
01017     col[0]= cp[0];
01018     col[1]= cp[1];
01019     col[2]= cp[2];
01020 }
01021 
01022 // get the color, in char pointer
01023 void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
01024 {
01025     const unsigned char *cp;
01026     
01027     cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
01028     col[0]= cp[0];
01029     col[1]= cp[1];
01030     col[2]= cp[2];
01031     col[3]= cp[3];
01032 }
01033 
01034 void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
01035 {
01036     const unsigned char *cp;
01037     
01038     cp= UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
01039     col[0]= cp[0];
01040     col[1]= cp[1];
01041     col[2]= cp[2];
01042     col[3]= cp[3];
01043 }
01044 
01045 // blends and shades between two char color pointers
01046 void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
01047 {
01048     int r, g, b;
01049     CLAMP(fac, 0.0f, 1.0f);
01050     r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
01051     g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
01052     b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
01053     
01054     r= r<0?0:(r>255?255:r);
01055     g= g<0?0:(g>255?255:g);
01056     b= b<0?0:(b>255?255:b);
01057     
01058     glColor3ub(r, g, b);
01059 }
01060 
01061 void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], int offset)
01062 {
01063     int r, g, b;
01064 
01065     r= offset+(int)cp[0];
01066     g= offset+(int)cp[1];
01067     b= offset+(int)cp[2];
01068 
01069     CLAMP(r, 0, 255);
01070     CLAMP(g, 0, 255);
01071     CLAMP(b, 0, 255);
01072 
01073     col[0] = r;
01074     col[1] = g;
01075     col[2] = b;
01076 }
01077 
01078 // get a 3 byte color, blended and shaded between two other char color pointers
01079 void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset)
01080 {
01081     int r, g, b;
01082 
01083     CLAMP(fac, 0.0f, 1.0f);
01084     r= offset+floor((1.0f-fac)*cp1[0] + fac*cp2[0]);
01085     g= offset+floor((1.0f-fac)*cp1[1] + fac*cp2[1]);
01086     b= offset+floor((1.0f-fac)*cp1[2] + fac*cp2[2]);
01087 
01088     CLAMP(r, 0, 255);
01089     CLAMP(g, 0, 255);
01090     CLAMP(b, 0, 255);
01091 
01092     col[0] = r;
01093     col[1] = g;
01094     col[2] = b;
01095 }
01096 
01097 void UI_ThemeClearColor(int colorid)
01098 {
01099     float col[3];
01100     
01101     UI_GetThemeColor3fv(colorid, col);
01102     glClearColor(col[0], col[1], col[2], 0.0);
01103 }
01104 
01105 void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
01106 {
01107     switch(axis)
01108     {
01109         case 'X':
01110             dst_col[0]= src_col[0]>219?255:src_col[0]+36;
01111             dst_col[1]= src_col[1]<26?0:src_col[1]-26;
01112             dst_col[2]= src_col[2]<26?0:src_col[2]-26;
01113             break;
01114         case 'Y':
01115             dst_col[0]= src_col[0]<46?0:src_col[0]-36;
01116             dst_col[1]= src_col[1]>189?255:src_col[1]+66;
01117             dst_col[2]= src_col[2]<46?0:src_col[2]-36;
01118             break;
01119         case 'Z':
01120             dst_col[0]= src_col[0]<26?0:src_col[0]-26; 
01121             dst_col[1]= src_col[1]<26?0:src_col[1]-26; 
01122             dst_col[2]= src_col[2]>209?255:src_col[2]+46;
01123             break;
01124         default:
01125             BLI_assert(!"invalid axis arg");
01126     }
01127 }
01128 
01129 /* ************************************************************* */
01130 
01131 /* patching UserDef struct and Themes */
01132 void init_userdef_do_versions(void)
01133 {
01134     Main *bmain= G.main;
01135 //  countall();
01136     
01137     /* the UserDef struct is not corrected with do_versions() .... ugh! */
01138     if(U.wheellinescroll == 0) U.wheellinescroll = 3;
01139     if(U.menuthreshold1==0) {
01140         U.menuthreshold1= 5;
01141         U.menuthreshold2= 2;
01142     }
01143     if(U.tb_leftmouse==0) {
01144         U.tb_leftmouse= 5;
01145         U.tb_rightmouse= 5;
01146     }
01147     if(U.mixbufsize==0) U.mixbufsize= 2048;
01148     if (strcmp(U.tempdir, "/") == 0) {
01149         BLI_system_temporary_dir(U.tempdir);
01150     }
01151     if (U.autokey_mode == 0) {
01152         /* 'add/replace' but not on */
01153         U.autokey_mode = 2;
01154     }
01155     if (U.savetime <= 0) {
01156         U.savetime = 1;
01157 // XXX      error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
01158     }
01159     /* transform widget settings */
01160     if(U.tw_hotspot==0) {
01161         U.tw_hotspot= 14;
01162         U.tw_size= 20;          // percentage of window size
01163         U.tw_handlesize= 16;    // percentage of widget radius
01164     }
01165     if(U.pad_rot_angle==0)
01166         U.pad_rot_angle= 15;
01167 
01168     /* signal for derivedmesh to use colorband */
01169     /* run incase this was on and is now off in the user prefs [#28096] */
01170     vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight):NULL);
01171 
01172     if (bmain->versionfile <= 191) {
01173         BLI_strncpy(U.plugtexdir, U.textudir, sizeof(U.plugtexdir));
01174         strcpy(U.sounddir, "/");
01175     }
01176     
01177     /* patch to set Dupli Armature */
01178     if (bmain->versionfile < 220) {
01179         U.dupflag |= USER_DUP_ARM;
01180     }
01181     
01182     /* added seam, normal color, undo */
01183     if (bmain->versionfile <= 234) {
01184         bTheme *btheme;
01185         
01186         U.uiflag |= USER_GLOBALUNDO;
01187         if (U.undosteps==0) U.undosteps=32;
01188         
01189         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01190             /* check for alpha==0 is safe, then color was never set */
01191             if(btheme->tv3d.edge_seam[3]==0) {
01192                 SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255);
01193             }
01194             if(btheme->tv3d.normal[3]==0) {
01195                 SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
01196             }
01197             if(btheme->tv3d.vertex_normal[3]==0) {
01198                 SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
01199             }
01200             if(btheme->tv3d.face_dot[3]==0) {
01201                 SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255);
01202                 btheme->tv3d.facedot_size= 4;
01203             }
01204         }
01205     }
01206     if (bmain->versionfile <= 235) {
01207         /* illegal combo... */
01208         if (U.flag & USER_LMOUSESELECT) 
01209             U.flag &= ~USER_TWOBUTTONMOUSE;
01210     }
01211     if (bmain->versionfile <= 236) {
01212         bTheme *btheme;
01213         /* new space type */
01214         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01215             /* check for alpha==0 is safe, then color was never set */
01216             if(btheme->ttime.back[3]==0) {
01217                 // copied from ui_theme_init_default
01218                 btheme->ttime= btheme->tv3d;
01219                 SETCOLF(btheme->ttime.back,     0.45, 0.45, 0.45, 1.0);
01220                 SETCOLF(btheme->ttime.grid,     0.36, 0.36, 0.36, 1.0);
01221                 SETCOL(btheme->ttime.shade1,  173, 173, 173, 255);      // sliders
01222             }
01223             if(btheme->text.syntaxn[3]==0) {
01224                 SETCOL(btheme->text.syntaxn,    0, 0, 200, 255);    /* Numbers  Blue*/
01225                 SETCOL(btheme->text.syntaxl,    100, 0, 0, 255);    /* Strings  red */
01226                 SETCOL(btheme->text.syntaxc,    0, 100, 50, 255);   /* Comments greenish */
01227                 SETCOL(btheme->text.syntaxv,    95, 95, 0, 255);    /* Special */
01228                 SETCOL(btheme->text.syntaxb,    128, 0, 80, 255);   /* Builtin, red-purple */
01229             }
01230         }
01231     }
01232     if (bmain->versionfile <= 237) {
01233         bTheme *btheme;
01234         /* bone colors */
01235         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01236             /* check for alpha==0 is safe, then color was never set */
01237             if(btheme->tv3d.bone_solid[3]==0) {
01238                 SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
01239                 SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);
01240             }
01241         }
01242     }
01243     if (bmain->versionfile <= 238) {
01244         bTheme *btheme;
01245         /* bone colors */
01246         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01247             /* check for alpha==0 is safe, then color was never set */
01248             if(btheme->tnla.strip[3]==0) {
01249                 SETCOL(btheme->tnla.strip_select,   0xff, 0xff, 0xaa, 255);
01250                 SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
01251             }
01252         }
01253     }
01254     if (bmain->versionfile <= 239) {
01255         bTheme *btheme;
01256         
01257         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01258             /* Lamp theme, check for alpha==0 is safe, then color was never set */
01259             if(btheme->tv3d.lamp[3]==0) {
01260                 SETCOL(btheme->tv3d.lamp,   0, 0, 0, 40);
01261 /* TEMPORAL, remove me! (ton) */                
01262                 U.uiflag |= USER_PLAINMENUS;
01263             }
01264             
01265         }
01266         if(U.obcenter_dia==0) U.obcenter_dia= 6;
01267     }
01268     if (bmain->versionfile <= 241) {
01269         bTheme *btheme;
01270         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01271             /* Node editor theme, check for alpha==0 is safe, then color was never set */
01272             if(btheme->tnode.syntaxn[3]==0) {
01273                 /* re-uses syntax color storage */
01274                 btheme->tnode= btheme->tv3d;
01275                 SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
01276                 SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255);  /* TH_NODE, backdrop */
01277                 SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255);  /* in/output */
01278                 SETCOL(btheme->tnode.syntaxb, 127,127,127, 255);    /* operator */
01279                 SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255);  /* generator */
01280                 SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255);  /* group */
01281             }
01282             /* Group theme colors */
01283             if(btheme->tv3d.group[3]==0) {
01284                 SETCOL(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255);
01285                 SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
01286             }
01287             /* Sequence editor theme*/
01288             if(btheme->tseq.movie[3]==0) {
01289                 SETCOL(btheme->tseq.movie,  81, 105, 135, 255);
01290                 SETCOL(btheme->tseq.image,  109, 88, 129, 255);
01291                 SETCOL(btheme->tseq.scene,  78, 152, 62, 255);
01292                 SETCOL(btheme->tseq.audio,  46, 143, 143, 255);
01293                 SETCOL(btheme->tseq.effect,     169, 84, 124, 255);
01294                 SETCOL(btheme->tseq.plugin,     126, 126, 80, 255);
01295                 SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
01296                 SETCOL(btheme->tseq.meta,   109, 145, 131, 255);
01297             }
01298         }
01299         
01300         /* set defaults for 3D View rotating axis indicator */ 
01301         /* since size can't be set to 0, this indicates it's not saved in startup.blend */
01302         if (U.rvisize == 0) {
01303             U.rvisize = 15;
01304             U.rvibright = 8;
01305             U.uiflag |= USER_SHOW_ROTVIEWICON;
01306         }
01307         
01308     }
01309     if (bmain->versionfile <= 242) {
01310         bTheme *btheme;
01311         
01312         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01313             /* long keyframe color */
01314             /* check for alpha==0 is safe, then color was never set */
01315             if(btheme->tact.strip[3]==0) {
01316                 SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
01317                 SETCOL(btheme->tact.strip_select,   0xff, 0xff, 0xaa, 204);
01318                 SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
01319             }
01320             
01321             /* IPO-Editor - Vertex Size*/
01322             if(btheme->tipo.vertex_size == 0) {
01323                 btheme->tipo.vertex_size= 3;
01324             }
01325         }
01326     }
01327     if (bmain->versionfile <= 243) {
01328         /* set default number of recently-used files (if not set) */
01329         if (U.recent_files == 0) U.recent_files = 10;
01330     }
01331     if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
01332         bTheme *btheme;
01333         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01334             SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
01335         }
01336         if(U.coba_weight.tot==0)
01337             init_colorband(&U.coba_weight, 1);
01338     }
01339     if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
01340         bTheme *btheme;
01341         for (btheme= U.themes.first; btheme; btheme= btheme->next) {
01342             /* these should all use the same color */
01343             SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
01344             SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
01345             SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
01346             SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
01347             SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
01348             //SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); Not needed anymore
01349             SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
01350         }
01351     }
01352     if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
01353         bTheme *btheme;
01354         for (btheme= U.themes.first; btheme; btheme= btheme->next) {
01355             /* action channel groups (recolor anyway) */
01356             SETCOL(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
01357             SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
01358             
01359             /* bone custom-color sets */
01360             if (btheme->tarm[0].solid[3] == 0)
01361                 ui_theme_init_boneColorSets(btheme);
01362         }
01363     }
01364     if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
01365         U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE;
01366     }
01367     if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
01368         bTheme *btheme;
01369         
01370         /* adjust themes */
01371         for (btheme= U.themes.first; btheme; btheme= btheme->next) {
01372             char *col;
01373             
01374             /* IPO Editor: Handles/Vertices */
01375             col = btheme->tipo.vertex;
01376             SETCOL(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
01377             col = btheme->tipo.vertex_select;
01378             SETCOL(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
01379             btheme->tipo.handle_vertex_size= btheme->tipo.vertex_size;
01380             
01381             /* Sequence/Image Editor: colors for GPencil text */
01382             col = btheme->tv3d.bone_pose;
01383             SETCOL(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
01384             SETCOL(btheme->tima.bone_pose, col[0], col[1], col[2], 255);
01385             col = btheme->tv3d.vertex_select;
01386             SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
01387         }
01388     }
01389     if (bmain->versionfile < 250) {
01390         bTheme *btheme;
01391         
01392         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01393             /* this was not properly initialized in 2.45 */
01394             if(btheme->tima.face_dot[3]==0) {
01395                 SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
01396                 SETCOL(btheme->tima.face_dot, 255, 133, 0, 255);
01397                 btheme->tima.facedot_size= 2;
01398             }
01399             
01400             /* DopeSheet - (Object) Channel color */
01401             SETCOL(btheme->tact.ds_channel,     82, 96, 110, 255);
01402             SETCOL(btheme->tact.ds_subchannel,  124, 137, 150, 255);
01403             /* DopeSheet - Group Channel color (saner version) */
01404             SETCOL(btheme->tact.group, 79, 101, 73, 255);
01405             SETCOL(btheme->tact.group_active, 135, 177, 125, 255);
01406             
01407             /* Graph Editor - (Object) Channel color */
01408             SETCOL(btheme->tipo.ds_channel,     82, 96, 110, 255);
01409             SETCOL(btheme->tipo.ds_subchannel,  124, 137, 150, 255);
01410             /* Graph Editor - Group Channel color */
01411             SETCOL(btheme->tipo.group, 79, 101, 73, 255);
01412             SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
01413             
01414             /* Nla Editor - (Object) Channel color */
01415             SETCOL(btheme->tnla.ds_channel,     82, 96, 110, 255);
01416             SETCOL(btheme->tnla.ds_subchannel,  124, 137, 150, 255);
01417             /* NLA Editor - New Strip colors */
01418             SETCOL(btheme->tnla.strip,          12, 10, 10, 128); 
01419             SETCOL(btheme->tnla.strip_select,   255, 140, 0, 255);
01420         }
01421         
01422         /* adjust grease-pencil distances */
01423         U.gp_manhattendist= 1;
01424         U.gp_euclideandist= 2;
01425         
01426         /* adjust default interpolation for new IPO-curves */
01427         U.ipo_new= BEZT_IPO_BEZ;
01428     }
01429     
01430     if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
01431         bTheme *btheme;
01432 
01433         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01434             
01435             /* common (new) variables, it checks for alpha==0 */
01436             ui_theme_init_new(btheme);
01437 
01438             if(btheme->tui.wcol_num.outline[3]==0)
01439                 ui_widget_color_init(&btheme->tui);
01440             
01441             /* Logic editor theme, check for alpha==0 is safe, then color was never set */
01442             if(btheme->tlogic.syntaxn[3]==0) {
01443                 /* re-uses syntax color storage */
01444                 btheme->tlogic= btheme->tv3d;
01445                 SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
01446             }
01447 
01448             SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
01449             SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
01450         }
01451     }
01452 
01453     if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
01454         /* new audio system */
01455         if(U.audiochannels == 0)
01456             U.audiochannels = 2;
01457         if(U.audiodevice == 0) {
01458 #ifdef WITH_OPENAL
01459             U.audiodevice = 2;
01460 #endif
01461 #ifdef WITH_SDL
01462             U.audiodevice = 1;
01463 #endif
01464         }
01465         if(U.audioformat == 0)
01466             U.audioformat = 0x24;
01467         if(U.audiorate == 0)
01468             U.audiorate = 44100;
01469     }
01470 
01471     if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
01472         U.gameflags |= USER_DISABLE_VBO;
01473     
01474     if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
01475         wmKeyMap *km;
01476         
01477         for(km=U.user_keymaps.first; km; km=km->next) {
01478             if (strcmp(km->idname, "Armature_Sketch")==0)
01479                 strcpy(km->idname, "Armature Sketch");
01480             else if (strcmp(km->idname, "View3D")==0)
01481                 strcpy(km->idname, "3D View");
01482             else if (strcmp(km->idname, "View3D Generic")==0)
01483                 strcpy(km->idname, "3D View Generic");
01484             else if (strcmp(km->idname, "EditMesh")==0)
01485                 strcpy(km->idname, "Mesh");
01486             else if (strcmp(km->idname, "TimeLine")==0)
01487                 strcpy(km->idname, "Timeline");
01488             else if (strcmp(km->idname, "UVEdit")==0)
01489                 strcpy(km->idname, "UV Editor");
01490             else if (strcmp(km->idname, "Animation_Channels")==0)
01491                 strcpy(km->idname, "Animation Channels");
01492             else if (strcmp(km->idname, "GraphEdit Keys")==0)
01493                 strcpy(km->idname, "Graph Editor");
01494             else if (strcmp(km->idname, "GraphEdit Generic")==0)
01495                 strcpy(km->idname, "Graph Editor Generic");
01496             else if (strcmp(km->idname, "Action_Keys")==0)
01497                 strcpy(km->idname, "Dopesheet");
01498             else if (strcmp(km->idname, "NLA Data")==0)
01499                 strcpy(km->idname, "NLA Editor");
01500             else if (strcmp(km->idname, "Node Generic")==0)
01501                 strcpy(km->idname, "Node Editor");
01502             else if (strcmp(km->idname, "Logic Generic")==0)
01503                 strcpy(km->idname, "Logic Editor");
01504             else if (strcmp(km->idname, "File")==0)
01505                 strcpy(km->idname, "File Browser");
01506             else if (strcmp(km->idname, "FileMain")==0)
01507                 strcpy(km->idname, "File Browser Main");
01508             else if (strcmp(km->idname, "FileButtons")==0)
01509                 strcpy(km->idname, "File Browser Buttons");
01510             else if (strcmp(km->idname, "Buttons Generic")==0)
01511                 strcpy(km->idname, "Property Editor");
01512         }
01513     }
01514     if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
01515         if(U.wmdrawmethod == USER_DRAW_TRIPLE)
01516             U.wmdrawmethod = USER_DRAW_AUTOMATIC;
01517     }
01518     
01519     if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
01520         if (U.flag & USER_LMOUSESELECT) 
01521             U.flag &= ~USER_TWOBUTTONMOUSE;
01522     }
01523     if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
01524         bTheme *btheme;
01525         
01526         /* default new handle type is auto handles */
01527         U.keyhandles_new = HD_AUTO;
01528         
01529         /* init new curve colors */
01530         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01531             /* init colors used for handles in 3D-View  */
01532             SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
01533             SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
01534             SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
01535             SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
01536             SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
01537             SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
01538             SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
01539             SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
01540             SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
01541             
01542             /* same colors again for Graph Editor... */
01543             SETCOL(btheme->tipo.handle_free, 0, 0, 0, 255);
01544             SETCOL(btheme->tipo.handle_auto, 0x90, 0x90, 0x00, 255);
01545             SETCOL(btheme->tipo.handle_vect, 0x40, 0x90, 0x30, 255);
01546             SETCOL(btheme->tipo.handle_align, 0x80, 0x30, 0x60, 255);
01547             SETCOL(btheme->tipo.handle_sel_free, 0, 0, 0, 255);
01548             SETCOL(btheme->tipo.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
01549             SETCOL(btheme->tipo.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
01550             SETCOL(btheme->tipo.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
01551             
01552             /* edge crease */
01553             SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
01554         }
01555     }
01556     if (bmain->versionfile <= 252) {
01557         bTheme *btheme;
01558 
01559         /* init new curve colors */
01560         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01561             if (btheme->tv3d.lastsel_point[3] == 0)
01562                 SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
01563         }
01564     }
01565     if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
01566         bTheme *btheme;
01567         
01568         /* interface_widgets.c */
01569         struct uiWidgetColors wcol_progress= {
01570             {0, 0, 0, 255},
01571             {190, 190, 190, 255},
01572             {100, 100, 100, 180},
01573             {68, 68, 68, 255},
01574             
01575             {0, 0, 0, 255},
01576             {255, 255, 255, 255},
01577             
01578             0,
01579             5, -5
01580         };
01581         
01582         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01583             /* init progress bar theme */
01584             btheme->tui.wcol_progress= wcol_progress;
01585         }
01586     }
01587 
01588     if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
01589         bTheme *btheme;
01590         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01591             SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
01592             SETCOL(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
01593             SETCOL(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
01594         }
01595     }
01596     
01597     if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) {
01598         bTheme *btheme;
01599         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01600             if((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width= 1;
01601         }
01602     }
01603 
01604     if (bmain->versionfile < 257) {
01605         /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs, so that it doesn't linger around from old configs like a ghost */
01606         U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
01607     }
01608 
01609     if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 2)) {
01610         bTheme *btheme;
01611         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01612             btheme->tnode.noodle_curving = 5;
01613         }
01614     }
01615 
01616     if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
01617         bTheme *btheme;
01618         
01619         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01620             btheme->tv3d.speaker[3] = 255;
01621         }
01622     }
01623 
01624     if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 3)) {
01625         bTheme *btheme;
01626         
01627         /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead 
01628          * was changed in 260 as part of GSoC11, but version patch was wrong
01629          */
01630         if (U.keyhandles_new == HD_AUTO) 
01631             U.keyhandles_new = HD_AUTO_ANIM;
01632         
01633         for(btheme= U.themes.first; btheme; btheme= btheme->next) {     
01634             if(btheme->tv3d.bundle_solid[3] == 0)
01635                 SETCOL(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
01636             
01637             if(btheme->tv3d.camera_path[3] == 0)
01638                 SETCOL(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
01639                 
01640             if((btheme->tclip.back[3]) == 0) {
01641                 btheme->tclip= btheme->tv3d;
01642                 
01643                 SETCOL(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
01644                 SETCOL(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
01645                 SETCOL(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
01646                 SETCOL(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
01647                 SETCOL(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
01648                 SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
01649                 SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
01650                 SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
01651                 SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
01652                 SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
01653                 SETCOL(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
01654                 SETCOL(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
01655                 btheme->tclip.handle_vertex_size= 4;
01656             }
01657             
01658             /* auto-clamped handles -> based on auto */
01659             if(btheme->tipo.handle_auto_clamped[3] == 0)
01660                 SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
01661             if(btheme->tipo.handle_sel_auto_clamped[3] == 0)
01662                 SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
01663         }
01664         
01665         /* enable (Cycles) addon by default */
01666         if(!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) {
01667             bAddon *baddon= MEM_callocN(sizeof(bAddon), "bAddon");
01668             BLI_strncpy(baddon->module, "cycles", sizeof(baddon->module));
01669             BLI_addtail(&U.addons, baddon);
01670         }
01671     }
01672 
01673     if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) {
01674         bTheme *btheme;
01675 
01676         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
01677             SETCOL(btheme->tui.panel.header, 0, 0, 0, 25);
01678             btheme->tui.icon_alpha= 1.0;
01679         }
01680     }
01681 
01682     /* GL Texture Garbage Collection (variable abused above!) */
01683     if (U.textimeout == 0) {
01684         U.texcollectrate = 60;
01685         U.textimeout = 120;
01686     }
01687     if (U.memcachelimit <= 0) {
01688         U.memcachelimit = 32;
01689     }
01690     if (U.frameserverport == 0) {
01691         U.frameserverport = 8080;
01692     }
01693     if (U.dbl_click_time == 0) {
01694         U.dbl_click_time = 350;
01695     }
01696     if (U.anim_player_preset == 0) {
01697         U.anim_player_preset = 1 ;
01698     }
01699     if (U.scrcastfps == 0) {
01700         U.scrcastfps = 10;
01701         U.scrcastwait = 50;
01702     }
01703     if (U.v2d_min_gridsize == 0) {
01704         U.v2d_min_gridsize= 35;
01705     }
01706     if (U.dragthreshold == 0 )
01707         U.dragthreshold= 5;
01708     if (U.widget_unit==0)
01709         U.widget_unit= (U.dpi * 20 + 36)/72;
01710     if (U.anisotropic_filter <= 0)
01711         U.anisotropic_filter = 1;
01712 
01713     if (U.ndof_sensitivity == 0.0f) {
01714         U.ndof_sensitivity = 1.0f;
01715         U.ndof_flag = NDOF_LOCK_HORIZON |
01716             NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
01717     }
01718     if (U.tweak_threshold == 0 )
01719         U.tweak_threshold= 10;
01720 
01721     /* funny name, but it is GE stuff, moves userdef stuff to engine */
01722 // XXX  space_set_commmandline_options();
01723     /* this timer uses U */
01724 // XXX  reset_autosave();
01725 
01726 }