diff options
author | Ton Roosendaal <ton@blender.org> | 2003-10-15 16:26:26 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2003-10-15 16:26:26 +0400 |
commit | 6480956c5854cb8bcd21c76b57f3d9287fe0d430 (patch) | |
tree | 3c7a5f7ec316b800f6ea70d0f848445f4d948639 /source/blender | |
parent | 0c1bad34c76443bcf254fdc8d1f807af097f0902 (diff) |
- expanded internal windowmanager that it allows button panels in any
window (type)
- each SpaceData struct (not the window!) can get 'block handlers'
assigned, basically event codes that invoke drawing button panels.
- this is saved in files, and Panels behave in any window like it does now
in buttonswindow
- it also means that a 'space window' should leave with a matrix set for
buttons level
- try it in view3d header menu, 'view'->'backdrop'. this opens the old
viewbuttons
- it all works non blocking! instant updates of viewbuttons visible in
3d window now.
Not done yet:
- checking and fixing frontbuffer drawing (select a wireframe draws over)
- temporally vertices cannot be selected, is my next project
- closing or hiding Panels...
- styling stuff... i committed for others to review as well.
Have fun. this is certainly a huge improvement over the old viewbuttons!
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 17 | ||||
-rw-r--r-- | source/blender/include/BIF_interface.h | 2 | ||||
-rw-r--r-- | source/blender/include/BIF_mywindow.h | 3 | ||||
-rw-r--r-- | source/blender/include/BIF_space.h | 15 | ||||
-rw-r--r-- | source/blender/include/BSE_drawview.h | 3 | ||||
-rw-r--r-- | source/blender/include/interface.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 55 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_types.h | 5 | ||||
-rw-r--r-- | source/blender/src/butspace.c | 7 | ||||
-rw-r--r-- | source/blender/src/buttons.txt | 204 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 2 | ||||
-rw-r--r-- | source/blender/src/drawipo.c | 1 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 213 | ||||
-rw-r--r-- | source/blender/src/header_info.c | 9 | ||||
-rw-r--r-- | source/blender/src/header_view3d.c | 39 | ||||
-rw-r--r-- | source/blender/src/interface.c | 86 | ||||
-rw-r--r-- | source/blender/src/mywindow.c | 8 | ||||
-rw-r--r-- | source/blender/src/space.c | 43 |
19 files changed, 451 insertions, 266 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 0568d0c837b..8a31016c6d8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3811,6 +3811,23 @@ static void do_versions(Main *main) } } } + } + + if(main->versionfile <= 229) { + bScreen *sc; + + // new variable blockscale, for panels in any area + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->blockscale==0.0) sl->blockscale= 0.7; + } + } + } } /* don't forget to set version number in blender.c! */ diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h index 8f65505443f..1b91d6a6c31 100644 --- a/source/blender/include/BIF_interface.h +++ b/source/blender/include/BIF_interface.h @@ -154,7 +154,7 @@ void uiPanelPush(uiBlock *block); void uiPanelPop(uiBlock *block); extern uiBlock *uiFindOpenPanelBlockName(ListBase *lb, char *name); extern int uiAlignPanelStep(struct ScrArea *sa, float fac); - +extern void uiSetPanelStyle(int); #endif /* BIF_INTERFACE_H */ diff --git a/source/blender/include/BIF_mywindow.h b/source/blender/include/BIF_mywindow.h index c16098f1f17..40896eec8ff 100644 --- a/source/blender/include/BIF_mywindow.h +++ b/source/blender/include/BIF_mywindow.h @@ -85,6 +85,8 @@ void bwin_load_winmatrix(int winid, float mat[][4]); void bwin_get_viewmatrix(int winid, float mat[][4]); void bwin_get_winmatrix(int winid, float mat[][4]); +void bwin_scalematrix(int winid, float x, float y, float z); + void bwin_ortho(int winid, float x1, float x2, float y1, float y2, float n, float f); void bwin_ortho2(int win, float x1, float x2, float y1, float y2); void bwin_frustum(int winid, float x1, float x2, float y1, float y2, float n, float f); @@ -100,6 +102,7 @@ void myswapbuffers(void); void mygetmatrix(float mat[][4]); void mymultmatrix(float [][4]); + void myloadmatrix(float mat[][4]); void mywinset(int wid); void myortho(float x1, float x2, float y1, float y2, float n, float f); diff --git a/source/blender/include/BIF_space.h b/source/blender/include/BIF_space.h index 7ef1e7085f0..aface0285b6 100644 --- a/source/blender/include/BIF_space.h +++ b/source/blender/include/BIF_space.h @@ -46,6 +46,18 @@ struct BWinEvent; #define BUT_HORIZONTAL 1 #define BUT_VERTICAL 2 +/* is hardcoded in DNA_space_types.h */ +#define SPACE_MAXHANDLER 8 + +/* view3d handler codes */ +#define VIEW3D_HANDLER_SETTINGS 1 +#define VIEW3D_HANDLER_OBJECT 2 +#define VIEW3D_HANDLER_VERTEX 3 + +/* ipo handler codes */ +#define IPO_HANDLER_SETTINGS 20 + + void scrarea_do_windraw (struct ScrArea *sa); void scrarea_do_winchange (struct ScrArea *sa); @@ -54,6 +66,9 @@ void scrarea_do_headdraw (struct ScrArea *sa); void scrarea_do_headchange (struct ScrArea *sa); /* space.c */ +extern void add_blockhandler(struct ScrArea *sa, short eventcode); +extern void rem_blockhandler(struct ScrArea *sa, short eventcode); + extern void space_set_commmandline_options(void); extern void allqueue(unsigned short event, short val); extern void allspace(unsigned short event, short val); diff --git a/source/blender/include/BSE_drawview.h b/source/blender/include/BSE_drawview.h index 299c697a30f..c98f75e9a43 100644 --- a/source/blender/include/BSE_drawview.h +++ b/source/blender/include/BSE_drawview.h @@ -45,8 +45,11 @@ void two_sided(int val); void circf(float x, float y, float rad); void circ(float x, float y, float rad); void backdrawview3d(int test); + +void do_viewbuts(unsigned short event); void drawview3dspace(struct ScrArea *sa, void *spacedata); void drawview3d_render(struct View3D *v3d); + int update_time(void); void calc_viewborder(struct View3D *v3d, struct rcti *viewborder_r); void view3d_set_1_to_1_viewborder(struct View3D *v3d); diff --git a/source/blender/include/interface.h b/source/blender/include/interface.h index 18572049007..7a81a047bfa 100644 --- a/source/blender/include/interface.h +++ b/source/blender/include/interface.h @@ -137,5 +137,8 @@ #define UI_BLOCK_COLLUMNS 1 #define UI_BLOCK_ROWS 2 +#define UI_PNL_TRANSP 0 +#define UI_PNL_SOLID 1 + #endif diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 85aebbcd5b9..5618b8e40d4 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -85,7 +85,7 @@ typedef struct Panel { /* the part from uiBlock that needs saved in file */ char panelname[64], tabname[64]; /* defined as UI_MAX_NAME_STR */ short ofsx, ofsy, sizex, sizey; short flag, active; /* active= used currently by a uiBlock */ - int pad2; + short style, pad2; struct Panel *paneltab; /* this panel is tabbed in *paneltab */ } Panel; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 8674eb3fb4c..5ec7892add8 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -55,21 +55,29 @@ struct BlendHandle; typedef struct SpaceLink SpaceLink; struct SpaceLink { SpaceLink *next, *prev; - int spacetype, pad; + int spacetype; + float blockscale; struct ScrArea *area; + short blockhandler[8]; }; typedef struct SpaceInfo { SpaceLink *next, *prev; - int spacetype, pad1; + int spacetype; + float blockscale; struct ScrArea *area; + + short blockhandler[8]; } SpaceInfo; typedef struct SpaceIpo { SpaceLink *next, *prev; - int spacetype, pad1; + int spacetype; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + unsigned int rowbut, pad2; View2D v2d; @@ -90,9 +98,11 @@ typedef struct SpaceIpo { typedef struct SpaceButs { SpaceLink *next, *prev; int spacetype; - short re_align, pad1; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + short cursens, curact; short align, tabo; /* align for panels, tab is old tab */ View2D v2d; @@ -110,6 +120,8 @@ typedef struct SpaceButs { short scriptblock; short scaflag; + short re_align, pad1; + int pad2; char texact, tab[7]; /* storing tabs for each context */ @@ -117,9 +129,12 @@ typedef struct SpaceButs { typedef struct SpaceSeq { SpaceLink *next, *prev; - int spacetype, pad; + int spacetype; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + View2D v2d; short mainb, zoom; @@ -129,9 +144,12 @@ typedef struct SpaceSeq { typedef struct SpaceFile { SpaceLink *next, *prev; - int spacetype, pad; + int spacetype; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + struct direntry *filelist; int totfile; char title[24]; @@ -163,9 +181,12 @@ typedef struct SpaceFile { typedef struct SpaceOops { SpaceLink *next, *prev; - int spacetype, pad; + int spacetype; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + View2D v2d; ListBase oops; @@ -176,9 +197,12 @@ typedef struct SpaceOops { typedef struct SpaceImage { SpaceLink *next, *prev; - int spacetype, pad; + int spacetype; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + View2D v2d; struct Image *image; @@ -194,17 +218,25 @@ typedef struct SpaceImage { typedef struct SpaceNla{ struct SpaceLink *next, *prev; int spacetype; - short menunr, lock; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + + short menunr, lock; + int pad; + View2D v2d; } SpaceNla; typedef struct SpaceText { SpaceLink *next, *prev; - int spacetype, pad; + int spacetype; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + struct Text *text; int top, viewlines; @@ -259,7 +291,8 @@ typedef struct ImaDir { typedef struct SpaceImaSel { SpaceLink *next, *prev; - int spacetype, pad1; + int spacetype; + float blockscale; struct ScrArea *area; char title[28]; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 8f1956a36b8..cf19e79f3a3 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -61,9 +61,12 @@ typedef struct BGpic { typedef struct View3D { struct SpaceLink *next, *prev; - int spacetype, pad; + int spacetype; + float blockscale; struct ScrArea *area; + short blockhandler[8]; + float viewmat[4][4]; float viewinv[4][4]; float persmat[4][4]; diff --git a/source/blender/src/butspace.c b/source/blender/src/butspace.c index 11e3783780a..b17156057e2 100644 --- a/source/blender/src/butspace.c +++ b/source/blender/src/butspace.c @@ -59,6 +59,8 @@ #include "BLI_blenlib.h" +#include "BSE_drawview.h" // for do_viewbuttons.c .... hurms + #include "BIF_gl.h" #include "BIF_graphics.h" #include "BIF_keyval.h" @@ -251,7 +253,7 @@ void do_butspace(unsigned short event) do_headerbuttons(event); } else if(event<=B_VIEWBUTS) { - //do_viewbuts(event); + do_viewbuts(event); } else if(event<=B_LAMPBUTS) { do_lampbuts(event); @@ -310,7 +312,8 @@ void do_butspace(unsigned short event) else if(event<=B_CONSTRAINTBUTS) { do_constraintbuts(event); } - else if(event>=REDRAWVIEW3D) allqueue(event, 0); + else if(event==REDRAWVIEW3D) allqueue(event, 1); // 1=do header too + else if(event>REDRAWVIEW3D) allqueue(event, 0); } /* new active object */ diff --git a/source/blender/src/buttons.txt b/source/blender/src/buttons.txt index 10a430142c4..36d00fd6295 100644 --- a/source/blender/src/buttons.txt +++ b/source/blender/src/buttons.txt @@ -231,210 +231,6 @@ static int packdummy = 0; /* **************************** VIEW ************************ */ -static void view3d_change_bgpic_ima(View3D *v3d, Image *newima) { - if (v3d->bgpic && v3d->bgpic->ima!=newima) { - if (newima) - id_us_plus((ID*) newima); - if (v3d->bgpic->ima) - v3d->bgpic->ima->id.us--; - v3d->bgpic->ima= newima; - - if(v3d->bgpic->rect) MEM_freeN(v3d->bgpic->rect); - v3d->bgpic->rect= NULL; - - allqueue(REDRAWBUTSVIEW, 0); - } -} -static void view3d_change_bgpic_tex(View3D *v3d, Tex *newtex) { - if (v3d->bgpic && v3d->bgpic->tex!=newtex) { - if (newtex) - id_us_plus((ID*) newtex); - if (v3d->bgpic->tex) - v3d->bgpic->tex->id.us--; - v3d->bgpic->tex= newtex; - - allqueue(REDRAWBUTSVIEW, 0); - } -} - -static void load_bgpic_image(char *name) -{ - Image *ima; - View3D *vd; - - vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); - if(vd==0 || vd->bgpic==0) return; - - ima= add_image(name); - if(ima) { - if(vd->bgpic->ima) { - vd->bgpic->ima->id.us--; - } - vd->bgpic->ima= ima; - - free_image_buffers(ima); /* force read again */ - ima->ok= 1; - } - allqueue(REDRAWBUTSVIEW, 0); - -} - -void do_viewbuts(unsigned short event) -{ - View3D *vd; - char *name; - - vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); - if(vd==0) return; - - switch(event) { - case B_LOADBGPIC: - if(vd->bgpic && vd->bgpic->ima) name= vd->bgpic->ima->name; - else name= G.ima; - - activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_bgpic_image); - break; - case B_BLENDBGPIC: - if(vd->bgpic && vd->bgpic->rect) setalpha_bgpic(vd->bgpic); - break; - case B_BGPICBROWSE: - if(vd->bgpic) { - if (G.buts->menunr==-2) { - activate_databrowse((ID*) vd->bgpic->ima, ID_IM, 0, B_BGPICBROWSE, &G.buts->menunr, do_viewbuts); - } else if (G.buts->menunr>0) { - Image *newima= (Image*) BLI_findlink(&G.main->image, G.buts->menunr-1); - - if (newima) - view3d_change_bgpic_ima(vd, newima); - } - } - break; - case B_BGPICCLEAR: - if (vd->bgpic) - view3d_change_bgpic_ima(vd, NULL); - break; - case B_BGPICTEX: - if (vd->bgpic) { - if (G.buts->texnr==-2) { - activate_databrowse((ID*) vd->bgpic->tex, ID_TE, 0, B_BGPICTEX, &G.buts->texnr, do_viewbuts); - } else if (G.buts->texnr>0) { - Tex *newtex= (Tex*) BLI_findlink(&G.main->tex, G.buts->texnr-1); - - if (newtex) - view3d_change_bgpic_tex(vd, newtex); - } - } - break; - case B_BGPICTEXCLEAR: - if (vd->bgpic) - view3d_change_bgpic_tex(vd, NULL); - break; - } -} - -void viewbuts(void) -{ - View3D *vd; - ID *id; - uiBlock *block; - char *strp, str[64]; - - /* searching for spacedata */ - vd= scrarea_find_space_of_type(curarea, SPACE_VIEW3D); - if(vd==0) return; - - sprintf(str, "buttonswin %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - - if(vd->flag & V3D_DISPBGPIC) { - if(vd->bgpic==0) { - vd->bgpic= MEM_callocN(sizeof(BGpic), "bgpic"); - vd->bgpic->size= 5.0; - vd->bgpic->blend= 0.5; - } - } - - uiDefButS(block, TOG|BIT|1, REDRAWBUTSVIEW, "BackGroundPic", 347,160,127,29 , - &vd->flag, 0, 0, 0, 0, "Display a picture in the 3D background"); - if(vd->bgpic) { - uiDefButF(block, NUM, B_DIFF, "Size:", - 478,160,82,29, &vd->bgpic->size, 0.1, - 250.0, 100, 0, "Set the size for the width of the BackGroundPic"); - - id= (ID *)vd->bgpic->ima; - IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr)); - if(strp[0]) - uiDefButS(block, MENU, B_BGPICBROWSE, strp, 347,112,20,19, &(G.buts->menunr), 0, 0, 0, 0, "Browse"); - MEM_freeN(strp); - - uiDefBut(block, BUT, B_LOADBGPIC, "LOAD", 370,112,189,19, 0, 0, 0, 0, 0, "Specify the BackGroundPic"); - uiDefButF(block, NUMSLI, B_BLENDBGPIC, "Blend:", 347,84,213,19,&vd->bgpic->blend, 0.0,1.0, 0, 0, "Set the BackGroundPic transparency"); - - if(vd->bgpic->ima) { - uiDefBut(block, TEX, 0,"BGpic: ", 347,136,211,19,&vd->bgpic->ima->name,0.0,100.0, 0, 0, "The Selected BackGroundPic"); - uiDefIconBut(block, BUT, B_BGPICCLEAR, ICON_X, 347+211,112,20,19, 0, 0, 0, 0, 0, "Remove background image link"); - } - - /* There is a bug here ... (what bug? where? what is this? - zr) */ - /* texture block: */ - id= (ID *)vd->bgpic->tex; - IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->tex), id, &(G.buts->texnr)); - if (strp[0]) - uiDefButS(block, MENU, B_BGPICTEX, strp, 347, 20, 20,19, &(G.buts->texnr), 0, 0, 0, 0, "Browse"); - MEM_freeN(strp); - - uiDefBut(block, LABEL, 0, "Select texture for animated backgroundimage", 370, 20, 300,19, 0, 0, 0, 0, 0, ""); - - if (id) { - uiDefBut(block, TEX, B_IDNAME, "TE:", 347,0,211,19, id->name+2, 0.0, 18.0, 0, 0, ""); - uiDefIconBut(block, BUT, B_BGPICTEXCLEAR, ICON_X, 347+211,0,20,19, 0, 0, 0, 0, 0, "Remove background texture link"); - } - } - - uiDefButF(block, NUM, B_DIFF, "Grid:", 347, 60, 105, 19, &vd->grid, 0.001, 1000.0, 100, 0, "Set the distance between gridlines"); - uiDefButS(block, NUM, B_DIFF, "GridLines:", 452, 60, 105, 19, &vd->gridlines, 0.0, 100.0, 100, 0, "Set the number of gridlines"); - uiDefButF(block, NUM, B_DIFF, "Lens:", 557, 60, 105, 19, &vd->lens, 10.0, 120.0, 100, 0, "Set the lens for the perspective view"); - - uiDefButF(block, NUM, B_DIFF, "ClipStart:", 347, 40, 105, 19, &vd->near, 0.1*vd->grid, 100.0, 100, 0, "Set startvalue in perspective view mode"); - uiDefButF(block, NUM, B_DIFF, "ClipEnd:", 452, 40, 105, 19, &vd->far, 1.0, 1000.0*vd->grid, 100, 0, "Set endvalue in perspective view mode"); - - /* for(b=0; b<8; b++) { */ - /* for(a=0; a<8; a++) { */ - /* uiDefButC(block, TOG|BIT|(7-a), 0, "", 100+12*a, 100-12*b, 12, 12, &(arr[b]),0,0,0,0); ,""*/ - /* } */ - /* } */ - /* DefBut(BUT, 1001, "print", 50,100,50,20, 0, 0, 0, 0,0); */ - - uiDrawBlock(block); -} - -void output_pic(char *name) -{ - strcpy(G.scene->r.pic, name); - allqueue(REDRAWBUTSRENDER, 0); -} - -void backbuf_pic(char *name) -{ - Image *ima; - - strcpy(G.scene->r.backbuf, name); - allqueue(REDRAWBUTSRENDER, 0); - - ima= add_image(name); - if(ima) { - free_image_buffers(ima); /* force read again */ - ima->ok= 1; - } -} - -void ftype_pic(char *name) -{ - strcpy(G.scene->r.ftype, name); - allqueue(REDRAWBUTSRENDER, 0); -} - - /* **************************** VIEW ************************ */ diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index 046eaf7c7d6..7db7ba4a8ec 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -1058,7 +1058,7 @@ static void texture_panel_colors(Tex *tex) static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *la) { extern char texstr[15][8]; // butspace.c - MTex *mt; + MTex *mt=NULL; uiBlock *block; ID *id, *idfrom; int a, yco, loos; diff --git a/source/blender/src/drawipo.c b/source/blender/src/drawipo.c index 452a91ed768..77f07e8eb5c 100644 --- a/source/blender/src/drawipo.c +++ b/source/blender/src/drawipo.c @@ -507,7 +507,6 @@ void test_view2d(View2D *v2d, int winx, int winy) } } } - } diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index bb7ead592d6..0af25fd2908 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -66,6 +66,7 @@ #include "DNA_texture_types.h" #include "DNA_view3d_types.h" #include "DNA_userdef_types.h" +#include "DNA_space_types.h" #include "BKE_action.h" #include "BKE_anim.h" @@ -73,6 +74,7 @@ #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_ika.h" +#include "BKE_library.h" #include "BKE_image.h" #include "BKE_ipo.h" #include "BKE_key.h" @@ -98,7 +100,7 @@ #include "BSE_drawview.h" #include "BSE_headerbuttons.h" #include "BSE_seqaudio.h" - +#include "BSE_filesel.h" #include "RE_renderconverter.h" @@ -107,6 +109,7 @@ #include "interface.h" #include "blendef.h" #include "mydevice.h" +#include "butspace.h" // event codes /* Modules used */ #include "render.h" @@ -810,6 +813,208 @@ static void draw_view_icon(void) glDisable(GL_BLEND); } +/* ******************* view3d space & buttons ************** */ + +static void view3d_change_bgpic_ima(View3D *v3d, Image *newima) { + if (v3d->bgpic && v3d->bgpic->ima!=newima) { + if (newima) + id_us_plus((ID*) newima); + if (v3d->bgpic->ima) + v3d->bgpic->ima->id.us--; + v3d->bgpic->ima= newima; + + if(v3d->bgpic->rect) MEM_freeN(v3d->bgpic->rect); + v3d->bgpic->rect= NULL; + + allqueue(REDRAWVIEW3D, 0); + } +} +static void view3d_change_bgpic_tex(View3D *v3d, Tex *newtex) { + if (v3d->bgpic && v3d->bgpic->tex!=newtex) { + if (newtex) + id_us_plus((ID*) newtex); + if (v3d->bgpic->tex) + v3d->bgpic->tex->id.us--; + v3d->bgpic->tex= newtex; + + allqueue(REDRAWVIEW3D, 0); + } +} + +static void load_bgpic_image(char *name) +{ + Image *ima; + View3D *vd; + + vd= G.vd; + if(vd==0 || vd->bgpic==0) return; + + ima= add_image(name); + if(ima) { + if(vd->bgpic->ima) { + vd->bgpic->ima->id.us--; + } + vd->bgpic->ima= ima; + + free_image_buffers(ima); /* force read again */ + ima->ok= 1; + } + allqueue(REDRAWVIEW3D, 0); + +} + +void do_viewbuts(unsigned short event) +{ + View3D *vd; + char *name; + + vd= G.vd; + if(vd==0) return; + + switch(event) { + case B_LOADBGPIC: + if(vd->bgpic && vd->bgpic->ima) name= vd->bgpic->ima->name; + else name= G.ima; + + activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_bgpic_image); + break; + case B_BLENDBGPIC: + if(vd->bgpic && vd->bgpic->rect) setalpha_bgpic(vd->bgpic); + break; + case B_BGPICBROWSE: + if(vd->bgpic) { + if (G.buts->menunr==-2) { + activate_databrowse((ID*) vd->bgpic->ima, ID_IM, 0, B_BGPICBROWSE, &G.buts->menunr, do_viewbuts); + } else if (G.buts->menunr>0) { + Image *newima= (Image*) BLI_findlink(&G.main->image, G.buts->menunr-1); + + if (newima) + view3d_change_bgpic_ima(vd, newima); + } + } + break; + case B_BGPICCLEAR: + if (vd->bgpic) + view3d_change_bgpic_ima(vd, NULL); + break; + case B_BGPICTEX: + if (vd->bgpic) { + if (G.buts->texnr==-2) { + activate_databrowse((ID*) vd->bgpic->tex, ID_TE, 0, B_BGPICTEX, &G.buts->texnr, do_viewbuts); + } else if (G.buts->texnr>0) { + Tex *newtex= (Tex*) BLI_findlink(&G.main->tex, G.buts->texnr-1); + + if (newtex) + view3d_change_bgpic_tex(vd, newtex); + } + } + break; + case B_BGPICTEXCLEAR: + if (vd->bgpic) + view3d_change_bgpic_tex(vd, NULL); + break; + } +} + + +static void view3d_panel_settings(void) // VIEW3D_HANDLER_SETTINGS +{ + uiBlock *block; + View3D *vd; + ID *id; + char *strp; + + vd= G.vd; + + block= uiNewBlock(&curarea->uiblocks, "view3d_panel_settings", UI_EMBOSSX, UI_HELV, curarea->win); + uiSetPanelStyle(UI_PNL_SOLID); + if(uiNewPanel(curarea, block, "Backdrop and settings", "View3d", 10, 10, 318, 204)==0) return; + uiSetPanelStyle(UI_PNL_TRANSP); + + if(vd->flag & V3D_DISPBGPIC) { + if(vd->bgpic==0) { + vd->bgpic= MEM_callocN(sizeof(BGpic), "bgpic"); + vd->bgpic->size= 5.0; + vd->bgpic->blend= 0.5; + } + } + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, TOG|BIT|1, REDRAWVIEW3D, "BackGroundPic", 10,160,150,20 , &vd->flag, 0, 0, 0, 0, "Display a picture in the 3D background"); + uiBlockSetCol(block, BUTGREY); + + if(vd->bgpic) { + + uiDefButF(block, NUM, B_DIFF, "Size:", 160,160,150,20, &vd->bgpic->size, 0.1, 250.0, 100, 0, "Set the size for the width of the BackGroundPic"); + + id= (ID *)vd->bgpic->ima; + IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr)); + if(strp[0]) + uiDefButS(block, MENU, B_BGPICBROWSE, strp, 10,140,20,19, &(G.buts->menunr), 0, 0, 0, 0, "Browse"); + MEM_freeN(strp); + + if(vd->bgpic->ima) { + uiDefBut(block, TEX, 0,"BGpic: ", 30,140,260,19,&vd->bgpic->ima->name,0.0,100.0, 0, 0, "The Selected BackGroundPic"); + uiDefIconBut(block, BUT, B_BGPICCLEAR, ICON_X, 290,140,20,19, 0, 0, 0, 0, 0, "Remove background image link"); + } + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_LOADBGPIC, "LOAD", 10,120,100,19, 0, 0, 0, 0, 0, "Specify the BackGroundPic"); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUMSLI, B_BLENDBGPIC, "Blend:", 120,120,190,19,&vd->bgpic->blend, 0.0,1.0, 0, 0, "Set the BackGroundPic transparency"); + + uiDefBut(block, LABEL, 0, "Select texture for animated backgroundimage", + 10,100,300,19, 0, 0, 0, 0, 0, ""); + /* There is a bug here ... (what bug? where? what is this? - zr) */ + /* (ton) the use of G.buts->texnr is hackish */ + /* texture block: */ + id= (ID *)vd->bgpic->tex; + IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->tex), id, &(G.buts->texnr)); + if (strp[0]) + uiDefButS(block, MENU, B_BGPICTEX, strp, 10, 80, 20,19, &(G.buts->texnr), 0, 0, 0, 0, "Browse"); + MEM_freeN(strp); + + if (id) { + uiDefBut(block, TEX, B_IDNAME, "TE:", 30,80,260,19, id->name+2, 0.0, 18.0, 0, 0, ""); + uiDefIconBut(block, BUT, B_BGPICTEXCLEAR, ICON_X, 290,80,20,19, 0, 0, 0, 0, 0, "Remove background texture link"); + } + } + + uiDefButF(block, NUM, B_DIFF, "Grid:", 10, 50, 150, 19, &vd->grid, 0.001, 1000.0, 10, 0, "Set the distance between gridlines"); + uiDefButS(block, NUM, B_DIFF, "GridLines:", 160, 50, 150, 19, &vd->gridlines, 0.0, 100.0, 100, 0, "Set the number of gridlines"); + uiDefButF(block, NUM, B_DIFF, "Lens:", 10, 30, 150, 19, &vd->lens, 10.0, 120.0, 100, 0, "Set the lens for the perspective view"); + + uiDefButF(block, NUM, B_DIFF, "ClipStart:", 10, 10, 150, 19, &vd->near, 0.1*vd->grid, 100.0, 100, 0, "Set startvalue in perspective view mode"); + uiDefButF(block, NUM, B_DIFF, "ClipEnd:", 160, 10, 150, 19, &vd->far, 1.0, 1000.0*vd->grid, 100, 0, "Set endvalue in perspective view mode"); + + +} + + + +static void view3d_blockhandlers(ScrArea *sa) +{ + View3D *v3d= sa->spacedata.first; + short a; + + for(a=0; a<SPACE_MAXHANDLER; a++) { + + switch(v3d->blockhandler[a]) { + + case VIEW3D_HANDLER_SETTINGS: + view3d_panel_settings(); // 3d header + break; + case VIEW3D_HANDLER_OBJECT: + + break; + case VIEW3D_HANDLER_VERTEX: + + break; + + } + } + uiDrawBlocksPanels(sa, 0); + +} + void drawview3dspace(ScrArea *sa, void *spacedata) { Base *base; @@ -1006,7 +1211,10 @@ void drawview3dspace(ScrArea *sa, void *spacedata) draw_area_emboss(sa); - persp(1); + /* it is important to end a view in a transform compatible with buttons */ + + bwin_scalematrix(sa->win, G.vd->blockscale, G.vd->blockscale, G.vd->blockscale); + view3d_blockhandlers(sa); curarea->win_swap= WIN_BACK_OK; @@ -1014,6 +1222,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) G.vd->flag |= V3D_NEEDBACKBUFDRAW; addafterqueue(curarea->win, BACKBUFDRAW, 1); } + } diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 4c472831b7f..f87db3649e9 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -34,7 +34,8 @@ * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ - + +#include <math.h> #include <stdlib.h> #include <string.h> @@ -65,6 +66,7 @@ #include "BDR_editcurve.h" #include "BDR_editmball.h" #include "BDR_editobject.h" + #include "BIF_editarmature.h" #include "BIF_editfont.h" #include "BIF_editmesh.h" @@ -80,6 +82,8 @@ #include "BIF_toets.h" #include "BIF_toolbox.h" #include "BIF_usiblender.h" +#include "BIF_drawscene.h" + #include "BKE_blender.h" #include "BKE_exotic.h" #include "BKE_global.h" @@ -89,10 +93,13 @@ #include "BKE_packedFile.h" #include "BKE_scene.h" #include "BKE_world.h" + #include "BLI_arithb.h" #include "BLI_blenlib.h" #include "BLO_writefile.h" + #include "BPY_extern.h" + #include "BSE_editipo.h" #include "BSE_filesel.h" #include "BSE_headerbuttons.h" diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index f486c90447b..15b70da650c 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -52,6 +52,8 @@ #include "FTF_Api.h" #endif +#include "MEM_guardedalloc.h" + #include "DNA_ID.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" @@ -59,12 +61,31 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "DNA_image_types.h" +#include "DNA_texture_types.h" + +#include "BKE_library.h" +#include "BKE_curve.h" +#include "BKE_displist.h" +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_mesh.h" +#include "BKE_image.h" + +#include "BLI_blenlib.h" + +#include "BSE_edit.h" +#include "BSE_editipo.h" +#include "BSE_headerbuttons.h" +#include "BSE_view.h" + #include "BDR_editcurve.h" #include "BDR_editface.h" #include "BDR_editmball.h" #include "BDR_editobject.h" #include "BDR_vpaint.h" + #include "BIF_editlattice.h" #include "BIF_editarmature.h" #include "BIF_editfont.h" @@ -79,19 +100,12 @@ #include "BIF_space.h" #include "BIF_toets.h" #include "BIF_toolbox.h" -#include "BKE_curve.h" -#include "BKE_displist.h" -#include "BKE_global.h" -#include "BKE_main.h" -#include "BKE_mesh.h" -#include "BSE_edit.h" -#include "BSE_editipo.h" -#include "BSE_headerbuttons.h" -#include "BSE_view.h" +#include "BIF_gl.h" #include "blendef.h" #include "interface.h" #include "mydevice.h" +#include "butspace.h" #include "BIF_poseobject.h" @@ -209,6 +223,7 @@ static uiBlock *view3d_view_cameracontrolsmenu(void *arg_unused) return block; } + static void do_view3d_viewmenu(void *arg, int event) { extern int play_anim(int mode); @@ -265,6 +280,9 @@ static void do_view3d_viewmenu(void *arg, int event) case 13: /* Play Back Animation */ play_anim(0); break; + case 14: /* Backdrop and settings Panel */ + add_blockhandler(curarea, VIEW3D_HANDLER_SETTINGS); + break; } allqueue(REDRAWVIEW3D, 0); } @@ -279,6 +297,9 @@ static uiBlock *view3d_viewmenu(void *arg_unused) uiBlockSetButmFunc(block, do_view3d_viewmenu, NULL); uiBlockSetCol(block, MENUCOL); + uiDefIconTextBut(block, BUTM, 1, ICON_BUTS, "Backdrop and Settings Panel", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, ""); + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + if ((G.vd->viewbut == 0) && !(G.vd->persp == 2)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "User", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "User", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); if (G.vd->persp == 2) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Camera|NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index 4840fe78c65..21e29ea1831 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -4598,7 +4598,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) else if(block->panel->paneltab==NULL) { if( block->miny <= uevent->mval[1] && block->maxy >= uevent->mval[1] ) inside= 1; - + /* clicked at panel header? */ if(uevent->event==LEFTMOUSE) { if( block->panel->flag & PNL_CLOSEDX) { @@ -4614,6 +4614,14 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) return UI_EXIT_LOOP; // exit loops because of moving panels } } + else if(uevent->event==PADPLUSKEY || uevent->event==PADMINUS) { + SpaceLink *sl= curarea->spacedata.first; + + if(uevent->event==PADPLUSKEY) sl->blockscale+= 0.1; + else sl->blockscale-= 0.1; + CLAMP(sl->blockscale, 0.6, 1.0); + addqueue(block->winq, REDRAW, 1); + } } } @@ -4778,6 +4786,7 @@ 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); @@ -6148,6 +6157,15 @@ void uiNewPanelTabbed(char *panelname, char *groupname) group_tabbed= groupname; } +/* another global... */ +static int pnl_style= UI_PNL_TRANSP; + +void uiSetPanelStyle(int style) +{ + pnl_style= style; +} + + /* ofsx/ofsy only used for new panel definitions */ /* return 1 if visible (create buttons!) */ int uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int ofsx, int ofsy, int sizex, int sizey) @@ -6177,6 +6195,7 @@ int uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int pa->ofsy= ofsy & ~(PNL_GRID-1); pa->sizex= sizex; pa->sizey= sizey; + pa->style= pnl_style; /* pre align, for good sorting later on */ if(sa->spacetype==SPACE_BUTS && pa->prev) { @@ -6561,24 +6580,31 @@ static void ui_draw_panel(uiBlock *block) else { uiSetRoundBox(3); - //glColor3ub(160, 160, 167); - //uiRoundBox(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 10); - glColor3ub(218, 218, 218); - uiRoundRect(block->minx, block->miny, block->maxx, block->maxy+PNL_HEADER, 10); - - glColor3ub(198, 198, 198); - //glRectf(block->minx, block->miny, block->maxx, block->maxy); - - if(G.buts->align) { - glColor3ub(206, 206, 206); - if(G.buts->align==BUT_HORIZONTAL) ui_set_panel_pattern('h'); - else ui_set_panel_pattern('v'); - - //glRectf(block->minx, block->miny, block->maxx, block->maxy); - glDisable(GL_POLYGON_STIPPLE); + if(block->panel->style== UI_PNL_SOLID) { + glColor3ub(160, 160, 167); + uiRoundBox(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 10); + // blend now for panels in 3d window, test... + glEnable(GL_BLEND); + glColor4ub(198, 198, 198, 100); + glRectf(block->minx, block->miny, block->maxx, block->maxy); + + if(G.buts->align) { + glColor4ub(206, 206, 206, 100); + if(G.buts->align==BUT_HORIZONTAL) ui_set_panel_pattern('h'); + else ui_set_panel_pattern('v'); + + glRectf(block->minx, block->miny, block->maxx, block->maxy); + glDisable(GL_POLYGON_STIPPLE); + } + glDisable(GL_BLEND); + } + else { + glColor3ub(218, 218, 218); + uiRoundRect(block->minx, block->miny, block->maxx, block->maxy+PNL_HEADER, 10); } + ui_draw_panel_header(block); // border @@ -6684,7 +6710,6 @@ int uiAlignPanelStep(ScrArea *sa, float fac) int a, tot=0, done; if(sa->spacetype!=SPACE_BUTS) { - printf("align not supported yet here\n"); return 0; } @@ -6955,13 +6980,12 @@ static void test_add_new_tabs(ScrArea *sa) static void ui_drag_panel(uiBlock *block) { - SpaceButs *sbuts= curarea->spacedata.first; Panel *panel= block->panel; - short first=1, ofsx, ofsy, dx=0, dy=0, dxo=0, dyo=0, mval[2], mvalo[2]; + short align=0, first=1, ofsx, ofsy, dx=0, dy=0, dxo=0, dyo=0, mval[2], mvalo[2]; - if(curarea->spacetype!=SPACE_BUTS) { - printf("align not supported yet here\n"); - return; + if(curarea->spacetype==SPACE_BUTS) { + SpaceButs *sbuts= curarea->spacedata.first; + align= sbuts->align; } uiGetMouse(block->win, mvalo); @@ -6982,7 +7006,7 @@ static void ui_drag_panel(uiBlock *block) dy= (mval[1]-mvalo[1]) & ~(PNL_GRID-1); } - if(dx!=dxo || dy!=dyo || first || sbuts->align) { + if(dx!=dxo || dy!=dyo || first || align) { dxo= dx; dyo= dy; first= 0; @@ -6991,7 +7015,7 @@ static void ui_drag_panel(uiBlock *block) check_panel_overlap(curarea, panel); - if(sbuts->align) uiAlignPanelStep(curarea, 0.2); + if(align) uiAlignPanelStep(curarea, 0.2); /* warn: this re-allocs blocks! */ scrarea_do_windraw(curarea); @@ -7024,7 +7048,7 @@ static void ui_drag_panel(uiBlock *block) panel->flag &= ~PNL_SELECT; check_panel_overlap(curarea, NULL); // clears - if(sbuts->align==0) addqueue(block->win, REDRAW, 1); + if(align==0) addqueue(block->win, REDRAW, 1); else ui_animate_panels(curarea); } @@ -7137,12 +7161,12 @@ static void panel_clicked_tabs(uiBlock *block, int mousex) /* also it supposes a block has panel, and isnt a menu */ static void ui_do_panel(uiBlock *block, uiEvent *uevent) { - SpaceButs *sbuts= curarea->spacedata.first; Panel *pa; + int align= 0; - if(curarea->spacetype!=SPACE_BUTS) { - printf("align not supported yet here\n"); - return; + if(curarea->spacetype==SPACE_BUTS) { + SpaceButs *sbuts= curarea->spacedata.first; + align= sbuts->align; } /* mouse coordinates in panel space! */ @@ -7158,7 +7182,7 @@ static void ui_do_panel(uiBlock *block, uiEvent *uevent) if(button) { if(block->panel->flag & PNL_CLOSED) block->panel->flag &= ~PNL_CLOSED; - else if(sbuts->align==BUT_HORIZONTAL) block->panel->flag |= PNL_CLOSEDX; + else if(align==BUT_HORIZONTAL) block->panel->flag |= PNL_CLOSEDX; else block->panel->flag |= PNL_CLOSEDY; for(pa= curarea->panels.first; pa; pa= pa->next) { @@ -7167,7 +7191,7 @@ static void ui_do_panel(uiBlock *block, uiEvent *uevent) else pa->flag &= ~PNL_CLOSED; } } - if(sbuts->align==0) addqueue(block->win, REDRAW, 1); + if(align==0) addqueue(block->win, REDRAW, 1); else ui_animate_panels(curarea); } diff --git a/source/blender/src/mywindow.c b/source/blender/src/mywindow.c index 78f3443fa7b..cfee5d27b45 100644 --- a/source/blender/src/mywindow.c +++ b/source/blender/src/mywindow.c @@ -249,6 +249,14 @@ void bwin_multmatrix(int winid, float mat[][4]) glGetFloatv(GL_MODELVIEW_MATRIX, (float *)win->viewmat); } +void bwin_scalematrix(int winid, float x, float y, float z) +{ + bWindow *win= bwin_from_winid(winid); + + glScalef(x, y, z); + glGetFloatv(GL_MODELVIEW_MATRIX, (float *)win->viewmat); +} + void bwin_clear_viewmat(int swin) { bWindow *win; diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 70a8bdbd098..ebf56e2f7de 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -158,6 +158,43 @@ void space_mipmap_button_function(int event); unsigned short convert_for_nonumpad(unsigned short event); void free_soundspace(SpaceSound *ssound); +/* *************************************** */ + +/* don't know yet how the handlers will evolve, for simplicity + i choose for an array with eventcodes, this saves in a file! + */ +void add_blockhandler(ScrArea *sa, short eventcode) +{ + SpaceLink *sl= sa->spacedata.first; + short a; + + // find empty spot + for(a=0; a<SPACE_MAXHANDLER; a++) { + if( sl->blockhandler[a]==eventcode ); + else if( sl->blockhandler[a]==0) { + sl->blockhandler[a]= eventcode; + break; + } + } + if(a==SPACE_MAXHANDLER) printf("error; max blockhandlers reached!\n"); +} + +void rem_blockhandler(ScrArea *sa, short eventcode) +{ + SpaceLink *sl= sa->spacedata.first; + short a; + + for(a=0; a<SPACE_MAXHANDLER; a++) { + if( sl->blockhandler[a]==eventcode) { + sl->blockhandler[a]= 0; + break; + } + } +} + + + + /* ************* SPACE: VIEW3D ************* */ /* extern void drawview3dspace(ScrArea *sa, void *spacedata); BSE_drawview.h */ @@ -510,12 +547,16 @@ void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) int doredraw= 0, pupval; if(curarea->win==0) return; /* when it comes from sa->headqread() */ - if(event==MOUSEY) return; + if(val) { if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0; + if(event==MOUSEY) return; + + if(event==UI_BUT_EVENT) do_butspace(val); // temporal, view3d deserves own queue? + /* TEXTEDITING?? */ if(G.obedit && G.obedit->type==OB_FONT) { switch(event) { |