Fixed up the implementation of Area on GTK+ and the Area test. Seems to be fine, though for some reason holding down a mouse button doesn't generate a drag in GTK+ 3.10...
This commit is contained in:
parent
3e25992f09
commit
b46167f1e2
|
@ -53,7 +53,13 @@ func newArea(ab *areabase) Area {
|
|||
scroller: newScroller(widget, false), // not natively scrollable,
|
||||
clickCounter: new(clickCounter),
|
||||
}
|
||||
// TODO connect signals
|
||||
for _, c := range areaCallbacks {
|
||||
g_signal_connect(
|
||||
C.gpointer(unsafe.Pointer(a.drawingarea)),
|
||||
c.name,
|
||||
c.callback,
|
||||
C.gpointer(unsafe.Pointer(a)))
|
||||
}
|
||||
a.SetSize(a.width, a.height)
|
||||
return a
|
||||
}
|
||||
|
@ -68,6 +74,20 @@ func (a *area) RepaintAll() {
|
|||
C.gtk_widget_queue_draw(a._widget)
|
||||
}
|
||||
|
||||
var areaCallbacks = []struct {
|
||||
name string
|
||||
callback C.GCallback
|
||||
}{
|
||||
{ "draw", area_draw_callback },
|
||||
{ "button-press-event", area_button_press_event_callback },
|
||||
{ "button-release-event", area_button_release_event_callback },
|
||||
{ "motion-notify-event", area_motion_notify_event_callback },
|
||||
{ "enter-notify-event", area_enterleave_notify_event_callback },
|
||||
{ "leave-notify-event", area_enterleave_notify_event_callback },
|
||||
{ "key-press-event", area_key_press_event_callback },
|
||||
{ "key-release-event", area_key_release_event_callback },
|
||||
}
|
||||
|
||||
//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
|
||||
|
|
|
@ -10,6 +10,8 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
)
|
||||
|
||||
var closeOnClick = flag.Bool("close", false, "close on click")
|
||||
|
@ -43,10 +45,12 @@ type testwin struct {
|
|||
|
||||
type areaHandler struct{}
|
||||
func (a *areaHandler) Paint(r image.Rectangle) *image.RGBA {
|
||||
return image.NewRGBA(r)
|
||||
i := image.NewRGBA(r)
|
||||
draw.Draw(i, r, &image.Uniform{color.RGBA{128,0,128,255}}, image.ZP, draw.Src)
|
||||
return i
|
||||
}
|
||||
func (a *areaHandler) Mouse(me MouseEvent) bool { return false }
|
||||
func (a *areaHandler) Key(ke KeyEvent) bool { return false }
|
||||
func (a *areaHandler) Mouse(me MouseEvent) bool { fmt.Printf("%#v\n", me); return false }
|
||||
func (a *areaHandler) Key(ke KeyEvent) bool { fmt.Printf("%#v\n", ke); return false }
|
||||
|
||||
func (tw *testwin) make(done chan struct{}) {
|
||||
tw.t = NewTab()
|
||||
|
|
Loading…
Reference in New Issue