diff options
author | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2019-08-06 22:21:49 +0200 |
---|---|---|
committer | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2019-08-06 22:21:49 +0200 |
commit | 36a96ed68d7d3d9d85e1ba15fa4f9037204883d3 (patch) | |
tree | 159ef92512d82f3cda10862a9853a52b06cbabd6 /subprojects | |
parent | ee26d95c039abcd34fd9aeb826208616e9f1ca4d (diff) | |
parent | 4eaed5bcb796a8b775f6381b1c6643b523b38aff (diff) | |
download | tracker.lv2-36a96ed68d7d3d9d85e1ba15fa4f9037204883d3.tar.xz |
Merge commit '4eaed5bcb796a8b775f6381b1c6643b523b38aff'
Diffstat (limited to 'subprojects')
-rw-r--r-- | subprojects/d2tk/VERSION | 2 | ||||
-rw-r--r-- | subprojects/d2tk/example/example.c | 4 | ||||
-rw-r--r-- | subprojects/d2tk/src/base.c | 17 | ||||
-rw-r--r-- | subprojects/d2tk/test/base.c | 108 |
4 files changed, 119 insertions, 12 deletions
diff --git a/subprojects/d2tk/VERSION b/subprojects/d2tk/VERSION index eddad3c..33a73c4 100644 --- a/subprojects/d2tk/VERSION +++ b/subprojects/d2tk/VERSION @@ -1 +1 @@ -0.1.779 +0.1.783 diff --git a/subprojects/d2tk/example/example.c b/subprojects/d2tk/example/example.c index b410d8e..b13a026 100644 --- a/subprojects/d2tk/example/example.c +++ b/subprojects/d2tk/example/example.c @@ -732,7 +732,9 @@ _render_c_frame(d2tk_base_t *base, const d2tk_rect_t *rect) const unsigned k = d2tk_table_get_index(tab); char lbl [32]; - const ssize_t lbl_len = snprintf(lbl, sizeof(lbl), "This is frame #%u", k); + const ssize_t lbl_len = (k % 2) + ? snprintf(lbl, sizeof(lbl), "This is frame #%u", k) + : 0; D2TK_BASE_FRAME(base, bnd_outer, lbl_len, lbl, frm) { diff --git a/subprojects/d2tk/src/base.c b/subprojects/d2tk/src/base.c index 496e459..0a68dd0 100644 --- a/subprojects/d2tk/src/base.c +++ b/subprojects/d2tk/src/base.c @@ -324,6 +324,11 @@ D2TK_API d2tk_table_t * d2tk_table_begin(const d2tk_rect_t *rect, unsigned N, unsigned M, d2tk_flag_t flag, d2tk_table_t *tab) { + if( (N == 0) || (M == 0) ) + { + return NULL; + } + unsigned w; unsigned h; @@ -360,7 +365,7 @@ d2tk_table_begin(const d2tk_rect_t *rect, unsigned N, unsigned M, D2TK_API bool d2tk_table_not_end(d2tk_table_t *tab) { - return tab->k < tab->NM; + return tab && (tab->k < tab->NM); } D2TK_API d2tk_table_t * @@ -432,8 +437,12 @@ d2tk_frame_begin(d2tk_base_t *base, const d2tk_rect_t *rect, const uint64_t hash = d2tk_hash_dict(dict); d2tk_rect_shrink(&frm->rect, rect, 2*style->padding); - frm->rect.y += h; - frm->rect.h -= h; + + if(has_lbl) + { + frm->rect.y += h; + frm->rect.h -= h; + } D2TK_CORE_WIDGET(core, hash, widget) { @@ -443,7 +452,7 @@ d2tk_frame_begin(d2tk_base_t *base, const d2tk_rect_t *rect, const size_t ref = d2tk_core_bbox_push(core, true, rect); - if(lbl) + if(has_lbl) { bnd_inner.h = h; diff --git a/subprojects/d2tk/test/base.c b/subprojects/d2tk/test/base.c index 6145113..ca5c3af 100644 --- a/subprojects/d2tk/test/base.c +++ b/subprojects/d2tk/test/base.c @@ -780,6 +780,39 @@ _test_table_rel() } static void +_test_table_rel_empty() +{ + d2tk_mock_ctx_t ctx = { + .check = NULL + }; + + d2tk_base_t *base = d2tk_base_new(&d2tk_mock_driver_lazy, &ctx); + const d2tk_rect_t rect = D2TK_RECT(0, 0, DIM_W, DIM_H); + assert(base); + + bool visited = false; + + D2TK_BASE_TABLE(&rect, 0, 0, D2TK_FLAG_TABLE_REL, tab) + { + visited = true; + } + + D2TK_BASE_TABLE(&rect, 0, 1, D2TK_FLAG_TABLE_REL, tab) + { + visited = true; + } + + D2TK_BASE_TABLE(&rect, 1, 0, D2TK_FLAG_TABLE_REL, tab) + { + visited = true; + } + + assert(visited == false); + + d2tk_base_free(base); +} + +static void _test_table_abs() { #define N 12 @@ -813,7 +846,42 @@ _test_table_abs() } static void -_test_frame() +_test_table_abs_empty() +{ + d2tk_mock_ctx_t ctx = { + .check = NULL + }; + + d2tk_base_t *base = d2tk_base_new(&d2tk_mock_driver_lazy, &ctx); + const d2tk_rect_t rect = D2TK_RECT(0, 0, DIM_W, DIM_H); + assert(base); + + bool visited = false; + + D2TK_BASE_TABLE(&rect, 0, 0, D2TK_FLAG_TABLE_ABS, tab) + { + visited = true; + } + + D2TK_BASE_TABLE(&rect, 0, 1, D2TK_FLAG_TABLE_ABS, tab) + { + visited = true; + } + + D2TK_BASE_TABLE(&rect, 1, 0, D2TK_FLAG_TABLE_ABS, tab) + { + visited = true; + } + + assert(visited == false); + + d2tk_base_free(base); +#undef M +#undef N +} + +static void +_test_frame_with_label() { d2tk_mock_ctx_t ctx = { .check = NULL @@ -828,10 +896,35 @@ _test_frame() const d2tk_rect_t *bnd = d2tk_frame_get_rect(frm); assert(bnd); - assert(bnd->x > rect.x); - assert(bnd->y > rect.y); - assert(bnd->w < rect.w); - assert(bnd->h < rect.h); + assert(bnd->x > rect.x); //FIXME + assert(bnd->y > rect.y); //FIXME + assert(bnd->w < rect.w); //FIXME + assert(bnd->h < rect.h); //FIXME + } + + d2tk_base_free(base); +} + +static void +_test_frame_wo_label() +{ + d2tk_mock_ctx_t ctx = { + .check = NULL + }; + + d2tk_base_t *base = d2tk_base_new(&d2tk_mock_driver_lazy, &ctx); + const d2tk_rect_t rect = D2TK_RECT(0, 0, DIM_W, DIM_H); + assert(base); + + D2TK_BASE_FRAME(base, &rect, 0, NULL, frm) + { + const d2tk_rect_t *bnd = d2tk_frame_get_rect(frm); + + assert(bnd); + assert(bnd->x > rect.x); //FIXME + assert(bnd->y > rect.y); //FIXME + assert(bnd->w < rect.w); //FIXME + assert(bnd->h < rect.h); //FIXME } d2tk_base_free(base); @@ -1910,8 +2003,11 @@ main(int argc __attribute__((unused)), char **argv __attribute__((unused))) _test_get_set(); _test_state_dump(); _test_table_rel(); + _test_table_rel_empty(); _test_table_abs(); - _test_frame(); + _test_table_abs_empty(); + _test_frame_with_label(); + _test_frame_wo_label(); _test_layout_relative_x(); _test_layout_relative_y(); _test_layout_absolute_x(); |