subsurface/display.h
Dirk Hohndel 53f809ccca 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>
2011-10-04 12:27:55 -07:00

29 lines
827 B
C

#ifndef DISPLAY_H
#define DISPLAY_H
#include <cairo.h>
extern void repaint_dive(void);
extern void do_print(void);
/*
* Cairo scaling really is horribly horribly mis-designed.
*
* Which is sad, because I really like Cairo otherwise. But
* the fact that the line width is scaled with the same scale
* as the coordinate system is a f*&%ing disaster. So we
* can't use it, and instead have this butt-ugly wrapper thing..
*/
struct graphics_context {
int printer;
cairo_t *cr;
double maxx, maxy;
double leftx, rightx;
double topy, bottomy;
};
extern void plot(struct graphics_context *gc, cairo_rectangle_int_t *drawing_area, struct dive *dive);
extern void set_source_rgb(struct graphics_context *gc, double r, double g, double b);
extern void attach_tooltip(int x, int y, int w, int h, const char *text);
#endif