diff options
author | Ton Roosendaal <ton@blender.org> | 2003-10-17 18:02:08 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2003-10-17 18:02:08 +0400 |
commit | 0321602b6524ee2f7139610824893695d2f59b68 (patch) | |
tree | d38b4cde5cfdb7ace2671f730c4c4ee515bb980c /source/blender | |
parent | 00cf36d6a5ce06f07960616bc06d06ceeea0f886 (diff) |
- The basic layer for Themes in place!
- currently only implemented for 3d window
- create as many themes you like, and name them
- default theme is not editable, and always will be defined at startup
(initTheme)
- saves in .B.blend
- themes for spaces can become local too, so you can set individual
3d windows at theme 'Maya' or so. (to be implemented)
- it uses alpha as well...!
API:
This doesnt use the old method with BFCOLORID blahblah. The API is copied
from OpenGL conventions (naming) as much as possible:
- void BIF_ThemeColor(ScrArea *sa, int colorid)
sets a color... id's are in BIF_resources.h (TH_GRID, TH_WIRE, etc)
- void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset)
sets a color with offset, no more weird COLORSHADE_LGREY stuff
- void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col)
like opengl, this gives you in *col the three rgb values
- void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col)
or the one to get 4 bytes
ThemeColor calls for globals (UI etc) can also call NULL for *sa... this
is to be implemented still.
Next step: cleaning up interface.c for all weird colorcalls.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 27 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 8 | ||||
-rw-r--r-- | source/blender/include/BIF_interface.h | 2 | ||||
-rw-r--r-- | source/blender/include/BIF_resources.h | 57 | ||||
-rw-r--r-- | source/blender/include/BSE_drawoops.h | 3 | ||||
-rw-r--r-- | source/blender/include/butspace.h | 7 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 51 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 9 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 97 | ||||
-rw-r--r-- | source/blender/src/drawoops.c | 7 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 34 | ||||
-rw-r--r-- | source/blender/src/editscreen.c | 4 | ||||
-rw-r--r-- | source/blender/src/ghostwinlay.c | 1 | ||||
-rw-r--r-- | source/blender/src/header_view3d.c | 5 | ||||
-rw-r--r-- | source/blender/src/interface.c | 47 | ||||
-rw-r--r-- | source/blender/src/interface_panel.c | 23 | ||||
-rw-r--r-- | source/blender/src/language.c | 1 | ||||
-rw-r--r-- | source/blender/src/resources.c | 292 | ||||
-rw-r--r-- | source/blender/src/space.c | 182 | ||||
-rw-r--r-- | source/blender/src/usiblender.c | 7 |
20 files changed, 757 insertions, 107 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 8a31016c6d8..358c99df3de 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3862,6 +3862,25 @@ static void lib_link_all(FileData *fd, Main *main) lib_link_library(fd, main); /* only init users */ } +static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) +{ + Link *link; + + bfd->user= read_struct(fd, bhead); + bfd->user->themes.first= bfd->user->themes.last= NULL; + + bhead = blo_nextbhead(fd, bhead); + + /* read all attached data */ + while(bhead && bhead->code==DATA) { + link= read_struct(fd, bhead); + BLI_addtail(&bfd->user->themes, link); + bhead = blo_nextbhead(fd, bhead); + } + + return bhead; +} + BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r) { BHead *bhead= blo_firstbhead(fd); @@ -3881,14 +3900,14 @@ BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r) case DNA1: case TEST: case REND: - case USER: - if (bhead->code==USER) { - bfd->user= read_struct(fd, bhead); - } else if (bhead->code==GLOB) { + if (bhead->code==GLOB) { fg= read_struct(fd, bhead); } bhead = blo_nextbhead(fd, bhead); break; + case USER: + bhead= read_userdef(bfd, fd, bhead); + break; case ENDB: bhead = NULL; break; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 03316bf00e3..546ff3b60e6 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -472,7 +472,15 @@ static void write_renderinfo(WriteData *wd) /* for renderdaemon */ static void write_userdef(WriteData *wd) { + bTheme *btheme; + writestruct(wd, USER, "UserDef", 1, &U); + + btheme= U.themes.first; + while(btheme) { + writestruct(wd, DATA, "bTheme", 1, btheme); + btheme= btheme->next; + } } static void write_effects(WriteData *wd, ListBase *lb) diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h index 188caf77bae..579810a5903 100644 --- a/source/blender/include/BIF_interface.h +++ b/source/blender/include/BIF_interface.h @@ -89,7 +89,7 @@ struct ScrArea; #define UI_PNL_CLOSE 32 #define UI_PNL_STOW 64 #define UI_PNL_TO_MOUSE 128 - +#define UI_PNL_UNSTOW 256 /* definitions for icons (and their alignment) in buttons */ /* warning the first 4 flags are internal */ diff --git a/source/blender/include/BIF_resources.h b/source/blender/include/BIF_resources.h index 01f04f0f35e..d81c18068f8 100644 --- a/source/blender/include/BIF_resources.h +++ b/source/blender/include/BIF_resources.h @@ -324,9 +324,61 @@ typedef enum { #define BIFNCOLORIDS (BIFCOLORID_LAST-BIFCOLORID_FIRST + 1) } BIFColorID; + +/* ---------- theme ----------- */ + +// uibutton colors + + +#define TH_THEMEUI 99 + +// common colors among spaces + +enum { + TH_BACK = 100, + TH_TEXT, + TH_TEXT_HI, + TH_HEADER, + TH_PANEL, + TH_SHADE1, + TH_SHADE2, + TH_HILITE, + + TH_GRID, + TH_WIRE, + TH_SELECT, + TH_ACTIVE, + TH_TRANSFORM, + TH_VERTEX, + TH_VERTEX_SELECT, + TH_VERTEX_SIZE, + TH_EDGE, + TH_EDGE_SELECT, + TH_FACE, + TH_FACE_SELECT +}; + +/* specific defines per space should have higher define values */ + +struct bTheme; + +void BIF_InitThemeColors(void); +void BIF_ThemeColor(struct ScrArea *sa, int colorid); +void BIF_ThemeColor4(struct ScrArea *sa, int colorid); +void BIF_ThemeColorShade(struct ScrArea *sa, int colorid, int offset); + +// get only one value, not scaled +float BIF_GetThemeColorf(struct ScrArea *sa, int colorid); +// get three color values, scaled to 0.0-1.0 range +void BIF_GetThemeColor3fv(struct ScrArea *sa, int colorid, float *col); +// get the byte values +void BIF_GetThemeColor3ubv(struct ScrArea *sa, int colorid, char *col); +void BIF_GetThemeColor4ubv(struct ScrArea *sa, int colorid, char *col); + void BIF_resources_init (void); void BIF_resources_free (void); + int BIF_get_icon_width (BIFIconID icon); int BIF_get_icon_height (BIFIconID icon); void BIF_draw_icon (BIFIconID icon); @@ -334,4 +386,9 @@ void BIF_draw_icon_blended (BIFIconID icon, BIFColorID color, BIFColorShade shad void BIF_set_color (BIFColorID color, BIFColorShade shade); +/* only for buttons in theme editor! */ +char *BIF_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid); +char *BIF_ThemeColorsPup(int spacetype); + + #endif /* BIF_ICONS_H */ diff --git a/source/blender/include/BSE_drawoops.h b/source/blender/include/BSE_drawoops.h index b042fc097fa..78a8107f8e2 100644 --- a/source/blender/include/BSE_drawoops.h +++ b/source/blender/include/BSE_drawoops.h @@ -35,7 +35,6 @@ struct ScrArea; struct Oops; -struct uiBlock; void boundbox_oops(void); void give_oopslink_line(struct Oops *oops, struct OopsLink *ol, float *v1, float *v2); @@ -44,7 +43,7 @@ void draw_icon_oops(float *co, short type); void mysbox(float x1, float y1, float x2, float y2); unsigned int give_oops_color(short type, short sel, unsigned int *border); void calc_oopstext(char *str, float *v1); -void draw_oops(struct Oops *oops, struct uiBlock *block); +void draw_oops(struct Oops *oops); void drawoopsspace(struct ScrArea *sa, void *spacedata); #endif /* BSE_DRAWOOPS */ diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 013c2184bf6..aa196a8d32b 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -491,6 +491,13 @@ enum { B_CONSTRAINT_CHANGENAME, B_CONSTRAINT_CHANGETARGET }; +/* *********************** */ + +#define B_INFOBUTS 3400 +/* defines local in space.c only */ + +/* *********************** */ + /* *********************** */ /* BUTTON BUT: > 4000 */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index db5f83ebb07..e9129ca368d 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -35,6 +35,56 @@ #ifndef DNA_USERDEF_TYPES_H #define DNA_USERDEF_TYPES_H +/* themes; defines in BIF_resource.h */ + +// global, button colors + +typedef struct ThemeUI { + char back[4]; + char text[4]; + +} ThemeUI; + +// try to put them all in one, if needed a spacial struct can be created as well +// for example later on, when we introduce wire colors for ob types or so... +typedef struct ThemeSpace { + char back[4]; + char text[4]; + char text_hi[4]; + char header[4]; + char panel[4]; + + char shade1[4]; + char shade2[4]; + + char hilite[4]; + char grid[4]; + + char wire[4], select[4]; + char active[4], transform[4]; + char vertex[4], vertex_select[4]; + char edge[4], edge_select[4]; + char face[4], face_select[4]; + + char vertex_size, pad; + short pad1; + +} ThemeSpace; + + +typedef struct bTheme { + struct bTheme *next, *prev; + char name[32]; + + ThemeUI tui; + + ThemeSpace tbuts; + ThemeSpace tv3d; + ThemeSpace tfile; + ThemeSpace tipo; + +} bTheme; + typedef struct UserDef { short flag, dupflag; int savetime; @@ -59,6 +109,7 @@ typedef struct UserDef { short transopts; short menuthreshold1, menuthreshold2; char fontname[64]; + struct ListBase themes; } UserDef; extern UserDef U; /* from usiblender.c !!!! */ diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index 13a95622e59..a0766383221 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -2400,6 +2400,7 @@ static void material_panel_preview(Material *ma) void material_panels() { Material *ma; + MTex *mtex; Object *ob= OBACT; if(ob==0) return; @@ -2415,8 +2416,12 @@ void material_panels() if(ma) { material_panel_shading(ma); material_panel_texture(ma); - material_panel_map_input(ma); - material_panel_map_to(ma); + + mtex= ma->mtex[ ma->texact ]; + if(mtex && mtex->tex) { + material_panel_map_input(ma); + material_panel_map_to(ma); + } } } } diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 93d4972a80c..0ff8088f31c 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -86,6 +86,7 @@ #include "BIF_editarmature.h" #include "BIF_editika.h" #include "BIF_editmesh.h" +#include "BIF_resources.h" #include "BDR_drawmesh.h" #include "BDR_drawobject.h" @@ -183,12 +184,6 @@ unsigned int rectllib_sel[81]= {0xff777777,0xff777777,0xfff64c,0xfff64c,0xfff64c unsigned int rectl_set[81]= {0xff777777,0xff777777,0xaaaaaa,0xaaaaaa,0xaaaaaa,0xaaaaaa,0xaaaaaa,0xff777777,0xff777777,0xff777777,0xaaaaaa,0xaaaaaa,0xff777777,0xff777777,0xff777777,0xaaaaaa,0xaaaaaa,0xff777777,0xaaaaaa,0xaaaaaa,0x4e4e4e,0x10100,0x202020,0x0,0x4e4e4d,0xaaaaaa,0xaaaaaa,0xaaaaaa,0xff777777,0x0,0xaaa100,0xaaaaaa,0xaaa100,0x0,0xff777777,0xaaaaaa,0xaaaaaa,0xff777777,0x202020,0xfffde2,0xffffff,0xaaaaaa,0x202020,0xff777777,0xaaaaaa,0xaaaaaa,0xff777777,0x10100,0xaaaaaa,0xfffde2,0xaaa100,0x0,0xff777777,0xaaaaaa,0xaaaaaa,0xaaaaaa,0x4f4f4f,0x0,0x202020,0x10100,0x4e4e4e,0xaaaaaa,0xaaaaaa,0xff777777,0xaaaaaa,0xaaaaaa,0xff777777,0xff777777,0xff777777,0xaaaaaa,0xaaaaaa,0xff777777,0xff777777,0xff777777,0xaaaaaa,0xaaaaaa,0xaaaaaa,0xaaaaaa,0xaaaaaa,0xff777777,0xff777777}; -#define B_YELLOW 0x77FFFF -#define B_PURPLE 0xFF70FF - - -unsigned int selcol= 0xFF88FF; -unsigned int actselcol= 0xFFBBFF; static unsigned int colortab[24]= {0x0, 0xFF88FF, 0xFFBBFF, @@ -720,7 +715,7 @@ void drawcamera(Object *ob) mygetsingmatrix(G.vd->persmat); if(cam->flag & CAM_SHOWLIMITS) - draw_limit_line(cam->clipsta, cam->clipend, B_YELLOW); + draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF); wrld= G.scene->world; if(cam->flag & CAM_SHOWMIST) @@ -734,12 +729,14 @@ static void tekenvertslatt(short sel) { Lattice *lt; BPoint *bp; + float size; int a, uxt, u, vxt, v, wxt, w; - glPointSize(3.0); + size= BIF_GetThemeColorf(curarea, TH_VERTEX_SIZE); + glPointSize(size); - if(sel) cpack(B_YELLOW); - else cpack(B_PURPLE); + if(sel) BIF_ThemeColor(curarea, TH_VERTEX_SELECT); + else BIF_ThemeColor(curarea, TH_VERTEX); glBegin(GL_POINTS); @@ -1037,15 +1034,14 @@ void calc_nurbverts_ext(void) void tekenvertices(short sel) { EditVert *eve; - - glPointSize(2.0); + float size; + + size= BIF_GetThemeColorf(curarea, TH_VERTEX_SIZE); + glPointSize(size); - if(sel) cpack(B_YELLOW); - else cpack(B_PURPLE); -#ifdef __NLA /* __TEKENTEST */ -// if (sel==2) -// cpack (0x0000FF); -#endif /* __TEKENTEST */ + if(sel) BIF_ThemeColor(curarea, TH_VERTEX_SELECT); + else BIF_ThemeColor(curarea, TH_VERTEX); + glBegin(GL_POINTS); eve= (EditVert *)G.edve.first; @@ -1053,11 +1049,6 @@ void tekenvertices(short sel) if(eve->h==0 && (eve->f & 1)==sel ) { glVertex3fv(eve->co); } -#ifdef __NLA /* __TEKENTEST */ -// if (eve->totweight && sel==2) -// glVertex3fv(eve->co); - -#endif /* __TEKENTEST */ eve= eve->next; } glEnd(); @@ -2407,6 +2398,10 @@ static void drawmeshwire(Object *ob) if(ob==G.obedit || (G.obedit && ob->data==G.obedit->data)) { if(G.f & (G_FACESELECT+G_DRAWFACES)) { /* faces */ + char col1[4], col2[4]; + + BIF_GetThemeColor4ubv(curarea, TH_FACE, col1); + BIF_GetThemeColor4ubv(curarea, TH_FACE_SELECT, col2); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); @@ -2416,8 +2411,8 @@ static void drawmeshwire(Object *ob) if(evl->v1->h==0 && evl->v2->h==0 && evl->v3->h==0) { if(1) { - if(vlakselectedAND(evl, 1)) glColor4ub(200, 100, 200, 60); - else glColor4ub(0, 50, 150, 30); + if(vlakselectedAND(evl, 1)) glColor4ub(col2[0], col2[1], col2[2], col2[3]); + else glColor4ub(col1[0], col1[1], col1[2], col1[3]); glBegin(evl->v4?GL_QUADS:GL_TRIANGLES); glVertex3fv(evl->v1->co); @@ -2427,13 +2422,13 @@ static void drawmeshwire(Object *ob) glEnd(); } else { - if(vlakselectedAND(evl, 1)) cpack(0x559999); - else cpack(0x664466); + if(vlakselectedAND(evl, 1)) glColor4ub(col2[0], col2[1], col2[2], col2[3]); + else glColor4ub(col1[0], col1[1], col1[2], col1[3]); if(evl->v4 && evl->v4->h==0) { CalcCent4f(cent, evl->v1->co, evl->v2->co, evl->v3->co, evl->v4->co); - glBegin(GL_LINE_LOOP); + glBegin(GL_QUADS); VecMidf(fvec, cent, evl->v1->co); glVertex3fv(fvec); VecMidf(fvec, cent, evl->v2->co); glVertex3fv(fvec); VecMidf(fvec, cent, evl->v3->co); glVertex3fv(fvec); @@ -2443,7 +2438,7 @@ static void drawmeshwire(Object *ob) else { CalcCent3f(cent, evl->v1->co, evl->v2->co, evl->v3->co); - glBegin(GL_LINE_LOOP); + glBegin(GL_TRIANGLES); VecMidf(fvec, cent, evl->v1->co); glVertex3fv(fvec); VecMidf(fvec, cent, evl->v2->co); glVertex3fv(fvec); VecMidf(fvec, cent, evl->v3->co); glVertex3fv(fvec); @@ -2463,15 +2458,17 @@ static void drawmeshwire(Object *ob) cpack(0x0); if(G.f & G_DRAWEDGES) { /* Use edge Highlighting */ + char col[4]; + BIF_GetThemeColor3ubv(curarea, TH_EDGE_SELECT, col); glShadeModel(GL_SMOOTH); eed= G.eded.first; glBegin(GL_LINES); while(eed) { if(eed->h==0) { - if(eed->v1->f & 1) cpack(0x559999); else cpack(0x0); + if(eed->v1->f & 1) glColor3ub(col[0], col[1], col[2]); else cpack(0x0); glVertex3fv(eed->v1->co); - if(eed->v2->f & 1) cpack(0x559999); else cpack(0x0); + if(eed->v2->f & 1) glColor3ub(col[0], col[1], col[2]); else cpack(0x0); glVertex3fv(eed->v2->co); } eed= eed->next; @@ -2783,13 +2780,16 @@ static void tekenvertsN(Nurb *nu, short sel) { BezTriple *bezt; BPoint *bp; + float size; int a; if(nu->hide) return; - if(sel) cpack(B_YELLOW); - else cpack(B_PURPLE); - glPointSize(3.0); + if(sel) BIF_ThemeColor(curarea, TH_VERTEX_SELECT); + else BIF_ThemeColor(curarea, TH_VERTEX); + + size= BIF_GetThemeColorf(curarea, TH_VERTEX_SIZE); + glPointSize(size); glBegin(GL_POINTS); @@ -3453,22 +3453,33 @@ void draw_object(Base *base) if((G.f & (G_BACKBUFSEL+G_PICKSEL)) == 0) { project_short(ob->obmat[3], &base->sx); - if(G.moving==1 && (base->flag & (SELECT+BA_PARSEL))) colindex= 12; + if(G.moving==1 && (base->flag & (SELECT+BA_PARSEL))) BIF_ThemeColor(curarea, TH_TRANSFORM); else { + + BIF_ThemeColor(curarea, TH_WIRE); if((G.scene->basact)==base) { - if(base->flag & (SELECT+BA_WASSEL)) colindex= 2; + if(base->flag & (SELECT+BA_WASSEL)) BIF_ThemeColor(curarea, TH_ACTIVE); } else { - if(base->flag & (SELECT+BA_WASSEL)) colindex= 1; + if(base->flag & (SELECT+BA_WASSEL)) BIF_ThemeColor(curarea, TH_SELECT); + } + + // no theme yet + if(ob->id.lib) { + if(base->flag & (SELECT+BA_WASSEL)) colindex = 4; + else colindex = 5; } - if(ob->id.lib) colindex+= 3; - else if(warning_recursive==1) colindex+= 6; - else if(ob->flag & OB_FROMGROUP) colindex+= 9; + else if(warning_recursive==1) { + if(base->flag & (SELECT+BA_WASSEL)) colindex = 7; + else colindex = 8; + } + } - col= colortab[colindex]; - cpack(col); - + if(colindex) { + col= colortab[colindex]; + cpack(col); + } } /* maximum drawtype */ diff --git a/source/blender/src/drawoops.c b/source/blender/src/drawoops.c index 0642e76819c..8c955eb38d9 100644 --- a/source/blender/src/drawoops.c +++ b/source/blender/src/drawoops.c @@ -272,7 +272,7 @@ void calc_oopstext(char *str, float *v1) } -void draw_oops(Oops *oops, uiBlock *block) +void draw_oops(Oops *oops) { OopsLink *ol; float v1[2], x1, y1, x2, y2, f1, f2; @@ -367,7 +367,6 @@ void draw_oops(Oops *oops, uiBlock *block) void drawoopsspace(ScrArea *sa, void *spacedata) { - uiBlock *block; Oops *oops; int ofsx, ofsy; @@ -404,14 +403,14 @@ void drawoopsspace(ScrArea *sa, void *spacedata) oops= G.soops->oops.first; while(oops) { if(oops->hide==0) { - if(oops->flag & SELECT); else draw_oops(oops, block); + if(oops->flag & SELECT); else draw_oops(oops); } oops= oops->next; } oops= G.soops->oops.first; while(oops) { if(oops->hide==0) { - if(oops->flag & SELECT) draw_oops(oops, block); + if(oops->flag & SELECT) draw_oops(oops); } oops= oops->next; } diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index f6b65efbe74..267cab4eb52 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -404,7 +404,7 @@ void timestr(double time, char *str) } -static void drawgrid(void) +static void drawgrid(ScrArea *sa) { /* extern short bgpicmode; */ float wx, wy, x, y, fw, fx, fy, dx; @@ -448,7 +448,7 @@ static void drawgrid(void) persp(PERSP_WIN); - cpack(0x606060); + BIF_ThemeColor(sa, TH_GRID); x+= (wx); y+= (wy); @@ -485,7 +485,7 @@ static void drawgrid(void) } -static void drawfloor(void) +static void drawfloor(ScrArea *sa) { View3D *vd; float vert[3], grid; @@ -500,7 +500,7 @@ static void drawfloor(void) gridlines= vd->gridlines/2; grid= gridlines*vd->grid; - cpack(0x606060); + BIF_ThemeColor(sa, TH_GRID); for(a= -gridlines;a<=gridlines;a++) { @@ -509,7 +509,7 @@ static void drawfloor(void) else cpack(0x402000); } else if(a==1) { - cpack(0x606060); + BIF_ThemeColor(sa, TH_GRID); } @@ -522,7 +522,7 @@ static void drawfloor(void) glEnd(); } - cpack(0x606060); + BIF_ThemeColor(sa, TH_GRID); for(a= -gridlines;a<=gridlines;a++) { if(a==0) { @@ -530,7 +530,7 @@ static void drawfloor(void) else cpack(0); } else if(a==1) { - cpack(0x606060); + BIF_ThemeColor(sa, TH_GRID); } glBegin(GL_LINE_STRIP); @@ -787,7 +787,7 @@ static void draw_selected_name(char *name) sprintf(info, "(%d) %s", CFRA, name); - cpack(0xFFFFFF); + BIF_ThemeColor(curarea, TH_TEXT_HI); glRasterPos2i(30, 10); BMF_DrawString(G.fonts, info); } @@ -943,7 +943,7 @@ static void view3d_panel_object(short cntrl) // VIEW3D_HANDLER_OBJECT if(ob==NULL) return; block= uiNewBlock(&curarea->uiblocks, "view3d_panel_object", UI_EMBOSSX, UI_HELV, curarea->win); - uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_STOW | cntrl); + uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); uiSetPanelHandler(VIEW3D_HANDLER_OBJECT); // for close and esc if(uiNewPanel(curarea, block, "Object", "View3d", 10, 230, 318, 204)==0) return; @@ -980,7 +980,7 @@ static void view3d_panel_settings(cntrl) // VIEW3D_HANDLER_BACKGROUND vd= G.vd; block= uiNewBlock(&curarea->uiblocks, "view3d_panel_settings", UI_EMBOSSX, UI_HELV, curarea->win); - uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_STOW | cntrl); + uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); uiSetPanelHandler(VIEW3D_HANDLER_BACKGROUND); // for close and esc if(uiNewPanel(curarea, block, "Backdrop and settings", "View3d", 10, 10, 318, 204)==0) return; @@ -1094,14 +1094,18 @@ void drawview3dspace(ScrArea *sa, void *spacedata) glClearColor(0.0, 0.0, 0.0, 0.0); } else { - glClearColor(0.45, 0.45, 0.45, 0.0); + float col[3]; + BIF_GetThemeColor3fv(sa, TH_BACK, col); + glClearColor(col[0], col[1], col[2], 0.0); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); } else { - glClearColor(0.45, 0.45, 0.45, 0.0); + float col[3]; + BIF_GetThemeColor3fv(sa, TH_BACK, col); + glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); } @@ -1109,7 +1113,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) persp(PERSP_STORE); // store correct view for persp(PERSP_VIEW) calls if(G.vd->view==0 || G.vd->persp!=0) { - drawfloor(); + drawfloor(sa); if(G.vd->persp==2) { if(G.scene->world) { if(G.scene->world->mode & WO_STARS) RE_make_stars(star_stuff_init_func, @@ -1120,7 +1124,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) } } else { - drawgrid(); + drawgrid(sa); if(G.vd->flag & V3D_DISPBGPIC) { draw_bgpic(); @@ -1320,7 +1324,7 @@ void drawview3d_render(struct View3D *v3d) if (v3d->drawtype==OB_TEXTURE && G.scene->world) { glClearColor(G.scene->world->horr, G.scene->world->horg, G.scene->world->horb, 0.0); } else { - glClearColor(0.45, 0.45, 0.45, 0.0); + glClearColor(0.45, 0.45, 0.45, 0.0); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c index a3813220dc9..6517d6718e3 100644 --- a/source/blender/src/editscreen.c +++ b/source/blender/src/editscreen.c @@ -299,8 +299,8 @@ void headerbox(ScrArea *area) glClearColor(SCR_BACK, SCR_BACK, SCR_BACK, 0.0); glClear(GL_COLOR_BUFFER_BIT); - if(area_is_active_area(area)) BIF_set_color(HEADERCOLSEL, COLORSHADE_LMEDIUM); - else BIF_set_color(HEADERCOL, COLORSHADE_LMEDIUM); + if(area_is_active_area(area)) BIF_ThemeColor(area, TH_HEADER); + else BIF_ThemeColorShade(area, TH_HEADER, -20); /* weird values here... is because of window matrix that centres buttons */ if(area->headertype==HEADERTOP) { diff --git a/source/blender/src/ghostwinlay.c b/source/blender/src/ghostwinlay.c index ffe10f0a19b..916279ab26b 100644 --- a/source/blender/src/ghostwinlay.c +++ b/source/blender/src/ghostwinlay.c @@ -42,6 +42,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_ListBase.h" #include "DNA_userdef_types.h" /* U.flag & TWOBUTTONMOUSE */ #include "BLI_blenlib.h" diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 70c4c106818..4d61e9cd494 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -280,10 +280,10 @@ static void do_view3d_viewmenu(void *arg, int event) play_anim(0); break; case 14: /* Backdrop Panel */ - add_blockhandler(curarea, VIEW3D_HANDLER_BACKGROUND, 0); + add_blockhandler(curarea, VIEW3D_HANDLER_BACKGROUND, UI_PNL_UNSTOW); break; case 15: /* View Panel */ - add_blockhandler(curarea, VIEW3D_HANDLER_VIEW, 0); + add_blockhandler(curarea, VIEW3D_HANDLER_VIEW, UI_PNL_UNSTOW); break; } allqueue(REDRAWVIEW3D, 0); @@ -2923,7 +2923,6 @@ void view3d_buttons(void) } } - xco+=XIC; /* Always do this last */ curarea->headbutlen= xco+2*XIC; diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index 131c3651102..bebb0257da3 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -2664,7 +2664,7 @@ static int ui_do_but_MENU(uiBut *but) int width, height, a, xmax, starty; short startx; int columns=1, rows=0, boxh, event; - short x1, y1; + short x1, y1, active= -1; short mval[2]; MenuData *md; @@ -2709,15 +2709,18 @@ static int ui_do_but_MENU(uiBut *but) /* find active item */ fvalue= ui_get_but_val(but); - for(a=0; a<md->nitems; a++) { - if( md->items[a].retval== (int)fvalue ) break; + for(active=0; active<md->nitems; active++) { + if( md->items[active].retval== (int)fvalue ) break; } /* no active item? */ - if(a==md->nitems) { - if(md->title) a= -1; - else a= 0; + if(active==md->nitems) { + if(md->title) active= -1; + else active= 0; } + /* for now disabled... works confusing because you think it's a title or so.... */ + active= -1; + /* here we go! */ startx= but->x1; starty= but->y1; @@ -2731,7 +2734,7 @@ static int ui_do_but_MENU(uiBut *but) } for(a=0; a<md->nitems; a++) { - + x1= but->x1 + width*((int)a/rows); y1= but->y1 - boxh*(a%rows) + (rows-1)*boxh; @@ -2739,7 +2742,8 @@ static int ui_do_but_MENU(uiBut *but) uiDefBut(block, SEPR, B_NOP, "", x1, y1,(short)(width-(rows>1)), (short)(boxh-1), NULL, 0.0, 0.0, 0, 0, ""); } else { - uiDefBut(block, BUTM|but->pointype, but->retval, md->items[a].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), but->poin, (float) md->items[a].retval, 0.0, 0, 0, ""); + uiBut *bt= uiDefBut(block, BUTM|but->pointype, but->retval, md->items[a].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), but->poin, (float) md->items[a].retval, 0.0, 0, 0, ""); + if(active==a) bt->flag |= UI_ACTIVE; } } @@ -4269,7 +4273,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) if(block->win != mywinget()) return UI_NOTHING; /* filter some unwanted events */ - if(uevent==0 || uevent->event==LEFTSHIFTKEY || uevent->event==RIGHTSHIFTKEY) return UI_NOTHING; + if(uevent==0 || uevent->event==0 || uevent->event==LEFTSHIFTKEY || uevent->event==RIGHTSHIFTKEY) return UI_NOTHING; if(block->flag & UI_BLOCK_ENTER_OK) { if(uevent->event == RETKEY && uevent->val) { @@ -4447,8 +4451,11 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) /* hilite case 2 */ if(but->flag & UI_ACTIVE) { if( (but->flag & UI_MOUSE_OVER)==0) { - but->flag &= ~UI_ACTIVE; - if(but->type != LABEL && but->embossfunc != ui_emboss_N) ui_draw_but(but); + /* we dont clear active flag until mouse move, for Menu buttons to remain showing active item when opened */ + if (uevent->event==MOUSEY) { + but->flag &= ~UI_ACTIVE; + if(but->type != LABEL && but->embossfunc != ui_emboss_N) ui_draw_but(but); + } } else if(but->type==BLOCK || but->type==MENU) { // automatic opens block button (pulldown) int time; @@ -4489,16 +4496,18 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) if(uevent->val || (block->flag & UI_BLOCK_RET_1)==0) { if ELEM3(uevent->event, LEFTMOUSE, PADENTER, RETKEY) { - - butevent= ui_do_button(block, but, uevent); - if(butevent) addqueue(block->winq, UI_BUT_EVENT, (short)butevent); + /* when mouse outside, don't do button */ + if(inside || uevent->event!=LEFTMOUSE) { + butevent= ui_do_button(block, but, uevent); + if(butevent) addqueue(block->winq, UI_BUT_EVENT, (short)butevent); - /* i doubt about the next line! */ - /* if(but->func) mywinset(block->win); */ + /* i doubt about the next line! */ + /* if(but->func) mywinset(block->win); */ - if( (block->flag & UI_BLOCK_LOOP) && but->type==BLOCK); - else - if(/*but->func ||*/ butevent) retval= UI_RETURN_OK; + if( (block->flag & UI_BLOCK_LOOP) && but->type==BLOCK); + else + if(/*but->func ||*/ butevent) retval= UI_RETURN_OK; + } } } } diff --git a/source/blender/src/interface_panel.c b/source/blender/src/interface_panel.c index 5093b463d94..086c498fdce 100644 --- a/source/blender/src/interface_panel.c +++ b/source/blender/src/interface_panel.c @@ -88,9 +88,13 @@ #include "interface.h" #include "blendef.h" - +// globals extern float UIwinmat[4][4]; +// internal prototypes +static void stow_unstow(uiBlock *block); + + /* --------- generic helper drawng calls ---------------- */ /* supposes you draw the actual box atop of this. */ @@ -454,6 +458,11 @@ int uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int } } + block->panel= pa; + block->handler= pnl_handler; + pa->active= 1; + pa->control= pnl_control; + if(pnl_control & UI_PNL_TO_MOUSE) { short mval[2]; @@ -465,10 +474,12 @@ int uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int if(pa->flag & PNL_CLOSED) pa->flag &= ~PNL_CLOSED; } - block->panel= pa; - block->handler= pnl_handler; - pa->active= 1; - pa->control= pnl_control; + if(pnl_control & UI_PNL_UNSTOW) { + if(pa->flag & PNL_CLOSEDY) { + pa->flag &= ~PNL_CLOSED; + stow_unstow(block); // toggles! + } + } /* clear ugly globals */ panel_tabbed= group_tabbed= NULL; @@ -1482,7 +1493,7 @@ static void stow_unstow(uiBlock *block) Panel *pa; int ok=0, x, y, width; - if(block->panel->flag & PNL_CLOSEDY) { + if(block->panel->flag & PNL_CLOSEDY) { // flag has been set how it should become! width= (curarea->winx-320)/sl->blockscale; if(width<5) width= 5; diff --git a/source/blender/src/language.c b/source/blender/src/language.c index e330d617672..f92f86876cc 100644 --- a/source/blender/src/language.c +++ b/source/blender/src/language.c @@ -31,6 +31,7 @@ #include <string.h> #include <stdlib.h> +#include "DNA_ListBase.h" #include "DNA_userdef_types.h" #include "BKE_global.h" /* G */ diff --git a/source/blender/src/resources.c b/source/blender/src/resources.c index 06e7c3bc348..279bd2f6f25 100644 --- a/source/blender/src/resources.c +++ b/source/blender/src/resources.c @@ -46,12 +46,19 @@ #include "MEM_guardedalloc.h" +#include "DNA_ListBase.h" +#include "DNA_userdef_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" + #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "BIF_gl.h" #include "BIF_resources.h" +#include "BLI_blenlib.h" +#include "blendef.h" // CLAMP #include "datatoc.h" typedef struct { @@ -322,4 +329,289 @@ void BIF_resources_free(void) MEM_freeN(common_colors_arr); MEM_freeN(common_icons_arr); + +} + + +/* ******************************************************** */ +/* THEMES */ +/* ******************************************************** */ + + +char *BIF_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) +{ + ThemeSpace *ts= NULL; + char error[3]={240, 0, 240}; + char *cp= error; + + if(btheme) { + // first check for ui buttons theme + if(colorid < TH_THEMEUI) { + + } + else { + + switch(spacetype) { + case SPACE_BUTS: + ts= &btheme->tbuts; + break; + case SPACE_VIEW3D: + ts= &btheme->tv3d; + break; + case SPACE_FILE: + ts= &btheme->tfile; + break; + case SPACE_IPO: + ts= &btheme->tipo; + break; + default: + ts= &btheme->tbuts; + break; + } + + switch(colorid) { + case TH_BACK: + cp= ts->back; break; + case TH_TEXT: + cp= ts->text; break; + case TH_TEXT_HI: + cp= ts->text_hi; break; + case TH_HEADER: + cp= ts->header; break; + case TH_SHADE1: + cp= ts->shade1; break; + case TH_SHADE2: + cp= ts->shade2; break; + case TH_HILITE: + cp= ts->hilite; break; + + case TH_GRID: + cp= ts->grid; break; + case TH_WIRE: + cp= ts->wire; break; + case TH_SELECT: + cp= ts->select; break; + case TH_ACTIVE: + cp= ts->active; break; + case TH_TRANSFORM: + cp= ts->transform; break; + case TH_VERTEX: + cp= ts->vertex; break; + case TH_VERTEX_SELECT: + cp= ts->vertex_select; break; + case TH_VERTEX_SIZE: + cp= &ts->vertex_size; break; + case TH_EDGE: + cp= ts->edge; break; + case TH_EDGE_SELECT: + cp= ts->edge_select; break; + case TH_FACE: + cp= ts->face; break; + case TH_FACE_SELECT: + cp= ts->face_select; break; + + } + + } + } + + return cp; +} + +#define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; + +// initialize +void BIF_InitThemeColors(void) +{ + bTheme *btheme= U.themes.first; + + /* we search for the theme with name Default */ + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + if(strcmp("Default", btheme->name)==0) break; + } + + if(btheme==NULL) { + btheme= MEM_callocN(sizeof(bTheme), "theme"); + BLI_addtail(&U.themes, btheme); + strcpy(btheme->name, "Default"); + } + + /* buttons */ + + /* space view3d */ + SETCOL(btheme->tv3d.back, 115, 115, 115, 255); + SETCOL(btheme->tv3d.text, 0, 0, 0, 255); + SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255); + SETCOL(btheme->tv3d.header, 195, 195, 195, 255); + SETCOL(btheme->tv3d.panel, 165, 165, 165, 100); + + SETCOL(btheme->tv3d.grid, 0x60, 0x60, 0x60, 255); + SETCOL(btheme->tv3d.wire, 0x0, 0x0, 0x0, 255); + SETCOL(btheme->tv3d.select, 0xff, 0x88, 0xff, 255); + SETCOL(btheme->tv3d.active, 0xff, 0xbb, 0xff, 255); + SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255); + SETCOL(btheme->tv3d.vertex, 0xff, 0x70, 0xff, 255); + SETCOL(btheme->tv3d.vertex_select, 0xff, 0xff, 0x70, 255); + btheme->tv3d.vertex_size= 2; + SETCOL(btheme->tv3d.edge, 0x0, 0x0, 0x0, 255); + SETCOL(btheme->tv3d.edge_select, 0x90, 0x90, 0x30, 255); + SETCOL(btheme->tv3d.face, 0, 50, 150, 30); + SETCOL(btheme->tv3d.face_select, 200, 100, 200, 60); + + /* copy this to the others, to have something initialized */ + + btheme->tbuts= btheme->tv3d; + btheme->tfile= btheme->tv3d; + btheme->tipo= btheme->tv3d; + +} + +char *BIF_ThemeColorsPup(int spacetype) +{ + char *cp= MEM_callocN(20*32, "theme pup"); + char str[32]; + + if(spacetype==0) { + strcpy(cp, "Not Yet"); + } + else { + // first defaults for each space + sprintf(str, "Background %%x%d|", TH_BACK); strcat(cp, str); + sprintf(str, "Text %%x%d|", TH_TEXT); strcat(cp, str); + sprintf(str, "Text Hilite %%x%d|", TH_TEXT_HI); strcat(cp, str); + sprintf(str, "Header %%x%d|", TH_HEADER); strcat(cp, str); + sprintf(str, "Panel %%x%d|", TH_PANEL); strcat(cp, str); + strcat(cp,"%l|"); + + if(spacetype==SPACE_VIEW3D) { + sprintf(str, "Grid %%x%d|", TH_GRID); strcat(cp, str); + sprintf(str, "Wire %%x%d|", TH_WIRE); strcat(cp, str); + sprintf(str, "Object Selected %%x%d|", TH_SELECT); strcat(cp, str); + sprintf(str, "Object Active %%x%d|", TH_ACTIVE); strcat(cp, str); + sprintf(str, "Transform %%x%d|", TH_TRANSFORM); strcat(cp, str); + strcat(cp,"%l|"); + sprintf(str, "Vertex %%x%d|", TH_VERTEX); strcat(cp, str); + sprintf(str, "Vertex Selected %%x%d|", TH_VERTEX_SELECT); strcat(cp, str); + sprintf(str, "Vertex Size %%x%d|", TH_VERTEX_SIZE); strcat(cp, str); + //sprintf(str, "Edge %%x%d|", TH_EDGE); strcat(cp, str); + sprintf(str, "Edge Selected %%x%d|", TH_EDGE_SELECT); strcat(cp, str); + sprintf(str, "Face %%x%d|", TH_FACE); strcat(cp, str); + // last item without '|' + sprintf(str, "Face Selected %%x%d", TH_FACE_SELECT); strcat(cp, str); + } + else { + sprintf(str, "Main Shade %%x%d|", TH_SHADE1); strcat(cp, str); + sprintf(str, "Alt Shade %%x%d|", TH_SHADE2); strcat(cp, str); + // last item without '|' + sprintf(str, "General Hilite %%x%d", TH_HILITE); strcat(cp, str); + } + } + return cp; +} + +// for space windows only +void BIF_ThemeColor(ScrArea *sa, int colorid) +{ + bTheme *btheme= U.themes.first; + char *cp; + + if(btheme) { + cp= BIF_ThemeGetColorPtr(btheme, sa->spacetype, colorid); + glColor3ub(cp[0], cp[1], cp[2]); + } + else { // debug mostly, you never know + glColor3ub(255, 0, 255); + } +} + +// plus alpha +void BIF_ThemeColor4(ScrArea *sa, int colorid) +{ + bTheme *btheme= U.themes.first; + char *cp; + + if(btheme) { + cp= BIF_ThemeGetColorPtr(btheme, sa->spacetype, colorid); + glColor4ub(cp[0], cp[1], cp[2], cp[3]); + } + else { // debug mostly, you never know + glColor3ub(255, 0, 255); + } +} + +void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset) +{ + bTheme *btheme= U.themes.first; + int r, g, b; + char *cp; + + if(btheme) { + cp= BIF_ThemeGetColorPtr(btheme, sa->spacetype, colorid); + r= offset + (int) cp[0]; + CLAMP(r, 0, 255); + g= offset + (int) cp[1]; + CLAMP(g, 0, 255); + b= offset + (int) cp[2]; + CLAMP(b, 0, 255); + glColor3ub(r, g, b); + } + else { // debug mostly, you never know + glColor3ub(255, 0, 255); + } } + +// get individual values, not scaled +float BIF_GetThemeColorf(ScrArea *sa, int colorid) +{ + bTheme *btheme= U.themes.first; + char *cp; + + if(btheme) { + cp= BIF_ThemeGetColorPtr(btheme, sa->spacetype, colorid); + return ((float)cp[0]); + } + return 1.0; +} + +// get the color, range 0.0-1.0 +void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col) +{ + bTheme *btheme= U.themes.first; + char *cp; + + if(btheme) { + cp= BIF_ThemeGetColorPtr(btheme, sa->spacetype, colorid); + col[0]= ((float)cp[0])/255.0; + col[1]= ((float)cp[1])/255.0; + col[2]= ((float)cp[2])/255.0; + } +} + +void BIF_GetThemeColor3ubv(ScrArea *sa, int colorid, char *col) +{ + bTheme *btheme= U.themes.first; + char *cp; + + if(btheme) { + cp= BIF_ThemeGetColorPtr(btheme, sa->spacetype, colorid); + col[0]= cp[0]; + col[1]= cp[1]; + col[2]= cp[2]; + } +} + +void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col) +{ + bTheme *btheme= U.themes.first; + char *cp; + + if(btheme) { + cp= BIF_ThemeGetColorPtr(btheme, sa->spacetype, colorid); + col[0]= cp[0]; + col[1]= cp[1]; + col[2]= cp[2]; + col[3]= cp[3]; + } +} + + diff --git a/source/blender/src/space.c b/source/blender/src/space.c index c8ba4603109..744ea874114 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1517,6 +1517,126 @@ void space_sound_button_function(int event) } } +#define B_ADD_THEME 3301 +#define B_DEL_THEME 3302 +#define B_NAME_THEME 3303 +#define B_THEMECOL 3304 +#define B_UPDATE_THEME 3305 +#define B_CHANGE_THEME 3306 +#define B_THEME_COPY 3307 +#define B_THEME_PASTE 3308 + + +// needed for event; choose new 'curmain' resets it... +static short th_curcol= TH_BACK; +static char *th_curcol_ptr= NULL; +static char th_curcol_arr[4]={0, 0, 0, 255}; + +void info_user_themebuts(uiBlock *block, short y1, short y2, short y3) +{ + bTheme *btheme, *bt; + int spacetype= 0; + static short cur=1, curmain=2; + short a, tot=0, isbuiltin= 0; + char string[20*32], *strp; + + y3= y2+23; // exception! + + /* count total, max 16! */ + for(bt= U.themes.first; bt; bt= bt->next) tot++; + + /* if cur not is 1; move that to front of list */ + if(cur!=1) { + a= 1; + for(bt= U.themes.first; bt; bt= bt->next, a++) { + if(a==cur) { + BLI_remlink(&U.themes, bt); + BLI_addhead(&U.themes, bt); + cur= 1; + break; + } + } + } + + /* the current theme */ + btheme= U.themes.first; + if(strcmp(btheme->name, "Default")==0) isbuiltin= 1; + + /* construct popup script */ + string[0]= 0; + for(bt= U.themes.first; bt; bt= bt->next) { + strcat(string, bt->name); + if(btheme->next) strcat(string, " |"); + } + uiDefButS(block, MENU, B_UPDATE_THEME, string, 45,y3,200,20, &cur, 0, 0, 0, 0, "Current theme"); + + /* add / delete / name */ + uiBlockSetCol(block, BUTSALMON); + if(tot<16) + uiDefBut(block, BUT, B_ADD_THEME, "Add", 45,y2,200,20, NULL, 0, 0, 0, 0, "Makes new copy of this theme"); + if(tot>1 && isbuiltin==0) + uiDefBut(block, BUT, B_DEL_THEME, "Delete", 45,y1,200,20, NULL, 0, 0, 0, 0, "Delete theme"); + uiBlockSetCol(block, BUTGREY); + + if(isbuiltin) return; + + /* name */ + uiDefBut(block, TEX, B_NAME_THEME, "", 255,y3,200,20, btheme->name, 1.0, 30.0, 0, 0, "Rename theme"); + + /* main choices pup */ + uiDefButS(block, MENU, B_CHANGE_THEME, "UI and Buttons %x1|3D View %x2|Ipo Window %x3|Buttons Window %x4|File Select %x5", + 255,y2,200,20, &curmain, 0, 0, 0, 0, "Specify theme for..."); + if(curmain==2) spacetype= SPACE_VIEW3D; + if(curmain==3) spacetype= SPACE_IPO; + if(curmain==4) spacetype= SPACE_BUTS; + if(curmain==5) spacetype= SPACE_FILE; + + /* color choices pup */ + if(curmain==1) strp= BIF_ThemeColorsPup(0); + else strp= BIF_ThemeColorsPup(spacetype); + uiDefButS(block, MENU, B_REDR, strp, 255,y1,200,20, &th_curcol, 0, 0, 0, 0, "Current color"); + MEM_freeN(strp); + + /* always make zero, ugly global... */ + th_curcol_ptr= NULL; + + /* sliders */ + if(curmain==1); + else { + char *col; + + th_curcol_ptr= col= BIF_ThemeGetColorPtr(btheme, spacetype, th_curcol); + + if(col && th_curcol==TH_VERTEX_SIZE) { + uiDefButC(block, NUMSLI, B_UPDATE_THEME,"Vertex size ", 465,y3,200,20, col, 1.0, 10.0, B_THEMECOL, 0, ""); + + } + else if(col) { + uiDefButC(block, NUMSLI, B_UPDATE_THEME,"R ", 465,y3,200,20, col, 0.0, 255.0, B_THEMECOL, 0, ""); + uiDefButC(block, NUMSLI, B_UPDATE_THEME,"G ", 465,y2,200,20, col+1, 0.0, 255.0, B_THEMECOL, 0, ""); + uiDefButC(block, NUMSLI, B_UPDATE_THEME,"B ", 465,y1,200,20, col+2, 0.0, 255.0, B_THEMECOL, 0, ""); + + uiDefButC(block, COL, B_THEMECOL, "", 675,y1,50,y3-y1+20, col, 0, 0, 0, 0, ""); + + if ELEM3(th_curcol, TH_PANEL, TH_FACE, TH_FACE_SELECT) { + uiDefButC(block, NUMSLI, B_UPDATE_THEME,"A ", 465,y3+25,200,20, col+3, 0.0, 255.0, B_THEMECOL, 0, ""); + } + + /* copy paste */ + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_THEME_COPY, "Copy Color", 755,y2,120,20, NULL, 0, 0, 0, 0, "Stores current color in buffer"); + uiDefBut(block, BUT, B_THEME_PASTE, "Paste Color", 755,y1,120,20, NULL, 0, 0, 0, 0, "Pastes buffer color"); + + uiDefButC(block, COL, 0, "", 885,y1,50,y2-y1+20, th_curcol_arr, 0, 0, 0, 0, ""); + + } + } + + + + uiClearButLock(); +} + void drawinfospace(ScrArea *sa, void *spacedata) { @@ -1539,7 +1659,7 @@ void drawinfospace(ScrArea *sa, void *spacedata) block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->win); - dx= (1280-90)/6; /* spacing for use in equally dividing 'tab' row */ + dx= (1280-90)/7; /* spacing for use in equally dividing 'tab' row */ xpos = 45; /* left padding */ ypos = 50; /* bottom padding for buttons */ @@ -1584,6 +1704,10 @@ void drawinfospace(ScrArea *sa, void *spacedata) (short)(xpos+2*dx),ypostab,(short)dx,buth, &U.userpref,1.0,2.0, 0, 0,""); + uiDefButI(block, ROW,B_USERPREF,"Themes", + (short)(xpos+2*dx),ypostab,(short)dx,buth, + &U.userpref,1.0,6.0, 0, 0,""); + uiDefButI(block, ROW,B_USERPREF,"Auto Save", (short)(xpos+3*dx),ypostab,(short)dx,buth, &U.userpref,1.0,3.0, 0, 0,""); @@ -1603,7 +1727,10 @@ void drawinfospace(ScrArea *sa, void *spacedata) /* line 2: left x co-ord, top y co-ord, width, height */ - if (U.userpref == 0) { /* view & controls */ + if(U.userpref == 6) { + info_user_themebuts(block, y1, y2, y3); + } + else if (U.userpref == 0) { /* view & controls */ uiDefBut(block, LABEL,0,"Display:", xpos,y3label,medprefbut,buth, @@ -2052,13 +2179,60 @@ void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt) { unsigned short event= evt->event; short val= evt->val; - + if(val) { if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0; switch(event) { case UI_BUT_EVENT: - do_global_buttons(val); + if(val==B_ADD_THEME) { + bTheme *btheme, *new; + + btheme= U.themes.first; + new= MEM_callocN(sizeof(bTheme), "theme"); + memcpy(new, btheme, sizeof(bTheme)); + BLI_addhead(&U.themes, new); + strcpy(new->name, "New User Theme"); + addqueue(sa->win, REDRAW, 1); + } + else if(val==B_DEL_THEME) { + bTheme *btheme= U.themes.first; + BLI_remlink(&U.themes, btheme); + MEM_freeN(btheme); + addqueue(sa->win, REDRAW, 1); + } + else if(val==B_NAME_THEME) { + bTheme *btheme= U.themes.first; + if(strcmp(btheme->name, "Default")==0) { + strcpy(btheme->name, "New User Theme"); + addqueue(sa->win, REDRAW, 1); + } + } + else if(val==B_UPDATE_THEME) { + allqueue(REDRAWALL, 0); + } + else if(val==B_CHANGE_THEME) { + th_curcol= TH_BACK; // backdrop color is always there... + addqueue(sa->win, REDRAW, 1); + } + else if(val==B_THEME_COPY) { + if(th_curcol_ptr) { + th_curcol_arr[0]= th_curcol_ptr[0]; + th_curcol_arr[1]= th_curcol_ptr[1]; + th_curcol_arr[2]= th_curcol_ptr[2]; + th_curcol_arr[3]= th_curcol_ptr[3]; + } + } + else if(val==B_THEME_PASTE) { + if(th_curcol_ptr) { + th_curcol_ptr[0]= th_curcol_arr[0]; + th_curcol_ptr[1]= th_curcol_arr[1]; + th_curcol_ptr[2]= th_curcol_arr[2]; + th_curcol_ptr[3]= th_curcol_arr[3]; + allqueue(REDRAWALL, 0); + } + } + else do_global_buttons(val); break; } diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index ce2e39d2bbc..2c48d560529 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -481,10 +481,11 @@ void BIF_init(void) initscreen(); /* for (visuele) speed, this first, then setscreen */ initbuttons(); + init_draw_rects(); /* drawobject.c */ init_gl_stuff(); /* drawview.c */ - BIF_read_homefile(); + BIF_InitThemeColors(); /* after read home file! */ readBlog(); strcpy(G.lib, G.sce); @@ -558,8 +559,10 @@ void exit_usiblender(void) mainwindow_close(); } + BLI_freelistN(&U.themes); + if(totblock!=0) { - printf("Error Totblck: %d\n",totblock); + printf("Error Totblock: %d\n",totblock); MEM_printmemlist(); } delete_autosave(); |