Commit Graph

1396 Commits

Author SHA1 Message Date
Elias Naur ea85e80dc8 io/router: support multiple pointer areas for same tag
Fixes gio#129

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 14:53:19 +02:00
Elias Naur 1c68b7d585 io/router: shorten tests by using f32.Pt short-hand
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 14:44:41 +02:00
Elias Naur 35e477757b io/router: remove redundant pointerHandler.transform field
The area transform is already stored in areaNode.

Updates gio#129

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 13:05:06 +02:00
Elias Naur 64a516d7c9 app/internal/window: [Windows] avoid race between Main and window closes
While here, replace the window hwnd-to-window map with a sync.Map.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 11:39:40 +02:00
Chris Waldon bda315e687 example/kitchen: add a button that is {dis,en}abled by the switch
This adds a simple button that defaults to being disabled, but can
be enabled by toggling the state of the existing Switch widget.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-06-08 10:19:31 +02:00
Chris Waldon cc5f8fcffe widget/material: add support for disabled buttons
This leverages the new semantics of a disabled layout.Context
to draw all of the button types in a disabled state.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-06-08 10:16:50 +02:00
Chris Waldon 3a31045dc9 layout: add Disabled method to Context
This adds a simple method that returns a copy of the Context
with no event queue. Widgets laid out with this Context will
never receive events, and can check whether the event queue
is nil as a hint for whether or not to draw themselves as
disabled.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-06-08 10:16:50 +02:00
Elias Naur d280d438c7 io/router: don't clear event queue before cancel events
There may be unrelated events in the queue, so it's not appropriate
to clear the queue just because an input Cancel event occurs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 18:20:18 +02:00
Elias Naur d86f96503f app/internal/window: [macOS] fix window sizes for unit.Px values
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 17:49:59 +02:00
Elias Naur 8761550839 widget: fix Enum.Changed to reset changed status
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 17:06:03 +02:00
Elias Naur b3d14d2dd4 example/windows: add example that demonstrates multiple windows
Updates gio#19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 16:33:39 +02:00
Elias Naur 352856fc24 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 16:33:39 +02:00
Elias Naur f710bdf8e8 app: update NewWindow docs to reflect multi-window support
Fixes gio#19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 16:31:06 +02:00
Elias Naur b07d34354e text,widget/material: make font collections explicit
Before this change, package font implemented a global font registry,
with the usual problems of package global state.

This change deletes the global registry and introduces the text.Collection
type for representing a list of fonts and their faces. Collection exports
Lookup that finds the closest match and its face.

The existing FontRegistry is renamed to Cache to reflect its new limited
functionality: a cache of shapes and measurements on top of a Collection.

Then, material.NewTheme is changed to take a Collection and initialize
a Cache.

