mirror of
https://github.com/mineracks/seedhammer-v1-companion.git
synced 2026-06-26 22:01:05 +10:00
The Phase 2 scaffolding boot screen is replaced with the actual
upstream v1.3.0 gui package running in browser. cmd/emulator now
calls gui.NewApp(plat, version) + drives a.Frame() in a goroutine.
Lifts:
gui/ (top-level UI + state machine)
gui/assets (icons, fonts, 9-patch images)
gui/layout (constraint-based UI layout)
gui/op (drawing op primitives)
gui/saver (screensaver + idle timeout)
gui/text (text shaping)
gui/widget (button/menu/keyboard widgets)
All 11 .go files lifted verbatim from seedhammer/seedhammer @ v1.3.0
(commit 2f071c1d...), import paths rewritten seedhammer.com → mineracks.
browserPlatform now implements gui.Platform (12 methods):
Events(deadline) — drains v1.Event chan, maps to gui.ButtonEvent
(gui.Button enum order matches platform/v1.Button,
so the conversion is a direct uint cast)
Wakeup() — no-op (no sleep state in browser)
PlateSizes() — backup.SquarePlate, backup.LargePlate
Engraver() — nullEngraver stub (browser can't punch metal)
EngraverParams() — copy of mjolnir.Params {StrokeWidth: 38,
Millimeter: 126}. Inlined because tarm/serial
(mjolnir's USB dep) doesn't compile to js/wasm.
CameraFrame(size) — emits FrameEvent{Error: stubbed} so QR-scan
screens fall through cleanly; real handoff
lands when SeedSigner sim wires up (Phase 2.5)
Now() — time.Now()
DisplaySize() — 240×240
Dirty(r) — records rect, resets chunk cursor
NextChunk() — one-shot: returns full sub-image once per
Dirty cycle, then flushes the whole frame
buffer to JS via emulatorPaint()
ScanQR() — returns nil decodes (stub)
Debug() — false
The Engraver interface is satisfied by nullEngraver — Engrave() returns
"engraver not connected" so the GUI's engrave flow fails cleanly
instead of looking like it's working.
WASM grows 2.7MB → 8.0MB (gui package + btcd + crypto deps + fonts
all linked in). Acceptable for the v1 emulator one-time cache.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
121 lines
2.2 KiB
Go
121 lines
2.2 KiB
Go
package gui
|
|
|
|
import (
|
|
"image/color"
|
|
|
|
"github.com/mineracks/seedhammer-v1-companion/font/comfortaa"
|
|
"github.com/mineracks/seedhammer-v1-companion/font/poppins"
|
|
"github.com/mineracks/seedhammer-v1-companion/gui/text"
|
|
)
|
|
|
|
var theme struct {
|
|
overlayMask uint8
|
|
activeMask uint8
|
|
inactiveMask uint8
|
|
}
|
|
|
|
type Styles struct {
|
|
title text.Style
|
|
subtitle text.Style
|
|
body text.Style
|
|
lead text.Style
|
|
button text.Style
|
|
word text.Style
|
|
keyboard text.Style
|
|
warning text.Style
|
|
nav text.Style
|
|
debug text.Style
|
|
progress text.Style
|
|
}
|
|
|
|
type Colors struct {
|
|
Background color.NRGBA
|
|
Text color.NRGBA
|
|
Primary color.NRGBA
|
|
}
|
|
|
|
var (
|
|
descriptorTheme Colors
|
|
singleTheme Colors
|
|
engraveTheme Colors
|
|
cameraTheme Colors
|
|
)
|
|
|
|
const leadingSize = 44
|
|
|
|
func init() {
|
|
prim := rgb(0x02427d)
|
|
descriptorTheme = Colors{
|
|
Background: rgb(0x267f26),
|
|
Text: rgb(0xe9f2ea),
|
|
Primary: prim,
|
|
}
|
|
singleTheme = Colors{
|
|
Background: rgb(0xdd9700),
|
|
Text: rgb(0xfbf4e8),
|
|
Primary: prim,
|
|
}
|
|
engraveTheme = Colors{
|
|
Background: rgb(0xd1e83cb),
|
|
Text: rgb(0xdffffff),
|
|
Primary: prim,
|
|
}
|
|
cameraTheme = Colors{
|
|
Text: rgb(0xfbf4e8),
|
|
}
|
|
theme.overlayMask = 0x55
|
|
theme.activeMask = 0x55
|
|
theme.inactiveMask = 0x55
|
|
}
|
|
|
|
func NewStyles() Styles {
|
|
return Styles{
|
|
title: text.Style{
|
|
Face: poppins.Bold23,
|
|
Alignment: text.AlignCenter,
|
|
LetterSpacing: -1,
|
|
LineHeight: 0.75,
|
|
},
|
|
body: text.Style{
|
|
Face: poppins.Regular16,
|
|
LineHeight: 0.75,
|
|
},
|
|
debug: text.Style{
|
|
Face: poppins.Bold10,
|
|
},
|
|
warning: text.Style{
|
|
Face: poppins.Bold23,
|
|
LineHeight: 0.75,
|
|
Alignment: text.AlignCenter,
|
|
},
|
|
lead: text.Style{
|
|
Face: poppins.Regular16,
|
|
LineHeight: 0.9,
|
|
Alignment: text.AlignCenter,
|
|
},
|
|
subtitle: text.Style{
|
|
Face: poppins.Bold16,
|
|
LineHeight: 0.9,
|
|
},
|
|
nav: text.Style{
|
|
Face: poppins.Bold23,
|
|
},
|
|
button: text.Style{
|
|
Face: poppins.Bold20,
|
|
Alignment: text.AlignCenter,
|
|
LineHeight: 0.70,
|
|
},
|
|
word: text.Style{
|
|
Face: comfortaa.Bold17,
|
|
},
|
|
keyboard: text.Style{
|
|
Face: poppins.Bold16,
|
|
},
|
|
progress: text.Style{
|
|
Face: poppins.Boldprogress45,
|
|
Alignment: text.AlignCenter,
|
|
LetterSpacing: -1,
|
|
},
|
|
}
|
|
}
|