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,500 @@
1
+ """Phase 9 Desktop Productivity Controls (Part 1): Breadcrumbs, Stepper, Timeline, CommandPalette."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from typing import Callable, Literal, Sequence
7
+
8
+ import glfw
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 CharEvent, KeyEvent, MouseEvent
23
+ from ..core.geometry import Constraints, Rect, Size
24
+ from ..core.state import State
25
+ from ..core.widget import Widget
26
+ from ..theme import Color, Theme
27
+
28
+ ToneRole = Literal["primary", "secondary", "tertiary", "error", "neutral"]
29
+
30
+
31
+ def _tone_colors(tone: ToneRole, theme: Theme) -> tuple[Color, Color]:
32
+ c = theme.colors
33
+ if tone == "primary":
34
+ return (c.primary, c.on_primary)
35
+ if tone == "secondary":
36
+ return (c.secondary, c.on_secondary)
37
+ if tone == "tertiary":
38
+ return (c.tertiary, c.on_tertiary)
39
+ if tone == "error":
40
+ return (c.error, c.on_error)
41
+ return (c.outline, c.surface)
42
+
43
+
44
+ # ---------------------------------------------------------------------------
45
+ # 1. Breadcrumbs
46
+ # ---------------------------------------------------------------------------
47
+
48
+
49
+ class Breadcrumbs(Widget):
50
+ """Clickable hierarchical breadcrumb trail (`Inicio › Ventas › Facturas`)."""
51
+
52
+ interactive = True
53
+ manages_own_box = False
54
+ cursor = "pointer"
55
+
56
+ def __init__(
57
+ self,
58
+ items: Sequence[str],
59
+ *,
60
+ separator: str = "›",
61
+ on_select: Callable[[int, str], None] | None = None,
62
+ ) -> None:
63
+ super().__init__()
64
+ self.items: list[str] = list(items)
65
+ self.separator = separator
66
+ self.on_select = on_select
67
+ self._hover_idx: int = -1
68
+ self._item_rects: list[Rect] = []
69
+
70
+ def _measure_content(self, constraints: Constraints, theme: Theme) -> Size:
71
+ font = font_for_style(theme.font_family, theme.typography.label_large)
72
+ sep_w = measure_text(font, f" {self.separator} ") + 4.0
73
+ total = sum(measure_text(font, it) + 12.0 for it in self.items)
74
+ if len(self.items) > 1:
75
+ total += sep_w * (len(self.items) - 1)
76
+ return Size(max(60.0, total + 8.0), 32.0)
77
+
78
+ def on_mouse_move(self, event: MouseEvent) -> None:
79
+ hit = -1
80
+ for i, r in enumerate(self._item_rects):
81
+ if r.contains(event.x, event.y):
82
+ hit = i
83
+ break
84
+ if hit != self._hover_idx:
85
+ self._hover_idx = hit
86
+ self.invalidate()
87
+
88
+ def on_mouse_leave(self) -> None:
89
+ super().on_mouse_leave()
90
+ self._hover_idx = -1
91
+
92
+ def on_mouse_up(self, event: MouseEvent) -> None:
93
+ was_pressed = self.pressed
94
+ super().on_mouse_up(event)
95
+ if not was_pressed:
96
+ return
97
+ for i, r in enumerate(self._item_rects):
98
+ if r.contains(event.x, event.y) and i < len(self.items) - 1:
99
+ if self.on_select is not None:
100
+ self.on_select(i, self.items[i])
101
+ return
102
+
103
+ def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
104
+ c = theme.colors
105
+ font = font_for_style(theme.font_family, theme.typography.label_large)
106
+ sep_w = measure_text(font, f" {self.separator} ")
107
+ self._item_rects = []
108
+ x = self.rect.x + 4.0
109
+ cy = self.rect.center_y
110
+ last = len(self.items) - 1
111
+
112
+ for i, label in enumerate(self.items):
113
+ tw = measure_text(font, label)
114
+ ir = Rect(x, self.rect.y + 2.0, tw + 12.0, self.rect.height - 4.0)
115
+ self._item_rects.append(ir)
116
+
117
+ if i == self._hover_idx and i < last:
118
+ canvas.drawRRect(
119
+ make_rrect(ir, 6.0),
120
+ skia.Paint(AntiAlias=True, Color=c.on_surface.with_alpha(theme.state_layers.hover).to_skia()),
121
+ )
122
+
123
+ fg = c.on_surface if i == last else (c.primary if i == self._hover_idx else c.on_surface_variant)
124
+ draw_text_centered_y(canvas, label, ir.x + 6.0, cy, font, fg)
125
+ x = ir.right
126
+ if i < last:
127
+ draw_text_centered_y(canvas, f" {self.separator} ", x, cy, font, c.outline)
128
+ x += sep_w + 4.0
129
+
130
+
131
+ # ---------------------------------------------------------------------------
132
+ # 2. Stepper / Wizard
133
+ # ---------------------------------------------------------------------------
134
+
135
+
136
+ class Stepper(Widget):
137
+ """Horizontal Material Design 3 multi-step Wizard / Stepper."""
138
+
139
+ interactive = True
140
+ manages_own_box = False
141
+ cursor = "pointer"
142
+
143
+ def __init__(
144
+ self,
145
+ steps: Sequence[str],
146
+ *,
147
+ current: int = 0,
148
+ error_step: int | None = None,
149
+ clickable: bool = True,
150
+ bind: State[int] | None = None,
151
+ on_change: Callable[[int], None] | None = None,
152
+ ) -> None:
153
+ super().__init__()
154
+ self.steps: list[str] = list(steps)
155
+ self.error_step = error_step
156
+ self.clickable = clickable
157
+ self._bind = bind
158
+ self.on_change = on_change
159
+ self._current: int = int(bind.value) if bind is not None else int(current)
160
+ self._step_rects: list[Rect] = []
161
+ self._fill_width = True
162
+ if bind is not None:
163
+ bind.subscribe(self._on_bound)
164
+
165
+ def _on_bound(self, idx: int) -> None:
166
+ self._current = max(0, min(len(self.steps) - 1, int(idx)))
167
+ self.invalidate()
168
+
169
+ @property
170
+ def current(self) -> int:
171
+ return self._current
172
+
173
+ @current.setter
174
+ def current(self, idx: int) -> None:
175
+ if not self.steps:
176
+ return
177
+ self._current = max(0, min(len(self.steps) - 1, int(idx)))
178
+ if self._bind is not None:
179
+ self._bind.value = self._current
180
+ self.invalidate()
181
+
182
+ def next_step(self) -> None:
183
+ self.current = self._current + 1
184
+ if self.on_change is not None:
185
+ self.on_change(self._current)
186
+
187
+ def prev_step(self) -> None:
188
+ self.current = self._current - 1
189
+ if self.on_change is not None:
190
+ self.on_change(self._current)
191
+
192
+ def _measure_content(self, constraints: Constraints, theme: Theme) -> Size:
193
+ w = constraints.max_width if constraints.max_width != float("inf") else 480.0
194
+ return Size(w, 64.0)
195
+
196
+ def on_mouse_up(self, event: MouseEvent) -> None:
197
+ was_pressed = self.pressed
198
+ super().on_mouse_up(event)
199
+ if not self.clickable or not was_pressed:
200
+ return
201
+ for i, sr in enumerate(self._step_rects):
202
+ if sr.contains(event.x, event.y):
203
+ self.current = i
204
+ if self.on_change is not None:
205
+ self.on_change(self._current)
206
+ return
207
+
208
+ def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
209
+ n = len(self.steps)
210
+ if n == 0:
211
+ return
212
+ c = theme.colors
213
+ lfont = font_for_style(theme.font_family, theme.typography.label_medium)
214
+ nfont = font_for_style(theme.font_family, theme.typography.label_small)
215
+ seg_w = self.rect.width / n
216
+ cy = self.rect.y + 22.0
217
+ rad = 14.0
218
+ self._step_rects = []
219
+
220
+ # Connectors first
221
+ for i in range(n - 1):
222
+ x1 = self.rect.x + (i + 0.5) * seg_w + rad + 4.0
223
+ x2 = self.rect.x + (i + 1.5) * seg_w - rad - 4.0
224
+ if x2 > x1:
225
+ done = i < self._current
226
+ col = c.primary if done else c.outline_variant
227
+ canvas.drawLine(x1, cy, x2, cy, skia.Paint(AntiAlias=True, Color=col.to_skia(), StrokeWidth=2.0))
228
+
229
+ # Nodes + labels
230
+ for i, label in enumerate(self.steps):
231
+ cx = self.rect.x + (i + 0.5) * seg_w
232
+ self._step_rects.append(Rect(self.rect.x + i * seg_w, self.rect.y, seg_w, self.rect.height))
233
+ is_err = self.error_step == i
234
+ is_done = i < self._current
235
+ is_active = i == self._current
236
+
237
+ if is_err:
238
+ bg, fg = c.error, c.on_error
239
+ elif is_done or is_active:
240
+ bg, fg = c.primary, c.on_primary
241
+ else:
242
+ bg, fg = c.surface_container_highest, c.on_surface_variant
243
+
244
+ canvas.drawCircle(cx, cy, rad, skia.Paint(AntiAlias=True, Color=bg.to_skia()))
245
+ if is_done and not is_err:
246
+ draw_icon(canvas, "check", cx, cy, 14.0, fg)
247
+ else:
248
+ num = "!" if is_err else str(i + 1)
249
+ nw = measure_text(nfont, num)
250
+ draw_text_centered_y(canvas, num, cx - nw * 0.5, cy, nfont, fg)
251
+
252
+ tw = measure_text(lfont, label)
253
+ lcol = c.error if is_err else (c.on_surface if (is_active or is_done) else c.on_surface_variant)
254
+ draw_text_centered_y(canvas, label, cx - tw * 0.5, self.rect.y + 50.0, lfont, lcol)
255
+
256
+
257
+ # ---------------------------------------------------------------------------
258
+ # 3. Timeline
259
+ # ---------------------------------------------------------------------------
260
+
261
+
262
+ @dataclass
263
+ class TimelineItem:
264
+ title: str
265
+ description: str = ""
266
+ timestamp: str = ""
267
+ icon: str | None = None
268
+ tone: ToneRole = "primary"
269
+
270
+
271
+ class Timeline(Widget):
272
+ """Vertical Material Design 3 activity / audit / shipping Timeline."""
273
+
274
+ manages_own_box = True
275
+ ITEM_H = 62.0
276
+
277
+ def __init__(self, items: Sequence[TimelineItem]) -> None:
278
+ super().__init__()
279
+ self.items: list[TimelineItem] = list(items)
280
+ self._fill_width = True
281
+
282
+ def _measure_content(self, constraints: Constraints, theme: Theme) -> Size:
283
+ w = constraints.max_width if constraints.max_width != float("inf") else 420.0
284
+ return Size(w, max(self.ITEM_H, len(self.items) * self.ITEM_H + 16.0))
285
+
286
+ def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
287
+ c = theme.colors
288
+ r = self.rect
289
+ rad_spec = self._shape_override if self._shape_override is not None else "medium"
290
+ rrect = make_rrect_spec(r, rad_spec, theme)
291
+ bg = resolve_color(self._bg_override, theme, c.surface) or c.surface
292
+ canvas.drawRRect(rrect, skia.Paint(AntiAlias=True, Color=bg.to_skia()))
293
+
294
+ tfont = font_for_style(theme.font_family, theme.typography.title_small)
295
+ dfont = font_for_style(theme.font_family, theme.typography.body_small)
296
+ sfont = font_for_style(theme.font_family, theme.typography.label_small)
297
+
298
+ axis_x = r.x + 28.0
299
+ n = len(self.items)
300
+ if n > 1:
301
+ y1 = r.y + 24.0
302
+ y2 = r.y + 24.0 + (n - 1) * self.ITEM_H
303
+ canvas.drawLine(axis_x, y1, axis_x, y2, skia.Paint(AntiAlias=True, Color=c.outline_variant.to_skia(), StrokeWidth=2.0))
304
+
305
+ for i, it in enumerate(self.items):
306
+ cy = r.y + 24.0 + i * self.ITEM_H
307
+ node_bg, node_fg = _tone_colors(it.tone, theme)
308
+ canvas.drawCircle(axis_x, cy, 11.0, skia.Paint(AntiAlias=True, Color=node_bg.to_skia()))
309
+ if it.icon:
310
+ draw_icon(canvas, it.icon, axis_x, cy, 12.0, node_fg)
311
+ else:
312
+ canvas.drawCircle(axis_x, cy, 4.0, skia.Paint(AntiAlias=True, Color=node_fg.to_skia()))
313
+
314
+ tx = axis_x + 22.0
315
+ draw_text_centered_y(canvas, it.title, tx, cy - 2.0, tfont, c.on_surface)
316
+ if it.description:
317
+ draw_text_centered_y(canvas, it.description, tx, cy + 17.0, dfont, c.on_surface_variant)
318
+ if it.timestamp:
319
+ sw = measure_text(sfont, it.timestamp)
320
+ draw_text_centered_y(canvas, it.timestamp, r.right - sw - 14.0, cy - 2.0, sfont, c.on_surface_variant)
321
+
322
+ if self._border_color_override is not None:
323
+ bc = resolve_color(self._border_color_override, theme)
324
+ if bc is not None:
325
+ bw = self._border_width_override if self._border_width_override is not None else 1.0
326
+ canvas.drawRRect(rrect, skia.Paint(AntiAlias=True, Color=bc.to_skia(), Style=skia.Paint.kStroke_Style, StrokeWidth=bw))
327
+
328
+
329
+ # ---------------------------------------------------------------------------
330
+ # 4. CommandPalette (Ctrl+K Fuzzy Launcher)
331
+ # ---------------------------------------------------------------------------
332
+
333
+
334
+ @dataclass
335
+ class CommandItem:
336
+ label: str
337
+ action: Callable[[], None] | None = None
338
+ icon: str | None = None
339
+ shortcut: str | None = None
340
+ category: str = ""
341
+
342
+
343
+ class CommandPalette(Widget):
344
+ """VS Code / Linear style floating Command Palette (`Ctrl+K`) with live search."""
345
+
346
+ interactive = True
347
+ focusable = True
348
+ auto_attach = False
349
+ manages_own_box = True
350
+
351
+ ITEM_H = 44.0
352
+
353
+ def __init__(
354
+ self,
355
+ commands: Sequence[CommandItem],
356
+ *,
357
+ placeholder: str = "Escribe un comando o busca...",
358
+ width: float = 520.0,
359
+ window=None,
360
+ ) -> None:
361
+ super().__init__()
362
+ self.commands: list[CommandItem] = list(commands)
363
+ self.placeholder = placeholder
364
+ self.palette_width = float(width)
365
+ self._target_window = window or context.current_window or context.last_window
366
+ self._query: str = ""
367
+ self._filtered: list[CommandItem] = list(self.commands)
368
+ self._active_idx: int = 0
369
+ self._card_rect: Rect = Rect(0, 0, self.palette_width, 280.0)
370
+
371
+ def _update_filter(self) -> None:
372
+ q = self._query.strip().lower()
373
+ if not q:
374
+ self._filtered = list(self.commands)
375
+ else:
376
+ self._filtered = [
377
+ cmd for cmd in self.commands
378
+ if q in cmd.label.lower() or q in cmd.category.lower()
379
+ ]
380
+ self._active_idx = 0
381
+
382
+ def open(self) -> None:
383
+ self._query = ""
384
+ self._update_filter()
385
+ win = self._target_window or context.last_window
386
+ if win is not None:
387
+ win.open_overlay(self)
388
+ win.set_focus(self)
389
+
390
+ def close(self) -> None:
391
+ win = self.window or self._target_window
392
+ if win is not None:
393
+ win.close_overlay(self)
394
+
395
+ def _run_selected(self) -> None:
396
+ if 0 <= self._active_idx < len(self._filtered):
397
+ cmd = self._filtered[self._active_idx]
398
+ self.close()
399
+ if cmd.action is not None:
400
+ cmd.action()
401
+
402
+ def _compute_card(self) -> Rect:
403
+ vis = min(6, max(1, len(self._filtered)))
404
+ h = 54.0 + vis * self.ITEM_H + 10.0
405
+ w = min(self.palette_width, max(280.0, self.rect.width - 32.0))
406
+ x = self.rect.center_x - w * 0.5
407
+ y = max(32.0, self.rect.y + self.rect.height * 0.14)
408
+ return Rect(x, y, w, h)
409
+
410
+ def hit_test(self, x: float, y: float) -> Widget | None:
411
+ return self if self.rect.contains(x, y) else None
412
+
413
+ def on_mouse_move(self, event: MouseEvent) -> None:
414
+ cr = self._card_rect
415
+ list_top = cr.y + 56.0
416
+ if cr.x <= event.x <= cr.right and event.y >= list_top:
417
+ idx = int((event.y - list_top) // self.ITEM_H)
418
+ if 0 <= idx < min(6, len(self._filtered)) and idx != self._active_idx:
419
+ self._active_idx = idx
420
+ self.invalidate()
421
+
422
+ def on_mouse_up(self, event: MouseEvent) -> None:
423
+ super().on_mouse_up(event)
424
+ if not self._card_rect.contains(event.x, event.y):
425
+ self.close()
426
+ return
427
+ list_top = self._card_rect.y + 56.0
428
+ if event.y >= list_top:
429
+ idx = int((event.y - list_top) // self.ITEM_H)
430
+ if 0 <= idx < min(6, len(self._filtered)):
431
+ self._active_idx = idx
432
+ self._run_selected()
433
+
434
+ def on_char(self, event: CharEvent) -> None:
435
+ self._query += event.char
436
+ self._update_filter()
437
+ self.invalidate()
438
+
439
+ def on_key(self, event: KeyEvent) -> None:
440
+ if event.action not in (glfw.PRESS, glfw.REPEAT):
441
+ return
442
+ vis = min(6, len(self._filtered))
443
+ if event.key == glfw.KEY_BACKSPACE:
444
+ self._query = self._query[:-1]
445
+ self._update_filter()
446
+ self.invalidate()
447
+ elif event.key == glfw.KEY_DOWN and vis:
448
+ self._active_idx = (self._active_idx + 1) % vis
449
+ self.invalidate()
450
+ elif event.key == glfw.KEY_UP and vis:
451
+ self._active_idx = (self._active_idx - 1) % vis
452
+ self.invalidate()
453
+ elif event.key in (glfw.KEY_ENTER, glfw.KEY_KP_ENTER):
454
+ self._run_selected()
455
+ elif event.key == glfw.KEY_ESCAPE:
456
+ self.close()
457
+
458
+ def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
459
+ c = theme.colors
460
+ # Scrim
461
+ canvas.drawRect(
462
+ skia.Rect.MakeXYWH(self.rect.x, self.rect.y, self.rect.width, self.rect.height),
463
+ skia.Paint(Color=Color(0, 0, 0, 95).to_skia()),
464
+ )
465
+
466
+ cr = self._compute_card()
467
+ self._card_rect = cr
468
+ draw_elevation_shadow(canvas, cr, theme.shape.large, 4, c.shadow)
469
+ rrect = make_rrect(cr, theme.shape.large)
470
+ canvas.drawRRect(rrect, skia.Paint(AntiAlias=True, Color=c.surface_container_high.to_skia()))
471
+
472
+ # Search input row
473
+ draw_icon(canvas, "search", cr.x + 24.0, cr.y + 27.0, 18.0, c.primary)
474
+ bfont = font_for_style(theme.font_family, theme.typography.body_large)
475
+ sfont = font_for_style(theme.font_family, theme.typography.label_small)
476
+ shown = self._query + "|" if self._query else self.placeholder
477
+ draw_text_centered_y(canvas, shown, cr.x + 44.0, cr.y + 27.0, bfont, c.on_surface if self._query else c.on_surface_variant)
478
+ canvas.drawLine(cr.x, cr.y + 52.0, cr.right, cr.y + 52.0, skia.Paint(Color=c.outline_variant.to_skia(), StrokeWidth=1.0))
479
+
480
+ items = self._filtered[:6]
481
+ if not items:
482
+ draw_text_centered_y(canvas, "Sin comandos coincidentes", cr.x + 20.0, cr.y + 78.0, bfont, c.on_surface_variant)
483
+ return
484
+
485
+ for i, cmd in enumerate(items):
486
+ ir = Rect(cr.x + 8.0, cr.y + 56.0 + i * self.ITEM_H, cr.width - 16.0, self.ITEM_H - 4.0)
487
+ is_act = i == self._active_idx
488
+ if is_act:
489
+ canvas.drawRRect(make_rrect(ir, 10.0), skia.Paint(AntiAlias=True, Color=c.secondary_container.to_skia()))
490
+ fg = c.on_secondary_container if is_act else c.on_surface
491
+ tx = ir.x + 12.0
492
+ if cmd.icon:
493
+ draw_icon(canvas, cmd.icon, ir.x + 20.0, ir.center_y, 16.0, fg)
494
+ tx = ir.x + 38.0
495
+ draw_text_centered_y(canvas, cmd.label, tx, ir.center_y, bfont, fg)
496
+ if cmd.shortcut:
497
+ sw = measure_text(sfont, cmd.shortcut)
498
+ pr = Rect(ir.right - sw - 18.0, ir.center_y - 11.0, sw + 12.0, 22.0)
499
+ canvas.drawRRect(make_rrect(pr, 6.0), skia.Paint(AntiAlias=True, Color=c.surface_container_highest.to_skia()))
500
+ draw_text_centered_y(canvas, cmd.shortcut, pr.x + 6.0, pr.center_y, sfont, c.on_surface_variant)