widget: fix Geometry::expand using other.height twice
The bounding-box height was computed from other.height + other.height instead of other.height + other.y, so the combined damage rectangle sent to the compositor was wrong whenever a widget's drawn area changed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
6af81b587c
commit
450a20bf63
+28
-1
@@ -40,7 +40,7 @@ impl Geometry {
|
||||
x,
|
||||
y,
|
||||
width: max(self.width + self.x, other.width + other.x) - x,
|
||||
height: max(self.height + self.y, other.height + other.height) - y,
|
||||
height: max(self.height + self.y, other.height + other.y) - y,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,3 +64,30 @@ pub trait Widget {
|
||||
fn draw(&mut self, fonts: &mut FontMap, view: &mut BufferView) -> Geometry;
|
||||
fn event(&mut self, _event: &Event) {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Geometry;
|
||||
|
||||
#[test]
|
||||
fn expand_is_bounding_box() {
|
||||
let a = Geometry {
|
||||
x: 10,
|
||||
y: 20,
|
||||
width: 5,
|
||||
height: 5,
|
||||
};
|
||||
let b = Geometry {
|
||||
x: 0,
|
||||
y: 100,
|
||||
width: 2,
|
||||
height: 2,
|
||||
};
|
||||
let e = a.expand(b);
|
||||
assert_eq!((e.x, e.y), (0, 20));
|
||||
assert_eq!(e.x + e.width, 15);
|
||||
assert_eq!(e.y + e.height, 102);
|
||||
let e2 = b.expand(a);
|
||||
assert_eq!((e2.x, e2.y, e2.width, e2.height), (e.x, e.y, e.width, e.height));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user