Commit Graph

13 Commits

Author SHA1 Message Date
David Crawshaw de4ba64cf5 app, event/key: keyboard events
First cut of events from physical keyboards.
Simple darwin/amd64 implementation.

Change-Id: I6e9d0a253387c841864ca9845ee729ea4f7573c7
Reviewed-on: https://go-review.googlesource.com/11815
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-22 20:09:27 +00:00
Nigel Tao c4654583ad event/touch: rename TypeStart to TypeBegin.
Change-Id: Ie8392cd6167fca1c0a7f10192824300d7885151d
Reviewed-on: https://go-review.googlesource.com/12342
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-18 04:39:45 +00:00
Nigel Tao 84f8e5edcc event: move event.Filter to app.Filter.
Change-Id: I11044a6e01b53e441c05fc1baec36718e783622f
Reviewed-on: https://go-review.googlesource.com/12288
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-17 01:18:36 +00:00
Nigel Tao b43065626f app: rename EndDraw to EndPaint.
Change-Id: I3e38df0e21be2246dd16886fa00c9360d42db145
Reviewed-on: https://go-review.googlesource.com/12282
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-16 03:33:11 +00:00
Nigel Tao e4c6af17e3 event: rename event.Foo to foo.Event.
Fixes golang/go#10444

Change-Id: Ie5a8ab8a09b1b1a4f7037da7cf945d39ab6a98fc
Reviewed-on: https://go-review.googlesource.com/12225
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-16 01:03:51 +00:00
Nigel Tao c0fb3fcc1e event: fix the build from a bad merge.
https://go-review.googlesource.com/#/c/11822/3/event/event.go
removed the fmt package dependency, but concurrently,
https://go-review.googlesource.com/#/c/11813/2/event/event.go
introduced new code that relied on fmt already being imported.

Change-Id: Ib5c66bf59850aa49d251778371c4863bfdf54655
Reviewed-on: https://go-review.googlesource.com/11859
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-03 02:19:54 +00:00
Nigel Tao 15dc27054b event: delete TouchType in favor of Change.
Change-Id: I8772c8d2690fbe6b636f1dcafe1393f6810d6716
Reviewed-on: https://go-review.googlesource.com/11822
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-03 01:56:41 +00:00
David Crawshaw f02d32beeb event: add String method to LifecycleStage enum
Change-Id: Iaa723e8db258540d60170216430295ac9dee1901
Reviewed-on: https://go-review.googlesource.com/11813
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-01 05:20:26 +00:00
Nigel Tao 42f0d17876 app: use one thread for both GL and other UI C code.
This change will break Darwin. I have only built and tested this on
desktop linux and Android linux. A follow-up CL will fix Darwin.

Currently, OpenGL gets its own thread, and UI C code (e.g. the Android
event loop, or the X11 event loop) gets its own thread. This relies on
multiple system-provided UI-related C libraries working nicely together,
even when running on different threads. Keeping all the C code on the
one thread seems more sound.

As side-effects:
  - In package app/debug, DrawFPS now takes an explicit Config.
  - In package app, some callbacks now take an explicit Config.
  - In package exp/sprite, Render now takes an explicit Config.
  - In package event, there are new events (Config, Draw, Lifecycle),
    and an event filter mechanism to replace multiple app Callbacks.
  - In package geom, the deprecated Width, Height and PixelsPerPt global
    variables were removed in favor of an event.Config that is
    explicitly passed around (and does not require mutex-locking).
    Converting a geom.Pt to pixels now requires passing a pixelsPerPt.
  - In package gl, the Do, Start and Stop functions are removed, as well
    as the need to call Start in its own goroutine. There is no longer a
    separate GL thread. Instead, package app explicitly performs any GL
    work (gl.DoWork) when some is available (gl.WorkAvailable).
  - In package gl/glutil, Image.Draw now takes an explicit Config.

Callbacks are no longer executed on 'the UI thread'.

Changing the app programming model from callbacks to events (since a
channel of events works with select) will be a follow-up change.

Change-Id: Id9865cd9ee1c45a98c613e9021a63c17226a64b1
Reviewed-on: https://go-review.googlesource.com/11351
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-26 07:43:17 +00:00
Gordon Klaus 253eb63b86 mobile/app: identify touches by ID to enable multitouch
An example of how to handle multiple concurrent touches using this design:

var touched = map[event.TouchSequenceID]*Widget{}
func touch(t event.Touch) {
    if t.Type == event.TouchStart {
        if w := widgetAt(t.Loc); w != nil {
            touched[t.ID] = w
        }
    }
    if w, ok := touched[t.ID]; ok {
         // move/scroll widget, etc
    }
    if t.Type == event.TouchEnd {
        delete(touched, t.ID)
    }
}

Change-Id: I79910ef30abe9a41bc0720783022b1af081fbd43
Reviewed-on: https://go-review.googlesource.com/1895
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Burcu Dogan <jbd@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-29 16:53:16 +00:00
David Symonds 7b659348a5 mobile: add import comments.
Change-Id: I0ff6d42a8e11f49df6fc3066e86be75015b93631
Reviewed-on: https://go-review.googlesource.com/1238
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-10 01:59:04 +00:00
Andrew Gerrand 9470e0ba58 go.mobile: use golang.org/x/... import paths
LGTM=bradfitz, rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/162710043
2014-11-10 08:55:57 +11:00
David Crawshaw 1a7379ccf0 go.mobile/event: types for user input events, starting with touch
LGTM=adg, nigeltao
R=nigeltao, bryanturley, adg, crawshaw
CC=davidday, golang-codereviews
https://golang.org/cl/141060043
2014-09-09 20:54:51 -04:00