mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
apps: support DestroyEvent
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+16
-20
@@ -152,24 +152,21 @@ func initProfiling() {
|
||||
func init() {
|
||||
flag.Parse()
|
||||
initProfiling()
|
||||
fonts.regular = mustLoadFont(goregular.TTF)
|
||||
fonts.bold = mustLoadFont(gobold.TTF)
|
||||
fonts.italic = mustLoadFont(goitalic.TTF)
|
||||
fonts.mono = mustLoadFont(gomono.TTF)
|
||||
var ops ui.Ops
|
||||
theme.text = colorMaterial(&ops, rgb(0x333333))
|
||||
theme.tertText = colorMaterial(&ops, rgb(0xbbbbbb))
|
||||
theme.brand = colorMaterial(&ops, rgb(0x62798c))
|
||||
theme.white = colorMaterial(&ops, rgb(0xffffff))
|
||||
w, err := app.NewWindow(&app.WindowOptions{
|
||||
Width: ui.Dp(400),
|
||||
Height: ui.Dp(800),
|
||||
Title: "Gophers",
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
go func() {
|
||||
fonts.regular = mustLoadFont(goregular.TTF)
|
||||
fonts.bold = mustLoadFont(gobold.TTF)
|
||||
fonts.italic = mustLoadFont(goitalic.TTF)
|
||||
fonts.mono = mustLoadFont(gomono.TTF)
|
||||
var ops ui.Ops
|
||||
theme.text = colorMaterial(&ops, rgb(0x333333))
|
||||
theme.tertText = colorMaterial(&ops, rgb(0xbbbbbb))
|
||||
theme.brand = colorMaterial(&ops, rgb(0x62798c))
|
||||
theme.white = colorMaterial(&ops, rgb(0xffffff))
|
||||
w := app.NewWindow(&app.WindowOptions{
|
||||
Width: ui.Dp(400),
|
||||
Height: ui.Dp(800),
|
||||
Title: "Gophers",
|
||||
})
|
||||
if err := newApp(w).run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -203,6 +200,8 @@ func (a *App) run() error {
|
||||
a.w.Redraw()
|
||||
}
|
||||
}
|
||||
case app.DestroyEvent:
|
||||
return e.Err
|
||||
case app.StageEvent:
|
||||
if e.Stage >= app.StageRunning {
|
||||
if a.ctxCancel == nil {
|
||||
@@ -217,9 +216,6 @@ func (a *App) run() error {
|
||||
a.ctxCancel = nil
|
||||
}
|
||||
}
|
||||
if e.Stage == app.StageDead {
|
||||
return a.w.Err()
|
||||
}
|
||||
case *app.CommandEvent:
|
||||
switch e.Type {
|
||||
case app.CommandBack:
|
||||
|
||||
Reference in New Issue
Block a user