From df8cbec7b8928c22a461468b6bef3078d3d831ea Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 21 Aug 2014 19:09:40 -0400 Subject: [PATCH] Quick update to Area GTK+ drawing in an attempt fo figure out what's going on: we store the Area's width/height already; no need to get it back out from GTK+ itself. --- redo/area_unix.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/redo/area_unix.go b/redo/area_unix.go index 781a11b..8c732b7 100644 --- a/redo/area_unix.go +++ b/redo/area_unix.go @@ -100,7 +100,6 @@ var areaCallbacks = []struct { //export our_area_draw_callback func our_area_draw_callback(widget *C.GtkWidget, cr *C.cairo_t, data C.gpointer) C.gboolean { var x0, y0, x1, y1 C.double - var maxwid, maxht C.gint a := (*area)(unsafe.Pointer(data)) // thanks to desrt in irc.gimp.net/#gtk+ @@ -109,8 +108,7 @@ func our_area_draw_callback(widget *C.GtkWidget, cr *C.cairo_t, data C.gpointer) // we do not need to clear the cliprect; GtkDrawingArea did it for us beforehand cliprect := image.Rect(int(x0), int(y0), int(x1), int(y1)) // the cliprect can actually fall outside the size of the Area; clip it by intersecting the two rectangles - C.gtk_widget_get_size_request(widget, &maxwid, &maxht) - cliprect = image.Rect(0, 0, int(maxwid), int(maxht)).Intersect(cliprect) + cliprect = image.Rect(0, 0, a.width, a.height).Intersect(cliprect) if cliprect.Empty() { // no intersection; nothing to paint return C.FALSE // signals handled without stopping the event chain (thanks to desrt again) } @@ -133,7 +131,7 @@ func our_area_draw_callback(widget *C.GtkWidget, cr *C.cairo_t, data C.gpointer) 0, 0) // origin of the surface // that just set the brush that cairo uses: we have to actually draw now // (via https://developer.gnome.org/gtkmm-tutorial/stable/sec-draw-images.html.en) - C.cairo_rectangle(cr, x0, y0, x1, y1) // breaking the nrom here since we have the coordinates as a C double already + C.cairo_rectangle(cr, x0, y0, x1, y1) // breaking the norm here since we have the coordinates as a C double already C.cairo_fill(cr) C.cairo_surface_destroy(surface) // free surface return C.FALSE // signals handled without stopping the event chain (thanks to desrt again)