core: Pass UpdateContext to set_visible

This commit is contained in:
Kamil Jarosz 2024-05-22 13:33:01 +02:00 committed by Nathan Adams
parent 133ea462ba
commit 23c1d32990
5 changed files with 9 additions and 9 deletions

View File

@ -592,7 +592,7 @@ fn set_visible<'gc>(
// Because this property dates to the era of Flash 4, this is actually coerced to an integer.
// `_visible = "false";` coerces to NaN and has no effect.
if let Some(n) = property_coerce_to_number(activation, val)? {
this.set_visible(activation.context.gc_context, n != 0.0);
this.set_visible(&mut activation.context, n != 0.0);
}
Ok(())
}

View File

@ -617,7 +617,7 @@ pub fn set_visible<'gc>(
if let Some(dobj) = this.as_display_object() {
let new_visible = args.get_bool(0);
dobj.set_visible(activation.context.gc_context, new_visible);
dobj.set_visible(&mut activation.context, new_visible);
}
Ok(Value::Undefined)

View File

@ -855,7 +855,7 @@ impl DisplayObjectWindow {
ui.checkbox(&mut is_visible, "Visible");
ui.end_row();
if is_visible != was_visible {
object.set_visible(context.gc_context, is_visible);
object.set_visible(context, is_visible);
}
ui.label("Blend mode");

View File

@ -1738,11 +1738,11 @@ pub trait TDisplayObject<'gc>:
/// Sets whether this display object will be visible.
/// Invisible objects are not rendered, but otherwise continue to exist normally.
/// Returned by the `_visible`/`visible` ActionScript properties.
fn set_visible(&self, gc_context: &Mutation<'gc>, value: bool) {
if self.base_mut(gc_context).set_visible(value) {
fn set_visible(&self, context: &mut UpdateContext<'_, 'gc>, value: bool) {
if self.base_mut(context.gc()).set_visible(value) {
if let Some(parent) = self.parent() {
// We don't need to invalidate ourselves, we're just toggling if the bitmap is rendered.
parent.invalidate_cached_bitmap(gc_context);
parent.invalidate_cached_bitmap(context.gc());
}
}
}
@ -2209,7 +2209,7 @@ pub trait TDisplayObject<'gc>:
}
if self.swf_version() >= 11 {
if let Some(visible) = place_object.is_visible {
self.set_visible(context.gc_context, visible);
self.set_visible(context, visible);
}
if let Some(mut color) = place_object.background_color {
let color = if color.a > 0 {

View File

@ -1293,14 +1293,14 @@ impl Player {
// Turn the dragged object invisible so that we don't pick it.
// TODO: This could be handled via adding a `HitTestOptions::SKIP_DRAGGED`.
let was_visible = display_object.visible();
display_object.set_visible(context.gc_context, false);
display_object.set_visible(context, false);
// Set `_droptarget` to the object the mouse is hovering over.
let drop_target_object = run_mouse_pick(context, false);
movie_clip.set_drop_target(
context.gc_context,
drop_target_object.map(|d| d.as_displayobject()),
);
display_object.set_visible(context.gc_context, was_visible);
display_object.set_visible(context, was_visible);
}
}
}