diff options
author | Ton Roosendaal <ton@blender.org> | 2005-12-28 18:42:51 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-12-28 18:42:51 +0300 |
commit | 9df1460777cceed839721ea99fd9623aedbb26f5 (patch) | |
tree | f4ad7ebfb6294be13c01a3dba67e55354973818e /source/blender/src/interface.c | |
parent | 7837866b1e226925b2a50041e3f0f56ac9e82021 (diff) |
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
Diffstat (limited to 'source/blender/src/interface.c')
-rw-r--r-- | source/blender/src/interface.c | 176 |
1 files changed, 147 insertions, 29 deletions
diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index 26784712b0c..351deab0e4b 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -69,11 +69,13 @@ #include "DNA_userdef_types.h" #include "DNA_vec_types.h" #include "DNA_object_types.h" +#include "DNA_texture_types.h" #include "DNA_vfont_types.h" #include "BKE_blender.h" #include "BKE_global.h" #include "BKE_library.h" +#include "BKE_texture.h" #include "BKE_utildefines.h" #include "BIF_gl.h" @@ -908,6 +910,9 @@ void uiDrawBlock(uiBlock *block) uiBut *but; short testmouse=0, mouse[2]; + /* we set this only once */ + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + /* handle pending stuff */ if(block->autofill) ui_autofill(block); if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0); @@ -2453,7 +2458,7 @@ static int ui_do_but_NUMSLI(uiBut *but) } /* event denotes if we make first item active or not */ -static int ui_do_but_BLOCK(uiBut *but, int event) +static uiBlock *ui_do_but_BLOCK(uiBut *but, int event) { uiBlock *block; uiBut *bt; @@ -2494,7 +2499,7 @@ static int ui_do_but_BLOCK(uiBut *but, int event) but->flag &= ~UI_SELECT; uibut_do_func(but); - return 0; + return block; } static int ui_do_but_BUTM(uiBut *but) @@ -2510,9 +2515,25 @@ static int ui_do_but_BUTM(uiBut *but) static int ui_do_but_LABEL(uiBut *but) { - - uibut_do_func(but); - return but->retval; + /* new label type, for nodes, ctrl+clock on text gives options */ + if(but->block_func) { + if(G.qual & LR_CTRLKEY) { + ListBase listb={NULL, NULL}; + uiBlock *block= ui_do_but_BLOCK(but, 0); + + BLI_addtail(&listb, block); + block->parent= NULL; /* we abused ui_do_but_BLOCK */ + uiDoBlocks(&listb, 0); + + uibut_do_func(but); + return but->retval; + } + return 0; + } + else { + uibut_do_func(but); + return but->retval; + } } static uiBut *ui_get_valid_link_button(uiBlock *block, uiBut *but, short *mval) @@ -3147,6 +3168,104 @@ static int ui_do_but_CHARTAB(uiBut *but) #endif +static int vergcband(const void *a1, const void *a2) +{ + const CBData *x1=a1, *x2=a2; + + if( x1->pos > x2->pos ) return 1; + else if( x1->pos < x2->pos) return -1; + return 0; +} + + +static void do_colorband_evt(ColorBand *coba) +{ + int a; + + if(coba==NULL) return; + + if(coba->tot<2) return; + + for(a=0; a<coba->tot; a++) coba->data[a].cur= a; + qsort(coba->data, coba->tot, sizeof(CBData), vergcband); + for(a=0; a<coba->tot; a++) { + if(coba->data[a].cur==coba->cur) { + if(coba->cur!=a) addqueue(curarea->win, REDRAW, 0); /* button cur */ + coba->cur= a; + break; + } + } +} + + +static int ui_do_but_COLORBAND(uiBut *but) +{ + ColorBand *coba= (ColorBand *)but->poin; + CBData *cbd; + float dx, width= but->x2-but->x1; + int a; + int mindist= 12, xco; + short mval[2], mvalo[2]; + + uiGetMouse(mywinget(), mvalo); + + if(G.qual & LR_CTRLKEY) { + /* insert new key on mouse location */ + if(coba->tot < MAXCOLORBAND-1) { + float pos= ((float)(mvalo[0] - but->x1))/width; + float col[4]; + + do_colorband(coba, pos, col); /* executes it */ + + coba->tot++; + coba->cur= coba->tot-1; + + coba->data[coba->cur].r= col[0]; + coba->data[coba->cur].g= col[1]; + coba->data[coba->cur].b= col[2]; + coba->data[coba->cur].a= col[3]; + coba->data[coba->cur].pos= pos; + + do_colorband_evt(coba); + } + } + else { + + /* first, activate new key when mouse is close */ + for(a=0, cbd= coba->data; a<coba->tot; a++, cbd++) { + xco= but->x1 + (cbd->pos*width); + xco= ABS(xco-mvalo[0]); + if(a==coba->cur) xco+= 5; // selected one disadvantage + if(xco<mindist) { + coba->cur= a; + mindist= xco; + } + } + + cbd= coba->data + coba->cur; + + while(get_mbut() & L_MOUSE) { + uiGetMouse(mywinget(), mval); + if(mval[0]!=mvalo[0]) { + dx= mval[0]-mvalo[0]; + dx/= width; + cbd->pos+= dx; + CLAMP(cbd->pos, 0.0, 1.0); + + ui_draw_but(but); + ui_block_flush_back(but->block); + + do_colorband_evt(coba); + cbd= coba->data + coba->cur; /* because qsort */ + + mvalo[0]= mval[0]; + } + BIF_wait_for_statechange(); + } + } + + return but->retval; +} /* ************************************************ */ @@ -3320,7 +3439,8 @@ static int ui_do_button(uiBlock *block, uiBut *but, uiEvent *uevent) case BLOCK: case PULLDOWN: if(uevent->val) { - retval= ui_do_but_BLOCK(but, uevent->event); + ui_do_but_BLOCK(but, uevent->event); + retval= 0; if(block->auto_open==0) block->auto_open= 1; } break; @@ -3341,6 +3461,9 @@ static int ui_do_button(uiBlock *block, uiBut *but, uiEvent *uevent) case HSVCUBE: retval= ui_do_but_HSVCUBE(but); break; + case BUT_COLORBAND: + retval= ui_do_but_COLORBAND(but); + break; #ifdef INTERNATIONAL case CHARTAB: @@ -4869,36 +4992,31 @@ void ui_check_but(uiBut *but) /* calc but->ofs, to draw the string shorter if too long */ but->ofs= 0; while(but->strwidth > (int)okwidth ) { - but->ofs++; - if(but->drawstr[but->ofs]) + if ELEM(but->type, NUM, TEX) { // only these cut off left + but->ofs++; but->strwidth= but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, transopts); - else but->strwidth= 0; - - /* textbut exception */ - if(but->pos != -1) { - pos= but->pos+strlen(but->str); - if(pos-1 < but->ofs) { - pos= but->ofs-pos+1; - but->ofs -= pos; - if(but->ofs<0) { - but->ofs= 0; - pos--; + + /* textbut exception */ + if(but->pos != -1) { + pos= but->pos+strlen(but->str); + if(pos-1 < but->ofs) { + pos= but->ofs-pos+1; + but->ofs -= pos; + if(but->ofs<0) { + but->ofs= 0; + pos--; + } + but->drawstr[ strlen(but->drawstr)-pos ]= 0; } - but->drawstr[ strlen(but->drawstr)-pos ]= 0; } } - - if(but->strwidth < 10) break; - } - - /* fix for buttons that better not have text cut off to the right */ - if(but->ofs) { - if ELEM(but->type, NUM, TEX); // only these cut off left else { - but->drawstr[ strlen(but->drawstr)-but->ofs ]= 0; - but->ofs= 0; + but->drawstr[ strlen(but->drawstr)-1 ]= 0; + but->strwidth= but->aspect*BIF_GetStringWidth(but->font, but->drawstr, transopts); } + + if(but->strwidth < 10) break; } } } |