core: Add Player::mouse_pressed_object
This commit is contained in:
parent
6146502b1a
commit
b0143ff918
|
@ -788,6 +788,7 @@ mod tests {
|
|||
log: &mut NullLogBackend::new(),
|
||||
video: &mut NullVideoBackend::new(),
|
||||
mouse_hovered_object: None,
|
||||
mouse_pressed_object: None,
|
||||
mouse_position: &(Twips::ZERO, Twips::ZERO),
|
||||
drag_object: &mut None,
|
||||
player: None,
|
||||
|
|
|
@ -60,6 +60,7 @@ where
|
|||
log: &mut NullLogBackend::new(),
|
||||
video: &mut NullVideoBackend::new(),
|
||||
mouse_hovered_object: None,
|
||||
mouse_pressed_object: None,
|
||||
mouse_position: &(Twips::ZERO, Twips::ZERO),
|
||||
drag_object: &mut None,
|
||||
player: None,
|
||||
|
|
|
@ -95,6 +95,9 @@ pub struct UpdateContext<'a, 'gc, 'gc_context> {
|
|||
/// The display object that the mouse is currently hovering over.
|
||||
pub mouse_hovered_object: Option<DisplayObject<'gc>>,
|
||||
|
||||
/// If the mouse is down, the display object that the mouse is currently pressing.
|
||||
pub mouse_pressed_object: Option<DisplayObject<'gc>>,
|
||||
|
||||
/// The location of the mouse when it was last over the player.
|
||||
pub mouse_position: &'a (Twips, Twips),
|
||||
|
||||
|
@ -266,6 +269,7 @@ impl<'a, 'gc, 'gc_context> UpdateContext<'a, 'gc, 'gc_context> {
|
|||
rng: self.rng,
|
||||
stage: self.stage,
|
||||
mouse_hovered_object: self.mouse_hovered_object,
|
||||
mouse_pressed_object: self.mouse_pressed_object,
|
||||
mouse_position: self.mouse_position,
|
||||
drag_object: self.drag_object,
|
||||
player: self.player.clone(),
|
||||
|
|
|
@ -59,7 +59,11 @@ struct GcRootData<'gc> {
|
|||
/// accessed in AVM2.
|
||||
stage: Stage<'gc>,
|
||||
|
||||
mouse_hovered_object: Option<DisplayObject<'gc>>, // TODO: Remove GcCell wrapped inside GcCell.
|
||||
/// The display object that the mouse is currently hovering over.
|
||||
mouse_hovered_object: Option<DisplayObject<'gc>>,
|
||||
|
||||
/// If the mouse is down, the display object that the mouse is currently pressing.
|
||||
mouse_pressed_object: Option<DisplayObject<'gc>>,
|
||||
|
||||
/// The object being dragged via a `startDrag` action.
|
||||
drag_object: Option<DragObject<'gc>>,
|
||||
|
@ -265,6 +269,7 @@ impl Player {
|
|||
library: Library::empty(gc_context),
|
||||
stage: Stage::empty(gc_context, movie_width, movie_height),
|
||||
mouse_hovered_object: None,
|
||||
mouse_pressed_object: None,
|
||||
drag_object: None,
|
||||
avm1: Avm1::new(gc_context, NEWEST_PLAYER_VERSION),
|
||||
avm2: Avm2::new(gc_context),
|
||||
|
@ -1354,6 +1359,7 @@ impl Player {
|
|||
self.gc_arena.mutate(|gc_context, gc_root| {
|
||||
let mut root_data = gc_root.0.write(gc_context);
|
||||
let mouse_hovered_object = root_data.mouse_hovered_object;
|
||||
let mouse_pressed_object = root_data.mouse_pressed_object;
|
||||
let focus_tracker = root_data.focus_tracker;
|
||||
let (
|
||||
stage,
|
||||
|
@ -1384,6 +1390,7 @@ impl Player {
|
|||
gc_context,
|
||||
stage,
|
||||
mouse_hovered_object,
|
||||
mouse_pressed_object,
|
||||
mouse_position,
|
||||
drag_object,
|
||||
player,
|
||||
|
@ -1430,7 +1437,10 @@ impl Player {
|
|||
.map(|clip| clip.current_frame());
|
||||
|
||||
// Hovered object may have been updated; copy it back to the GC root.
|
||||
root_data.mouse_hovered_object = update_context.mouse_hovered_object;
|
||||
let mouse_hovered_object = update_context.mouse_hovered_object;
|
||||
let mouse_pressed_object = update_context.mouse_pressed_object;
|
||||
root_data.mouse_hovered_object = mouse_hovered_object;
|
||||
root_data.mouse_pressed_object = mouse_pressed_object;
|
||||
|
||||
ret
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue