diff options
| -rw-r--r-- | go/main.go | 54 | 
1 files changed, 26 insertions, 28 deletions
| @@ -16,10 +16,10 @@ import (  )  type Limox struct { -	ConnState string -	Ui struct { -		Window *app.Window -	} +	ConnState  string +	Window     *app.Window +	Operations op.Ops +	Theme      *material.Theme  }  func main() { @@ -37,38 +37,36 @@ func main() {  }  func NewLimox() Limox { -	limox := Limox{} - -	limox.Ui.Window = app.NewWindow( -		app.Title("LimoX"), -		app.Size(unit.Dp(400), unit.Dp(600)), -	) - -	limox.ConnState = "disconnected" - -	return limox +	return Limox{ +		ConnState: "disconnected", +		Window: app.NewWindow( +			app.Title("LimoX"), +			app.Size(unit.Dp(400), unit.Dp(600)), +		), +		Operations: op.Ops{}, +		Theme:      material.NewTheme(gofont.Collection()), +	}  }  func (l *Limox) run() error { - -	th := material.NewTheme(gofont.Collection()) -	var ops op.Ops -  	for { -		e := <-l.Ui.Window.Events() +		e := <-l.Window.Events()  		switch e := e.(type) {  		case system.DestroyEvent:  			return e.Err  		case system.FrameEvent: -			gtx := layout.NewContext(&ops, e) - -			title := material.H3(th, l.ConnState) -			maroon := color.NRGBA{R: 0, G: 212, B: 0, A: 255} -			title.Color = maroon -			title.Alignment = text.Middle -			title.Layout(gtx) - -			e.Frame(gtx.Ops) +			l.draw(e)  		}  	}  } + +func (l *Limox) draw(e system.FrameEvent) { +	gtx := layout.NewContext(&l.Operations, e) + +	stateLabel := material.H3(l.Theme, l.ConnState) +	stateLabel.Color = color.NRGBA{R: 0, G: 212, B: 0, A: 255} +	stateLabel.Alignment = text.Middle +	stateLabel.Layout(gtx) + +	e.Frame(gtx.Ops) +} | 
