diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2017-05-27 18:30:08 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-05-30 09:26:30 +0200 |
commit | 83f11c231626f79433a021c526ffa1ac7521ae36 (patch) | |
tree | 72a3e0cfb3efd9e34455c8ad5d670a2e08900112 /ui.h | |
parent | 90b9483c806f0571988581c1712c7ca236c4a38c (diff) |
flowtop: Improve and unify up/down scrolling
Move scrolling logic to the ui.c module, it requires to have
some data iteration provided in flowtop.c and delegated to ui.c part.
So approach is that now flowtop provides 2 additional callbacks for:
1) Iterate over flows/procs list
2) Draw flow/proc on each iteration which is controlled from ui.c
it allows to unify scrolling logic and delegate it to the ui.c, in the
future it should allow to easy handle press event on selected row and
drow some additional information, or draw a cursor line per selected
row.
Also fixed case when down scrolling was bigger that printed rows, not
it is handled by ui part.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ui.h')
-rw-r--r-- | ui.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -9,6 +9,8 @@ enum ui_event_id { UI_EVT_SCROLL_LEFT, UI_EVT_SCROLL_RIGHT, + UI_EVT_SCROLL_UP, + UI_EVT_SCROLL_DOWN, UI_EVT_SELECT_NEXT, }; @@ -44,7 +46,12 @@ struct ui_table { int width; int height; int scroll_x; + int scroll_y; const char *delim; + int data_count; + + void * (* data_iter)(void *data); + void (* data_bind)(struct ui_table *tbl, const void *data); }; struct ui_tab; @@ -86,6 +93,12 @@ extern void ui_table_header_color_set(struct ui_table *tbl, int color); extern void ui_table_header_print(struct ui_table *tbl); extern void ui_table_event_send(struct ui_table *tbl, enum ui_event_id id); +extern void ui_table_data_iter_set(struct ui_table *tbl, void * (* iter)(void *data)); +extern void ui_table_data_bind_set(struct ui_table *tbl, + void (* bind)(struct ui_table *tbl, const void *data)); +extern void ui_table_data_bind(struct ui_table *tbl); +extern int ui_table_data_count(struct ui_table *tbl); +extern int ui_table_scroll_height(struct ui_table *tbl); extern struct ui_tab *ui_tab_create(void); extern void ui_tab_destroy(struct ui_tab *tab); |