diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2011-10-04 12:27:55 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2011-10-04 12:27:55 -0700 |
commit | 53f809ccca43354f443bb8e02621a5625eb38fde (patch) | |
tree | 00e6066c4d9ab9eaeb065aaf6752fd21e0c423cb /profile.c | |
parent | b72ade0e78825dd97add4c7607c574df351abed0 (diff) | |
download | subsurface-53f809ccca43354f443bb8e02621a5625eb38fde.tar.gz |
Replace event text with small red triangle and tooltip
We draw a little red triangle (of hardcoded size - not sure if this SHOULD
scale with the size of the plot... I like it better if it doesn't) to the
left of an event.
We then maintain an array of rectangles that each circumscribe one of
those event triangles and if the mouse pointer enters one of these
rectangles then we display (after a short delay) a tooltip with the event
text.
Manually creating these rectangles, maintaining the coordinate offset,
checking if we are inside one of these rectangles and then showing a
tooltip... this all seems like there should be gtk functions to do this by
default... but if there are then I failed to find them. So instead I
manually implemented the necessary logic.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -160,6 +160,7 @@ static void plot_text(struct graphics_context *gc, const text_render_options_t * static void plot_one_event(struct graphics_context *gc, struct plot_info *pi, struct event *event, const text_render_options_t *tro) { int i, depth = 0; + int x,y; for (i = 0; i < pi->nr; i++) { struct plot_data *data = pi->entry + i; @@ -167,7 +168,17 @@ static void plot_one_event(struct graphics_context *gc, struct plot_info *pi, st break; depth = data->val; } - plot_text(gc, tro, event->time.seconds, depth, "%s", event->name); + /* draw a little tirangular marker and attach tooltip */ + x = SCALEX(gc, event->time.seconds); + y = SCALEY(gc, depth); + set_source_rgba(gc, 1.0, 0.1, 0.1, 0.5); + cairo_move_to(gc->cr, x-6, y-3); + cairo_line_to(gc->cr, x , y-3); + cairo_line_to(gc->cr, x-3, y+3); + cairo_line_to(gc->cr, x-6, y-3); + cairo_stroke_preserve(gc->cr); + cairo_fill(gc->cr); + attach_tooltip(x-6, y-3, 6, 6, event->name); } static void plot_events(struct graphics_context *gc, struct plot_info *pi, struct dive *dive) |