-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.kv
213 lines (201 loc) · 9.68 KB
/
main.kv
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#: import read_file_text ae.files.read_file_text
#: import shader_parameter_alias ae.kivy_glsl.shader_parameter_alias
#: import shader_parameters ae.kivy_glsl.shader_parameters
# already imported via ae.kivy_sideloading/kv-string: #: import _f_ ae.kivy_file_chooser
#: import _u_ ae.kivy_user_prefs
<Main@BoxLayout>
orientation: 'vertical'
StackLayout:
orientation: 'tb-lr'
size_hint_y: None
height: app.button_height * 2
spacing: '3sp', 0
HelpToggler:
size_hint: None, None
size: usr_pref.size
UserPreferencesButton:
id: usr_pref
size_hint_x: None
width: self.height
FlowButton:
id: add_ren
tap_flow_id: id_of_flow('add', 'shader')
icon_name: id_of_flow('add', 'item')
disabled: not app.app_states['sel_sha_code']
size_hint_x: None
width: self.height * (2.1 if app.landscape else 1.0)
relief_ellipse_inner_colors: relief_colors((0.99, 0.99, 0.0))
relief_ellipse_inner_lines: 0 if self.disabled else int(self.height / 2.1)
FlowButton:
tap_flow_id: id_of_flow('del', 'shader')
icon_name: id_of_flow('delete', 'item')
disabled: len(app.app_states['shaders_args']) <= 1
size_hint_x: None
width: self.height * (2.1 if app.landscape else 1.0)
relief_square_inner_colors: relief_colors((0.99, 0.0, 0.0))
relief_square_inner_lines: 0 if self.disabled else int(self.height / 2.1)
ShadersBox:
id: shaders_box
size_hint_x: None
width:
self.parent.width - usr_pref.width - add_ren.width - sideloading_button.width - self.parent.spacing[0]*3
spacing: '3sp'
SideloadingButton:
id: sideloading_button
FlowToggler:
tap_flow_id: id_of_flow('toggle', 'tool_box')
text: "^" if tool_box.visible else "v"
size_hint_x: None
width: sideloading_button.width
font_size: app.app_states['font_size'] * 1.62
relief_ellipse_inner_colors: relief_colors(Window.clearcolor)
relief_ellipse_inner_lines: int(self.height / (2.1 if tool_box.visible else 1.5))
Widget:
size_hint_y: None
height: '6sp'
BoxLayout:
id: tool_box
visible: True
disabled: not self.visible
size_hint_y: None
height:
round(2.4 * app.app_states['font_size'] + input_values.height + shader_args_layout.minimum_height) \
if self.visible else 0
orientation: 'vertical'
padding: '6sp'
spacing: '3sp'
canvas:
Color:
rgba: app.font_color[:3] + (0.369 if tool_box.visible else 0.0, )
RoundedRectangle:
pos: self.pos
size: self.size
Color:
rgba: app.font_color[:3] + (0.69 if tool_box.visible else 0.0, )
Line:
width: sp(0.9)
rounded_rectangle: self.x + 1, self.y + 1, self.width - 2, self.height - 2, sp(9)
BoxLayout:
spacing: '3sp'
padding: '3sp'
size_hint_y: None
height: app.button_height if tool_box.visible else 0.0
FileChooserButton:
visible: tool_box.visible
ShaderArgInput:
id: shader_file_inp
arg_name: 'shader_filename'
OptionalButton:
tap_flow_id: id_of_flow('run', 'shader')
visible: tool_box.visible
width: self.height * 3 if self.visible else 0.0
_run_state: app.app_states['shaders_args'][app.app_states['shaders_idx']]['run_state']
text: _("pause") if self._run_state == 'running' else _("run")
relief_ellipse_inner_colors:
relief_colors(
(0.609, 0.999, 0.6) if self._run_state == 'running' else
(0.999, 0.999, 0.6) if self._run_state == 'paused' else
(0.999, 0.609, 0.6))
relief_ellipse_inner_lines: int(self.height / 2.7) if tool_box.visible else 0
OptionalButton:
tap_flow_id: id_of_flow('next', 'render_tick')
visible:
app.app_states['render_frequency'] == app.main_app.get_var('render_frequency_min') \
and tool_box.visible
text: "tick"
relief_square_inner_colors: relief_colors() if tool_box.visible else ()
relief_square_inner_lines: int(self.height / 3.9)
ShaderArgs:
id: shader_args_layout
ImageLabel:
id: input_values
font_size: app.app_states['font_size'] * 0.9
size_hint: 1 if tool_box.visible else None, None
opacity: 1 if tool_box.visible else 0
text_size: self.width, None
# self.height binding needed for initial redraw (else height is wrong for multiline label text)
size: self.width if tool_box.visible else 0, self.texture_size[1] or self.height if tool_box.visible else 0
RenderWidget:
id: render_widget
size_hint_y: 1
size_hint_min: sp(90), sp(90) # prevent division by zero on win resize
on_pos: app.main_app.on_render_wid_pos_size()
on_size: app.main_app.on_render_wid_pos_size()
ImageLabel:
id: status_bar
height: app.button_height * (1 + self.text.count("\n")) if self.text else 0.0
square_fill_ink: 0.999, 0.3, 0.3, 0.3
relief_square_inner_colors: relief_colors((0.999, 0.3, 0.3)) if self.text else ()
relief_square_inner_lines: int(self.height / 3.9)
<RenderWidget@ImageLabel>
on_touch_down:
if self.collide_point(*args[1].pos): \
app.main_app.hist_touch.append(app.main_app.last_touch); \
app.main_app.last_touch = (float(args[1].x), float(args[1].y)); \
app.main_app.update_input_values()
<FileChooserButton@OptionalButton>
tap_flow_id: id_of_flow('open', 'file_chooser', 'shader_filename')
tap_kwargs:
update_tap_kwargs(self, popup_kwargs=dict(
initial_path=app.app_states['file_chooser_initial_path'] or norm_path("{ado}") or ".", \
submit_to='shader_filename', filters=['*.glsl']))
text: "..."
size_hint_x: None
width: self.height
relief_ellipse_inner_colors: relief_colors()
relief_ellipse_inner_lines: int(self.height / 3.9)
<ShaderButton@FlowButton>
tap_flow_id: id_of_flow('sel', 'shader', self.text)
on_long_tap: app.main_app.change_flow(id_of_flow('toggle', 'tool_box'))
selected: app.app_states['shaders_idx'] == int(self.text.split("==")[0])
but_color: app.app_states['selected_item_ink' if self.selected else 'unselected_item_ink']
size_hint_x: 1.0 / (len(app.app_states['shaders_args']) + 1) * (2 if self.selected else 1)
height: self.parent.height if self.parent else self.height
ellipse_fill_ink: self.but_color
relief_ellipse_inner_colors: relief_colors(self.but_color)
relief_ellipse_inner_lines: int(self.height / 3.9)
<ShadersBox@DynamicChildrenBehavior+BoxLayout>
shader_buttons: []
child_data_maps: [dict(cls='ShaderButton', kwargs=kwargs) for kwargs in self.shader_buttons]
<ShaderArgInput>
size_hint_y: None
height: app.button_height if root.visible else 0.0
sai_alias_name: shader_parameter_alias(app.app_states['sel_sha_code'], root.arg_name)
sai_shader_args: app.app_states['shaders_args'][app.app_states['shaders_idx']]
visible: bool(root.parent and root.parent.parent.visible)
ImageLabel:
size_hint: 0.09, 1.0
font_size: app.app_states['font_size'] * 0.69
# strange: text is visible in dark mode (even with color.alpha==0), had to set it to "", alt: opacity = 0
text: _(root.sai_alias_name) + ":" if root.visible else ""
text_size: self.width, None
halign: 'right'
FlowInput:
background_color:
([0.9, 0.81, 0.78] if root.arg_name in root.sai_shader_args['err_arg_names'] else
[0.93, 0.96, 0.99]) + [0.999 if root.visible else 0.0]
focus_flow_id: id_of_flow('edit', 'shader_arg', root.arg_name)
text: root.sai_shader_args.get(root.arg_name) or root.sai_shader_args and False or ""
on_text:
# block update of shaders_args at app start/init and on refresh of the other/not-selected shaders/buttons
# .. and prevent adding of arg_name to shaders_args app state when in the switch/sel of shader
app.main_app.render_widget and app.main_app.shaders_idx == app.app_states['shaders_idx'] \
and (self.text or root.arg_name in app.main_app.shaders_args[app.main_app.shaders_idx]) and \
app.main_app.change_shader_arg(root.arg_name, self.text)
alias_name: root.sai_alias_name
sug_filename: os.path.join(norm_path("{sug}"), root.arg_name + "ShaderArg.txt")
auto_complete_texts: file_lines(self.sug_filename)
on_auto_complete_texts: write_file_text(self.auto_complete_texts, self.sug_filename)
<ShaderArgs@DynamicChildrenBehavior+GridLayout>
spacing: '9sp'
padding: '6sp'
cols: max(1, int(Window.width / (15 * app.main_app.font_size)))
child_data_maps:
[dict(cls='ShaderArgInput', kwargs=dict(arg_name=p)) for p in shader_parameters(app.app_states['sel_sha_code'])]
<UserPreferencesPopup>:
AppStateSlider:
app_state_name: 'render_frequency'
cursor_image:
app.main_app.img_file('timer_frequency', app.app_states['font_size'], app.app_states['light_theme'])
min: app.main_app.get_var('render_frequency_min')
max: app.main_app.get_var('render_frequency_max')