Граф коммитов

332 Коммитов

Автор SHA1 Сообщение Дата
Nigel Tao 03962049e1 shiny/iconvg: handle x/image/vector args dropping the f32.Vec2.
Change-Id: I81924868cdd0847923213013f7a74621a85b9761
Reviewed-on: https://go-review.googlesource.com/32773
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-11-15 00:53:41 +00:00
Nigel Tao d4689a4355 shiny/iconvg: rearrange some encode_test.go functions.
They now match the alphabetical order in testdata/README.

Change-Id: I03688c5a29c42e2a4683331fe97f72ed9828af0f
Reviewed-on: https://go-review.googlesource.com/32135
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-26 22:26:49 +00:00
Nigel Tao fb66711f39 shiny/iconvg: implement suggested palettes.
Change-Id: I5bd5f0d1c0c5c83be0216eb149c87fbce595d7ab
Reviewed-on: https://go-review.googlesource.com/31374
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-22 21:37:11 +00:00
Nigel Tao 8fd4879c86 shiny/iconvg: implement elliptical gradients.
Change-Id: I8db1977187c1137823b88d4616f6dc3d6ee70968
Reviewed-on: https://go-review.googlesource.com/31542
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-22 21:32:24 +00:00
Nigel Tao 77b22eef4f shiny/iconvg: regenerate testdata/*.png renderings.
The existing compare-to-golden reference renderings no longer matched
the actual output after the vector renderer changed in
https://golang.org/cl/31532 "vector: change ϕ from 10 to 9".

Change-Id: Iea1980065eee30c3e46927eac7dff65ac2d7c51e
Reviewed-on: https://go-review.googlesource.com/31545
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-10-22 08:27:14 +00:00
Shenghou Ma 3101306bde shiny/driver/x11driver: add support for other architectures on linux
Tested on linux/386.

Change-Id: I9a3a2744a0b057e258189780ca29f4bf2a72deb8
Reviewed-on: https://go-review.googlesource.com/31652
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-10-22 08:16:24 +00:00
tomheng 1f05e9045d shiny/driver: use new style mask and event constants on OSX 10.12
Some variables had been deprected since macOS, so we should use the new recommend one
and declare them on older OS X releases using Conditional compilation.

Fixes golang/go#17413.

Change-Id: Ib7e92e7e9bddb8d7940bd85e1f3db4535fcdbef0
Reviewed-on: https://go-review.googlesource.com/31543
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-21 11:18:01 +00:00
Nigel Tao 8e337e3095 shiny/example/widgetgallery: rename gallery to widgetgallery.
There's now also an example/icongallery.

Change-Id: Id677877a76d1d529c377d52385d643597badaf08
Reviewed-on: https://go-review.googlesource.com/31590
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 22:15:24 +00:00
David Crawshaw 160d7f5d3a Revert of shiny/driver: repace style mask and event constants deprecated since OSX 10.12
Reason for revert: constants not available on older OS X releases

Original issue's description:
> shiny/driver: repace style mask and event constants deprecated since OSX 10.12
> 
> Fixes golang/go#17413.
> 
> Change-Id: I4cc8a980fc1d6a45ceef48b282baa7a94663ae10
> Reviewed-on: https://go-review.googlesource.com/31539
> Reviewed-by: David Crawshaw <crawshaw@golang.org>
> 

Change-Id: I35bd4301ebf63689d6b7bb49a29b9ef85657ba1e
Reviewed-on: https://go-review.googlesource.com/31613
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 16:09:43 +00:00
tomheng 2a043f9483 shiny/driver: repace style mask and event constants deprecated since OSX 10.12
Fixes golang/go#17413.

Change-Id: I4cc8a980fc1d6a45ceef48b282baa7a94663ae10
Reviewed-on: https://go-review.googlesource.com/31539
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 15:00:35 +00:00
Nigel Tao 13aa1b9546 shiny/iconvg: implement gradients.
Change-Id: I7510d7f9b4182882853840987510522ad7ab0935
Reviewed-on: https://go-review.googlesource.com/31375
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 10:16:01 +00:00
Nigel Tao d96b5d282e shiny/example/icongallery: new example.
Change-Id: Idec41e7a1de0f5b7b1a794a3c317a3d7eae570f3
Reviewed-on: https://go-review.googlesource.com/31533
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 04:31:42 +00:00
Nigel Tao 585538dc76 shiny/iconvg: add note to think about Right-To-Left languages.
Change-Id: I583c0162e24cbd84170b48cb463e70ddfe64823b
Reviewed-on: https://go-review.googlesource.com/31531
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 04:02:16 +00:00
Nigel Tao 1d1aa78131 exp/shiny/iconvg: add testdata/favicon.
Also fix a Rasterizer.AbsArcTo bug. The testdata/arcs example, based on
the examples from the SVG spec, only uses RelArcTo.

Change-Id: Iad94323eedfdf40938543692cdf3faf0731796bf
Reviewed-on: https://go-review.googlesource.com/31372
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-19 04:01:52 +00:00
Nigel Tao 54ebac48fc exp/shiny/iconvg: quantize StartPath coordinates.
They should also be affected by Encoder.HighResolutionCoordinates.

Change-Id: I14c3fb56bddd6684dc59f947201774c1f4e58ead
Reviewed-on: https://go-review.googlesource.com/31373
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-19 03:57:35 +00:00
Nigel Tao 62c1663ba1 shiny/materialdesign/icons: generate the full icon set.
Change-Id: Idd4487bb91c24e400dfe24cfba4ed212f5241f29
Reviewed-on: https://go-review.googlesource.com/31124
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-18 06:55:47 +00:00
Nigel Tao 356123cc37 shiny/iconvg: implement arcs.
Change-Id: Id2948c1244afcf0f76410d981ebf2ad341168fa3
Reviewed-on: https://go-review.googlesource.com/31115
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-15 07:00:52 +00:00
Nigel Tao 2317e4db43 shiny/iconvg: make HighResolutionCoordinates optional.
On the full Material Design icon set, the 950 or so icons take up around
40% more bytes (172K vs 123K) at high resolution.

Change-Id: I6bd59c3aa75f7fc251c4283a0b244c656f1f9b86
Reviewed-on: https://go-review.googlesource.com/31111
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-14 23:57:30 +00:00
Nigel Tao 39af320eb4 shiny/materialdesign/icons: new package.
Change-Id: I717425a5dd47c325dc3f17286ede48932451d0cc
Reviewed-on: https://go-review.googlesource.com/30572
Reviewed-by: Sebastien Binet <seb.binet@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-13 23:26:53 +00:00
Nigel Tao e987cd14b8 shiny/iconvg: fix test breakage for the LOD case.
Change-Id: I0907f28110b2d6072c737821ad7152d306da191a
Reviewed-on: https://go-review.googlesource.com/30900
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-10-13 11:58:38 +00:00
Nigel Tao cb50aa2900 shiny/iconvg: implement Level Of Detail (LOD).
Change-Id: I39dd38b828eae2a00cbca6a6dc9354ff4b21e027
Reviewed-on: https://go-review.googlesource.com/30830
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-13 09:44:42 +00:00
Egon Elbre 807d650904 shiny/driver/gldriver: try multiple ANGLE platforms
On Windows mobile/gl uses ANGLE for EGL. ANGLE has multiple backends
and for some graphics cards one of these may work better than other.

Automatically try to choose the next platform when initialization fails:
1. Default
2. Direct3D 11
3. Direct3D 9
4. Direct3D 11 with WARP

Change-Id: Ief0911574afaf4ded3f578a1cd7b9639828f3486
Reviewed-on: https://go-review.googlesource.com/30754
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2016-10-12 12:24:32 +00:00
Nigel Tao 42596718c7 shiny/iconvg: add testdata/blank.ivg.
Change-Id: I24c19f54fe53513f1c3e70e47339d6fabc80c06b
Reviewed-on: https://go-review.googlesource.com/30734
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-11 07:53:09 +00:00
Nigel Tao 179d6e5f4d shiny/iconvg: add disassembly testdata.
Change-Id: Ia001d185d383b8a63096b215e9981968dfc1cd76
Reviewed-on: https://go-review.googlesource.com/30733
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-10 01:34:11 +00:00
Nigel Tao c686a6683f shiny/iconvg: make a decoding example_test.
Change-Id: I5e1c4d317ac00fddc787e41fd966c3f9e221bf78
Reviewed-on: https://go-review.googlesource.com/30570
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-09 22:55:42 +00:00
Nigel Tao c9a9d1b9ac shiny/iconvg: fix color blending.
Change-Id: I1be11ef544670b6d111fcd3db571b77202da103e
Reviewed-on: https://go-review.googlesource.com/30571
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-09 22:54:51 +00:00
Nigel Tao f2486d8f47 shiny/iconvg: implement colors.
Gradients remains a TODO.

Change-Id: Ia3eb4a2340cccffc83d0e051176b47615b3eed71
Reviewed-on: https://go-review.googlesource.com/30172
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-06 09:21:13 +00:00
Nigel Tao 3a707a345d shiny/iconvg: make the zero Encoder value usable.
Change-Id: Iee4b4be38ef43dab1475bf5cebdb678b08f8c29a
Reviewed-on: https://go-review.googlesource.com/29890
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-30 06:48:33 +00:00
Nigel Tao dabc0cb718 shiny/iconvg: implement a decoder.
Change-Id: I488531c8ae5b929e178de481f30acf0f88833b83
Reviewed-on: https://go-review.googlesource.com/29698
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-27 04:25:39 +00:00
Nigel Tao 77977c4438 shiny/iconvg: add 3 byte color encodings.
There are two new encodings, direct and indirect.

The indirect encoding, or at least some way to water down a custom palette
color, is necessary for icons like
https://raw.githubusercontent.com/google/material-design-icons/master/device/svg/production/ic_signal_wifi_2_bar_48px.svg
which say `<path fill-opacity=".3" d="etc">`. Rendering such icons need a
partially transparent version of a custom palette color, e.g. the theme
foreground color, which could be black for a traditional theme or white for a
dark theme.

The direct encoding doesn't offer anything beyond the existing 4 byte encoding,
other than being a shorter encoding. It could come up relatively often, though,
if e.g. the suggested palette's elements are all fully opaque. Reserved styling
opcodes aren't particularly scarce, so I think it's a win overall. I think we
might as well add it now, if we're adding the 3 byte indirect encoding, and
avoid re-basing the other opcodes again if we added it separately.

Also fix some opcode typos in encode.go, with TODOs for more tests.

Change-Id: I0dd004b8ccbeab77dbb6a954f650e7b470ef9af7
Reviewed-on: https://go-review.googlesource.com/29451
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-21 03:48:13 +00:00
Nigel Tao ccd3679621 shiny/iconvg: implement an encoder.
Change-Id: Ib34dca2ae43ba116784a098d0fa2d4cace92aef1
Reviewed-on: https://go-review.googlesource.com/29135
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-20 05:43:34 +00:00
Nigel Tao 1e90bdaf35 shiny/materialdesign/colornames: new package for named colors.
Change-Id: Ie61fe3d3385df7e1fc0ae814aeab165e8d368e6c
Reviewed-on: https://go-review.googlesource.com/29334
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-18 01:15:45 +00:00
Nigel Tao 00048b0dda shiny/iconvg: new package for a new format.
Docs only in this commit. Future commits will add code.

Change-Id: Ifb191dacdb317f565cb1b4a343c37941a6b05ec1
Reviewed-on: https://go-review.googlesource.com/28991
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-15 10:31:27 +00:00
Nigel Tao 14f0c66cee shiny/widget: let a Flow shrink as well as expand.
This will be needed for scrollable Sheets, where the parent (the Sheet)
should be laid out at a smaller size than its child.

Change-Id: Iacf69c90f263f24f9fd149f3864d23737c1593a8
Reviewed-on: https://go-review.googlesource.com/28345
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-04 08:27:17 +00:00
Nigel Tao da927ba5e2 shiny/driver/x11driver: fix ipcCreat constant.
That constant value had a typo. Its value (defined in
/usr/include/linux/ipc.h) is in octal, not hexadecimal.

"man shmget" suggests that the IPC_CREAT flag isn't necessary if the key
is IPC_PRIVATE, as has proven in practice by the current code passing
the wrong flag bit all along.

The best fix, for the Go code, is to delete all mentions of ipcCreat.

Change-Id: I1ec701b3069c35445058c1149f2e9d15bbf4cf4c
Reviewed-on: https://go-review.googlesource.com/28012
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-29 23:06:55 +00:00
Nigel Tao eb1e5e7fc7 shiny/widget: add width and height hints to Measure.
Change-Id: I6851e14709a3249e3b9281d5c3b8008c0ca50f6f
Reviewed-on: https://go-review.googlesource.com/26910
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-18 01:22:54 +00:00
Nigel Tao 7bf9f5bbc7 shiny/widget: add OnLifecycleEvent.
Change-Id: Ia2789e5a300a3b89188d3c009b40cc3ad9d39cc2
Reviewed-on: https://go-review.googlesource.com/25520
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-11 23:52:44 +00:00
Nigel Tao 6e7e2f19a2 shiny/widget: have Sheet.Paint honor origin and widget rect.
Also split the example/textedit UI into a header and body.

Change-Id: Id95cf599de35ce8a86cf50d9b3ed744b2ab23d6e
Reviewed-on: https://go-review.googlesource.com/25471
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-05 01:18:19 +00:00
Nigel Tao b2ed0200a8 shiny/driver/gldriver: (Cocoa) use the lifecycler.
Change-Id: Ic72c2ed7840d53c73da03649d7b221467b297007
Reviewed-on: https://go-review.googlesource.com/25351
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-04 02:41:14 +00:00
Nigel Tao fac9e6d4e3 shiny/driver/x11driver: sync with the X11 server on Publish.
Change-Id: Id443a021db0ff1748bf5c86df30e074bbf28ddb0
Reviewed-on: https://go-review.googlesource.com/25350
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-29 23:24:53 +00:00
Nigel Tao 3c4824dd1c shiny/widget/node: split Paint into Paint and PaintBase.
Also introduce the Sheet widget.

Follow-up changes will implement smooth scrolling, where cached textures
are simply re-drawn at different offsets, instead of a window-sized
buffer being drawn on and uploaded from scratch on every paint cycle.

Change-Id: Iea291a064200cb658004846cd6cf075131644464
Reviewed-on: https://go-review.googlesource.com/25321
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-29 00:06:37 +00:00
Nigel Tao 3ab07599bd shiny/driver/internal/lifecycler: add a drawContext arg.
The X11 gldriver doesn't set this, but it should, to be consistent with
Mac and Windows.

Change-Id: If64a65ba2efde9ecc90a5d1b0289441f6724005f
Reviewed-on: https://go-review.googlesource.com/25322
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-28 21:23:30 +00:00
Nigel Tao a8a52cda1d shiny/widget/theme: add a Color type.
Change-Id: I333ab9ea0f7b4a488c09bc47398d049810d71082
Reviewed-on: https://go-review.googlesource.com/25162
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-28 06:27:42 +00:00
Nigel Tao d9647ecdd0 shiny/widget: add Padder and Space widgets.
Change-Id: I0ba31ee05fc2d3d91fb9647f83f2b31b9bf9eb9c
Reviewed-on: https://go-review.googlesource.com/25161
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-27 23:46:21 +00:00
Nigel Tao 9a68861d0d shiny/example/gallery: build fix.
This should have been updated in f677a3c4 but was missed.

Change-Id: I6e5561af7ededd6c69d0f880c8c53432b3dbae83
Reviewed-on: https://go-review.googlesource.com/25160
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-07-23 08:19:25 +00:00
Alessandro Arzilli 9fc1c5cb40 shiny: add Compose key support for X11
Fixes golang/go#16332

Change-Id: Id72fe556380acca6c0cb20af7bda3bcec3783b4e
Reviewed-on: https://go-review.googlesource.com/24881
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-07-21 02:19:09 +00:00
Alex Brainman 7be2ce3612 shiny/driver/windriver: use StretchBlt when AlphaBlend is not available
Fixes golang/go#15668

Change-Id: I482f3f068cad79351f45c91e77faa1ec5f3b6060
Reviewed-on: https://go-review.googlesource.com/23110
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-07-17 07:39:57 +00:00
Nigel Tao bb8c306168 shiny/driver/gldriver: (X11) calculate PixelsPerPt.
This matches the x11driver.

Change-Id: I73cfc9e97a2291ff6c81f554268173838b0cd663
Reviewed-on: https://go-review.googlesource.com/24922
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-15 06:19:42 +00:00
Alex Brainman a435354249 shiny: make "go generate" command work on any OS
See issue golang/go#16368 for details.

Updates golang/go#16368

Change-Id: I6fe194b34ff9bb24d78e93a1bca76245385759f4
Reviewed-on: https://go-review.googlesource.com/24951
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-07-15 05:49:13 +00:00
Alex Brainman 09406ba090 shiny/driver/windriver: implement DrawUniform
Change-Id: Ia3be4e5b60f2330f8b593f72b93f2dfc6cda9c7b
Reviewed-on: https://go-review.googlesource.com/24950
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-07-15 05:48:30 +00:00
Alex Brainman ba190a0bf2 shiny/driver/internal/win32: use //go:uintptrescapes
Use //go:uintptrescapes for SendMessage and SendScreenMessage
to force its parameters to be stored on the heap.

Fixes golang/go#16341.

Change-Id: Idf12c75d0690a91f97448a6af42a048bdf7854a0
Reviewed-on: https://go-review.googlesource.com/24921
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-07-15 02:00:28 +00:00
Nigel Tao 0dcff69e0a shiny/widget/flex: build fix for the test code.
The widget.NewUniform signature changed in
https://go-review.googlesource.com/#/c/24871/

Change-Id: I7713df75d3cff87fbb1130d0880ad8b2b61abd1a
Reviewed-on: https://go-review.googlesource.com/24920
Reviewed-by: David Symonds <dsymonds@golang.org>
2016-07-14 02:42:57 +00:00
Nigel Tao f3b6d9893e shiny/widget: make Uniform a shell, not a leaf.
This lets us use a Uniform to fill a background color for other widgets.

Change-Id: I5f062296a0441ceb371d5ea94d6db7f4dab8f94c
Reviewed-on: https://go-review.googlesource.com/24872
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-13 22:50:58 +00:00
Nigel Tao f677a3c455 shiny/widget/node: generalize MarkNeedsPaint to Marks.
An upcoming change will distinguish between 'base' and 'top' paint
passes.

Change-Id: I8e2fcc97c1b7d90302c8f8ad8b3b89ab3bfc0e11
Reviewed-on: https://go-review.googlesource.com/24873
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-13 22:46:43 +00:00
Nigel Tao a16ab4a434 shiny/widget: add a Sizer widget.
Also remove the size fields from a Uniform.

Change-Id: I468eedeb5bc004f0f8caaadba146972c2e0c1e9f
Reviewed-on: https://go-review.googlesource.com/24871
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-13 00:09:02 +00:00
Nigel Tao 405556ced7 shiny/screen: add a DrawUniform method.
Change-Id: I4126fe22ac6262627a20332e5bac148c4981045c
Reviewed-on: https://go-review.googlesource.com/24754
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-10 04:01:29 +00:00
Nigel Tao d7547cb8f0 shiny/driver/gldriver: (cocoa) have wheel buttons send DirStep.
This matches gldriver (X11) and x11driver.

Change-Id: I9a6271b5f2a3725f74ef1c0f1f4f6c2bfc666782
Reviewed-on: https://go-review.googlesource.com/24636
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-07-02 00:18:33 +00:00
Nigel Tao 60b8ef124e shiny/driver: (win32) have wheel buttons send DirStep.
This matches gldriver (X11) and x11driver.

Change-Id: I3236cd6459e9fc148f07c16557f83d741ad04edd
Reviewed-on: https://go-review.googlesource.com/24637
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-02 00:18:15 +00:00
Nigel Tao 087c42272f shiny/driver: (X11) handle mouse.ButtonWheel{Left|Right}; send DirStep.
Also handle mouse.ButtonWheel{Up|Down} for the gldriver X11 flavor.

Change-Id: Ib2fd8ae4ae3ea93a37b0ae1ea40594ce1c3c9b46
Reviewed-on: https://go-review.googlesource.com/24635
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-02 00:10:34 +00:00
Nigel Tao 3cbfd087ee shiny/imageutil: new package.
Add an imageutil.Border function, for drawing outlined-but-not-filled
rectangles, such as widget borders, checkboxes, table cells, etc.

Change-Id: I1e55e5fe492a5d2bb4df6f03ab8d14c9cb9db67d
Reviewed-on: https://go-review.googlesource.com/24632
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-07-01 00:47:02 +00:00
Nigel Tao 3ca9ecf69c shiny/widget/theme: default to inconsolata.Regular8x16.
Change-Id: I42a073d3fbf8898100f83043cb3210a07b770396
Reviewed-on: https://go-review.googlesource.com/24630
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-30 03:43:47 +00:00
Nigel Tao 06a3f3d998 shiny/example/fluid: build fix: s/EventQueue/EventDeque/
Change-Id: I8ee0d73b63fc0441790236ca970593e6dc4e367f
Reviewed-on: https://go-review.googlesource.com/24631
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-30 03:42:33 +00:00
David Crawshaw 162a21c0f5 shiny: introduce glwidget package
A *glwidget.GL renders OpenGL calls into a shiny widget.

It is analogous to NSOpenGLView or GLSurfaceView.

This first version is extremely inefficient, it copies the pixels back
from the GL view to main memory, and then lets the gldriver copy it
again to a texture. But it gets the separate context concept clear,
and efficient rendering can be done in a later CL when the Paint method
has some reasonable way of accessing a Window's underlying GL texture.

It is in its own package to avoid adding a gldriver and cgo dependency
to the widget package.

This CL only contains X11 support, OS X will follow later.

Change-Id: Ib5044b62950eee070cd8b7729250e9c026b24b9f
Reviewed-on: https://go-review.googlesource.com/24300
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-06-29 14:41:18 +00:00
David Crawshaw 1500bdf735 gldriver: (cocoa) invert mouse wheel direction
MouseWheel{Down, Up} are actions for software to respond to, not
faithful retellings of what the physical device did. So in OS X's
default "natural scrolling" mode moving down the trackpad should
report MouseWheelUp.

Fixes golang/go#16020

Change-Id: Ia10aaef1f2c36b16646ff50ba3923685310d1a23
Reviewed-on: https://go-review.googlesource.com/24360
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-06-29 14:37:17 +00:00
Nigel Tao bce12f179c shiny/widget: add NeedsPaint tracking.
Change-Id: I300649bb1bf5eb23fdcfa6d01a7cad220612de5e
Reviewed-on: https://go-review.googlesource.com/24442
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-26 07:07:28 +00:00
Nigel Tao 3f87be713d shiny/widget: have Text.Paint only draw visible lines of text.
Change-Id: If7b59eccd96516953dc5c471683bf30e06220a8b
Reviewed-on: https://go-review.googlesource.com/24441
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-26 07:04:54 +00:00
Nigel Tao bac10ea90a shiny/gesture: new package for gesture events.
Change-Id: I4848263cbdf1da41d3b0dc5b13ca718a4c77c5ee
Reviewed-on: https://go-review.googlesource.com/24201
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-22 23:58:37 +00:00
Nigel Tao c8ad82d60a shiny/screen: change EventQueue to be a deque.
This sets us up for event filters such as gesture recognition, which generate
new events based on the most recent event.

Change-Id: I1aca2e4b1efb6846cd620ffef5b41b32e8cf7dd6
Reviewed-on: https://go-review.googlesource.com/24160
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-16 23:44:28 +00:00
Nigel Tao 16af74a906 shiny/widget: add a RunWindowOptions type.
Change-Id: I1aef0b2b7f5358a08e705bce5748edee63f07fdc
Reviewed-on: https://go-review.googlesource.com/24063
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-15 12:15:59 +00:00
Nigel Tao 991b113486 shiny/widget: add a text widget.
Lots of TODOs. This is just a first step.

Change-Id: I94890970913e5b915de4bad56cfd23e62f9dcd03
Reviewed-on: https://go-review.googlesource.com/24022
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-14 00:55:47 +00:00
David Crawshaw 5c9f2869a3 shiny/driver/gldriver: (X11) GL ES 3.0
Change-Id: Ibf27e0b326837d2bb19b0858471a32cdec04460f
Reviewed-on: https://go-review.googlesource.com/23822
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-06-09 15:05:00 +00:00
Nigel Tao ca6916602b shiny/text: add Height, LineCount and ParagraphCount methods.
Change-Id: I8770ac0ba12a478119b5a1020142c50ce948dd48
Reviewed-on: https://go-review.googlesource.com/23882
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-09 01:12:42 +00:00
Nigel Tao 9e6f92b7d2 shiny/widget/node: add a nextSibling arg to AppendChild.
Also rename AppendChild and RemoveChild to Insert and Remove.

Change-Id: I4a2200054ddae0d2174943c7a0d5da2a084cb451
Reviewed-on: https://go-review.googlesource.com/23743
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-03 23:41:17 +00:00
Nigel Tao 8bbbc12f39 shiny/widget: have NewContainer functions take children as args.
This can simplify building the widget tree, as demonstrated by the
example/layout program.

Also add the widget.WithLayoutData function to facilitate this.

Change-Id: Ia41555ab4d68f0f1057698d637115a80e5d4df3c
Reviewed-on: https://go-review.googlesource.com/23530
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-01 06:20:51 +00:00
Nigel Tao 0dc1be4934 shiny/driver: handle dstPoint or srcRect out of bounds.
This is for gldriver and x11driver. I don't know if the windriver does
the right thing if you pass e.g. dp = image.Pt(-64, 0) or sr =
image.Rect(-64, 0, 256, 128) to the Upload or Draw calls in
example/basic.

Also fix gldriver's Texture.Upload when the srcRect width is less than
the texture width.

Also fix gldriver's Window.Upload then the dstPoint is non-zero.

Also zero-initialize the x11driver's texture's pixels, as the X11 server
doesn't do this automatically.

Change-Id: Ifb6f93e2bea635977bc1ee911457af74acde658f
Reviewed-on: https://go-review.googlesource.com/23469
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-29 01:31:23 +00:00
Nigel Tao 13222e7ab1 shiny/driver/x11driver: set the texture repeat to "pad".
This means that out-of-bound texture reads return the in-bound edge
values instead of returning zero. Since the picture filter is
"bilinear", this is noticeable when scaling the entirety of the texture
(when srcRect = tex.Bounds()), such as in the example/fluid program.
Before this commit, the edges in the destination window were feathered.
After this commit, they are crisp, the same as the gldriver.

See section 9 "Source and Mask Transformations" of
https://www.x.org/releases/current/doc/renderproto/renderproto.txt

Change-Id: I4e4827d35311790bac0cd092fecb3953707976cb
Reviewed-on: https://go-review.googlesource.com/23500
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-27 22:56:44 +00:00
Nigel Tao 4390e29f98 shiny/driver/x11driver: fix non-zero src rect min.
Change-Id: Iecc597515983e078843c3863c3520e49caf20759
Reviewed-on: https://go-review.googlesource.com/23462
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-27 00:38:55 +00:00
David Crawshaw 5db43b795b shiny/widget/flex: justify-content support
Switch to rounding pixels to the closest integer to match Chrome's
output.

Change-Id: I94fea521e3ac40ba642bf5013f3cd48d477581b6
Reviewed-on: https://go-review.googlesource.com/23018
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-26 13:41:13 +00:00
David Crawshaw a41c8b809f shiny/widget/flex: support cross-axis alignment and reverse direction
Change-Id: I46af26ae6f32b193b95a7916bdee67dc3f50453e
Reviewed-on: https://go-review.googlesource.com/23017
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-25 14:50:37 +00:00
Nigel Tao bfb3779392 shiny/driver/gldriver: (cocoa) send mouse events when no button is down.
Change-Id: Id13e7adf0bf39e0dffb375384de3e24c8e8af7cd
Reviewed-on: https://go-review.googlesource.com/23332
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-24 22:59:37 +00:00
Nigel Tao 7576772392 shiny/driver/x11driver: make the mask per-texture instead of per-screen.
Change-Id: I13face3a82cd825663d84423e8beda2801cc700a
Reviewed-on: https://go-review.googlesource.com/23330
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-24 22:58:49 +00:00
Nigel Tao c2f815647a shiny/screen: add a link to the example programs.
Change-Id: If478c5dcf99e78eef017deff5a5f59f43d986e9f
Reviewed-on: https://go-review.googlesource.com/23331
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-24 22:57:05 +00:00
Nigel Tao eef72f398c shiny/example/goban: accomodate one-button mice such as MacBooks.
Change-Id: I6d4826620ae0c23bc363ae1fe8ba2de50feeb18f
Reviewed-on: https://go-review.googlesource.com/23333
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-24 22:52:28 +00:00
Nigel Tao 65a75e2df5 shiny/driver/x11driver: use a smaller (1x1) opaque mask image.
Change-Id: I499a22bfa446f835d4c005726ecabb9d1cde7107
Reviewed-on: https://go-review.googlesource.com/23270
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-21 22:46:47 +00:00
Nigel Tao e13ba9bcbc shiny/driver/gldriver: implement X11 key events.
Change-Id: I55d94ab8ab172884f9c4eee9b665ce15082ca746
Reviewed-on: https://go-review.googlesource.com/23198
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-19 23:54:01 +00:00
Nigel Tao 3b6fac6063 shiny/driver/x11driver: tighten the textureImpl.draw dst rectangle.
Change-Id: Ic65b8c8c0bae114fff607ac09046ad7d02652ecc
Reviewed-on: https://go-review.googlesource.com/23196
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-19 22:45:27 +00:00
David Crawshaw 6e6ea9385d shiny/widget/flex: basics of flex algorithm
Covers sections 9.3, 9.4, and implements a decent chunk of the sizing
described in section 9.7.

Change-Id: Ia3b24c2b568ef94a3ae779525971f29d61c39fe9
Reviewed-on: https://go-review.googlesource.com/23016
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-19 19:36:24 +00:00
David Crawshaw 5f8e80d104 shiny/widget/flex: add HTML printing of tests
The small piece of JavaScript prints the test result table so that it
can be copied directly into flex_test.go.

Change-Id: I8c6cb7f07b2f40b7028cf87c42db77b6924627ff
Reviewed-on: https://go-review.googlesource.com/23015
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-19 19:28:59 +00:00
Nigel Tao 0fea75285c shiny/driver/x11driver: have textureImpl.draw use an opaque mask.
This make the output match gldriver when op == draw.Src even if the
texture itself isn't fully opaque.

Change-Id: Ib2aba62e68da71f32d876def1e1d672c3403d441
Reviewed-on: https://go-review.googlesource.com/23190
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-18 12:50:04 +00:00
Alex Brainman 85546099da shiny/driver/internal/win32: actually send mouse events
At this moment mouse events are only sent when any mouse
button is down. Change this to always send mouse event.

Suggested by Nigel.

Change-Id: I42fe1cb3e7eeecc7eec96bc9356711167e1f5658
Reviewed-on: https://go-review.googlesource.com/23120
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-15 08:29:20 +00:00
David Crawshaw 5ba6c847fe shiny/widget/flex: new package for flex layout
This CL contains a new package, with a Node implementation that will lay
out its children following the CSS flexible layout algorithm.

The algorithm will follow in a subsequent CL.

Change-Id: I9c1af5f9b4b9c6346722b98c48eca521d7c4563d
Reviewed-on: https://go-review.googlesource.com/22683
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-13 23:45:45 +00:00
Nigel Tao 831f5ae1eb shiny/driver/gldriver: implement lifecycle events for X11.
This adds a new shiny/driver/internal/lifecycler package, to share code
across the various drivers.

Also remove the X11 gldriver's ButtonMotionMask event subscription, just
like the x11driver. It is redundant with PointerMotionMask.

Also fix an off-by-one error in the X11 "is a window visible"
calcuation. A 10 pixel wide window located at X == -10 will not be
visible, as the (x+width) upper bound is exclusive, not inclusive.

Change-Id: I0ded722160588e30d1e323a283a0d396ffd398a5
Reviewed-on: https://go-review.googlesource.com/23079
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-13 22:37:59 +00:00
Nigel Tao 48f38d6d96 shiny/driver/gldriver: (cocoa) don't set a mouse button for drags.
This fixes the example/fluid program.

Change-Id: Ia97bcb3db8f856f31ba39a2ce9649f6dabb27166
Reviewed-on: https://go-review.googlesource.com/23113
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-13 22:29:50 +00:00
Nigel Tao 8c14f43fbd shiny/widget/node: rename some function args.
FooEmbed receivers go from e to m. Event args go from ev to e.

Using e for events is consistent with other shiny code, such as
widget.go.

Change-Id: I4a33534616514ee8086896aff79d7c9a9c79a99d
Reviewed-on: https://go-review.googlesource.com/23075
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-13 22:28:36 +00:00
Alex Brainman 09bebe5f31 shiny/driver: only load Windows DLLs from the System32 directory
See issue golang/go#14959 for details.

Change-Id: I7c06b23b5cb98e4330fb85c025cad2cbd3db37ae
Reviewed-on: https://go-review.googlesource.com/23025
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-13 00:52:05 +00:00
Nigel Tao fa1b5a4b3a shiny/widget/node: add an OnMouseEvent method.
Change-Id: Ib3e001793e9bcb5c3bfc7577b93914873cd03d30
Reviewed-on: https://go-review.googlesource.com/23071
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-13 00:49:16 +00:00
Nigel Tao 737050245c shiny/widget: eliminate the Class concept.
There is no longer both Button and buttonClass types. There is now only one
type: Button.

In the shiny/widget/node package, the abstract and concrete types have been
renamed from Class and Node to Node and Embed.

Change-Id: I659edd23f40b8d2b3838e32cec542a5b8d1d5190
Reviewed-on: https://go-review.googlesource.com/22991
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-11 22:15:36 +00:00
Nigel Tao b13de41a1c shiny/widget: split off node and theme packages.
This de-clutters the top-level widget package, and focuses its package godoc
more for those using widgets and less for those implementing custom widgets.
The former should be the more common case.

Change-Id: I7e955a1b0aa59d05128fef83903f2d6cc138be68
Reviewed-on: https://go-review.googlesource.com/22934
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-09 22:12:42 +00:00
Alex Brainman 1c64c01b8b shiny/driver/windriver: cleanup documentation and some code
Remove outdated documentation.

Add some references to articles demonstrating how
to create GUI on Windows.

Also change mkbitmap to accept image.Point.

Change-Id: I2170047262d2ee1b0fab61b4d356da4c7f6153f4
Reviewed-on: https://go-review.googlesource.com/22913
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-09 07:30:11 +00:00
Nigel Tao cf9865442d shiny/widget: introduce the NodeWrapper type.
This eliminates the ".Node" in a number of "foo.Node" expressions.

Change-Id: I1e6c72a9e3244c7f2731ed4b6180316b53ce43f3
Reviewed-on: https://go-review.googlesource.com/22828
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-08 21:40:37 +00:00