Review done with Matt; so here's a nicer version of the 'mini node'.

- nodes now have in header a triangle to minimize them or restore view
- mininodes have a scale dragger on right hand
This commit is contained in:
Ton Roosendaal
2005-12-28 21:50:06 +00:00
parent 59ef1bca6a
commit 98577f4e02
5 changed files with 127 additions and 53 deletions

View File

@@ -89,8 +89,10 @@ typedef struct bNode {
void *storage; /* custom data, must be struct, for storage in file */
float locx, locy; /* root offset for drawing */
float width;
float width, miniwidth;
short custom1, custom2; /* to be abused for buttons */
int pad3;
rctf totr; /* entire boundbox */
rctf butr; /* optional buttons area */
rctf prvr; /* optional preview area */

View File

@@ -78,7 +78,7 @@ static void snode_drawstring(SpaceNode *snode, char *str, int okwidth)
char drawstr[NODE_MAXSTR];
int width;
if(str[0]==0) return;
if(str[0]==0 || okwidth<4) return;
BLI_strncpy(drawstr, str, NODE_MAXSTR);
width= snode->aspect*BIF_GetStringWidth(snode->curfont, drawstr, 0);
@@ -467,15 +467,14 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
static void node_update(bNode *node)
{
bNodeSocket *nsock;
float dy= node->locy;
if(node->flag & NODE_HIDDEN) {
float rad, drad;
node->totr.xmin= node->locx;
node->totr.xmax= node->locx + 3*HIDDEN_RAD;
node->totr.ymax= node->locy;
node->totr.ymin= node->locy - 2*HIDDEN_RAD;
node->totr.xmax= node->locx + 3*HIDDEN_RAD + node->miniwidth;
node->totr.ymax= node->locy + (HIDDEN_RAD - 0.5f*NODE_DY);
node->totr.ymin= node->totr.ymax - 2*HIDDEN_RAD;
/* output connectors */
rad=drad= M_PI/(1.0f + (float)BLI_countlist(&node->outputs));
@@ -494,6 +493,8 @@ static void node_update(bNode *node)
}
}
else {
float dy= node->locy;
/* header */
dy-= NODE_DY;
@@ -586,9 +587,6 @@ static void node_basis_draw(SpaceNode *snode, bNode *node)
uiSetRoundBox(3);
uiRoundBox(rct->xmin, rct->ymax-NODE_DY, rct->xmax, rct->ymax, BASIS_RAD);
/* open/close entirely? */
// ui_draw_tria_icon(rct->xmin+6.0f, rct->ymax-NODE_DY+5.0f, snode->aspect, 'h');
/* show/hide icons */
iconofs= rct->xmax;
@@ -619,8 +617,11 @@ static void node_basis_draw(SpaceNode *snode, bNode *node)
else
BIF_ThemeColor(TH_TEXT);
ui_rasterpos_safe(rct->xmin+6.0f, rct->ymax-NODE_DY+5.0f, snode->aspect);
snode_drawstring(snode, node->name, (int)(iconofs - rct->xmin-6.0f));
/* open/close entirely? */
ui_draw_tria_icon(rct->xmin+6.0f, rct->ymax-NODE_DY+5.0f, snode->aspect, 'v');
ui_rasterpos_safe(rct->xmin+18.0f, rct->ymax-NODE_DY+5.0f, snode->aspect);
snode_drawstring(snode, node->name, (int)(iconofs - rct->xmin-18.0f));
/* body */
BIF_ThemeColorShade(color_id, 20);
@@ -693,6 +694,7 @@ void node_hidden_draw(SpaceNode *snode, bNode *node)
{
bNodeSocket *sock;
rctf *rct= &node->totr;
float dx, centy= 0.5f*(rct->ymax+rct->ymin);
int color_id= node_get_colorid(node);
/* shadow */
@@ -711,13 +713,37 @@ void node_hidden_draw(SpaceNode *snode, bNode *node)
glDisable(GL_BLEND);
}
/* title */
if(node->flag & SELECT)
BIF_ThemeColor(TH_TEXT_HI);
else
BIF_ThemeColor(TH_TEXT);
/* open/close entirely? */
ui_draw_tria_icon(rct->xmin+9.0f, centy-6.0f, snode->aspect, 'h');
ui_rasterpos_safe(rct->xmin+18.0f, centy-4.0f, snode->aspect);
snode_drawstring(snode, node->name, (int)(rct->xmax - rct->xmin-18.0f -12.0f));
/* scale widget thing */
BIF_ThemeColorShade(color_id, -10);
dx= 10.0f;
fdrawline(rct->xmax-dx, centy-4.0f, rct->xmax-dx, centy+4.0f);
fdrawline(rct->xmax-dx-3.0f*snode->aspect, centy-4.0f, rct->xmax-dx-3.0f*snode->aspect, centy+4.0f);
BIF_ThemeColorShade(color_id, +30);
dx-= snode->aspect;
fdrawline(rct->xmax-dx, centy-4.0f, rct->xmax-dx, centy+4.0f);
fdrawline(rct->xmax-dx-3.0f*snode->aspect, centy-4.0f, rct->xmax-dx-3.0f*snode->aspect, centy+4.0f);
/* icon */
if(node->id) {
glEnable(GL_BLEND);
BIF_icon_set_aspect(node->id->icon_id, snode->aspect);
BIF_icon_draw(rct->xmin+HIDDEN_RAD, -1.0f+rct->ymin+HIDDEN_RAD/2, node->id->icon_id);
glDisable(GL_BLEND);
}
// if(node->id) {
// glEnable(GL_BLEND);
// BIF_icon_set_aspect(node->id->icon_id, snode->aspect);
// BIF_icon_draw(rct->xmin+HIDDEN_RAD, -1.0f+rct->ymin+HIDDEN_RAD/2, node->id->icon_id);
// glDisable(GL_BLEND);
// }
/* sockets */
for(sock= node->inputs.first; sock; sock= sock->next) {

View File

@@ -166,9 +166,6 @@ static void draw_markers_time( void )
{
TimeMarker *marker;
BIF_icon_set_aspect(ICON_MARKER, 1.0f);
BIF_icon_set_aspect(ICON_MARKER_HLT, 1.0f);
/* unselected markers are drawn at the first time */
for(marker= G.scene->markers.first; marker; marker= marker->next) {
if(!(marker->flag & SELECT)) draw_marker(marker);

View File

@@ -365,8 +365,11 @@ static void scale_node(SpaceNode *snode, bNode *node)
short mval[2], mvalo[2];
/* store old */
oldwidth= node->width;
if(node->flag & NODE_HIDDEN)
oldwidth= node->miniwidth;
else
oldwidth= node->width;
getmouseco_areawin(mvalo);
areamouseco_to_ipoco(G.v2d, mvalo, &mxstart, &mystart);
@@ -379,8 +382,14 @@ static void scale_node(SpaceNode *snode, bNode *node)
mvalo[0]= mval[0];
mvalo[1]= mval[1];
node->width= oldwidth + mx-mxstart;
CLAMP(node->width, node->typeinfo->minwidth, node->typeinfo->maxwidth);
if(node->flag & NODE_HIDDEN) {
node->miniwidth= oldwidth + mx-mxstart;
CLAMP(node->miniwidth, 0.0f, 100.0f);
}
else {
node->width= oldwidth + mx-mxstart;
CLAMP(node->width, node->typeinfo->minwidth, node->typeinfo->maxwidth);
}
force_draw(0);
}
@@ -475,6 +484,67 @@ static void node_set_active(SpaceNode *snode, bNode *node)
}
}
static int do_header_node(SpaceNode *snode, bNode *node, float mx, float my)
{
rctf totr= node->totr;
totr.ymin= totr.ymax-20.0f;
totr.xmax= totr.xmin+15.0f;
if(BLI_in_rctf(&totr, mx, my)) {
node->flag |= NODE_HIDDEN;
allqueue(REDRAWNODE, 0);
return 1;
}
totr.xmax= node->totr.xmax;
totr.xmin= totr.xmax-18.0f;
if(node->typeinfo->flag & NODE_PREVIEW) {
if(BLI_in_rctf(&totr, mx, my)) {
node->flag ^= NODE_PREVIEW;
allqueue(REDRAWNODE, 0);
return 1;
}
totr.xmin-=18.0f;
}
if(node->typeinfo->flag & NODE_OPTIONS) {
if(BLI_in_rctf(&totr, mx, my)) {
node->flag ^= NODE_OPTIONS;
allqueue(REDRAWNODE, 0);
return 1;
}
}
totr= node->totr;
totr.xmin= totr.xmax-10.0f;
totr.ymax= totr.ymin+10.0f;
if(BLI_in_rctf(&totr, mx, my)) {
scale_node(snode, node);
return 1;
}
return 0;
}
static int do_header_hidden_node(SpaceNode *snode, bNode *node, float mx, float my)
{
rctf totr= node->totr;
totr.xmax= totr.xmin+15.0f;
if(BLI_in_rctf(&totr, mx, my)) {
node->flag &= ~NODE_HIDDEN;
allqueue(REDRAWNODE, 0);
return 1;
}
totr.xmax= node->totr.xmax;
totr.xmin= node->totr.xmax-15.0f;
if(BLI_in_rctf(&totr, mx, my)) {
scale_node(snode, node);
return 1;
}
return 0;
}
/* return 0: nothing done */
static int node_mouse_select(SpaceNode *snode, unsigned short event)
{
@@ -487,34 +557,13 @@ static int node_mouse_select(SpaceNode *snode, unsigned short event)
/* first check for the headers or scaling widget */
for(node= snode->nodetree->nodes.first; node; node= node->next) {
if((node->flag & NODE_HIDDEN)==0) {
rctf totr= node->totr;
totr.ymin= totr.ymax-20.0f;
totr.xmin= totr.xmax-18.0f;
if(node->typeinfo->flag & NODE_PREVIEW) {
if(BLI_in_rctf(&totr, mx, my)) {
node->flag ^= NODE_PREVIEW;
allqueue(REDRAWNODE, 0);
return 1;
}
totr.xmin-=18.0f;
}
if(node->typeinfo->flag & NODE_OPTIONS) {
if(BLI_in_rctf(&totr, mx, my)) {
node->flag ^= NODE_OPTIONS;
allqueue(REDRAWNODE, 0);
return 1;
}
}
totr= node->totr;
totr.xmin= totr.xmax-10.0f;
totr.ymax= totr.ymin+10.0f;
if(BLI_in_rctf(&totr, mx, my)) {
scale_node(snode, node);
if(node->flag & NODE_HIDDEN) {
if(do_header_hidden_node(snode, node, mx, my))
return 1;
}
else {
if(do_header_node(snode, node, mx, my))
return 1;
}
}
}

View File

@@ -773,8 +773,6 @@ static void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3,
/* triangle 'icon' for panel header */
void ui_draw_tria_icon(float x, float y, float aspect, char dir)
{
BIF_ThemeColor(TH_TEXT_HI);
if(dir=='h') {
ui_draw_anti_tria( x, y+1, x, y+10.0, x+7, y+6.25);
}
@@ -1114,6 +1112,8 @@ void ui_draw_panel(uiBlock *block)
/* draw collapse icon */
BIF_ThemeColor(TH_TEXT_HI);
if(panel->flag & PNL_CLOSEDY)
ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+5, block->aspect, 'h');
else if(panel->flag & PNL_CLOSEDX)