summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-21 11:43:37 -0400
committerPietro Gagliardi <[email protected]>2014-08-21 11:43:37 -0400
commit5ddef4113332035429ac54b5ba62f4539eb20da0 (patch)
tree60bc7a336b9823f0f7958cd3ccc2a88a353854a4
parentc9f8955758545c08bb8b58bab094e5fd4ff3562b (diff)
Added Area.Repaint() and implemented it on GTK+. Untested as of yet.
-rw-r--r--redo/area.go5
-rw-r--r--redo/area_unix.go8
2 files changed, 13 insertions, 0 deletions
diff --git a/redo/area.go b/redo/area.go
index 75f47b2..829fc33 100644
--- a/redo/area.go
+++ b/redo/area.go
@@ -37,6 +37,11 @@ type Area interface {
// It panics if width or height is zero or negative.
SetSize(width int, height int)
+ // Repaint marks the given rectangle of the Area as needing to be redrawn.
+ // The given rectangle is clipped to the Area's size.
+ // If, after clipping, the rectangle is empty, Repaint does nothing.
+ Repaint(r image.Rectangle)
+
// RepaintAll marks the entirety of the Area as needing to be redrawn.
RepaintAll()
}
diff --git a/redo/area_unix.go b/redo/area_unix.go
index e50c465..c65ca72 100644
--- a/redo/area_unix.go
+++ b/redo/area_unix.go
@@ -70,6 +70,14 @@ func (a *area) SetSize(width, height int) {
C.gtk_widget_set_size_request(a._widget, C.gint(a.width), C.gint(a.height))
}
+func (a *area) Repaint(r image.Rectangle) {
+ r = image.Rect(0, 0, a.width, a.height).Intersect(r)
+ if r.Empty() {
+ return
+ }
+ C.gtk_widget_queue_draw_area(a._widget, C.gint(r.Min.X), C.gint(r.Max.Y), C.gint(r.Dx()), C.gint(r.Dy()))
+}
+
func (a *area) RepaintAll() {
C.gtk_widget_queue_draw(a._widget)
}