package layout_test import ( "testing" "time" "git.eeqj.de/sneak/hdmistat/internal/fbdraw" "git.eeqj.de/sneak/hdmistat/internal/layout" ) // ExampleScreen shows how to create a screen that implements FrameGenerator type ExampleScreen struct { name string fps float64 width int height int } func (s *ExampleScreen) GenerateFrame(grid *fbdraw.CharGrid) error { // Create a draw context that works on the provided grid draw := layout.NewDraw(grid) // Clear the screen draw.Clear() // Draw a title draw.Color(layout.Color("cyan")).Bold() draw.TextCenter(0, 2, "Example Screen: %s", s.name) // Create a grid for structured layout contentGrid := draw.Grid(5, 5, 70, 20) contentGrid.Border(layout.Color("gray50")) // Add some content contentGrid.Color(layout.Color("white")).WriteCenter(1, "Current Time: %s", time.Now().Format("15:04:05")) // Draw a progress bar contentGrid.Color(layout.Color("green")).Bar(10, 5, 50, 75.0, layout.Color("green")) // Add system stats contentGrid.Color(layout.Color("yellow")).Write(2, 8, "CPU: %.1f%%", 42.5) contentGrid.Color(layout.Color("orange")).Write(2, 9, "Memory: %s / %s", layout.Bytes(4*1024*1024*1024), layout.Bytes(16*1024*1024*1024)) return nil } func (s *ExampleScreen) FramesPerSecond() float64 { return s.fps } func (s *ExampleScreen) Init(width, height int) error { s.width = width s.height = height return nil } func TestExampleUsage(t *testing.T) { // This is just an example - in real usage you'd use NewFBDisplayAuto() // For testing we'll skip since we don't have a framebuffer t.Skip("Example test - requires framebuffer") // Add screens _ = carousel.AddScreen("Dashboard", &ExampleScreen{name: "Dashboard", fps: 1.0}) _ = carousel.AddScreen("System Monitor", &ExampleScreen{name: "System Monitor", fps: 2.0}) _ = carousel.AddScreen("Network Stats", &ExampleScreen{name: "Network Stats", fps: 0.5}) // In a real application, you would run this in a goroutine // ctx := context.Background() // go carousel.Run(ctx) }