feat: port the client to MyGo native UI (0.3.0)
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.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
+74
@@ -0,0 +1,74 @@
|
||||
package ui
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestTextShadow casts the shadows of two glyphs under them and their
|
||||
// strokes, offset and blurred as asked.
|
||||
func TestTextShadow(t *testing.T) {
|
||||
black, red, white := RGB(0, 0, 0), RGB(255, 0, 0), RGB(255, 255, 255)
|
||||
tt := coreNewTester(func(c *context) {
|
||||
coreText(c, "HH").FontSize(32).TextColor(black).TextStroke(1, white).TextShadow(5, 7, 4, red)
|
||||
}, 300, 100)
|
||||
shadows, fills, under := strokesAndFills(tt, red, black)
|
||||
strokes, _, strokesUnder := strokesAndFills(tt, red, white)
|
||||
if len(shadows) != 2 || len(fills) != 2 || !under {
|
||||
t.Fatalf("%d shadows, %d fills, shadows under: %v; want 2, 2, true", len(shadows), len(fills), under)
|
||||
}
|
||||
if len(strokes) != 2 || !strokesUnder {
|
||||
t.Errorf("shadows under strokes: %v", strokesUnder)
|
||||
}
|
||||
for i, s := range shadows {
|
||||
f := fills[i]
|
||||
dx, dy := s.X+s.W/2-(f.X+f.W/2), s.Y+s.H/2-(f.Y+f.H/2)
|
||||
// The blur widens it by three sigmas, of half the blur, each side.
|
||||
if dx < 4 || dx > 6 || dy < 6 || dy > 8 || s.W < f.W+10 || s.H < f.H+10 {
|
||||
t.Errorf("shadow %d at %v,%v %v×%v, its glyph at %v,%v %v×%v", i, s.X, s.Y, s.W, s.H, f.X, f.Y, f.W, f.H)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestTextShadowSpans casts the shadows of a paragraph's text, inherited
|
||||
// but where an inline element casts none, and of a span's own.
|
||||
func TestTextShadowSpans(t *testing.T) {
|
||||
black, red, blue := RGB(0, 0, 0), RGB(255, 0, 0), RGB(0, 0, 255)
|
||||
tt := coreNewTester(func(c *context) {
|
||||
coreColumn(c).TextShadow(1, 1, 0, red).Children(func() {
|
||||
coreRichText(c).TextColor(black).Children(func() {
|
||||
coreText(c, "ab")
|
||||
coreText(c, "cd").TextShadow(0, 0, 0, Color{})
|
||||
})
|
||||
coreRichText(c, Span{Text: "ef"}, Span{Text: "g", Shadow: NewTextShadow(0, 2, 0, blue)}).TextColor(black)
|
||||
})
|
||||
}, 300, 100)
|
||||
reds, fills, _ := strokesAndFills(tt, red, black)
|
||||
blues, _, _ := strokesAndFills(tt, blue, black)
|
||||
if len(reds) != 4 || len(blues) != 1 || len(fills) != 7 {
|
||||
t.Errorf("%d red shadows, %d blue, %d fills; want 4, 1, 7", len(reds), len(blues), len(fills))
|
||||
}
|
||||
}
|
||||
|
||||
// TestTextShadowRenders paints a shadow offset beside its white glyph,
|
||||
// red, and blurred over more pixels.
|
||||
func TestTextShadowRenders(t *testing.T) {
|
||||
view := func(blur float32) func(c *context) {
|
||||
return func(c *context) {
|
||||
coreBox(c).Fill().Background(RGB(255, 255, 255)).Children(func() {
|
||||
coreText(c, "H").FontSize(40).TextColor(RGB(255, 255, 255)).TextShadow(40, 0, blur, RGB(255, 0, 0))
|
||||
})
|
||||
}
|
||||
}
|
||||
sharp, soft := coreRender(view(0), 140, 60, 1), coreRender(view(12), 140, 60, 1)
|
||||
// The pixels the shadow reddens along the middle row.
|
||||
var sharpEdge, softEdge int
|
||||
for x := 0; x < 140; x++ {
|
||||
if c := sharp.RGBAAt(x, 30); c.G < 128 {
|
||||
sharpEdge++
|
||||
}
|
||||
if c := soft.RGBAAt(x, 30); c.G < 250 {
|
||||
softEdge++
|
||||
}
|
||||
}
|
||||
if sharpEdge == 0 || softEdge <= sharpEdge {
|
||||
t.Errorf("red pixels across the middle: %d sharp, %d blurred", sharpEdge, softEdge)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user