First step towards a context menu in the profile view

This is completely bogus as all it does is print out the corresponding
time for the spot we right-clicked on the profile. But that at least shows
that the infrastructure is working as intended...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-03-17 16:13:02 -07:00
parent a094b2b88a
commit bfa37c3cac
3 changed files with 44 additions and 0 deletions

View file

@ -141,6 +141,15 @@ static const color_t profile_color[] = {
#define SCALEY(gc,y) (((y)-gc->topy)/(gc->bottomy-gc->topy)*gc->maxy)
#define SCALE(gc,x,y) SCALEX(gc,x),SCALEY(gc,y)
/* keep the last used gc around so we can invert the SCALEX calculation in
* order to calculate a time value for an x coordinate */
static struct graphics_context last_gc;
int x_to_time(double x)
{
int seconds = (x - last_gc.drawing_area.x) / last_gc.maxx * (last_gc.rightx - last_gc.leftx) + last_gc.leftx;
return (seconds > 0) ? seconds : 0;
}
static void move_to(struct graphics_context *gc, double x, double y)
{
cairo_move_to(gc->cr, SCALE(gc, x, y));
@ -700,6 +709,9 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi
gc->leftx = 0; gc->rightx = maxtime;
gc->topy = 0; gc->bottomy = 1.0;
last_gc = *gc;
set_source_rgba(gc, TIME_GRID);
cairo_set_line_width_scaled(gc->cr, 2);