quantumgui 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. quantumgui/__init__.py +9 -0
  2. quantumgui/__main__.py +6 -0
  3. quantumgui/cli.py +341 -0
  4. quantumgui/core/__init__.py +39 -0
  5. quantumgui/core/animation.py +221 -0
  6. quantumgui/core/audit.py +323 -0
  7. quantumgui/core/context.py +54 -0
  8. quantumgui/core/data_source.py +426 -0
  9. quantumgui/core/draw.py +428 -0
  10. quantumgui/core/enterprise.py +402 -0
  11. quantumgui/core/enterprise_app.py +419 -0
  12. quantumgui/core/events.py +34 -0
  13. quantumgui/core/geometry.py +108 -0
  14. quantumgui/core/native_dialogs.py +276 -0
  15. quantumgui/core/pdf_report.py +390 -0
  16. quantumgui/core/rules.py +284 -0
  17. quantumgui/core/state.py +42 -0
  18. quantumgui/core/task_runner.py +181 -0
  19. quantumgui/core/widget.py +498 -0
  20. quantumgui/core/window.py +920 -0
  21. quantumgui/core/xlsx_export.py +145 -0
  22. quantumgui/py.typed +0 -0
  23. quantumgui/theme/__init__.py +32 -0
  24. quantumgui/theme/hct.py +191 -0
  25. quantumgui/theme/theme.py +93 -0
  26. quantumgui/theme/tokens.py +423 -0
  27. quantumgui/ui.py +2142 -0
  28. quantumgui/widgets/__init__.py +168 -0
  29. quantumgui/widgets/advanced.py +499 -0
  30. quantumgui/widgets/button.py +224 -0
  31. quantumgui/widgets/charts.py +625 -0
  32. quantumgui/widgets/charts_bi.py +528 -0
  33. quantumgui/widgets/charts_extra.py +430 -0
  34. quantumgui/widgets/charts_pro.py +568 -0
  35. quantumgui/widgets/checkbox.py +199 -0
  36. quantumgui/widgets/chip.py +219 -0
  37. quantumgui/widgets/containers.py +321 -0
  38. quantumgui/widgets/data_controls.py +487 -0
  39. quantumgui/widgets/data_grid.py +956 -0
  40. quantumgui/widgets/data_table.py +551 -0
  41. quantumgui/widgets/date_picker.py +407 -0
  42. quantumgui/widgets/display_media.py +372 -0
  43. quantumgui/widgets/display_pro.py +407 -0
  44. quantumgui/widgets/drawer.py +252 -0
  45. quantumgui/widgets/enterprise_controls.py +934 -0
  46. quantumgui/widgets/fab.py +261 -0
  47. quantumgui/widgets/forms_pro.py +703 -0
  48. quantumgui/widgets/forms_pro_media.py +587 -0
  49. quantumgui/widgets/inputs.py +870 -0
  50. quantumgui/widgets/layout_pro.py +162 -0
  51. quantumgui/widgets/list_view.py +307 -0
  52. quantumgui/widgets/masked_input.py +131 -0
  53. quantumgui/widgets/master_detail.py +155 -0
  54. quantumgui/widgets/navigation.py +382 -0
  55. quantumgui/widgets/overlays.py +355 -0
  56. quantumgui/widgets/productivity.py +500 -0
  57. quantumgui/widgets/productivity_boards.py +544 -0
  58. quantumgui/widgets/radio.py +209 -0
  59. quantumgui/widgets/scroll_view.py +129 -0
  60. quantumgui/widgets/select.py +373 -0
  61. quantumgui/widgets/sheets.py +249 -0
  62. quantumgui/widgets/slider.py +209 -0
  63. quantumgui/widgets/switch.py +196 -0
  64. quantumgui/widgets/tabs.py +175 -0
  65. quantumgui/widgets/text.py +101 -0
  66. quantumgui/widgets/text_field.py +490 -0
  67. quantumgui/widgets/time_picker.py +499 -0
  68. quantumgui-1.0.0.dist-info/METADATA +137 -0
  69. quantumgui-1.0.0.dist-info/RECORD +73 -0
  70. quantumgui-1.0.0.dist-info/WHEEL +5 -0
  71. quantumgui-1.0.0.dist-info/entry_points.txt +2 -0
  72. quantumgui-1.0.0.dist-info/licenses/LICENSE +32 -0
  73. quantumgui-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,487 @@
