app: update documentation

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-28 14:14:10 -06:00
parent e59f91dfd0
commit eae39d8556
3 changed files with 17 additions and 24 deletions
+8 -9
View File
@@ -27,19 +27,18 @@ var extraArgs string
// On Android ID is the package property of AndroidManifest.xml, // On Android ID is the package property of AndroidManifest.xml,
// on iOS ID is the CFBundleIdentifier of the app Info.plist, // on iOS ID is the CFBundleIdentifier of the app Info.plist,
// on Wayland it is the toplevel app_id, // on Wayland it is the toplevel app_id,
// on X11 it is the X11 XClassHint // on X11 it is the X11 XClassHint.
// //
// ID is set by the gogio tool or manually with the -X linker flag. For example, // ID is set by the [gioui.org/cmd/gogio] tool or manually with the -X linker flag. For example,
// //
// go build -ldflags="-X 'gioui.org/app.ID=org.gioui.example.Kitchen'" . // go build -ldflags="-X 'gioui.org/app.ID=org.gioui.example.Kitchen'" .
// //
// Note that ID is treated as a constant, and that changing it at runtime // Note that ID is treated as a constant, and that changing it at runtime
// is not supported. Default value of ID is filepath.Base(os.Args[0]). // is not supported. The default value of ID is filepath.Base(os.Args[0]).
var ID = "" var ID = ""
// A FrameEvent requests a new frame in the form of a list of // A FrameEvent requests a new frame in the form of a list of
// operations that describes what to display and how to handle // operations that describes the window content.
// input.
type FrameEvent struct { type FrameEvent struct {
// Now is the current animation. Use Now instead of time.Now to // Now is the current animation. Use Now instead of time.Now to
// synchronize animation and to avoid the time.Now call overhead. // synchronize animation and to avoid the time.Now call overhead.
@@ -53,7 +52,7 @@ type FrameEvent struct {
// Frame completes the FrameEvent by drawing the graphical operations // Frame completes the FrameEvent by drawing the graphical operations
// from ops into the window. // from ops into the window.
Frame func(frame *op.Ops) Frame func(frame *op.Ops)
// Source is the interface between the interface state and widgets. // Source is the interface between the window and widgets.
Source input.Source Source input.Source
} }
@@ -65,13 +64,13 @@ type Insets struct {
Top, Bottom, Left, Right unit.Dp Top, Bottom, Left, Right unit.Dp
} }
// NewContext is a shorthand for // NewContext is shorthand for
// //
// layout.Context{ // layout.Context{
// Ops: ops, // Ops: ops,
// Now: e.Now, // Now: e.Now,
// Queue: e.Queue, // Source: e.Source,
// Config: e.Config, // Metric: e.Metric,
// Constraints: layout.Exact(e.Size), // Constraints: layout.Exact(e.Size),
// } // }
// //
+4 -10
View File
@@ -8,12 +8,12 @@ See https://gioui.org for instructions to set up and run Gio programs.
# Windows # Windows
Create a new Window by calling NewWindow. On mobile platforms or when Gio Create a new [Window] by calling [NewWindow]. On mobile platforms or when Gio
is embedded in another project, NewWindow merely connects with a previously is embedded in another project, NewWindow merely connects with a previously
created window. created window.
A Window is run by calling NextEvent in a loop. The most important event is A Window is run by calling its NextEvent method in a loop. The most important event is
FrameEvent that prompts an update of the window contents. [FrameEvent] that prompts an update of the window contents.
For example: For example:
@@ -30,7 +30,7 @@ For example:
} }
A program must keep receiving events from the event channel until A program must keep receiving events from the event channel until
DestroyEvent is received. [DestroyEvent] is received.
# Main # Main
@@ -55,12 +55,6 @@ For example, to display a blank but otherwise functional window:
app.Main() app.Main()
} }
# Event queue
A FrameEvent's Queue method returns an event.Queue implementation that distributes
incoming events to the event handlers declared in the last frame.
See the gioui.org/io/event package for more information about event handlers.
# Permissions # Permissions
The packages under gioui.org/app/permission should be imported The packages under gioui.org/app/permission should be imported
+5 -5
View File
@@ -335,7 +335,7 @@ func (w *Window) processFrame(d driver) {
w.updateAnimation(d) w.updateAnimation(d)
} }
// Invalidate the window such that a FrameEvent will be generated immediately. // Invalidate the window such that a [FrameEvent] will be generated immediately.
// If the window is inactive, the event is sent when the window becomes active. // If the window is inactive, the event is sent when the window becomes active.
// //
// Note that Invalidate is intended for externally triggered updates, such as a // Note that Invalidate is intended for externally triggered updates, such as a
@@ -374,12 +374,12 @@ func (w *Window) Option(opts ...Option) {
// Run f in the same thread as the native window event loop, and wait for f to // Run f in the same thread as the native window event loop, and wait for f to
// return or the window to close. Run is guaranteed not to deadlock if it is // return or the window to close. Run is guaranteed not to deadlock if it is
// invoked during the handling of a ViewEvent, FrameEvent, // invoked during the handling of a [ViewEvent], [FrameEvent],
// StageEvent; call Run in a separate goroutine to avoid deadlock in all // [StageEvent]; call Run in a separate goroutine to avoid deadlock in all
// other cases. // other cases.
// //
// Note that most programs should not call Run; configuring a Window with // Note that most programs should not call Run; configuring a Window with
// CustomRenderer is a notable exception. // [CustomRenderer] is a notable exception.
func (w *Window) Run(f func()) { func (w *Window) Run(f func()) {
done := make(chan struct{}) done := make(chan struct{})
w.driverDefer(func(d driver) { w.driverDefer(func(d driver) {
@@ -724,7 +724,7 @@ func (w *Window) destroyGPU() {
} }
} }
// waitFrame waits for the client to either call FrameEvent.Frame // waitFrame waits for the client to either call [FrameEvent.Frame]
// or to continue event handling. // or to continue event handling.
func (w *Window) waitFrame(d driver) *op.Ops { func (w *Window) waitFrame(d driver) *op.Ops {
for { for {