Skip to content

Commit e52cf62

Browse files
committed
Updates to infinite whiteboard background
* Fix white background for image uploads to only be drawn in the image area * Draw the tldraw infinite whiteboard background as part of the pattern rather than re-drawing it separately each time
1 parent ef9a874 commit e52cf62

1 file changed

Lines changed: 25 additions & 28 deletions

File tree

bbb_presentation_video/renderer/presentation.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ def update_pan_zoom(self, event: events.PanZoomEvent) -> None:
229229
self.pan_zoom_changed = True
230230
print(f"\tPresentation: pan: {self.pan} zoom: {self.zoom}")
231231

232+
def render_image(self) -> None:
233+
assert isinstance(self.page, GdkPixbuf.Pixbuf)
234+
assert self.page_size is not None
235+
236+
ctx = self.ctx
237+
238+
apply_slide_transform(ctx, self.trans)
239+
# Render on an opaque white background (transparent PNGs...)
240+
ctx.set_source_rgb(1, 1, 1)
241+
ctx.rectangle(0, 0, self.page_size.width, self.page_size.height)
242+
ctx.fill()
243+
Gdk.cairo_set_source_pixbuf(ctx, self.page, 0, 0)
244+
ctx.paint()
245+
232246
def render_pdf(self) -> None:
233247
assert isinstance(self.page, Poppler.Page)
234248
assert self.page_size is not None
@@ -417,15 +431,16 @@ def finalize_frame(self) -> bool:
417431
ctx = self.ctx
418432
ctx.push_group()
419433

434+
# Draw the extended background for tldraw infinite whiteboard
435+
ctx.save()
436+
apply_slide_transform(ctx, self.trans)
437+
ctx.set_source_rgb(*TLDRAW_DRAWING_BG)
438+
ctx.paint()
439+
ctx.restore()
440+
420441
if self.page:
421442
if self.filetype is ImageType.IMAGE:
422-
assert isinstance(self.page, GdkPixbuf.Pixbuf)
423-
apply_slide_transform(ctx, self.trans)
424-
# Render on an opaque white background (transparent PNGs...)
425-
ctx.set_source_rgb(1, 1, 1)
426-
ctx.paint()
427-
Gdk.cairo_set_source_pixbuf(ctx, self.page, 0, 0)
428-
ctx.paint()
443+
self.render_image()
429444
elif self.filetype is ImageType.PDF:
430445
self.render_pdf()
431446

@@ -438,29 +453,11 @@ def finalize_frame(self) -> bool:
438453

439454
def render(self) -> None:
440455
"""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
460456
if self.pattern is not None:
457+
ctx = self.ctx
458+
ctx.save()
461459
ctx.set_source(self.pattern)
462460
ctx.paint()
461+
ctx.restore()
463462
else:
464463
print("No pattern to render!")
465-
466-
ctx.restore()

0 commit comments

Comments
 (0)