-
Notifications
You must be signed in to change notification settings - Fork 5
/
Program.fs
74 lines (57 loc) · 2.03 KB
/
Program.fs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
open ImGuiNET
open ImGuiNET.FSharp
open System.Drawing
[<EntryPoint>]
let main _ =
let viewModel = {|
itemOk = ref false
radiobox = ref 0
|}
let rec startup() =
Gui.window "Splash" [
fun _ ->
Styles.setGreenColorScheme()
setGuiBuilder page1
]()
and page1() =
Gui.app [
Gui.window "Demo Window" [
Gui.text "Page 1" ++ Gui.button "Page 2" (fun () -> setGuiBuilder page2) |> Gui.alignText
Gui.checkbox "Item OK?" viewModel.itemOk (fun var -> printfn $"it's {var}")
Gui.radioboxes [
"radio 1", 1
"radio 2", 2
"radio 3", 3
] viewModel.radiobox
(fun var -> printfn $"clicked {var}")
(fun var -> printfn $"changed {var}")
]
commonStatusBar
]()
and page2 () =
Gui.app [
Gui.window "Demo Window" [
Gui.button "Page 1" (fun () -> setGuiBuilder page1) ++ Gui.text "Page 2" |> Gui.alignText
Gui.text "Nothing to see here"
]
commonStatusBar
]()
and commonStatusBar() =
let framerate = ImGui.GetIO().Framerate
Gui.statusBar "Status Bar" [
Gui.button "Quit" closeGui
Gui.text "\t"
Gui.text "Item Status: " ++ (match !viewModel.itemOk with
| true -> Gui.coloredText Color.Green "OK"
| false -> Gui.coloredText Color.Red "Failed"
)
Gui.text "\t\t"
Gui.text $"{framerate} FPS"
]()
// only one will run at a time, but can create it after it's destroyed
// if gui is disposed it will be stopped
let gui = startOrUpdateGuiWith "Demo" startup
System.Threading.Thread.Sleep(2000)
dispatchToGui(fun () -> viewModel.radiobox := 2)
//setGuiBuilder startup
0 // return an integer exit code