Skip to content

Commit

Permalink
fix(painter): 🐛 adjusted painting of bounds after window resize
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Adoo authored and rchangelog[bot] committed Oct 28, 2024
1 parent e5e7fc1 commit d3efd02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ Please only add new entries below the [Unreleased](#unreleased---releasedate) he
- **core**: Nodes created by a class implementation may not be disposed of when switching to another class. (#637 @M-Adoo)
- **core**: When merge multiple `MixBuiltin` widgets, there may be a premature dropping of the outer `MixBuiltin` before it should occur. (#639 @M-Adoo)
- **core**: `watch!` does not notify the initial value. (#640 @M-Adoo)

- **core**: fix watch multi builtin events not work (#641 @wjian23)

- **core**: fix widget layout when h_algin and v_align are embedded in each other (#641 @wjian23)
- **painter**: fix elements may not be painted after window resize. (#644 @M-Adoo)

### Breaking

Expand Down
6 changes: 2 additions & 4 deletions painter/src/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::{
/// X-axis values progress toward the right edge of the canvas, while Y-axis
/// values increase towards the bottom edge of the canvas.
pub struct Painter {
viewport: Rect,
init_state: PainterState,
state_stack: Vec<PainterState>,
commands: Vec<PaintCommand>,
Expand Down Expand Up @@ -178,7 +177,6 @@ impl Painter {
init_state,
commands: vec![],
path_builder: Path::builder(),
viewport,
}
}

Expand All @@ -191,11 +189,11 @@ impl Painter {
self.reset();
}

pub fn viewport(&self) -> &Rect { &self.viewport }
pub fn viewport(&self) -> &Rect { &self.init_state.bounds }

/// Change the bounds of the painter can draw.But it won't take effect until
/// the next time you call [`Painter::reset`]!.
pub fn set_viewport(&mut self, bounds: Rect) { self.viewport = bounds; }
pub fn set_viewport(&mut self, bounds: Rect) { self.init_state.bounds = bounds; }

pub fn intersection_paint_bounds(&self, rect: &Rect) -> Option<Rect> {
self.paint_bounds().intersection(rect)
Expand Down

0 comments on commit d3efd02

Please sign in to comment.