|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/uwu/frenyard" |
| 5 | + "github.com/uwu/frenyard/design" |
| 6 | + "github.com/uwu/frenyard/framework" |
| 7 | + "github.com/uwu/frenyard/integration" |
| 8 | +) |
| 9 | + |
| 10 | +func main() { |
| 11 | + // This controls the framerate |
| 12 | + frenyard.TargetFrameTime = 0.016 |
| 13 | + |
| 14 | + // Initialize our main container capable of slide animations |
| 15 | + slideContainer := framework.NewUISlideTransitionContainerPtr(nil) |
| 16 | + slideContainer.FyEResize(design.SizeWindowInit) |
| 17 | + |
| 18 | + // Initialize our window and bind it to our container element |
| 19 | + wnd, err := framework.CreateBoundWindow("Frenyard Example", true, design.ThemeBackground, slideContainer) |
| 20 | + if err != nil { |
| 21 | + panic(err) |
| 22 | + } |
| 23 | + |
| 24 | + // Setup sets the sizes, fonts and borders according to a reasonable inferred |
| 25 | + // scale. |
| 26 | + design.Setup(frenyard.InferScale(wnd)) |
| 27 | + wnd.SetSize(design.SizeWindow) |
| 28 | + |
| 29 | + // Initialize our app struct, referencable from anywhere. |
| 30 | + app := (&UpApplication{ |
| 31 | + MainContainer: slideContainer, |
| 32 | + Window: wnd, |
| 33 | + UpQueued: make(chan func(), 16), |
| 34 | + TeleportSettings: framework.SlideTransition{}, |
| 35 | + }) |
| 36 | + |
| 37 | + // Start an instant transition to our main screen. |
| 38 | + app.Teleport( |
| 39 | + // A 'document', with a title header and body. |
| 40 | + design.LayoutDocument( |
| 41 | + design.Header{ |
| 42 | + Title: "Example App", |
| 43 | + }, |
| 44 | + // Main flexbox container, contains all elements. |
| 45 | + framework.NewUIFlexboxContainerPtr(framework.FlexboxContainer{ |
| 46 | + DirVertical: true, |
| 47 | + Slots: []framework.FlexboxSlot{ |
| 48 | + { |
| 49 | + Element: framework.NewUILabelPtr(integration.NewTextTypeChunk("Hello World!", design.GlobalFont), design.ThemeText, 0, frenyard.Alignment2i{}), |
| 50 | + }, |
| 51 | + }, |
| 52 | + }), |
| 53 | + // Sets the flexbox container to be scrollable. |
| 54 | + true, |
| 55 | + ), |
| 56 | + ) |
| 57 | + |
| 58 | + // Start the backend. Stops when ExitFlag is set to true. |
| 59 | + frenyard.GlobalBackend.Run(func(frameTime float64) { |
| 60 | + select { |
| 61 | + case fn := <-app.UpQueued: |
| 62 | + |
| 63 | + fn() |
| 64 | + default: |
| 65 | + } |
| 66 | + }) |
| 67 | +} |
0 commit comments