2
0
mirror of synced 2025-02-23 06:48:15 +00:00

84 Commits

Author SHA1 Message Date
Hana Kim
40167cfb81 example/ivy/android: fix a typo that caused a program bug
Additional '=' was added after '&',
but 0 != (a &= b) is still valid in java

Change-Id: I9c7b524941e0553c9fc5095adc5fc7819c4823b0
Reviewed-on: https://go-review.googlesource.com/23950
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-09 16:57:57 +00:00
Hana Kim
ac3648cc3c example/ivy/android: upgrade gobind plugin to 0.2.6
For golang/go#15554

Also update app target sdk api to 23.

Change-Id: Id66b17b4388703e9806cc50def554b3c58606e24
Reviewed-on: https://go-review.googlesource.com/23690
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2016-06-02 20:00:16 +00:00
Hana Kim
df6b37ba82 misc/androidstudio: release gradle plugin 0.2.6
Also
- include a properties file for org.golang.mobile.bind.canary
which is used to canary before release.
- update example/bind/android gradle config.

Change-Id: I1dd0ff94a772b287a2f9be1a915ea72b1c3b0d52
Reviewed-on: https://go-review.googlesource.com/23678
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-02 18:18:59 +00:00
Hyang-Ah Hana Kim
2e1e39e5a6 misc/androidstudio: release gobind gradle plugin 0.2.4
That supports GOARCH property.

Also this CL updates examples and upgrades the android gradle plugin
used in examples (from 1.2.3 to 1.5.0)

For golang/go#12819

Change-Id: Ibfed128eaf725775810aa539bd5c0e1ca88f1b85
Reviewed-on: https://go-review.googlesource.com/20331
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-08 02:06:34 +00:00
Hyang-Ah (Hana) Kim
04168c3bfb example/bind/android: update gradle version
from 0.2.2 to 0.2.3

Change-Id: I906200acf9615c8cc100b7d1ad5592e899e383fe
Reviewed-on: https://go-review.googlesource.com/19409
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-10 23:56:31 +00:00
David Crawshaw
e27aacb64e example/sprite: delete
Andrew's new example/flappy does a better job of demoing off these
packages, and I would like to keep our example count under contorl.

Change-Id: I77f4da78815055ab91510ce0cb97bbd7ac1bac3b
Reviewed-on: https://go-review.googlesource.com/18381
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-08 15:21:00 +00:00
Andrew Gerrand
441a9620b3 example/flappy: document texture issue, re-enable reset
Change-Id: I80ba6b4421e64c5470f7b88c92b89ca3686ebec4
Reviewed-on: https://go-review.googlesource.com/18352
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-01-07 03:28:10 +00:00
Andrew Gerrand
746653dcb3 example/flappy: add simple example game
This game was developed for and presented at GoCon Winter 2015 in Tokyo.

Change-Id: I08148e16a54355b79f634dce867b3c3c0a0153cb
Reviewed-on: https://go-review.googlesource.com/18245
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-01-07 03:14:55 +00:00
David Crawshaw
3abfce6c04 all: windows build tags
For golang/go#9306

Change-Id: Ia8778f5b371371d103c55c12606257ee7ca45fd4
Reviewed-on: https://go-review.googlesource.com/17778
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-12-14 17:43:10 +00:00
Daniel Skinner
3b97f7024e cmd/gomobile: synthesize minSdkVersion for manifest
Fixes golang/go#13172

Change-Id: I16cab3f74f668ce3522a1a14c979aca5c988347c
Reviewed-on: https://go-review.googlesource.com/16843
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-13 09:00:34 +00:00
David Crawshaw
7fe809f8e0 event/paint: mark paint events sent by the system
A paint.Event now has an External field. Whenever a paint event is
sent by the x/mobile/app package, it is marked as external so users
with an active paint loop can ignore them.

Implemented on OS X and Android, with examples updated.

Change-Id: Ibee8d65625c8818ff954936be48257ad30daa147
Reviewed-on: https://go-review.googlesource.com/15480
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-10-07 19:41:52 +00:00
Dan Caddigan
ca60936f19 example/ivy/android: fix parens grouping example
The current example 2**(2+3) yields the same result as not using
parenthesis.  The "grouped differently" example should use (2**2)+3
so that it yields a different result.

