-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathimgui-au3-example.au3
157 lines (111 loc) · 3.9 KB
/
imgui-au3-example.au3
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include "imgui.au3"
_ImGui_EnableViewports()
$hwnd = _ImGui_GUICreate("AutoIt ImGui", 1024, 768)
_WinAPI_ShowWindow($hwnd)
;~ GUISetState(@SW_SHOW, $Hwnd)
_ImGui_StyleColorsLight()
$io = _ImGui_GetIO()
$imstyle = _ImGui_GetStyle()
_ImGui_SetWindowTitleAlign(0.5, 0.5)
_ImGui_EnableDocking()
Local $i_list_view = 0
Local $i_radio_theme = 0
Local $f_slider = 5
Local $label_radio_theme[] = ["Light", "Dark", "Classic"]
Local $username = ""
Local $password = ""
Local $str_status = ""
Local $b_show_demo_window = False
Local $b_show_another_window = False
While 1
; when the user click close button on the window, this will return false
if Not _ImGui_PeekMsg() Then Exit
; must call
_ImGui_BeginFrame()
; Begin a new window
_ImGui_Begin("Demo ImGui-AutoIt")
_ImGui_Text("Chọn theme")
; Put next item to the same line (don't line break)
_ImGui_SameLine();
Local $old_theme = $i_radio_theme
_ImGui_RadioButton("Light", $i_radio_theme, 0)
_ImGui_SameLine();
_ImGui_RadioButton("Dark", $i_radio_theme, 1)
_ImGui_SameLine();
_ImGui_RadioButton("Classic", $i_radio_theme, 2)
_ImGui_SameLine();
if _ImGui_BeginCombo("##combo_theme", $label_radio_theme[$i_radio_theme]) Then
for $i = 0 To UBound($label_radio_theme) - 1
Local $selected = ($i_radio_theme == $i) ; if $i_radio_theme = $i then $selected = True
if _ImGui_Selectable($label_radio_theme[$i], $selected) Then
$i_radio_theme = $i
_ImGui_SetItemDefaultFocus()
EndIf
Next
_ImGui_EndCombo()
EndIf
If $old_theme <> $i_radio_theme Then
Switch $i_radio_theme
Case 0
_ImGui_StyleColorsLight()
Case 1
_ImGui_StyleColorsDark()
Case 2
_ImGui_StyleColorsClassic()
EndSwitch
EndIf
Local $winSize = _ImGui_GetWindowSize()
_ImGui_Separator()
; Download an image
Local $img = _ImGui_ImageFromURL("https://aommaster.com/blog/wp-content/uploads/2014/07/AutoItlogo.png")
If $img Then
; Get window size
Local $win_size = _ImGui_GetWindowSize()
; Draw the image
_ImGui_ImageFit($img, $win_size[0] - 10, 140)
EndIf
_ImGui_NewLine()
If _ImGui_CheckBox("Show demo window", $b_show_demo_window) Then _ImGui_EnableViewports($b_show_demo_window)
_ImGui_CheckBox("Show another window", $b_show_another_window)
if _ImGui_IsItemHovered() Then _ImGui_ToolTip("what's up")
; Seperate the window into 2 columns
_ImGui_Columns(2)
; Set the width for the column 0
_ImGui_SetColumnWidth(0, $winSize[0]*0.7)
; like line break
_ImGui_NewLine()
; put "##" before labels to hide then, remember to call _ImGui_PushItemWidth(-1) to expand the widget
_ImGui_PushItemWidth(-1)
_ImGui_InputTextWithHint("##username", "username", $username, $ImGuiInputTextFlags_CharsNoBlank)
_ImGui_InputTextWithHint("##password", "password", $password, $ImGuiInputTextFlags_Password)
_ImGui_PopItemWidth()
if $str_status <> "" then _ImGui_TextColored($str_status, 0xFF33BB44)
; go to the next column
_ImGui_NextColumn()
_ImGui_NewLine()
; _ImGui_Button return true if being clicked
if _ImGui_Button("LOGIN", -1, 40) Then $str_status = ($str_status == "" ? "Login success" : "")
_ImGui_Columns(1)
_ImGui_NewLine()
; begin a child window inside the main window
_ImGui_BeginChild("##child_list_view1", $winSize*0.6, $winSize[1] *0.3, true, $ImGuiWindowFlags_ChildWindow)
for $i = 0 To 10
if _ImGui_Selectable("Selectable - " & $i, $i = $i_list_view) Then
$i_list_view = $i
EndIf
Next
_ImGui_EndChild()
; call after done with _ImGui_Begin
_ImGui_End()
If $b_show_another_window Then
_ImGui_Begin("Another window")
_ImGui_Text("Hello there..")
if _ImGui_Button("close me") Then $b_show_another_window = False
_ImGui_End()
EndIf
If $b_show_demo_window Then _ImGui_ShowDemoWindow()
; must call
_ImGui_EndFrame()
WEnd