|
25 | 25 | from gi.repository import Gdk, GdkPixbuf, Gio, GLib, Poppler |
26 | 26 |
|
27 | 27 | from bbb_presentation_video import events |
28 | | -from bbb_presentation_video.events.helpers import Position, Size |
| 28 | +from bbb_presentation_video.events.helpers import Color, Position, Size |
| 29 | + |
| 30 | +# Background color for the infinite whiteboard (visible viewport without presentation content) |
| 31 | +TLDRAW_DRAWING_BG = Color.from_int(0xF9FAFB) |
29 | 32 |
|
30 | 33 |
|
31 | 34 | class ImageType(Enum): |
@@ -192,24 +195,6 @@ def print_transform(self) -> None: |
192 | 195 | f"scale: {self.trans.shapes_scale:.6f}" |
193 | 196 | ) |
194 | 197 |
|
195 | | - @property |
196 | | - def is_panned_outside(self) -> bool: |
197 | | - """Check if the viewport is showing areas outside the slide content.""" |
198 | | - if self.page_size is None: |
199 | | - return False |
200 | | - |
201 | | - # The size of the portion of the slide that will be shown |
202 | | - size = self.trans.size |
203 | | - # The top-left of the viewport on the slide |
204 | | - pos = self.trans.pos |
205 | | - |
206 | | - return ( |
207 | | - pos.x < 0 |
208 | | - or pos.y < 0 |
209 | | - or (pos.x + size.width) > self.page_size.width |
210 | | - or (pos.y + size.height) > self.page_size.height |
211 | | - ) |
212 | | - |
213 | 198 | def update_presentation(self, event: events.PresentationEvent) -> None: |
214 | 199 | if self.presentation == event["presentation"]: |
215 | 200 | print("\tPresentation: presentation did not change") |
@@ -453,11 +438,29 @@ def finalize_frame(self) -> bool: |
453 | 438 |
|
454 | 439 | def render(self) -> None: |
455 | 440 | """Composite the last-updated presentation image""" |
| 441 | + ctx = self.ctx |
| 442 | + ctx.save() |
| 443 | + |
| 444 | + # Draw TLDRAW_DRAWING_BG within the clipped viewport region when using tldraw whiteboard |
| 445 | + if self.tldraw_whiteboard: |
| 446 | + # Fill the visible viewport area with the tldraw background color |
| 447 | + ctx.translate(self.trans.padding.width, self.trans.padding.height) |
| 448 | + ctx.rectangle( |
| 449 | + 0, |
| 450 | + 0, |
| 451 | + self.trans.size.width * self.trans.scale, |
| 452 | + self.trans.size.height * self.trans.scale, |
| 453 | + ) |
| 454 | + ctx.set_source_rgb(*TLDRAW_DRAWING_BG) |
| 455 | + ctx.fill() |
| 456 | + # Reset transform |
| 457 | + ctx.translate(-self.trans.padding.width, -self.trans.padding.height) |
| 458 | + |
| 459 | + # Render the presentation content on top |
456 | 460 | if self.pattern is not None: |
457 | | - ctx = self.ctx |
458 | | - ctx.save() |
459 | 461 | ctx.set_source(self.pattern) |
460 | 462 | ctx.paint() |
461 | | - ctx.restore() |
462 | 463 | else: |
463 | 464 | print("No pattern to render!") |
| 465 | + |
| 466 | + ctx.restore() |
0 commit comments