-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
155 lines (135 loc) · 4.41 KB
/
test.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
# import flet as ft
# import json
# all_controls = {}
# all_regions = {}
# selected = None
# itemName = None
# buttonDown = False
# # list_file = "widgets/widgets_list.json"
# # with open(list_file, "rb") as f:
# # supportedControls = list(map(lambda x: list(x.keys())[0], json.loads(f.read())))
# outlineContainer = ft.Container(
# border=ft.border.all(color=ft.colors.DEEP_ORANGE_900, width=3),
# )
# def isInRange(x, y, region):
# if (
# (x >= region.get("begin_x"))
# and (y >= region.get("begin_y"))
# and (x <= region.get("end_x"))
# and (y <= region.get("end_y"))
# ):
# return True
# return False
# def main(page: ft.Page):
# global outlineContainer
# page.window_height = 1000
# page.window_width = 1000
# def show_outline(selected):
# global outlineContainer
# outlineContainer.left = selected.left
# outlineContainer.top = selected.top
# outlineContainer.width = selected.width
# outlineContainer.height = selected.height
# outlineContainer.visible = True
# outlineContainer.update()
# def buttonDown(e: ft.TapEvent):
# global buttonDown
# buttonDown = True
# def itemselection(e: ft.TapEvent):
# global buttonDown
# if not buttonDown:
# return
# global all_controls
# global all_regions
# global selected
# global itemName
# global outlineContainer
# selected = None
# outlineContainer.visible = False
# outlineContainer.update()
# for name, region in all_regions.items():
# if isInRange(e.local_x, e.local_y, region):
# item = all_controls.get(name)
# selected = item
# itemName = name
# break
# if selected == None:
# return
# show_outline(selected=selected)
# return
# def on_pan_update2(e: ft.DragUpdateEvent):
# global left_pressed
# global selected
# global itemName
# global outlineContainer
# if selected == None:
# print("kslalsd")
# return
# outlineContainer.visible = False
# outlineContainer.update()
# new_left = max(0, (selected.left or 0) + e.delta_x)
# new_top = max(0, (selected.top or 0) + e.delta_y)
# all_regions.update(
# {
# itemName: {
# "begin_x": new_left,
# "begin_y": new_top,
# "end_x": new_left + selected.width,
# "end_y": new_top + selected.height,
# }
# }
# )
# selected.left = new_left
# selected.top = new_top
# selected.update()
# show_outline(selected=selected)
# main_stack = ft.Stack(
# controls=[
# ft.Container(
# border=ft.border.all(1.9, color="#383838"),
# border_radius=ft.border_radius.all(8),
# bgcolor=ft.colors.BLACK,
# margin=ft.margin.only(left=0, top=0),
# )
# ],
# height=1000,
# width=1000,
# )
# for item in all_controls.values():
# main_stack.controls.append(item)
# main_stack.controls.append(outlineContainer)
# gd1 = ft.GestureDetector(
# mouse_cursor=ft.MouseCursor.MOVE,
# drag_interval=5,
# on_pan_update=on_pan_update2,
# on_tap_down=buttonDown,
# on_tap_up=itemselection,
# width=1000,
# height=1000,
# # left=4000,
# # top=1500,
# content=main_stack,
# )
# # gd2 = ft.GestureDetector(
# # mouse_cursor=ft.MouseCursor.MOVE,
# # on_long_press_start=on_long_press,
# # on_pan_update=on_pan_update2,
# # drag_interval=10,
# # on_tap=on_tap1,
# # on_long_press_end=on_long_press,
# # left=700,
# # top=300,
# # content=ft.Container(
# # # bgcolor=ft.colors.BLUE,
# # width=row2.height,
# # height=row2.height,
# # content=row2,
# # ),
# # )
# # stack = ft.Stack([gd1], width=4000, height=1500)
# page.add(gd1)
# main_stack.update()
# ft.app(target=main)
# # # def __init__(self, conn: Connection, session_id):
# # # super(ft.Page).__init__(conn, session_id)
# # container = None