Updates gio#19 because multiple windows require a separate (writable) Cache per
window, while (read-only) Collections may be shared.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 16:27:43 +02:00
Elias Naur c2c31a4d00 app/internal/window: [Windows] support multiple windows
Updates gio#19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 16:27:43 +02:00
Elias Naur 65078cdece app/internal/window: [macOS] simplify NewWindow
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 14:48:54 +02:00
Elias Naur 78565c9232 cmd,example: bump gio version
Updates gio#128

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 08:44:41 +02:00
Elias Naur 483084f4be app/internal/window: [macOS] delay window creation until ready
Fixes #128

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 08:42:36 +02:00
Elias Naur 0749afc13c example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-06 19:31:12 +02:00
Elias Naur 144a5a9cf5 app/internal/window: [macOS] introduce serious cascading
This time without arbitrary offsets and with support for multiple
windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-06 19:27:25 +02:00
Elias Naur 4408c2a695 app/internal/window: [macOS] support more than one window
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-06 19:09:02 +02:00
Elias Naur 476bf8d263 app/internal/window: [macOS] only terminate app when last window closes
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 12:10:23 +02:00
Elias Naur 9efdc3409c app/internal/window: [macOS] remove window reference from app delegate
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 12:10:23 +02:00
Elias Naur 7c22a888b1 app/internal/window: [macOS] make GioDelegate window-independent
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 12:10:23 +02:00
Elias Naur 34c212d152 app/internal/window: [macOS] split out gio_createWindow
Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 12:10:23 +02:00
Elias Naur 4f64ac1736 io/pointer: remove special case note
Scroll events are no longer special after gioui.org/commit/65d4707e3.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 11:45:55 +02:00
Elias Naur a4e572d0e3 cmd,example: gump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 10:57:08 +02:00
Elias Naur 65d4707e3e io/pointer,io/router,gesture: add pointer.Foremost priority
Replace the pointer.Scroll special case with a new priority that
indicates the foremost handler, checked in gesture.Scroll.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 10:46:19 +02:00
Elias Naur 2accb88381 app/internal/window: [macOS] fix zero-length clipboard reads
Fixes #126

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 10:09:17 +02:00
Elias Naur 278e9bc334 app/internal/window: [macOS] remove useless retain/release
The window and its view is guaranteed to outlast the display link.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-03 21:20:06 +02:00
Elias Naur c225daa845 app/internal/window: [macOS] use regular map for view-to-window lookups
All accesses to the view map now happens on the main thread, so
there is no need for a sync.Map anymore.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-03 21:20:02 +02:00
Gordon Klaus 1a070a36b6 io/pointer: add Drag event type
This eliminates needless redraws for handlers that care about drag events and not move events, like gesture.Scroll.

Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-03 20:04:16 +02:00
Elias Naur cb5cc02560 app/internal/window: [macOS] remove frivolous cascadeTopLeftFromPoint call
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-03 19:13:06 +02:00
Gordon Klaus 33a87ac61c io/router: deliver scroll events only to the foremost scroll handler
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-03 15:38:56 +02:00
Gordon Klaus 9d2a6c48d8 io/pointer: add InputOp.Types to specify which types of events to receive
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-03 15:29:12 +02:00
Elias Naur 4484674ab1 layout: don't run alloc tests with -race
The race runtime allocates where the non-race runtime doesn't.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-03 10:18:57 +02:00
Gordon Klaus e188d0e6ff io/pointer,gesture,app/internal/window: add pointer.Scroll event type
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-03 10:08:22 +02:00
Elias Naur 275a91f26a io/router: remove countPointerEvents
assertEventSequence is shorter and clearer and more precise.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-03 10:03:53 +02:00
Elias Naur d489c20b84 io/pointer: update documentation examples
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 16:37:38 +02:00
Elias Naur fc290f3457 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 15:49:16 +02:00
Elias Naur 4cb96ccad9 app/internal/window: [macOS] always draw synchronously
Asynchronous draws introduces flickering on resizes.

Fixes #123

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 15:07:04 +02:00
Elias Naur ff71d0c518 io/router: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 14:20:40 +02:00
Elias Naur 9196ce0369 cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 12:20:20 +02:00
Elias Naur c19ed05342 op: change CallOp to be a return value from MacroOp.Stop
Converting

	macro := op.Record(ops)
	...
	macro.Stop()

	macro.Add()

to

	macro := op.Record(ops)
	...
	call := macro.Stop()

	call.Add(ops)

Which is more general (call.Add can take a different ops than the op.Record
that started it), and enforced the order between Stop and the subsequent Add.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 12:07:20 +02:00
Elias Naur ce0cc706ad layout: add test that Flex doesn't allocate
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 11:37:45 +02:00
Elias Naur 2bdf8c3851 layout: add test that Stack doesn't allocate
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 11:36:36 +02:00
Elias Naur acc23a5b3e op: make MacroOp methods take value receivers
The only mutable field is "recording", which is used for a sanity
check. THat check is performed (less generally) by Ops.macroStack.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 11:12:37 +02:00
Elias Naur 3e8c502550 op: return value StackOp from Push and make Pop use a value receiver
To match Record, we'd like Push to return a value. To do that and
support the one-line

	defer op.Push(ops).Pop()

Pop needs to use a value receiver as well. Drop the active field
and make it so. The field was only a sanity check, a check which is
already done by Ops.stackStack, albeit with a less specific panic.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 10:52:46 +02:00
Thomas Bruyelle ae8a377cda op: add op.Push and op.Record funcs
The funcs replace stack.Push and macro.Record, which become private.
This makes stack and macro faster to write, in particular for stacks
where you can just write the following line to save and restore the
state :

  defer op.Push(ops).Pop()

This usage requires Push to return a pointer (since Pop has a pointer
receiver), or else the code doesn't compile.

For consistancy, I tried to do the same for op.Record, but this implied
to turn all the MacroOp fields into pointers, and this caused some
panics. As a result, op.Record doesn't return a pointer.

An other side effect pointed by Larry Clapp: StackOp and MacroOp are not
re-usable any more, you have to allocate a new one for each usage, using
the described funcs above.

Signed-off-by: Thomas Bruyelle <thomas.bruyelle@gmail.com>
2020-06-02 10:39:56 +02:00
Pierre.Curto bade277876 widget: Clickable: added support for NumClicks
Clickable.Clicks() now returns the number of clicks.

Signed-off-by: Pierre.Curto <pierre.curto@gmail.com>
2020-06-02 10:26:14 +02:00