core: Make set_width & set_height call relayout

this requires an UpdateContext to be passed into both methods
This commit is contained in:
Richy McGregor 2023-10-06 01:15:58 +10:00 committed by Nathan Adams
parent dad0bbaac8
commit 4c819b5fca
4 changed files with 20 additions and 24 deletions

View File

@ -609,7 +609,7 @@ fn set_width<'gc>(
val: Value<'gc>,
) -> Result<(), Error<'gc>> {
if let Some(val) = property_coerce_to_number(activation, val)? {
this.set_width(activation.context.gc_context, val);
this.set_width(&mut activation.context, val);
}
Ok(())
}
@ -624,7 +624,7 @@ fn set_height<'gc>(
val: Value<'gc>,
) -> Result<(), Error<'gc>> {
if let Some(val) = property_coerce_to_number(activation, val)? {
this.set_height(activation.context.gc_context, val);
this.set_height(&mut activation.context, val);
}
Ok(())
}

View File

@ -130,9 +130,8 @@ pub fn set_height<'gc>(
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.as_display_object() {
let new_height = args.get_f64(activation, 0)?;
if new_height >= 0.0 {
dobj.set_height(activation.context.gc_context, new_height);
dobj.set_height(&mut activation.context, new_height);
}
}
@ -187,9 +186,8 @@ pub fn set_width<'gc>(
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.as_display_object() {
let new_width = args.get_f64(activation, 0)?;
if new_width >= 0.0 {
dobj.set_width(activation.context.gc_context, new_width);
dobj.set_width(&mut activation.context, new_width);
}
}

View File

@ -1353,7 +1353,8 @@ pub trait TDisplayObject<'gc>:
/// The width is based on the AABB of the object.
/// Set by the ActionScript `_width`/`width` properties.
/// This does odd things on rotated clips to match the behavior of Flash.
fn set_width(&self, gc_context: &Mutation<'gc>, value: f64) {
fn set_width(&self, context: &mut UpdateContext<'_, 'gc>, value: f64) {
let gc_context = context.gc_context;
let object_bounds = self.bounds();
let object_width = object_bounds.width().to_pixels();
let object_height = object_bounds.height().to_pixels();
@ -1400,7 +1401,8 @@ pub trait TDisplayObject<'gc>:
/// Sets the pixel height of this display object in local space.
/// Set by the ActionScript `_height`/`height` properties.
/// This does odd things on rotated clips to match the behavior of Flash.
fn set_height(&self, gc_context: &Mutation<'gc>, value: f64) {
fn set_height(&self, context: &mut UpdateContext<'_, 'gc>, value: f64) {
let gc_context = context.gc_context;
let object_bounds = self.bounds();
let object_width = object_bounds.width().to_pixels();
let object_height = object_bounds.height().to_pixels();

View File

@ -1887,14 +1887,12 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
.to_pixels()
}
fn set_width(&self, gc_context: &Mutation<'gc>, value: f64) {
let mut write = self.0.write(gc_context);
write.bounds.set_width(Twips::from_pixels(value));
write.base.base.set_transformed_by_script(true);
drop(write);
self.redraw_border(gc_context);
fn set_width(&self, context: &mut UpdateContext<'_, 'gc>, value: f64) {
let mut edit_text = self.0.write(context.gc_context);
edit_text.bounds.set_width(Twips::from_pixels(value));
edit_text.base.base.set_transformed_by_script(true);
drop(edit_text);
self.relayout(context);
}
fn height(&self) -> f64 {
@ -1904,14 +1902,12 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
.to_pixels()
}
fn set_height(&self, gc_context: &Mutation<'gc>, value: f64) {
let mut write = self.0.write(gc_context);
write.bounds.set_height(Twips::from_pixels(value));
write.base.base.set_transformed_by_script(true);
drop(write);
self.redraw_border(gc_context);
fn set_height(&self, context: &mut UpdateContext<'_, 'gc>, value: f64) {
let mut edit_text = self.0.write(context.gc_context);
edit_text.bounds.set_height(Twips::from_pixels(value));
edit_text.base.base.set_transformed_by_script(true);
drop(edit_text);
self.relayout(context);
}
fn set_matrix(&self, gc_context: &Mutation<'gc>, matrix: Matrix) {