Skip to content

Commit

Permalink
Emit event on scale factor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jun 26, 2024
1 parent 3531ed3 commit f04743e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ declare_class!(
triangle.redraw();
}
}

#[method(viewDidChangeBackingProperties:)]
fn changed_backing_properties(&self) {
let new_size = scaled_view_frame(self);
tracing::debug!(
live_resize = unsafe { self.inLiveResize() },
?new_size,
"triggered `viewDidChangeBackingProperties:`"
);
let triangle = self.ivars().get().expect("initialized");
triangle.resize(new_size.width as u32, new_size.height as u32);
if cfg!(all(
feature = "immediate-redraw",
not(feature = "display-link")
)) {
triangle.redraw();
}
}
}

#[cfg(not(target_os = "macos"))]
Expand Down Expand Up @@ -137,7 +155,7 @@ declare_class!(
unsafe impl WgpuTriangleView {
#[method(step:)]
fn step(&self, _sender: &CADisplayLink) {
tracing::debug!("triggered `step:`");
tracing::trace!("triggered `step:`");
if cfg!(feature = "immediate-redraw") {
let triangle = self.ivars().get().expect("initialized");
triangle.redraw();
Expand Down

0 comments on commit f04743e

Please sign in to comment.