Checkpoint
This commit is contained in:
160 files changed
+76293
-387
No files matched your search
@@ -0,0 +1,72 @@
|
||||
package screen
|
||||
|
||||
import (
|
||||
"image"
|
||||
|
||||
"github.com/BeatGlow/beatglow/hardware"
|
||||
"github.com/BeatGlow/beatglow/ui"
|
||||
"github.com/BeatGlow/beatglow/ui/widget"
|
||||
"github.com/BeatGlow/display"
|
||||
)
|
||||
|
||||
type boot struct {
|
||||
display display.Display
|
||||
widgets []ui.Widget
|
||||
}
|
||||
|
||||
func Boot(displays ...display.Display) ui.Screen {
|
||||
widgets := make([]ui.Widget, len(displays))
|
||||
for i, display := range displays {
|
||||
if i == 0 {
|
||||
widgets[i] = newBoot(display)
|
||||
} else {
|
||||
widgets[i] = newEmpty(display)
|
||||
}
|
||||
}
|
||||
|
||||
return &boot{
|
||||
display: displays[0],
|
||||
widgets: widgets,
|
||||
}
|
||||
}
|
||||
|
||||
func (boot) String() string { return "boot" }
|
||||
func (boot) HandleInput(_ hardware.InputEvent) {}
|
||||
|
||||
func (s *boot) SetVisible(_ bool) {
|
||||
s.display.Clear()
|
||||
}
|
||||
|
||||
func (s *boot) Widgets() []ui.Widget {
|
||||
return s.widgets
|
||||
}
|
||||
|
||||
func newBoot(display display.Display) ui.Widget {
|
||||
var (
|
||||
style = ui.StylesFor(display.ColorModel()).Boot
|
||||
size = display.Bounds().Size()
|
||||
)
|
||||
switch {
|
||||
case size.Y >= 64:
|
||||
style.Font.SetPointSize(style.FontSize * 2)
|
||||
default:
|
||||
style.Font.SetPointSize(style.FontSize)
|
||||
}
|
||||
|
||||
var (
|
||||
width, height = style.Font.MeasureText("beatglow")
|
||||
at = image.Pt(
|
||||
(size.X-width)/2,
|
||||
(size.Y-height)/2,
|
||||
)
|
||||
)
|
||||
|
||||
text := widget.NewText(display, at)
|
||||
text.SetStyle(style)
|
||||
text.Set("beatglow")
|
||||
return text
|
||||
}
|
||||
|
||||
func newEmpty(display display.Display) ui.Widget {
|
||||
return widget.Empty{display}
|
||||
}
|
||||
Reference in new issue
Block a user