Commit Graph

1309 Commits

Author SHA1 Message Date
Elias Naur 22b367cb33 app/internal/window: [Android] don't block in runOnMain
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-20 20:22:45 +02:00
Elias Naur ac62e3a7ab op/clip: add Rect.Add shorthand
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-20 10:21:11 +02:00
Elias Naur 7a13c2c905 widget/material: correctly apply alpha to ProgressBar color
color.RGBA values are pre-multiplied, so transparency must be applied
to all components.

Fixes gio#117

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 15:39:43 +02:00
Elias Naur 5a8e1c5acf layout: expand Constraints documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 15:21:27 +02:00
Elias Naur 013ea395b4 all: use new rectangle and point convenience functions
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 11:03:30 +02:00
Elias Naur d82eb8fc66 layout,f32: add convenience functions for rectangles and points
layout.FRect, layout.FPt for converting from integer to floating point,
useful for drawing operations.

f32.Pt is a shorthand that mirrors image.Pt.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 10:59:32 +02:00
Elias Naur 99080023e4 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 10:16:25 +02:00
Elias Naur dac8ffc002 layout: add Exact for constructing rigid Constraints matching a size
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 10:12:11 +02:00
Elias Naur 8a6d4f699c layout: expand Stack documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 10:05:27 +02:00
Elias Naur 7bf3265ccd layout,widget: transpose Constraints to use image.Points for limits
Instead of

    type Contraints struct {
	    Width, Height Constraint
    }

use

    type Constraints struct {
	    Min, Max image.Point
    }

which leads to simpler use. For example, the Min method is trivally replaced by
the field, and the RigidConstraints constructor is no longer a net win.

API Change. Rewrites:

    gofmt -r 'gtx.Constraints.Min() -> gtx.Constraints.Min'
    gofmt -r 'gtx.Constraints.Width.Min -> gtx.Constraints.Min.X'
    gofmt -r 'gtx.Constraints.Height.Min -> gtx.Constraints.Min.Y'
    gofmt -r 'gtx.Constraints.Height.Max -> gtx.Constraints.Max.Y'
    gofmt -r 'gtx.Constraints.Width.Max -> gtx.Constraints.Max.X'

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 09:58:07 +02:00
Elias Naur 67a9d9e9d7 io/system: improve FrameEvent documentation
Phrase stolen from Egon's architecture document.

Replace tabs with spaces in the example while here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-18 17:52:54 +02:00
Wagner Riffel 0bf6de6cfa f32: add package Rect shorthand function
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2020-05-18 11:11:03 +02:00
Elias Naur dc7a8fd9ea example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:52:17 +02:00
Elias Naur 03db2817ac all: rename io/event.Key to Tag
Key had an unfortunate association with keyboard input.

This is an API change. The following rewrites were run to fixup
Gio code:

        $ gofmt -r 'pointer.InputOp{Key:a} -> pointer.InputOp{Tag:a}' -w .
        $ gofmt -r 'pointer.InputOp{Key:a, Grab:b} -> pointer.InputOp{Tag:a, Grab:b}' -w .
        $ gofmt -r 'key.InputOp{Key:a} -> key.InputOp{Tag:a}' -w .
        $ gofmt -r 'key.InputOp{Key:a, Focus:b} -> key.InputOp{Tag:a, Focus:b}' -w .
        $ gofmt -r 'event.Key -> event.Tag' -w .

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:48:12 +02:00
Elias Naur e89277951c example/kitchen: add clipboard example
Updates gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:14:30 +02:00
Elias Naur 59bc001677 app,io/system: implement clipboard reading and writing
The app.ReadClipboard and app.WriteClipboard can be used to interact
with the system clipboard. The clipboard may be asynchronous, so
system.ClipboardEvent is introduced to deliver the result of a read.

