mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Change plot routine to take a drawing_area as argument
Previously we passed in width and height and the routine itself decided to keep 5% margin around each edge - oddly doing this with double precision, even though this is all integer coordinates. Instead we are now passing in a drawing_area. We are kind of abusing the cairo_rectangle_int_t data type here - but it seemed silly to redefine a new data type for this. Width and height give the size of the TOTAL drawing area (as before). x and y give the offset from the edges - so the EFFECTIVE drawing area is width-2x and height-2y This is in preparation for adding tooltips - those need to know the coordinate offsets from the edges - so having this hard coded inside the plot function didn't make sense anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d7e35c512c
commit
b72ade0e78
4 changed files with 15 additions and 14 deletions
13
gtk-gui.c
13
gtk-gui.c
|
@ -674,18 +674,21 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer
|
|||
{
|
||||
struct dive *dive = current_dive;
|
||||
struct graphics_context gc = { .printer = 0 };
|
||||
int w,h;
|
||||
static cairo_rectangle_int_t drawing_area;
|
||||
|
||||
w = widget->allocation.width;
|
||||
h = widget->allocation.height;
|
||||
/* the drawing area gives TOTAL width * height - x,y is used as the topx/topy offset
|
||||
* so effective drawing area is width-2x * height-2y */
|
||||
drawing_area.width = widget->allocation.width;
|
||||
drawing_area.height = widget->allocation.height;
|
||||
drawing_area.x = drawing_area.width / 20.0;
|
||||
drawing_area.y = drawing_area.height / 20.0;
|
||||
|
||||
gc.cr = gdk_cairo_create(widget->window);
|
||||
set_source_rgb(&gc, 0, 0, 0);
|
||||
cairo_paint(gc.cr);
|
||||
|
||||
if (dive)
|
||||
plot(&gc, w, h, dive);
|
||||
|
||||
plot(&gc, &drawing_area, dive);
|
||||
cairo_destroy(gc.cr);
|
||||
|
||||
return FALSE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue