feat: add gio instances and settings shell
This commit is contained in:
+30
-2
@@ -2,10 +2,16 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"chub/internal/platform/logging"
|
||||
"chub/internal/ui"
|
||||
"gioui.org/app"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op"
|
||||
"gioui.org/unit"
|
||||
"gioui.org/widget/material"
|
||||
)
|
||||
|
||||
const version = "0.1.0-dev"
|
||||
@@ -14,5 +20,27 @@ func main() {
|
||||
ctx := context.Background()
|
||||
logger := logging.New(os.Stderr)
|
||||
logger.InfoContext(ctx, "chub starting", "version", version)
|
||||
fmt.Printf("Chub %s\n", version)
|
||||
go runWindow(logger)
|
||||
app.Main()
|
||||
}
|
||||
|
||||
func runWindow(logger *slog.Logger) {
|
||||
window := new(app.Window)
|
||||
window.Option(app.Title("Chub 浏览器管理"), app.Size(unit.Dp(1100), unit.Dp(720)))
|
||||
theme := material.NewTheme()
|
||||
shell := ui.NewShell(theme)
|
||||
var ops op.Ops
|
||||
for {
|
||||
switch event := window.Event().(type) {
|
||||
case app.DestroyEvent:
|
||||
if event.Err != nil {
|
||||
logger.ErrorContext(context.Background(), "chub window closed", "error", event.Err)
|
||||
}
|
||||
return
|
||||
case app.FrameEvent:
|
||||
gtx := app.NewContext(&ops, event)
|
||||
shell.Layout(layout.Context(gtx))
|
||||
event.Frame(gtx.Ops)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user