diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2024-08-09 14:52:03 -0600 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2024-08-09 14:52:03 -0600 |
commit | 5ffec6ed7c40522c88a5bb62fe22e233b358244f (patch) | |
tree | 95103636dd98a5016c7650f6ef1ca95ccec7a166 /Sources/SwiftLVGLDemo/Main.swift | |
parent | fa3bba6792cdef4a11554d9538aa39e7fdb9b04c (diff) |
initial commit
Diffstat (limited to 'Sources/SwiftLVGLDemo/Main.swift')
-rw-r--r-- | Sources/SwiftLVGLDemo/Main.swift | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Sources/SwiftLVGLDemo/Main.swift b/Sources/SwiftLVGLDemo/Main.swift new file mode 100644 index 0000000..2e53d4d --- /dev/null +++ b/Sources/SwiftLVGLDemo/Main.swift @@ -0,0 +1,33 @@ +import CLVGL +import SwiftLVGL + +@main +struct Main { + static func main() { + lv_init() + let _ = lv_sdl_window_create(480, 480) + let _ = lv_sdl_mouse_create() + + var myCounter: Int = 0 + + let label = LVGLLabel("", alignment: .bottomMid) + let button = LVGLButton("Click Me", eventType: .pressed) { event in + if let event = event, event.eventCode == .pressed { + myCounter += 1 + label.setText("You clicked the button \(myCounter) times") + } + } + let _ = LVGLButton("Shift Button", alignment: .bottomRight, eventType: .pressed) { event in + button.align(alignment: .leftMid) + } + + let _ = LVGLSlider("", alignment: .topMid, yOffset: 50) + + let _ = LVGLSwitch(alignment: .rightMid) + + while true { + lv_timer_handler() + usleep(5000) + } + } +} |