Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Frizi committed Jun 19, 2023
1 parent 52d71f0 commit 453cf66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/rust/ensogl/core/src/control/io/mouse/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::borrow::Borrow;
use web::dom::Shape;



// =============
// === Event ===
// =============
Expand Down
19 changes: 11 additions & 8 deletions lib/rust/ensogl/core/src/display/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,8 +1430,8 @@ enum TaskState {
/// Extended API for tests.
pub mod test_utils {
use super::*;
use enso_callback::traits::*;
use display::shape::ShapeInstance;
use enso_callback::traits::*;

const MOCK_CANVAS_SHAPE: Shape =
Shape { width: 1000.0, height: 750.0, pixel_ratio: 2.5 };
Expand All @@ -1450,30 +1450,33 @@ pub mod test_utils {

/// Simulate mouse move and hover with manually specified event data and target.
fn hover_raw(&self, data: mouse::MouseEventData, target: PointerTargetId) -> &Self {
self
.emit_move(mouse::Move::simulated(data, MOCK_CANVAS_SHAPE))
.set_hover_target(target)
self.emit_move(mouse::Move::simulated(data, MOCK_CANVAS_SHAPE)).set_hover_target(target)
}

/// Simulate mouse hover and click with manually specified event data and target.
fn click_on_raw(&self, data: mouse::MouseEventData, target: PointerTargetId) -> &Self {
self.hover_raw(data, target).emit_down(mouse::Down::simulated(data, MOCK_CANVAS_SHAPE))
self.hover_raw(data, target)
.emit_down(mouse::Down::simulated(data, MOCK_CANVAS_SHAPE))
.emit_up(mouse::Up::simulated(data, MOCK_CANVAS_SHAPE))
}

/// Simulate mouse hover on a on given shape.
fn hover<S>(&self, shape: &ShapeInstance<S>, pos: Vector2) -> &Self {
self.hover_raw(mouse::MouseEventData::primary_at(pos), PointerTargetId::Symbol { id: shape.sprite.borrow().global_instance_id })
self.hover_raw(mouse::MouseEventData::primary_at(pos), PointerTargetId::Symbol {
id: shape.sprite.borrow().global_instance_id,
})
}

/// Simulate mouse hover on background.
fn hover_background(&self, pos: Vector2) -> &Self {
self.hover_raw(mouse::MouseEventData::primary_at(pos), PointerTargetId::Background)
}

/// Simulate mouse hover and click on given shape.
fn click_on<S>(&self, shape: &ShapeInstance<S>, pos: Vector2) {
self.click_on_raw(mouse::MouseEventData::primary_at(pos), PointerTargetId::Symbol { id: shape.sprite.borrow().global_instance_id });
self.click_on_raw(mouse::MouseEventData::primary_at(pos), PointerTargetId::Symbol {
id: shape.sprite.borrow().global_instance_id,
});
}
/// Simulate mouse click on background.
fn click_on_background(&self, pos: Vector2) {
Expand Down

0 comments on commit 453cf66

Please sign in to comment.