Change-Id: If5f63ec03adba4402c51822d6c13646a26384730
Reviewed-on: https://go-review.googlesource.com/14960
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2015-10-02 19:42:16 +00:00
Paul Hankin
80ead7f4f8 sprite: Use gl.Context instead of package-level OpenGL calls.
The package-level OpenGL calls in golang.org/x/mobile/gl were removed.
This change fixes the example sprite app to use their replacement.

Change-Id: I1884e9292133375194c963e71540acaef0908d66
Reviewed-on: https://go-review.googlesource.com/15051
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-26 17:12:14 +00:00
Nigel Tao
159023b619 example/basic: fix typo.
Change-Id: I53c6804729211ceb4546c5276314dc67eeff7a51
Reviewed-on: https://go-review.googlesource.com/14935
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-24 06:47:40 +00:00
David Crawshaw
59ab51f73f gl: move to context methods
All OpenGL functions are now methods on a Context interface. The
gl.Context matches the one loaded into thread-local storage in C.

For mobile apps, the context is owned by an app.App. For now, it is
provided through the events channel on a lifecycle event. Long-term,
it should probably be available by a method on app.App, but this is
inherently racey with our current use of a channel to deliver events.

Shiny-based programs will have a gl.Context associated with a each
shiny.Window. The expectation is each Window will have different
contexts, allowing them to draw separately.

Change-Id: Ie09986fb74e493129f2ea542a151c95c6fa29812
Reviewed-on: https://go-review.googlesource.com/13431
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-23 23:46:16 +00:00
David Crawshaw
9e848912c3 app: turn filtering functions into methods on App
Change-Id: I69a6ac9930303945bd2d69a1995f28021bb3b0b0
Reviewed-on: https://go-review.googlesource.com/14796
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-23 05:17:31 +00:00
David Crawshaw
0064789433 exp/gl/glutil: remove global texture cache
It is now the user's job to track the lifetime of a glutil.Image
relative to a (currently implicit, soon to be explicit) GL context.

This is an attempt to move glutil.Image closer to the model for
buffers and textures in shiny. Long-term, I would like to adopt that
model, and this is a step in that direction. It also makes the
introduction of *gl.Context possible, so this is a pre-req for
cl/13431.

Change-Id: I8e6855211b3e67c97d5831c5c4e443e857c83d50
Reviewed-on: https://go-review.googlesource.com/14795
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-23 04:24:22 +00:00
Nigel Tao
4c15c79e19 app: change EndPaint to Publish.
More than a name change, the painting model changes so that the app, not
the library, is responsible for driving painting. If the app is
animating and wants paint events at 60 Hz, it has to ask for that. If
the app is not animating and doesn't need to update its screen, it
shouldn't get any paint events.

Plenty of TODOs, and this CL doesn't get us to a perfect place, but it
is a checkpoint along the way.

The darwin_*.go code changes were minimal. I don't even have a Mac or
iOS device to test that this even builds. Even so, the TODOs about not
sending paint.Events unconditionally are important TODOs. That's the
whole point of switching to this model. I'll leave the actual
implementation to you (crawshaw).

Out of all the example apps, the change to example/network/main.go is
probably the most interesting.

It seems like there ought to be some way to reduce the copy/paste
between all of the example app code, but I'll leave that for future CLs.

Change-Id: I17e11c06174110c68e17f7183b2d8af19b6a170e
Reviewed-on: https://go-review.googlesource.com/14300
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-17 03:17:09 +00:00
David Crawshaw
b10f681911 example/ivy/ios: remove unnecessary indentation
Change-Id: Ie4898a25eeb3230be6acb0fb85d2cff636f2880e
Reviewed-on: https://go-review.googlesource.com/14600
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-09-15 12:59:24 +00:00
David Crawshaw
b0ae6f9325 example/ivy/ios: add iOS source code
Change-Id: Ifabbfcfd75a92b0eb81631e3bb6eca1e4228139a
Reviewed-on: https://go-review.googlesource.com/14208
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-09-14 21:08:49 +00:00
Hyang-Ah (Hana) Kim
9e2ad8c60e example/ivy/android: configure version code/name (3/1.0.2)
Change-Id: I378f41a54c7bb6cf81988c344a086e6a506e9dfe
Reviewed-on: https://go-review.googlesource.com/14202
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-02 21:16:25 +00:00
Hyang-Ah (Hana) Kim
e565eadcd6 example/ivy/android: fix problems caused by old bugs in WebView.
1) Clear button did not shrink the WebView size. It's an old bug in
Android WebView, and fixed recently (android-L, maybe). This CL avoids
the problem by replacing the webview with a freshly allocated new webview
object. It's heavy-weight, but the Clear event should be rare.

