lnvis

nanovg lightning network visualizer
git clone git://jb55.com/lnvis
Log | Files | Refs | README | LICENSE

commit c1f3a7878834571ce3f9a6d302a364df442860d6
parent 229c858b4a349e5f3740f95fa04d78d7e6795b7b
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 16 Aug 2018 08:23:25 -0700

wip channel info

Diffstat:
Mupdate.c | 51++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 11 deletions(-)

diff --git a/update.c b/update.c @@ -150,22 +150,51 @@ static void physics(struct ln *ln, double dt) } +static void print_channel_info(struct channel chan) -// force graph update logic -void update(struct ln *ln, double dt) + +static void handle_click(struct ln *ln) { // click detection - if (ln->clicked) { - struct node *hit = hit_node(ln); - ln->drag_target = hit; - ln->last_drag_target = hit; - } + struct channel *chan = NULL; + struct node *hit = hit_node(ln); + + ln->drag_target = hit; + ln->last_drag_target = hit; - if (ln->right_clicked) { - struct node *hit = hit_node(ln); - if (hit != NULL) - filter_network(NULL, hit, ln); + if (!hit) + return; + + // print some info about channels + for (u32 i = 0; i < ln->channel_count; i++) { + chan = &ln->channels[i]; + + if (chan->filtered) + continue; + + if (nodeid_eq(chan->nodes[0]->id, hit->id) || + nodeid_eq(chan->nodes[1]->id, hit->id)) + print_channel_info(chan); } +} + + +static void handle_rightclick(struct ln *ln) +{ + struct node *hit = hit_node(ln); + if (hit != NULL) + filter_network(NULL, hit, ln); +} + + +// force graph update logic +void update(struct ln *ln, double dt) +{ + if (ln->clicked) + handle_click(ln); + + if (ln->right_clicked) + handle_rightclick(ln); // stop dragging if (!ln->mdown && ln->drag_target) {