2020-03-08 09:10:41 +00:00
|
|
|
package alui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"opslag.de/schobers/allg5"
|
|
|
|
"opslag.de/schobers/geom"
|
|
|
|
)
|
|
|
|
|
|
|
|
type UI struct {
|
|
|
|
ctx *Context
|
|
|
|
main Control
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUI(disp *allg5.Display, main Control) *UI {
|
|
|
|
ctx := &Context{
|
|
|
|
Display: disp,
|
|
|
|
Fonts: NewFonts(),
|
|
|
|
Palette: Palette{},
|
|
|
|
}
|
|
|
|
return &UI{ctx, main}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ui *UI) Context() *Context { return ui.ctx }
|
|
|
|
|
|
|
|
func (ui *UI) Destroy() {
|
|
|
|
ui.ctx.Fonts.Destroy()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ui *UI) Fonts() *Fonts { return ui.ctx.Fonts }
|
|
|
|
|
|
|
|
func (ui *UI) SetPalette(p Palette) { ui.ctx.Palette = p }
|
|
|
|
|
|
|
|
func (ui *UI) layoutBounds(bounds geom.RectangleF32) {
|
|
|
|
ui.main.Layout(ui.ctx, bounds)
|
|
|
|
}
|
|
|
|
|
2020-04-10 09:00:27 +00:00
|
|
|
func (ui *UI) Handle(e allg5.Event) { ui.main.Handle(ui.ctx, e) }
|
2020-03-08 09:10:41 +00:00
|
|
|
|
|
|
|
func (ui *UI) Render() {
|
|
|
|
ui.RenderBounds(ui.ctx.DisplayBounds())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ui *UI) RenderBounds(bounds geom.RectangleF32) {
|
|
|
|
ui.ctx.Cursor = allg5.MouseCursorDefault
|
|
|
|
ui.layoutBounds(bounds)
|
|
|
|
ui.main.Render(ui.ctx, bounds)
|
|
|
|
ui.ctx.Display.SetMouseCursor(ui.ctx.Cursor)
|
|
|
|
}
|