mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Create tool-tip with depth/pressure for the whole profile area
This extends on our current tooltip logic (which shows events when you mouse over them) to show tooltips for the whole profile area. If you mouse over an event, that is still shown in the tooltip, but even in the absense of events, the tooltip will be active, and mousing over the profile area will show the time, depth and pressure. This can certainly be improved upon further, but even in this form it is useful. Fixes #9 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fe4f13f184
commit
01e8984d7d
4 changed files with 84 additions and 19 deletions
43
profile.c
43
profile.c
|
@ -900,6 +900,8 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi
|
|||
maxtime = get_maxtime(pi);
|
||||
maxdepth = get_maxdepth(pi);
|
||||
|
||||
gc->maxtime = maxtime;
|
||||
|
||||
/* Time markers: at most every 10 seconds, but no more than 12 markers.
|
||||
* We start out with 10 seconds and increment up to 30 minutes,
|
||||
* depending on the dive time.
|
||||
|
@ -1908,11 +1910,12 @@ static void plot_set_scale(scale_mode_t scale)
|
|||
}
|
||||
}
|
||||
|
||||
void plot(struct graphics_context *gc, cairo_rectangle_t *drawing_area, struct dive *dive, scale_mode_t scale)
|
||||
void plot(struct graphics_context *gc, struct dive *dive, scale_mode_t scale)
|
||||
{
|
||||
struct plot_info *pi;
|
||||
static struct sample fake[4];
|
||||
struct sample *sample = dive->sample;
|
||||
cairo_rectangle_t *drawing_area = &gc->drawing_area;
|
||||
int nr = dive->samples;
|
||||
|
||||
plot_set_scale(scale);
|
||||
|
@ -1994,5 +1997,41 @@ void plot(struct graphics_context *gc, cairo_rectangle_t *drawing_area, struct d
|
|||
|
||||
plot_depth_scale(gc, pi);
|
||||
|
||||
free(pi);
|
||||
if (gc->printer) {
|
||||
free(pi);
|
||||
} else {
|
||||
free(gc->plot_info);
|
||||
gc->plot_info = pi;
|
||||
}
|
||||
}
|
||||
|
||||
static void plot_string(struct plot_data *entry, char *buf, size_t bufsize)
|
||||
{
|
||||
int depth_decimals, pressure;
|
||||
const char *depth_unit, *pressure_unit;
|
||||
double depth;
|
||||
|
||||
depth = get_depth_units(entry->depth, &depth_decimals, &depth_unit);
|
||||
pressure = get_pressure_units(GET_PRESSURE(entry), &pressure_unit);
|
||||
|
||||
snprintf(buf, bufsize, "%.*f %s\n%d %s",
|
||||
depth_decimals, depth, depth_unit,
|
||||
pressure, pressure_unit);
|
||||
}
|
||||
|
||||
void get_plot_details(struct graphics_context *gc, int time, char *buf, size_t bufsize)
|
||||
{
|
||||
struct plot_info *pi = gc->plot_info;
|
||||
|
||||
*buf = 0;
|
||||
if (pi) {
|
||||
int i;
|
||||
for (i = 0; i < pi->nr; i++) {
|
||||
struct plot_data *entry = pi->entry + i;
|
||||
if (entry->sec >= time) {
|
||||
plot_string(entry, buf, bufsize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue