@@ 42,7 42,7 @@ func main() {
defer cancel()
// Go ahead and build our first application window. On some platforms (Android),
// making a window performs one-time initialization of platform integrations (like defining app.DataDir).
- win := app.NewWindow()
+ win := app.NewWindow(app.Title("Todo"))
dataDir, err := app.DataDir()
if err != nil {
log.Printf("could not determine data dir, trying cwd: %v", err)
@@ 115,7 115,7 @@ func (u *UI) hotkeys(gtx C) {
case "N":
if event.Modifiers.Contain(key.ModShortcut) {
// Launch a new window.
- go NewUI(u.parentCtx, u.backend, app.NewWindow()).Run()
+ go NewUI(u.parentCtx, u.backend, app.NewWindow(app.Title("Todo"))).Run()
}
case key.NameF1:
if !u.tracing {
@@ 164,6 164,9 @@ func (u *UI) Run() error {
defer u.cancel()
// Declare a Gio operation list to use building frames.
var ops op.Ops
+
+ // Track whether the environment is drawing window decorations for us.
+ var decorated bool
// Iterate events from our Gio window.
for ev := range u.w.Events() {
switch ev := ev.(type) {
@@ 172,6 175,8 @@ func (u *UI) Run() error {
// the user manually closing it, or the OS forcing it to close. Either way,
// we return to end the event loop.
return ev.Err
+ case app.ConfigEvent:
+ decorated = ev.Config.Decorated
case system.FrameEvent:
trace.WithRegion(u.parentCtx, "frame", func() {
// If we get a frame event, it's time to display a new frame. First, we
@@ 182,7 187,7 @@ func (u *UI) Run() error {
// Install some global key event handlers for some dev hotkeys.
u.hotkeys(gtx)
// Then we lay out our UI to generate an operation list.
- u.page.Layout(gtx)
+ u.page.Layout(gtx, !decorated)
})
trace.WithRegion(u.parentCtx, "render", func() {
// Then we give the operation list to Gio. This actually triggers rendering
@@ 140,12 140,17 @@ func (p *Page) Update(gtx C) {
}
// Layout builds your UI within the operation list in gtx.
-func (p *Page) Layout(gtx C) D {
+func (p *Page) Layout(gtx C, showHeader bool) D {
p.Update(gtx)
return layout.Flex{
Axis: layout.Vertical,
}.Layout(gtx,
- layout.Rigid(p.layoutHeader),
+ layout.Rigid(func(gtx layout.Context) layout.Dimensions {
+ if !showHeader {
+ return D{}
+ }
+ return p.layoutHeader(gtx)
+ }),
layout.Rigid(p.layoutCreateTaskForm),
layout.Flexed(1, p.layoutTaskList),
)