Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
58 lines
2.1 KiB
Go
58 lines
2.1 KiB
Go
package ui
|
|
|
|
// fitter measures the content of a window that takes its content's size
|
|
// (mygo.FlyoutOptions.FitContent, surface.Conn.ContentSize) as each frame
|
|
// lays it out, and tells the window when that size changed: the window
|
|
// resizes, and the frame that follows lays the content out at its size,
|
|
// as a browser lays out a popup at the size of its page's content.
|
|
type fitter struct {
|
|
// widths returns the bounds of the window's width, in its DIPs, 0 for
|
|
// none; tell hears the size.
|
|
widths func() (min, max float64)
|
|
tell func(width, height float64)
|
|
// told is the size last told, and before the one told before it;
|
|
// laid is the window's size the last frame was laid out at.
|
|
told, before, laid [2]float32
|
|
}
|
|
|
|
func newFitter(widths func() (min, max float64), tell func(width, height float64)) *fitter {
|
|
none := [2]float32{-1, -1}
|
|
return &fitter{widths: widths, tell: tell, told: none, before: none}
|
|
}
|
|
|
|
// measureFit measures the size the frame's content takes, in the window's
|
|
// DIPs: its max-content width, within the window's bounds, and its height
|
|
// at that width, as an html element of width: fit-content and height:
|
|
// auto. Elements placed absolutely, as overlays and toasts, take none of
|
|
// it, nor does the inspector, which the content keeps its size beside.
|
|
//
|
|
// A frame laid out at the size it last told, which measures the size it
|
|
// told before that, holds: its view builds the content after the window's
|
|
// size (Context.Size), which would have it resize back and forth. The
|
|
// content changing in a frame at the same size as the last tells it.
|
|
func (rt *engine) measureFit(root *node) {
|
|
f := rt.fit
|
|
if f == nil || rt.insp.open {
|
|
return
|
|
}
|
|
z := float32(1)
|
|
if rt.zoomed() {
|
|
z = rt.contentZoom
|
|
}
|
|
lo, hi := f.widths()
|
|
w := max(contentWidth(root, true)*z, float32(lo))
|
|
if hi > 0 {
|
|
w = min(w, float32(hi))
|
|
}
|
|
h := (contentHeight(root, max(w/z-root.padX(), 0)) + root.padY()) * z
|
|
ww, wh, _ := rt.host.size()
|
|
resized := f.laid != [2]float32{ww, wh}
|
|
f.laid = [2]float32{ww, wh}
|
|
m := [2]float32{w, h}
|
|
if m == f.told || resized && m == f.before {
|
|
return
|
|
}
|
|
f.before, f.told = f.told, m
|
|
f.tell(float64(w), float64(h))
|
|
}
|