core: Fix avm2 button bounding box when using scroll rects

This commit is contained in:
Nathan Adams 2023-08-12 19:52:33 +02:00
parent 3117469e20
commit 5e1a30cf4a
7 changed files with 22 additions and 3 deletions

View File

@ -1153,7 +1153,7 @@ pub trait TDisplayObject<'gc>:
/// the overall AABB. /// the overall AABB.
fn bounds_with_transform(&self, matrix: &Matrix) -> Rectangle<Twips> { fn bounds_with_transform(&self, matrix: &Matrix) -> Rectangle<Twips> {
// A scroll rect completely overrides an object's bounds, // A scroll rect completely overrides an object's bounds,
// and can even the bounding box to be larger than the actual content // and can even grow the bounding box to be larger than the actual content
if let Some(scroll_rect) = self.scroll_rect() { if let Some(scroll_rect) = self.scroll_rect() {
return *matrix return *matrix
* Rectangle { * Rectangle {

View File

@ -620,8 +620,17 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
} }
fn bounds_with_transform(&self, matrix: &Matrix) -> Rectangle<Twips> { fn bounds_with_transform(&self, matrix: &Matrix) -> Rectangle<Twips> {
// [NA]: The diff between this and the base impl is a lack of scroll_rect. // A scroll rect completely overrides an object's bounds,
// Intentional, or bug? // and can even grow the bounding box to be larger than the actual content
if let Some(scroll_rect) = self.scroll_rect() {
return *matrix
* Rectangle {
x_min: Twips::ZERO,
y_min: Twips::ZERO,
x_max: scroll_rect.width(),
y_max: scroll_rect.height(),
};
}
// Get self bounds // Get self bounds
let mut bounds = *matrix * self.self_bounds(); let mut bounds = *matrix * self.self_bounds();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,2 @@
frame 1: (x=0, y=0, w=100, h=100)
frame 2: (x=0, y=0, w=100, h=100)

View File

@ -0,0 +1,8 @@
num_ticks = 3
[image_comparisons.output]
tolerance = 0
[player_options]
# Visual test will test the render bounds, whereas output test does the "normal" bounds
with_renderer = { optional = true, sample_count = 1 }