Documentation
¶
Overview ¶
Package windowapp adapts an *app.App to the window.Handler contract: it exposes the app's double-buffered framebuffer to a native presenter and routes native mouse/scroll/key events into the ui.Scene. It is deliberately decoupled from the window package (it satisfies the interface structurally), so both build on every platform and the routing logic is unit-testable without any Cocoa dependency.
Index ¶
- type Handler
- func (h *Handler) A11yElements() []window.A11yElement
- func (h *Handler) ContextMenuActive() bool
- func (h *Handler) ContextMenuEvent(ev toolkit.Event)
- func (h *Handler) Frame() ([]byte, int, int, bool)
- func (h *Handler) Key(name string, r rune)
- func (h *Handler) MouseDown(x, y int)
- func (h *Handler) MouseMove(x, y int)
- func (h *Handler) MouseUp(x, y int)
- func (h *Handler) NativeControls() []toolkit.NativeControl
- func (h *Handler) NeedsPresent() bool
- func (h *Handler) PresentImmediate() bool
- func (h *Handler) PresentThrottle() bool
- func (h *Handler) Resize(w, height int, scale float64)
- func (h *Handler) Scroll(dy int)
- func (h *Handler) SecondaryClick(x, y int)
- func (h *Handler) SetSystemClipboard(c window.SystemClipboard)
- func (h *Handler) Shortcut(r rune, ctrl, meta bool)
- func (h *Handler) SystemAppearance(a window.SystemAppearance)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler adapts an app to the presenter's data-source/input-sink interface.
pending* records a text-selectable hit (a feed card, a sidebar row, or a non-interactive reading surface) whose action is DEFERRED from the press to the release: a press begins a text selection instead of acting, and MouseUp decides — a drag that produced a selection suppresses the action and keeps the selection for a copy; a plain click (no drag) runs the recorded action.
func New ¶
New wraps a to be driven by a native window. It installs the platform browser opener as the app's sign-in URL opener (through the openURLIn seam, so tests substituting it are honoured), letting the app start a browser sign-in without importing this package.
func (*Handler) A11yElements ¶
func (h *Handler) A11yElements() []window.A11yElement
A11yElements describes what the app is showing, satisfying window.Accessible so a back-end with an accessibility API can expose it.
It is the ui package's tree flattened into the window package's neutral shape. The translation exists precisely so window stays a generic surface that never imports ui: the presenter learns the roles and labels without learning what a feed or a subscription is.
The rects pass through unchanged. ui.A11yNode already carries device-pixel, top-left coordinates — the same space the framebuffer and MouseDown use — so there is nothing to convert here, and the back-end owns the trip to whatever its platform wants.
func (*Handler) ContextMenuActive ¶
ContextMenuActive reports whether a context menu is popped up, so the window routes input to it rather than the scene. Satisfies window.ContextMenuHost.
func (*Handler) ContextMenuEvent ¶
ContextMenuEvent forwards one input event to the open context menu.
func (*Handler) Frame ¶
Frame returns the current framebuffer, its device dimensions, and whether it changed since the last call.
func (*Handler) Key ¶
Key handles editing keys and printable runes for whichever view/field is focused (topbar search in the feed, or the settings text fields).
func (*Handler) MouseDown ¶
MouseDown routes a click across the feed, detail and settings views: open an item, follow a link, switch a filter or profile, or drive the settings editor.
func (*Handler) MouseMove ¶
MouseMove forwards pointer motion to the scene. Back-ends deliver a left-button drag as MouseMove, so while a press is held inside the embedded web-preview browser the motion is routed there first as a drag (letting a grabbed scrollbar thumb — horizontal or vertical — track the pointer); otherwise it falls through to the scene, which applies it only while a sidebar/preview-divider drag is in progress.
func (*Handler) MouseUp ¶
MouseUp ends any in-progress sidebar-divider drag and releases a pressed web-preview toolbar button (clearing its click-feedback face).
func (*Handler) NativeControls ¶
func (h *Handler) NativeControls() []toolkit.NativeControl
NativeControls describes the interactive controls the app wants backed by real OS controls this frame, satisfying application.NativeControlProvider so a back-end that can embed native controls lays them over the framebuffer. The descriptors are the toolkit's own, already in the framebuffer's device-pixel, top-left space the platform expects — the same reason A11yElements passes its rects through unchanged — so there is nothing to convert here. It is the Scene that decides what should be native; this only forwards its list.
func (*Handler) NeedsPresent ¶
NeedsPresent reports whether the present loop should repaint now: a queued scene write is waiting, or the scene is still animating. A gated loop uses it to skip the blit on an idle, unchanged window; see internal/window's ticker.
func (*Handler) PresentImmediate ¶
PresentImmediate reports that queued content must be blitted without throttle delay; the gated present loop uses it to override its spinner throttle.
func (*Handler) PresentThrottle ¶
PresentThrottle reports that the only motion is the loading spinner, which the gated present loop may redraw below its tick rate; see internal/window.
func (*Handler) Scroll ¶
Scroll scrolls the feed by a device-pixel wheel delta, unless the pointer is over the embedded web-preview browser — then the wheel scrolls the page.
func (*Handler) SecondaryClick ¶
SecondaryClick opens a context menu when the secondary press landed on a sidebar subscription (a real source, not the All filter) or a virtual folder. The menu is the toolkit's own ContextMenu widget — this only builds its items and their actions, which reuse the same scene/app operations the rest of the UI uses, and hands it to the scene to present. A press anywhere else is ignored.
func (*Handler) SetSystemClipboard ¶
func (h *Handler) SetSystemClipboard(c window.SystemClipboard)
SetSystemClipboard installs the native back-end's OS pasteboard as the toolkit-wide clipboard, so every text widget's copy/cut/paste and the app's copy actions go through it. It satisfies the optional window.ClipboardController capability. window.SystemClipboard has the same method set as toolkit.Clipboard, so it installs directly.
func (*Handler) Shortcut ¶
Shortcut handles a command-style modifier chord (Ctrl/Cmd + a base key) forwarded by the native back-end. In the feed view with the embedded web preview active, a chord whose base rune matches the configured zoom-in / zoom-out key zooms the browser through its MVVM commands; every other chord is ignored so ordinary shortcuts fall through untouched. This satisfies the optional window.ShortcutSink capability (asserted below).
func (*Handler) SystemAppearance ¶
func (h *Handler) SystemAppearance(a window.SystemAppearance)
SystemAppearance applies host look-and-feel harvested by the native back-end (dark/light, accent, system font) to the app. This satisfies the optional window.AppearanceSink capability; the compile-time assertion below keeps the signature in step with the contract.