Commit Graph

20 Commits

Author SHA1 Message Date
David Crawshaw 51384a9898 event/config: add Orientation
There are several variations on orientation. iOS expposes a little
more orientation information through its basic enum than Android
does, but the more powerful Android API gives you degrees around a
circle, which while strictly more powerful, doesn't tell you easily
where the status bar is.

What I'm thinking with this is the primary use of an orientation
concept is to decide whether or not to lay out a UI for a wide screen.
This gives you that.

Later I hope the sensor API will give far more information about the
physical orientation of the device.

Change-Id: I00ff598853c7ed618cde266729d8d05e1a02a601
Reviewed-on: https://go-review.googlesource.com/13361
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-08-10 12:46:05 +00:00
Nigel Tao fa181effb8 event/config: add a Bounds method.
This is analogous to the image.Image's Bounds method.

Change-Id: I2be927f21008107b535cb79e231149cb8d4e8e36
Reviewed-on: https://go-review.googlesource.com/13152
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-07 00:14:21 +00:00
Nigel Tao 8fffdfa9fd event/{mouse,touch}: work in float32 pixels, not geom.Pt.
Higher-level widget or animation libraries should probably work in
geom.Pt, but pixels instead of (1/72s of) inches seems a better fit for
lower-level event libraries. Needlessly converting from (float32) pixels
to (float32) points and back can be lossy and lead to off-by-one errors.

Change-Id: I68102e36f2574b07b44c6a1b7281f4f27f9174cf
Reviewed-on: https://go-review.googlesource.com/13002
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-04 07:35:09 +00:00
David Crawshaw 0c8ff9f648 app, event/paint: plumb through paint Generation
Change-Id: I82bac0dc24943c64560a0bac4687cbbbb8b5c328
Reviewed-on: https://go-review.googlesource.com/12841
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-30 16:09:38 +00:00
Nigel Tao cdc5281044 event/config: specify width and height in both pixels and points.
Change-Id: I494c17b2bad6c920ea20b22046d1d3fbc7b6b1d4
Reviewed-on: https://go-review.googlesource.com/12700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-28 01:48:05 +00:00
Nigel Tao f2f4efe74b event/mouse: new package.
Change-Id: Idd30a70bf62971ecea8ee9db905d4a0a8baf6525
Reviewed-on: https://go-review.googlesource.com/12667
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-28 01:28:46 +00:00
David Crawshaw bd8a095b54 event/key: add Code type
Also add a few missing codes.

Change-Id: I26b6db31067c67107fe4db142ec9f48ff13cc53e
Reviewed-on: https://go-review.googlesource.com/12536
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-24 12:23:42 +00:00
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