aboutsummaryrefslogtreecommitdiff
path: root/Sources/SwiftLVGLDemo/Main.swift
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2024-08-09 14:52:03 -0600
committerNavan Chauhan <navanchauhan@gmail.com>2024-08-09 14:52:03 -0600
commit5ffec6ed7c40522c88a5bb62fe22e233b358244f (patch)
tree95103636dd98a5016c7650f6ef1ca95ccec7a166 /Sources/SwiftLVGLDemo/Main.swift
parentfa3bba6792cdef4a11554d9538aa39e7fdb9b04c (diff)
initial commit
Diffstat (limited to 'Sources/SwiftLVGLDemo/Main.swift')
-rw-r--r--Sources/SwiftLVGLDemo/Main.swift33
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)
+ }
+ }
+}