-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
157 lines (136 loc) · 6.35 KB
/
index.py
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
import threading
import time
import json
from logger import get_logger
from sampleapp import Root
import xframes
from services import WidgetRegistrationService
from theme import ImGuiCol
from treetraversal import ShadowNodeTraversalHelper
theme2_colors = {
"darkestGrey": "#141f2c",
"darkerGrey": "#2a2e39",
"darkGrey": "#363b4a",
"lightGrey": "#5a5a5a",
"lighterGrey": "#7A818C",
"evenLighterGrey": "#8491a3",
"black": "#0A0B0D",
"green": "#75f986",
"red": "#ff0062",
"white": "#fff",
}
theme2 = {
"colors": {
str(ImGuiCol.Text.value): [theme2_colors["white"], 1],
str(ImGuiCol.TextDisabled.value): [theme2_colors["lighterGrey"], 1],
str(ImGuiCol.WindowBg.value): [theme2_colors["black"], 1],
str(ImGuiCol.ChildBg.value): [theme2_colors["black"], 1],
str(ImGuiCol.PopupBg.value): [theme2_colors["white"], 1],
str(ImGuiCol.Border.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.BorderShadow.value): [theme2_colors["darkestGrey"], 1],
str(ImGuiCol.FrameBg.value): [theme2_colors["black"], 1],
str(ImGuiCol.FrameBgHovered.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.FrameBgActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TitleBg.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TitleBgActive.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.TitleBgCollapsed.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.MenuBarBg.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.ScrollbarBg.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.ScrollbarGrab.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.ScrollbarGrabHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.ScrollbarGrabActive.value): [theme2_colors["darkestGrey"], 1],
str(ImGuiCol.CheckMark.value): [theme2_colors["darkestGrey"], 1],
str(ImGuiCol.SliderGrab.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.SliderGrabActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.Button.value): [theme2_colors["black"], 1],
str(ImGuiCol.ButtonHovered.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.ButtonActive.value): [theme2_colors["black"], 1],
str(ImGuiCol.Header.value): [theme2_colors["black"], 1],
str(ImGuiCol.HeaderHovered.value): [theme2_colors["black"], 1],
str(ImGuiCol.HeaderActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.Separator.value): [theme2_colors["darkestGrey"], 1],
str(ImGuiCol.SeparatorHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.SeparatorActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.ResizeGrip.value): [theme2_colors["black"], 1],
str(ImGuiCol.ResizeGripHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.ResizeGripActive.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.Tab.value): [theme2_colors["black"], 1],
str(ImGuiCol.TabHovered.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.TabActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TabUnfocused.value): [theme2_colors["black"], 1],
str(ImGuiCol.TabUnfocusedActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.PlotLines.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.PlotLinesHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.PlotHistogram.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.PlotHistogramHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TableHeaderBg.value): [theme2_colors["black"], 1],
str(ImGuiCol.TableBorderStrong.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TableBorderLight.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.TableRowBg.value): [theme2_colors["darkGrey"], 1],
str(ImGuiCol.TableRowBgAlt.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.TextSelectedBg.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.DragDropTarget.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.NavHighlight.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.NavWindowingHighlight.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.NavWindowingDimBg.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.ModalWindowDimBg.value): [theme2_colors["darkerGrey"], 1],
}
}
font_defs = {
"defs": [
{"name": "roboto-regular", "sizes": [16, 18, 20, 24, 28, 32, 36, 48]}
]
}
font_defs["defs"] = [
{"name": entry["name"], "size": size}
for entry in font_defs["defs"]
for size in entry["sizes"]
]
widget_registration_service = WidgetRegistrationService()
shadow_node_traversal_helper = ShadowNodeTraversalHelper(widget_registration_service)
logger = get_logger()
def start_app():
root = Root()
shadow_node_traversal_helper.traverse_tree(root)
def init():
start_app()
def on_text_changed(id, value):
logger.debug(f"text changed, widget {id} value {value}")
def on_combo_changed(id, value):
logger.debug(f"combo changed, widget {id} value {value}")
def on_numeric_value_changed(id, value):
logger.debug(f"numeric value changed, widget {id} value {value}")
def on_boolean_value_changed(id, value):
logger.debug(f"boolean value changed, widget {id} value {value}")
def on_multiple_numeric_values_changed(id, values):
logger.debug(f"multiple numeric values changed, widget {id} value {values}")
def on_click(id):
logger.debug("Clicked")
widget_registration_service.dispatch_on_click_event(id)
def run():
xframes.init(
"./assets",
json.dumps(font_defs),
json.dumps(theme2),
init,
on_text_changed,
on_combo_changed,
on_numeric_value_changed,
on_boolean_value_changed,
on_multiple_numeric_values_changed,
on_click
)
run()
flag = True
def keep_process_running():
while flag:
time.sleep(1)
# Start the keep-alive process in a separate thread
thread = threading.Thread(target=keep_process_running)
thread.daemon = True # Ensure the thread doesn't block program exit
thread.start()
# Main thread can perform other tasks
print("Main process continues to run...")
# time.sleep(5)
# flag = False # Stop the keep-alive process
thread.join() # Wait for the thread to finish