core: Add `DisplayObject::scaling_grid`
This commit is contained in:
parent
10ebc60a7d
commit
cc6320a2dc
|
@ -252,6 +252,10 @@ pub struct DisplayObjectBase<'gc> {
|
|||
#[collect(require_static)]
|
||||
next_scroll_rect: Rectangle<Twips>,
|
||||
|
||||
/// Rectangle used for 9-slice scaling (`DislayObject.scale9grid`).
|
||||
#[collect(require_static)]
|
||||
scaling_grid: Rectangle<Twips>,
|
||||
|
||||
/// If this Display Object should cacheAsBitmap - and if so, the cache itself.
|
||||
/// None means not cached, Some means cached.
|
||||
#[collect(require_static)]
|
||||
|
@ -282,6 +286,7 @@ impl<'gc> Default for DisplayObjectBase<'gc> {
|
|||
flags: DisplayObjectFlags::VISIBLE,
|
||||
scroll_rect: None,
|
||||
next_scroll_rect: Default::default(),
|
||||
scaling_grid: Default::default(),
|
||||
cache: None,
|
||||
}
|
||||
}
|
||||
|
@ -1616,6 +1621,14 @@ pub trait TDisplayObject<'gc>:
|
|||
}
|
||||
}
|
||||
|
||||
fn scaling_grid(&self) -> Rectangle<Twips> {
|
||||
self.base().scaling_grid.clone()
|
||||
}
|
||||
|
||||
fn set_scaling_grid(&self, gc_context: &Mutation<'gc>, rect: Rectangle<Twips>) {
|
||||
self.base_mut(gc_context).scaling_grid = rect;
|
||||
}
|
||||
|
||||
/// Whether this object has been removed. Only applies to AVM1.
|
||||
fn avm1_removed(&self) -> bool {
|
||||
self.base().avm1_removed()
|
||||
|
|
|
@ -598,6 +598,10 @@ impl<'gc> MovieClip<'gc> {
|
|||
.0
|
||||
.write(context.gc_context)
|
||||
.define_morph_shape(context, reader, 2),
|
||||
TagCode::DefineScalingGrid => self
|
||||
.0
|
||||
.write(context.gc_context)
|
||||
.define_scaling_grid(context, reader),
|
||||
TagCode::DefineShape => self
|
||||
.0
|
||||
.write(context.gc_context)
|
||||
|
@ -3473,6 +3477,25 @@ impl<'gc, 'a> MovieClipData<'gc> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn define_scaling_grid(
|
||||
&mut self,
|
||||
context: &mut UpdateContext<'_, 'gc>,
|
||||
reader: &mut SwfStream<'a>,
|
||||
) -> Result<(), Error> {
|
||||
let id = reader.read_u16()?;
|
||||
let rect = reader.read_rectangle()?;
|
||||
let library = context.library.library_for_movie_mut(self.movie());
|
||||
if let Some(character) = library.character_by_id(id) {
|
||||
if let Character::MovieClip(clip) = character {
|
||||
clip.set_scaling_grid(context.gc_context, rect);
|
||||
} else {
|
||||
tracing::warn!("DefineScalingGrid for invalid ID {}", id);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn define_morph_shape(
|
||||
&mut self,
|
||||
|
|
Loading…
Reference in New Issue