aboutsummaryrefslogtreecommitdiff
path: root/Sources/SwiftLVGLDemo/Main.swift
blob: 66d369c8619388309ed4398eff0241cc9c12b4c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)
    }
  }
}