1
+ """Material Design 3 Data Controls: TreeView, Pagination, ExpansionPanel, Skeleton."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import math
6
+ from dataclasses import dataclass, field
7
+ from typing import Any, Callable, Sequence
8
+
9
+ import skia
10
+
11
+ from ..core.context import context
12
+ from ..core.draw import (
13
+ draw_elevation_shadow,
14
+ draw_icon,
15
+ draw_text_centered_y,
16
+ font_for_style,
17
+ make_rrect,
18
+ make_rrect_spec,
19
+ measure_text,
20
+ resolve_color,
21
+ )
22
+ from ..core.events import MouseEvent
23
+ from ..core.geometry import Constraints, EdgeInsets, Rect, Size
24
+ from ..core.state import State
25
+ from ..core.widget import Widget
26
+ from ..theme import ShapeToken, Theme
27
+ from .containers import Column
28
+
29
+
30
+ @dataclass
31
+ class TreeNode:
32
+ """Hierarchical node for `ui.tree_view`."""
33
+
34
+ label: str
35
+ icon: str | None = None
36
+ children: list[TreeNode] = field(default_factory=list)
37
+ expanded: bool = False
38
+ data: Any = None
39
+
40
+
41
+ class TreeView(Widget):
42
+ """Material Design 3 hierarchical TreeView with expand/collapse and selection."""
43
+
44
+ interactive = True
45
+ manages_own_box = True
46
+ cursor = "pointer"
47
+
48
+ ROW_H = 38.0
49
+ INDENT = 22.0
50
+
51
+ def __init__(
52
+ self,
53
+ nodes: Sequence[TreeNode],
54
+ *,
55
+ on_select: Callable[[TreeNode], None] | None = None,
56
+ ) -> None:
57
+ super().__init__()
58
+ self.nodes: list[TreeNode] = list(nodes)
59
+ self.on_select = on_select
60
+ self._selected_node: TreeNode | None = None
61
+ self._hover_idx: int = -1
62
+ self._flat: list[tuple[int, TreeNode]] = []
63
+ self._fill_width = True
64
+ self._rebuild_flat()
65
+
66
+ def _rebuild_flat(self) -> None:
67
+ out: list[tuple[int, TreeNode]] = []
68
+
69
+ def walk(items: list[TreeNode], depth: int) -> None:
70
+ for node in items:
71
+ out.append((depth, node))
72
+ if node.children and node.expanded:
73
+ walk(node.children, depth + 1)
74
+
75
+ walk(self.nodes, 0)
76
+ self._flat = out
77
+
78
+ @property
79
+ def selected_node(self) -> TreeNode | None:
80
+ return self._selected_node
81
+
82
+ def _measure_content(self, constraints: Constraints, theme: Theme) -> Size:
83
+ self._rebuild_flat()
84
+ w = constraints.max_width if constraints.max_width != float("inf") else 300.0
85
+ h = max(self.ROW_H, len(self._flat) * self.ROW_H + 12.0)
86
+ return Size(w, h)
87
+
88
+ def _index_at(self, y: float) -> int:
89
+ idx = int((y - (self.rect.y + 6.0)) // self.ROW_H)
90
+ return idx if 0 <= idx < len(self._flat) else -1
91
+
92
+ def on_mouse_move(self, event: MouseEvent) -> None:
93
+ idx = self._index_at(event.y)
94
+ if idx != self._hover_idx:
95
+ self._hover_idx = idx
96
+ self.invalidate()
97
+
98
+ def on_mouse_leave(self) -> None:
99
+ super().on_mouse_leave()
100
+ self._hover_idx = -1
101
+
102
+ def on_mouse_up(self, event: MouseEvent) -> None:
103
+ was_pressed = self.pressed
104
+ super().on_mouse_up(event)
105
+ if not was_pressed or not self.rect.contains(event.x, event.y):
106
+ return
107
+ idx = self._index_at(event.y)
108
+ if idx == -1:
109
+ return
110
+ _depth, node = self._flat[idx]
111
+ if node.children:
112
+ node.expanded = not node.expanded
113
+ self._rebuild_flat()
114
+ self._selected_node = node
115
+ if self.on_select is not None:
116
+ self.on_select(node)
117
+ self.invalidate()
118
+
119
+ def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
120
+ self._rebuild_flat()
121
+ c = theme.colors
122
+ rad_spec = self._shape_override if self._shape_override is not None else "medium"
123
+ rad = rad_spec[0] if isinstance(rad_spec, tuple) else theme.shape.resolve(rad_spec)
124
+ if self._elevation_override:
125
+ sh = resolve_color(self._shadow_color_override, theme, c.shadow)
126
+ assert sh is not None
127
+ draw_elevation_shadow(canvas, self.rect, rad, self._elevation_override, sh)
128
+ rrect = make_rrect_spec(self.rect, rad_spec, theme)
129
+
130
+ bg = resolve_color(self._bg_override, theme, c.surface) or c.surface
131
+ bc = resolve_color(self._border_color_override, theme, c.outline_variant) or c.outline_variant
132
+ bw = self._border_width_override if self._border_width_override is not None else 1.0
133
+ canvas.drawRRect(rrect, skia.Paint(AntiAlias=True, Color=bg.to_skia()))
134
+ canvas.drawRRect(
135
+ rrect,
136
+ skia.Paint(AntiAlias=True, Color=bc.to_skia(), Style=skia.Paint.kStroke_Style, StrokeWidth=bw),
137
+ )
138
+
139
+ font = font_for_style(theme.font_family, theme.typography.body_medium)
140
+ for i, (depth, node) in enumerate(self._flat):
141
+ ry = self.rect.y + 6.0 + i * self.ROW_H
142
+ row_rect = Rect(self.rect.x + 6.0, ry, self.rect.width - 12.0, self.ROW_H)
143
+ is_sel = node is self._selected_node
144
+
145
+ if is_sel:
146
+ canvas.drawRRect(
147
+ make_rrect(row_rect, 8.0),
148
+ skia.Paint(AntiAlias=True, Color=c.secondary_container.to_skia()),
149
+ )
150
+ elif i == self._hover_idx:
151
+ canvas.drawRRect(
152
+ make_rrect(row_rect, 8.0),
153
+ skia.Paint(AntiAlias=True, Color=c.on_surface.with_alpha(theme.state_layers.hover).to_skia()),
154
+ )
155
+
156
+ fg = c.on_secondary_container if is_sel else c.on_surface
157
+ ic = c.on_secondary_container if is_sel else c.on_surface_variant
158
+ x = row_rect.x + 12.0 + depth * self.INDENT
159
+
160
+ if node.children:
161
+ draw_icon(canvas, "chevron_down" if node.expanded else "chevron_right", x + 6.0, row_rect.center_y, 14.0, ic)
162
+ x += 20.0
163
+
164
+ if node.icon:
165
+ draw_icon(canvas, node.icon, x + 8.0, row_rect.center_y, 16.0, ic)
166
+ x += 24.0
167
+
168
+ draw_text_centered_y(canvas, node.label, x, row_rect.center_y, font, fg)
169
+
170
+
171
+ class Pagination(Widget):
172
+ """Material Design 3 Pagination bar (`< 1 2 3 ... N >`)."""
173
+
174
+ interactive = True
175
+ cursor = "pointer"
176
+
177
+ BTN_SIZE = 36.0
178
+ GAP = 6.0
179
+
180
+ def __init__(
181
+ self,
182
+ total_pages: int,
183
+ *,
184
+ page: int = 1,
185
+ max_visible: int = 5,
186
+ bind: State[int] | None = None,
187
+ on_change: Callable[[int], None] | None = None,
188
+ ) -> None:
189
+ super().__init__()
190
+ self.total_pages = max(1, int(total_pages))
191
+ self.max_visible = max(3, int(max_visible))
192
+ self._bind = bind
193
+ self._page = max(1, min(self.total_pages, int(bind.value) if bind is not None else int(page)))
194
+ self.on_change = on_change
195
+ self._hover_token: str | None = None
196
+ self._hit_boxes: list[tuple[str, Rect]] = []
197
+
198
+ if bind is not None:
199
+ bind.subscribe(self._on_bound_change)
200
+
201
+ def _on_bound_change(self, val: int) -> None:
202
+ p = max(1, min(self.total_pages, int(val)))
203
+ if p != self._page:
204
+ self._page = p
205
+ self.invalidate()
206
+
207
+ @property
208
+ def page(self) -> int:
209
+ return self._page
210
+
211
+ @page.setter
212
+ def page(self, val: int) -> None:
213
+ p = max(1, min(self.total_pages, int(val)))
214
+ if p != self._page:
215
+ self._page = p
216
+ if self._bind is not None and self._bind.value != p:
217
+ self._bind.value = p
218
+ self.invalidate()
219
+
220
+ def _tokens(self) -> list[str]:
221
+ tokens = ["prev"]
222
+ n = self.total_pages
223
+ if n <= self.max_visible + 2:
224
+ tokens.extend(str(i) for i in range(1, n + 1))
225
+ else:
226
+ half = self.max_visible // 2
227
+ start = max(2, self._page - half)
228
+ end = min(n - 1, start + self.max_visible - 1)
229
+ start = max(2, end - self.max_visible + 1)
230
+ tokens.append("1")
231
+ if start > 2:
232
+ tokens.append("...")
233
+ tokens.extend(str(i) for i in range(start, end + 1))
234
+ if end < n - 1:
235
+ tokens.append("...")
236
+ tokens.append(str(n))
237
+ tokens.append("next")
238
+ return tokens
239
+
240
+ def _measure_content(self, constraints: Constraints, theme: Theme) -> Size:
241
+ toks = self._tokens()
242
+ w = len(toks) * self.BTN_SIZE + max(0, len(toks) - 1) * self.GAP
243
+ return Size(w, self.BTN_SIZE)
244
+
245
+ def on_mouse_move(self, event: MouseEvent) -> None:
246
+ found = None
247
+ for tok, r in self._hit_boxes:
248
+ if tok != "..." and r.contains(event.x, event.y):
249
+ found = tok
250
+ break
251
+ if found != self._hover_token:
252
+ self._hover_token = found
253
+ self.invalidate()
254
+
255
+ def on_mouse_leave(self) -> None:
256
+ super().on_mouse_leave()
257
+ self._hover_token = None
258
+
259
+ def on_mouse_up(self, event: MouseEvent) -> None:
260
+ was_pressed = self.pressed
261
+ super().on_mouse_up(event)
262
+ if not was_pressed:
263
+ return
264
+ for tok, r in self._hit_boxes:
265
+ if r.contains(event.x, event.y):
266
+ prev = self._page
267
+ if tok == "prev" and self._page > 1:
268
+ self.page = self._page - 1
269
+ elif tok == "next" and self._page < self.total_pages:
270
+ self.page = self._page + 1
271
+ elif tok.isdigit():
272
+ self.page = int(tok)
273
+ if self._page != prev and self.on_change is not None:
274
+ self.on_change(self._page)
275
+ return
276
+
277
+ def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
278
+ c = theme.colors
279
+ toks = self._tokens()
280
+ font = font_for_style(theme.font_family, theme.typography.label_large)
281
+ self._hit_boxes = []
282
+ x = self.rect.x
283
+ y = self.rect.center_y - self.BTN_SIZE * 0.5
284
+
285
+ for tok in toks:
286
+ br = Rect(x, y, self.BTN_SIZE, self.BTN_SIZE)
287
+ self._hit_boxes.append((tok, br))
288
+ is_active = tok.isdigit() and int(tok) == self._page
289
+ is_disabled = (tok == "prev" and self._page <= 1) or (tok == "next" and self._page >= self.total_pages)
290
+
291
+ if is_active:
292
+ canvas.drawCircle(br.center_x, br.center_y, self.BTN_SIZE * 0.5, skia.Paint(AntiAlias=True, Color=c.primary.to_skia()))
293
+ elif not is_disabled and tok == self._hover_token:
294
+ canvas.drawCircle(
295
+ br.center_x,
296
+ br.center_y,
297
+ self.BTN_SIZE * 0.5,
298
+ skia.Paint(AntiAlias=True, Color=c.on_surface.with_alpha(theme.state_layers.hover).to_skia()),
299
+ )
300
+
301
+ fg = c.on_primary if is_active else (c.on_surface.with_alpha(0.35) if is_disabled else c.on_surface)
302
+ if tok == "prev":
303
+ draw_icon(canvas, "chevron_left", br.center_x, br.center_y, 16.0, fg)
304
+ elif tok == "next":
305
+ draw_icon(canvas, "chevron_right", br.center_x, br.center_y, 16.0, fg)
306
+ else:
307
+ tw = measure_text(font, tok)
308
+ draw_text_centered_y(canvas, tok, br.center_x - tw * 0.5, br.center_y, font, fg)
309
+
310
+ x += self.BTN_SIZE + self.GAP
311
+
312
+
313
+ class ExpansionPanel(Widget):
314
+ """Material Design 3 collapsible Accordion / ExpansionPanel."""
315
+
316
+ interactive = True
317
+ manages_own_box = True
318
+ cursor = "pointer"
319
+
320
+ HEADER_H = 56.0
321
+
322
+ def __init__(
323
+ self,
324
+ title: str,
325
+ *,
326
+ subtitle: str | None = None,
327
+ icon: str | None = None,
328
+ expanded: bool = False,
329
+ on_toggle: Callable[[bool], None] | None = None,
330
+ ) -> None:
331
+ super().__init__()
332
+ self.title = title
333
+ self.subtitle = subtitle
334
+ self.icon = icon
335
+ self._expanded = bool(expanded)
336
+ self.on_toggle = on_toggle
337
+ self._fill_width = True
338
+
339
+ with context.detached():
340
+ self._body = Column(gap=10.0, align="stretch")
341
+ self._body._padding = EdgeInsets(12.0, 16.0, 16.0, 16.0)
342
+ self._body.visible(self._expanded)
343
+ self.add_child(self._body)
344
+
345
+ def __enter__(self) -> ExpansionPanel:
346
+ context.push_container(self._body)
347
+ return self
348
+
349
+ def __exit__(self, exc_type, exc_val, exc_tb) -> None:
350
+ context.pop_container()
351
+
352
+ @property
353
+ def expanded(self) -> bool:
354
+ return self._expanded
355
+
356
+ @expanded.setter
357
+ def expanded(self, val: bool) -> None:
358
+ b = bool(val)
359
+ if b != self._expanded:
360
+ self._expanded = b
361
+ self._body.visible(b)
362
+ self.invalidate()
363
+
364
+ def toggle(self) -> None:
365
+ self.expanded = not self._expanded
366
+ if self.on_toggle is not None:
367
+ self.on_toggle(self._expanded)
368
+
369
+ def _header_rect(self) -> Rect:
370
+ return Rect(self.rect.x, self.rect.y, self.rect.width, self.HEADER_H)
371
+
372
+ def _measure_content(self, constraints: Constraints, theme: Theme) -> Size:
373
+ w = constraints.max_width if constraints.max_width != float("inf") else 360.0
374
+ h = self.HEADER_H
375
+ if self._expanded:
376
+ bsz = self._body.measure(Constraints(0.0, w, 0.0, float("inf")), theme)
377
+ h += bsz.height
378
+ return Size(w, h)
379
+
380
+ def _layout_children(self, content_rect: Rect, theme: Theme) -> None:
381
+ if self._expanded:
382
+ bsz = self._body.measure(Constraints(0.0, content_rect.width, 0.0, float("inf")), theme)
383
+ self._body.layout(Rect(content_rect.x, content_rect.y + self.HEADER_H, content_rect.width, bsz.height), theme)
384
+
385
+ def on_mouse_up(self, event: MouseEvent) -> None:
386
+ was_pressed = self.pressed
387
+ super().on_mouse_up(event)
388
+ if was_pressed and self._header_rect().contains(event.x, event.y):
389
+ self.toggle()
390
+
391
+ def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
392
+ c = theme.colors
393
+ rad_spec = self._shape_override if self._shape_override is not None else "medium"
394
+ rad = rad_spec[0] if isinstance(rad_spec, tuple) else theme.shape.resolve(rad_spec)
395
+ if self._elevation_override:
396
+ sh = resolve_color(self._shadow_color_override, theme, c.shadow)
397
+ assert sh is not None
398
+ draw_elevation_shadow(canvas, self.rect, rad, self._elevation_override, sh)
399
+ rrect = make_rrect_spec(self.rect, rad_spec, theme)
400
+ bg = resolve_color(self._bg_override, theme, c.surface_container_low) or c.surface_container_low
401
+ canvas.drawRRect(rrect, skia.Paint(AntiAlias=True, Color=bg.to_skia()))
402
+
403
+ hr = self._header_rect()
404
+ if self.hovered and hr.contains(self.window._mouse_pos[0], self.window._mouse_pos[1]) if self.window else False:
405
+ canvas.save()
406
+ canvas.clipRRect(rrect, doAntiAlias=True)
407
+ canvas.drawRect(
408
+ skia.Rect.MakeXYWH(hr.x, hr.y, hr.width, hr.height),
409
+ skia.Paint(AntiAlias=True, Color=c.on_surface.with_alpha(theme.state_layers.hover).to_skia()),
410
+ )
411
+ canvas.restore()
412
+
413
+ tx = hr.x + 16.0
414
+ if self.icon:
415
+ draw_icon(canvas, self.icon, hr.x + 28.0, hr.center_y, 20.0, c.primary)
416
+ tx = hr.x + 52.0
417
+
418
+ tfont = font_for_style(theme.font_family, theme.typography.title_medium)
419
+ if self.subtitle:
420
+ draw_text_centered_y(canvas, self.title, tx, hr.center_y - 9.0, tfont, c.on_surface)
421
+ sfont = font_for_style(theme.font_family, theme.typography.body_small)
422
+ draw_text_centered_y(canvas, self.subtitle, tx, hr.center_y + 11.0, sfont, c.on_surface_variant)
423
+ else:
424
+ draw_text_centered_y(canvas, self.title, tx, hr.center_y, tfont, c.on_surface)
425
+
426
+ draw_icon(canvas, "chevron_up" if self._expanded else "chevron_down", hr.right - 24.0, hr.center_y, 18.0, c.on_surface_variant)
427
+
428
+ if self._expanded:
429
+ canvas.drawLine(
430
+ self.rect.x + 16.0,
431
+ hr.bottom,
432
+ self.rect.right - 16.0,
433
+ hr.bottom,
434
+ skia.Paint(AntiAlias=True, Color=c.outline_variant.to_skia(), StrokeWidth=1.0),
435
+ )
436
+
437
+ bc = resolve_color(self._border_color_override, theme, c.outline_variant) or c.outline_variant
438
+ bw = self._border_width_override if self._border_width_override is not None else 1.0
439
+ canvas.drawRRect(
440
+ rrect,
441
+ skia.Paint(AntiAlias=True, Color=bc.to_skia(), Style=skia.Paint.kStroke_Style, StrokeWidth=bw),
442
+ )
443
+
444
+
445
+ class Skeleton(Widget):
446
+ """Animated Material Design 3 shimmer loading placeholder."""
447
+
448
+ def __init__(
449
+ self,
450
+ *,
451
+ width: float | None = None,
452
+ height: float = 18.0,
453
+ shape: ShapeToken | float = "small",
454
+ ) -> None:
455
+ super().__init__()
456
+ if width is not None:
457
+ self._fixed_width = float(width)
458
+ else:
459
+ self._fill_width = True
460
+ self._fixed_height = float(height)
461
+ self._shape_override = shape
462
+
463
+ def _measure_content(self, constraints: Constraints, theme: Theme) -> Size:
464
+ w = self._fixed_width if self._fixed_width is not None else (
465
+ constraints.max_width if constraints.max_width != float("inf") else 200.0
466
+ )
467
+ return Size(w, self._fixed_height or 18.0)
468
+
469
+ def tick(self, now: float) -> bool:
470
+ return True # Smooth GPU shimmer sweep
471
+
472
+ def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
473
+ c = theme.colors
474
+ r = self.rect
475
+ rad = theme.shape.resolve(self._shape_override or "small")
476
+ rrect = make_rrect(r, rad)
477
+
478
+ base = c.surface_container_highest
479
+ hi = c.surface_container_low if theme.mode == "light" else c.surface_bright
480
+ phase = (now * 0.85) % 1.0
481
+ sweep_x = r.x - r.width * 0.4 + phase * (r.width * 1.8)
482
+ grad = skia.GradientShader.MakeLinear(
483
+ [(sweep_x - r.width * 0.3, r.y), (sweep_x + r.width * 0.3, r.y)],
484
+ [base.to_skia(), hi.to_skia(), base.to_skia()],
485
+ [0.0, 0.5, 1.0],
486
+ )
487
+ canvas.drawRRect(rrect, skia.Paint(AntiAlias=True, Shader=grad))