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