Updates gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:12:45 +02:00
Elias Naur f210651b08 app/internal/window,app/internal/windows: implement Windows clipboard access
Update gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:12:45 +02:00
Elias Naur 20fc81a57a app/internal/window: [wasm] implement clipboard
Update gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:12:45 +02:00
Elias Naur 503534e84e app/internal/window: [Android] move main thread dispatching to Go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:12:45 +02:00
Elias Naur bb4a02babc app/internal/window: [iOS] implement clipboard
Updates gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:12:45 +02:00
Elias Naur 7b5a03e0ec app/internal/window: X11 clipboard support
Updates gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:12:45 +02:00
Elias Naur 2da1d37ce7 app: implement Wayland clipboard support
Updates gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:12:45 +02:00
Elias Naur 9534337a43 app/internal/window: macOS clipboard support
Updates gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 1e934673d7 app/internal/window: [Android] implement clipboard
Updates gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 268e9e44b8 io/system: add ClipboardEvent for sending clipboard updates
Not wired up yet; each platform needs implementing low-level access
first.

Updates gio#31

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur fc0c046cab app/internal/window: [iOS] move main thread dispatch to Go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 77899c79d9 app/internal/window: [iOS] fold header files into Go preambles
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 0da1b1bdbc app/internal/log: fold header file into Go preamble
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur cfc1991ded app/headless: fold header files into Go preambles
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 5a0d183202 app/internal/window: [Android] fold os_android.h into os_android.go preamble
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur bfbb95674b app/internal/window: [Wayland] fold os_wayland.h into os_wayland.go preamble
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 10a81bf217 app/internal/window: [macOS] fold header files into Cgo preambles
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 85a75ee265 app/internal/window: [macOS] move main thread dispatching to Go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 65d79f295f app/internal/app: introduce runOnMain for main thread callbacks
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur a3dc2d6cdc app/internal/window: [macOS] run most callbacks on the main thread
Before this change, we had a viewDo that serialized a function on a view
on a single goroutine. For better or worse, most callbacks in Cocoa
happen on the main thread, so we might as well use that.

The only exception is the frame callback from the CADisplayLink.
We could force that through the main thread as well, but for
efficiency settle with making the view-to-window map synchronized.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 3569b0f31b app/internal/window: [macOS] assume valid view in synchronous draws
Asynchronous drawing happens only in onFrameCallback, where we have to
check for disappearing views. onDraw however, is synchronous and should
always have a valid view.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur bd8757e51f app/internal/window: [X11] make the notification pipe wakeup only
Before, the wakeup pipe both woke the event loop and implied a redraw.
We're going to use the notication for more, so deduce the need for redraw
from window state instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 4e3bc8f9aa app/clipboard: delete
The implementation was too optimistic: some platforms require a
window context for accessing the clipboard.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 15:43:12 +02:00
Elias Naur 53e3f0027c app: ignore incoming window events to dead windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 12:41:41 +02:00
Elias Naur e093ea28f7 app: ensure waiting window requests are stopped when a window closes
The Android RegisterFragment method would leak a goroutine if called
after the window was destroyed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 12:41:41 +02:00
Elias Naur b99151c211 app/internal/window: [Wayland] make notifications wakeup-only
Before, notifying the event loop implied a redraw. Derive the need
for redrawing expliticly and use the notification pipe for wakeups
only.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 12:09:18 +02:00
Elias Naur f2fee00bab Revert "gesture: only report TypePress for Click gestures if pointer is grabbed"
This reverts commit 062e2bc54b.

Reason: delays the press too much for the common case of an embedding List.
2020-05-16 12:09:18 +02:00
Elias Naur 9259b8f743 app/internal/window: [Wayland] move window-specific resource checks to window
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 44aec72d42 app/internal/window: [Wayland] move cursor from display to window
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 9daf082d22 app/internal/window: defer window and display destructors
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 728c20ab4a app/internal/window: [Wayland] move event processing to wlDisplay
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 26641344bc app/internal/window: [Wayland] move notification channel to wlDisplay
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 55881fc09c app/internal/window: [Wayland] remove redundant event dispatch
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 28a3de6e32 app/internal/window: [Wayland] delete unused field
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 0181f22d01 app/internal/window: block Main until all windows are closed
With this change, the Wayland backend now supports multiple windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00