Browse Source

blendish: new function for node backgrounds

pull/1/head
Leonard Ritter 10 years ago
parent
commit
7cda6169d9
2 changed files with 19 additions and 0 deletions
  1. +17
    -0
      blendish.h
  2. +2
    -0
      example.cpp

+ 17
- 0
blendish.h View File

@@ -383,6 +383,9 @@ void bndNodePort(NVGcontext *ctx, float x, float y, BNDwidgetState state,
void bndNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1,
BNDwidgetState state0, BNDwidgetState state1);

// Draw a node background with its upper left origin at (x,y) and size of (w,h)
void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h);

////////////////////////////////////////////////////////////////////////////////
// Estimator Functions
@@ -619,6 +622,8 @@ NVGcolor bndNodeWireColor(const BNDnodeTheme *theme, BNDwidgetState state);
#define BND_NODE_WIRE_OUTLINE_WIDTH 4
// stroke width of wire
#define BND_NODE_WIRE_WIDTH 2
// radius of node box
#define BND_NODE_RADIUS 10

////////////////////////////////////////////////////////////////////////////////

@@ -1088,6 +1093,18 @@ void bndNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1,
nvgStroke(ctx);
}

void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h) {
bndInnerBox(ctx,x,y,w,h+1,
BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,
bnd_theme.nodeTheme.nodeBackdropColor,
bnd_theme.nodeTheme.nodeBackdropColor);
bndOutlineBox(ctx,x,y,w,h+1,
BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,
bndTransparent(nvgRGBf(0,0,0)));
bndDropShadow(ctx,x,y,w,h,BND_NODE_RADIUS,
BND_SHADOW_FEATHER,BND_SHADOW_ALPHA);
}

////////////////////////////////////////////////////////////////////////////////

float bndLabelWidth(NVGcontext *ctx, int iconid, const char *label) {


+ 2
- 0
example.cpp View File

@@ -461,6 +461,8 @@ int row(int parent) {
void draw_noodles(NVGcontext *vg, int x, int y) {
int w = 200;
int s = 70;

bndNodeBackground(vg, x+w, y-50, 150, 200);
for (int i = 0; i < 9; ++i) {
int a = i%3;


Loading…
Cancel
Save