2) ScrollToBottom from the java side and the java script side interacted
strangely and prevented long results from displayed properly.

Also,

- now the gomobile bind generates the Java class in the
org.golang.ivy package. (ivy/build.gradle)

- modified the javascript in tape.html so long result texts are not
shortened initially. (tape.html)

Change-Id: I60660f3392cf17719daad4af89e05c2d82788175
Reviewed-on: https://go-review.googlesource.com/14201
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-02 14:49:09 +00:00
Hyang-Ah (Hana) Kim
fee22db634 example/ivy/android: initial check in.
This version is not yet released to Play store.
Compared to the version in the play store

- fixed the reappearing keyboard bug
- allows app install on SD card
- when demo is enabled, the demo mode message is displayed
- when demo is enabled, the submit action button appears next to the
  edit text.
- use robpike.io/ivy/mobile instead of the wrapper in my personal repo.
- the demo script read code was moved from go to java.
- use the up-to-date help message retrieved with mobile.Help.
- textview was replaced with webview with javascript.

TODO: the app built from this code doesn't work in old android devices.
Next cl will fix it.

TODO: build instruction - not very different from
golang.org/x/mobile/example/bind/android.

Change-Id: Ifb594b79f31091b6864ec3e0d8dbaff7986a5afc
Reviewed-on: https://go-review.googlesource.com/13870
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-02 05:29:24 +00:00
Hana Kim
49a82fefe3 all: support go get golang.org/x/mobile/... on Windows
Fixes golang/go#12212
Workaround for golang/go#12261 until golang/go#9306 is fixed.

Change-Id: I51c1bcfc92c1553fe2132586a0234b1c1af6aeb1
Reviewed-on: https://go-review.googlesource.com/13745
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-24 21:09:04 +00:00
Nigel Tao
f632204bcc event/config: rename to event/size.
Change-Id: I908b5f0818da32b2b040f430ebcc3762eb6f7570
Reviewed-on: https://go-review.googlesource.com/13601
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-13 13:31:00 +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
Burcu Dogan
1f62208640 example/bind/android: GOMOBILE gradle setting is optional
Fixes golang/go#11998.

Change-Id: I418a7cd5507c59244eef2be39e0074a82adb4c97
Reviewed-on: https://go-review.googlesource.com/13067
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-03 18:28:18 +00:00
Burcu Dogan
99196c8691 example/bind/ios: remove the failing build step
Regenerating the package from Xcode is not required, demo
should focus on building with a .framework bundle.

Removing the genhello.bash invoking build step to fix the Xcode
builds.

Change-Id: I793b7e1f5373a287432a0a605df0bde54b1daa84
Reviewed-on: https://go-review.googlesource.com/13036
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-01 23:05:44 +00:00
Hyang-Ah (Hana) Kim
e0b154b34c example/bind: Android studio example.
Change-Id: I4729e47a4a3c4474f4ad53704e7fec337583d9e2
Reviewed-on: https://go-review.googlesource.com/12800
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-31 20:10:44 +00:00
Hyang-Ah (Hana) Kim
8217477ff5 example/bind: iOS Objective-C @ xcode example
Change-Id: I10afa0961953e5a67f31479b564923b95ae5439f
Reviewed-on: https://go-review.googlesource.com/12821
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-31 20:00:56 +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
Hyang-Ah (Hana) Kim
b3bd3d29aa example: limit examples build to linux or darwin.
windows and other non-mobile os support is not there yet.

Change-Id: Ie9c456b646bfa0b0c489e1b6344b5afca4801c5f
Reviewed-on: https://go-review.googlesource.com/12744
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-28 16:32:30 +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
Florin Patan
6256dc3e64 example/network: use correct app event filter
This change allows the example/network from gomobile to compile
correctly.

Change-Id: Id0f722796e0224ec4a7c06b163a25a4f3a5fbcb3
Reviewed-on: https://go-review.googlesource.com/12471
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-21 14:54:22 +00:00
Jae Kwon
96f72abd68 cmd/gomobile: expect GoNativeActivity in external manifests
gomobile expects GoNativeActivity, otherwise current_ctx_clazz stays
null.
Fixed cmd/gomobile/manifest.go to expect GoNativeActivity, and fixed the
network example app.

