Skip to content

Commit

Permalink
Add tooltip support for select widget
Browse files Browse the repository at this point in the history
  • Loading branch information
x42 committed Mar 28, 2021
1 parent e297ee1 commit d7709c9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions widgets/robtk_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ typedef struct {
bool (*cb) (RobWidget* w, void* handle);
void* handle;

void (*ttip) (RobWidget* rw, bool on, void* handle);
void* ttip_handle;

void (*touch_cb) (void*, uint32_t, bool);
void* touch_hd;
uint32_t touch_id;
Expand Down Expand Up @@ -165,6 +168,7 @@ static void robtk_select_set_active_item(RobTkSelect *d, int i) {
if (i == d->active_item) return;
d->active_item = i;
if (d->cb) d->cb(d->rw, d->handle);
if (d->ttip) d->ttip (d->rw, false, d->ttip_handle);
queue_draw(d->rw);
}

Expand Down Expand Up @@ -226,6 +230,11 @@ static RobWidget* robtk_select_mousemove(RobWidget* handle, RobTkBtnEvent *ev) {
if (d->wraparound || d->active_item != d->item_count -1) pla = 1;
}
if (pla != d->lightarr) {
if (pla == 0 && d->ttip) {
d->ttip (d->rw, true, d->ttip_handle);
} else {
d->ttip (d->rw, false, d->ttip_handle);
}
d->lightarr = pla;
queue_draw(d->rw);
}
Expand Down Expand Up @@ -272,6 +281,9 @@ static void robtk_select_enter_notify(RobWidget *handle) {
d->prelight = TRUE;
queue_draw(d->rw);
}
if (d->ttip) {
d->ttip (d->rw, true, d->ttip_handle);
}
}

static void robtk_select_leave_notify(RobWidget *handle) {
Expand All @@ -284,6 +296,9 @@ static void robtk_select_leave_notify(RobWidget *handle) {
d->prelight = FALSE;
queue_draw(d->rw);
}
if (d->ttip) {
d->ttip (d->rw, false, d->ttip_handle);
}
}


Expand Down Expand Up @@ -322,6 +337,8 @@ static RobTkSelect * robtk_select_new() {
d->lightarr = 0;
d->cb = NULL;
d->handle = NULL;
d->ttip = NULL;
d->ttip_handle = NULL;
d->touch_cb = NULL;
d->touch_hd = NULL;
d->touch_id = 0;
Expand Down Expand Up @@ -389,6 +406,12 @@ static void robtk_select_set_callback(RobTkSelect *d, bool (*cb) (RobWidget* w,
d->handle = handle;
}

static void robtk_select_annotation_callback(RobTkSelect *d, void (*cb) (RobWidget* w, bool, void* handle), void* handle) {
d->ttip = cb;
d->ttip_handle = handle;
}


static void robtk_select_set_touch(RobTkSelect *d, void (*cb) (void*, uint32_t, bool), void* handle, uint32_t id) {
d->touch_cb = cb;
d->touch_hd = handle;
Expand Down

0 comments on commit d7709c9

Please sign in to comment.