Skip to content

Commit ef9a874

Browse files
committed
move tldraw infinite background color drawing to presentation render method
1 parent c17cdc8 commit ef9a874

2 files changed

Lines changed: 26 additions & 31 deletions

File tree

bbb_presentation_video/renderer/__init__.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from bbb_presentation_video.renderer.whiteboard import ShapesRenderer
2222

2323
DRAWING_BG = Color.from_int(0xE2E8ED)
24-
TLDRAW_DRAWING_BG = Color.from_int(0xF9FAFB)
2524

2625

2726
class Codec(Enum):
@@ -313,14 +312,7 @@ def render(self) -> None:
313312
# Base background color
314313
ctx = self.ctx
315314
ctx.save()
316-
if presentation.tldraw_whiteboard and (
317-
presentation.zoom.width > 1.0 or presentation.is_panned_outside
318-
):
319-
# when using infinite whiteboard, the view can be outside the slide
320-
# change background to tldraw bg color to match client
321-
ctx.set_source_rgb(*TLDRAW_DRAWING_BG)
322-
else:
323-
ctx.set_source_rgb(*DRAWING_BG)
315+
ctx.set_source_rgb(*DRAWING_BG)
324316
ctx.paint()
325317
ctx.restore()
326318

bbb_presentation_video/renderer/presentation.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
from gi.repository import Gdk, GdkPixbuf, Gio, GLib, Poppler
2626

2727
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)
2932

3033

3134
class ImageType(Enum):
@@ -192,24 +195,6 @@ def print_transform(self) -> None:
192195
f"scale: {self.trans.shapes_scale:.6f}"
193196
)
194197

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-
213198
def update_presentation(self, event: events.PresentationEvent) -> None:
214199
if self.presentation == event["presentation"]:
215200
print("\tPresentation: presentation did not change")
@@ -453,11 +438,29 @@ def finalize_frame(self) -> bool:
453438

454439
def render(self) -> None:
455440
"""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
456460
if self.pattern is not None:
457-
ctx = self.ctx
458-
ctx.save()
459461
ctx.set_source(self.pattern)
460462
ctx.paint()
461-
ctx.restore()
462463
else:
463464
print("No pattern to render!")
465+
466+
ctx.restore()

0 commit comments

Comments
 (0)