Skip to content

Commit

Permalink
feat(core): allow force redrawing of frames
Browse files Browse the repository at this point in the history
  • Loading branch information
zihadmahiuddin committed Feb 6, 2025
1 parent 1570d39 commit 29fa3e5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Please only add new entries below the [Unreleased](#unreleased---releasedate) he

## [@Unreleased] - @ReleaseDate

### Features
- **core**: Add the ability to force redraw a frame. (#pr @zihadmahiuddin)

## [0.4.0-alpha.26] - 2025-02-05

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion core/src/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl TestWindow {
self.run_frame_tasks();

AppCtx::frame_ticks().clone().next(Instant::now());
self.0.draw_frame();
self.0.draw_frame(false);
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ impl Window {

/// Draw an image what current render tree represent.
#[track_caller]
pub fn draw_frame(&self) -> bool {
pub fn draw_frame(&self, force: bool) -> bool {
AppCtx::run_until_stalled();
let mut ticker = self.frame_ticker.clone();
ticker.next(FrameMsg::NewFrame(Instant::now()));
self.run_frame_tasks();

self.update_painter_viewport();
let draw = self.need_draw() && !self.size().is_empty();
if draw {
if force || draw {
let root = self.tree().root();

let surface = {
Expand Down
2 changes: 1 addition & 1 deletion ribir/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl App {
if wnd.is_visible() != Some(false) {
// if this frame is really draw, request another redraw. To make sure the draw
// always end with a empty draw and emit an extra tick cycle message.
if wnd.draw_frame() {
if wnd.draw_frame(false) {
request_redraw(&wnd);
}
}
Expand Down

0 comments on commit 29fa3e5

Please sign in to comment.