From 5ffec6ed7c40522c88a5bb62fe22e233b358244f Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Fri, 9 Aug 2024 14:52:03 -0600 Subject: initial commit --- Sources/SwiftLVGLDemo/Main.swift | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Sources/SwiftLVGLDemo/Main.swift (limited to 'Sources/SwiftLVGLDemo/Main.swift') 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) + } + } +} -- cgit v1.2.3