Skip to content

Commit 8267db1

Browse files
committed
tig/tig_button(): Add TIG_SELECTED flag
Draw background in GFX_COLOR_PALETTE(2) to indicate button is selected
1 parent 6ab8bc9 commit 8267db1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/lib/tig/tig.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ tig_pressed(tig_ctx_t *tc, const gfx_rect_t *r)
210210
const int x2 = x1 + r->siz.width;
211211
const int y2 = y1 + r->siz.height;
212212

213+
if(tc->tc_tts == TTS_NONE)
214+
return 0;
215+
213216
return
214217
x1 <= tc->tc_touch_pos.x &&
215218
y1 <= tc->tc_touch_pos.y &&
@@ -502,7 +505,12 @@ tig_button(tig_ctx_t *tc, int flags, int width, const char *str)
502505
gdc->filled_rect(gd, &rect, 1);
503506
gdc->set_color(gd, GFX_COLOR_PALETTE(1));
504507
}
508+
} else if(flags & TIG_SELECTED) {
509+
gdc->set_color(gd, GFX_COLOR_PALETTE(2));
510+
gdc->filled_rect(gd, &rect, 1);
511+
gdc->set_color(gd, GFX_COLOR_PALETTE(1));
505512
}
513+
506514
gdc->rect(gd, &rect, 1);
507515

508516
pos.x += rect.siz.width / 2 - size.width / 2;

src/lib/tig/tig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ void tig_scroll_end(tig_ctx_t *tc, tig_scroll_state_t *tss);
7777
TIG_VALIGN_VIEW_CENTERED)
7878

7979
#define TIG_INLINE 0x20
80+
#define TIG_SELECTED 0x40
8081

8182
void tig_text(tig_ctx_t *ctx, int flags, const char *fmt, ...)
8283
__attribute__ ((format(printf, 3, 4)));

0 commit comments

Comments
 (0)