Change-Id: Idad6f9bec2fcbc876fbd6013009582868ad3e133
Reviewed-on: https://go-review.googlesource.com/12374
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-18 02:39:09 +00:00
Hyang-Ah (Hana) Kim
32ad533813 example/audio: use the latest config.Event in arranger func.
Change-Id: I452e9e7e37a983421acac23ab265b822fbc3db19
Reviewed-on: https://go-review.googlesource.com/12339
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-17 19:53:07 +00:00
David Crawshaw
c8a8acd495 example/sprite: move to events
Change-Id: I5f5b2aee9edebc7b50ee98e23da5f0fa7e06112d
Reviewed-on: https://go-review.googlesource.com/12335
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-17 17:57:13 +00:00
David Crawshaw
3ee73d9a25 example/audio: move to events
Change-Id: Ib6971e48abfa16b995d815ab37077c83940b9096
Reviewed-on: https://go-review.googlesource.com/12336
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-17 17:42:28 +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
David Crawshaw
c6888a7bae example/network: rewrite to use event loop
Change-Id: Ibcf8fa9aec7327e98d4a0cdb5c37bb39bcc41bf8
Reviewed-on: https://go-review.googlesource.com/12278
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-16 20:19:15 +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
David Crawshaw
460bd28e6c example/basic: rewrite to use event loop
Change-Id: Ic7d8557c42b17238f3dae7fc9287a7cdb5f55eb1
Reviewed-on: https://go-review.googlesource.com/12272
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-16 03:17:43 +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
Hyang-Ah (Hana) Kim
c68947979f example/network: a simple example to show AndroidManifest customization
Change-Id: I558925eca6be12772726cfff96b48fd4c6bbc303
Reviewed-on: https://go-review.googlesource.com/11892
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-07-09 17:52:27 +00:00
Nigel Tao
467d8559f2 f32: move to exp/f32.
In the long term, a lot of this package should be removed in favor of the
golang.org/x/image/math/f32 package. The latter is the common location for
matrix types shared across graphics libraries. For example, the
golang.org/x/image/draw package refers to golang.org/x/image/math/f64.

Change-Id: I9d7ccd3cb35912e0d9dc5bd46c919516ea840340
Reviewed-on: https://go-review.googlesource.com/11856
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-03 01:37:12 +00:00
Nigel Tao
bd8fa0d7bb gl/glutil: move to exp/gl/glutil.
Change-Id: I310c365300cb3fbf8a1abb630e26661fa7ef4844
Reviewed-on: https://go-review.googlesource.com/11824
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-01 11:41:50 +00:00
Nigel Tao
c7c93d6952 app/debug: move to exp/app/debug.
Change-Id: I97f3585ff155e8c5b95c5bb32cfa793980c81a9a
Reviewed-on: https://go-review.googlesource.com/11821
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-30 23:41:11 +00:00
David Crawshaw
8bb4ca139b asset: move app.Open to its own package
This does not break the dependency on the app package's AndroidContext
for loading assets on android. A potential answer for gobind-based
apps: add a SetAndroidContext method to app.Context. But I'll explore
that separately after the long weekend.

Change-Id: I812f899740e288c379eee7900f42d9d53926d4ce
Reviewed-on: https://go-review.googlesource.com/11675
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-29 21:49:28 +00:00
David Crawshaw
8144405762 app, bind: separate the app package from gobind
Historically, the app package implemented Go runtime initialization.
This was convoluted, so the package was used both by all-Go apps
(currently based on Android's NativeActivity) and bind-based apps.

With Go 1.5 we have -buildmode=c-shared, which does a lot of the work
of the old app package. That code was removed a while back, but both
all-Go and gobind-based apps still used package app. The intermingled
initialization processes led to some strange states.

This CL separates gobind-based apps completely from the app package.
As part of that users are now expected to use System.loadLibrary
themselves. (A future CL may want to make the loadLibrary call part
of the .aar generated by gomobile bind.)

Delete the libhello example, which has been replaced by gomobile bind,
which could do with its own example at some point. Also delete the
libhellojni example, which now has nothing to do with the x/mobile
repository.

Change-Id: I444397f246dbafe81e5c53532eb482c197d26f70
Reviewed-on: https://go-review.googlesource.com/11654
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-29 11:40:40 +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