bubbleUI 0.4.4a1__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.
bubble/glasskit/gpu.py ADDED
@@ -0,0 +1,43 @@
1
+ """Optional GPU-backed painting surface for glass windows.
2
+
3
+ QWidget normally paints through Qt's raster engine on the CPU. ``GpuSurface``
4
+ is a full-window ``QOpenGLWidget`` child that routes a QPainter scene through
5
+ Qt's OpenGL paint engine. It is intentionally only a drawing surface: the
6
+ blur itself is still computed by the imaging helpers.
7
+
8
+ The surface is kept behind normal child widgets, so labels, buttons and panels
9
+ remain crisp and keep their normal QWidget behaviour.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from typing import Callable
15
+
16
+ from PySide6.QtCore import Qt
17
+ from PySide6.QtGui import QPainter
18
+ from PySide6.QtOpenGLWidgets import QOpenGLWidget
19
+
20
+
21
+ class GpuSurface(QOpenGLWidget):
22
+ """A full-window GL surface that delegates painting to a callback."""
23
+
24
+ def __init__(self, parent, render: Callable[[QPainter], None],
25
+ *, transparent_for_mouse: bool = True):
26
+ super().__init__(parent)
27
+ self._render = render
28
+ if transparent_for_mouse:
29
+ self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
30
+ self.setAttribute(Qt.WidgetAttribute.WA_NoSystemBackground, True)
31
+ self.setAutoFillBackground(False)
32
+ self.setUpdateBehavior(QOpenGLWidget.UpdateBehavior.NoPartialUpdate)
33
+
34
+ def paintGL(self) -> None: # noqa: N802
35
+ painter = QPainter(self)
36
+ painter.setRenderHint(QPainter.RenderHint.Antialiasing)
37
+ painter.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform)
38
+ self._render(painter)
39
+ painter.end()
40
+
41
+
42
+ # Backwards-friendly name for code that used the demo-local class.
43
+ GpuBackdrop = GpuSurface