aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-02-09 19:34:21 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-02-09 19:34:21 +0100
commit565e3b008076979cc85102929cd528113b384ccb (patch)
treea928bf30db57634339e87617dc9056b0b1b06eca /example
parentc865d2b6896fe66113b2aa50ad44d6a2d29e1954 (diff)
downloadd2tk-565e3b008076979cc85102929cd528113b384ccb.tar.xz
base: prototype flowmatrix arc port lables.
Diffstat (limited to 'example')
-rw-r--r--example/example.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/example/example.c b/example/example.c
index 852b66b..46dfd64 100644
--- a/example/example.c
+++ b/example/example.c
@@ -471,12 +471,32 @@ _render_c_flowmatrix(d2tk_base_t *base, const d2tk_rect_t *rect)
const d2tk_id_t id = D2TK_ID_IDX((i*N + j)*N*N + k);
const unsigned x = d2tk_flowmatrix_arc_get_index_x(arc);
const unsigned y = d2tk_flowmatrix_arc_get_index_y(arc);
- bool *val = &value[i][j][k];
- state = d2tk_base_dial_bool(base, id, bnd, val);
- if(d2tk_state_is_changed(state))
+ if(y == nout) // source label
{
- fprintf(stderr, "Arc %u/%u %s\n", x, y, *val ? "ON" : "OFF");
+ char lbl [16];
+ const ssize_t lbl_len = snprintf(lbl, sizeof(lbl), "Source port %u", x);
+
+ d2tk_base_label(base, lbl_len, lbl, 0.8f, bnd,
+ D2TK_ALIGN_BOTTOM | D2TK_ALIGN_RIGHT);
+ }
+ else if(x == nin) // sink label
+ {
+ char lbl [16];
+ const ssize_t lbl_len = snprintf(lbl, sizeof(lbl), "Sink port %u", y);
+
+ d2tk_base_label(base, lbl_len, lbl, 0.8f, bnd,
+ D2TK_ALIGN_BOTTOM | D2TK_ALIGN_LEFT);
+ }
+ else // connector
+ {
+ bool *val = &value[i][j][k];
+
+ state = d2tk_base_dial_bool(base, id, bnd, val);
+ if(d2tk_state_is_changed(state))
+ {
+ fprintf(stderr, "Arc %u/%u %s\n", x, y, *val ? "ON" : "OFF");
+ }
}
}
}