Skip to content

Commit

Permalink
Revert "Allowing EnsoGL mouse to interact with more than 4096 sprites…
Browse files Browse the repository at this point in the history
… at the same time. (#3351)" (#3368)

This reverts commit 546c333.
  • Loading branch information
akavel committed Mar 29, 2022
1 parent 546c333 commit 7152e0d
Show file tree
Hide file tree
Showing 65 changed files with 549 additions and 1,196 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,9 @@ impl ProjectName {

// === Mouse IO ===

mouse_down <- model.view.events.mouse_down.constant(());
frp.source.is_hovered <+ bool(&model.view.events.mouse_out,
&model.view.events.mouse_over);
frp.source.mouse_down <+ model.view.events.mouse_down.constant(());
frp.source.mouse_down <+ model.view.events.mouse_down;

not_selected <- frp.output.selected.map(|selected| !selected);
mouse_over_if_not_selected <- model.view.events.mouse_over.gate(&not_selected);
Expand All @@ -281,7 +280,7 @@ impl ProjectName {
);
on_deselect <- not_selected.gate(&not_selected).constant(());

edit_click <- mouse_down.gate(&frp.ide_text_edit_mode);
edit_click <- model.view.events.mouse_down.gate(&frp.ide_text_edit_mode);
start_editing <- any(edit_click,frp.input.start_editing);
eval_ start_editing ({
text.set_focus(true);
Expand Down
28 changes: 14 additions & 14 deletions app/gui/view/graph-editor/src/component/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ensogl::application::Application;
use ensogl::data::color;
use ensogl::display;
use ensogl::display::scene::Scene;
use ensogl::gui::component::PointerTarget;
use ensogl::gui::component::ShapeViewEvents;
use ensogl_hardcoded_theme as theme;
use nalgebra::Rotation2;

Expand Down Expand Up @@ -74,7 +74,7 @@ trait EdgeShape: display::Object {
fn id(&self) -> display::object::Id {
self.display_object().id()
}
fn events(&self) -> &PointerTarget;
fn events(&self) -> &ShapeViewEvents;
fn set_color(&self, color: color::Rgba);
fn set_color_focus(&self, color: color::Rgba);

Expand Down Expand Up @@ -172,8 +172,8 @@ trait AnyEdgeShape {
/// Return references to all `EdgeShape`s in this `AnyEdgeShape`.
fn shapes(&self) -> Vec<&dyn EdgeShape>;

/// Connect the given `PointerTargetProxy` to the mouse events of all sub-shapes.
fn register_proxy_frp(&self, network: &frp::Network, frp: &PointerTargetProxy) {
/// Connect the given `ShapeViewEventsProxy` to the mouse events of all sub-shapes.
fn register_proxy_frp(&self, network: &frp::Network, frp: &ShapeViewEventsProxy) {
for shape in &self.shapes() {
let event = shape.events();
let id = shape.id();
Expand Down Expand Up @@ -374,7 +374,7 @@ macro_rules! define_corner_start {
self.focus_split_angle.set(angle);
}

fn events(&self) -> &PointerTarget {
fn events(&self) -> &ShapeViewEvents {
&self.events
}

Expand Down Expand Up @@ -469,7 +469,7 @@ macro_rules! define_corner_end {
self.focus_split_angle.set(angle);
}

fn events(&self) -> &PointerTarget {
fn events(&self) -> &ShapeViewEvents {
&self.events
}

Expand Down Expand Up @@ -549,7 +549,7 @@ macro_rules! define_line {
self.focus_split_angle.set(angle);
}

fn events(&self) -> &PointerTarget {
fn events(&self) -> &ShapeViewEvents {
&self.events
}

Expand Down Expand Up @@ -621,7 +621,7 @@ macro_rules! define_arrow { () => {
self.focus_split_angle.set(angle);
}

fn events(&self) -> &PointerTarget {
fn events(&self) -> &ShapeViewEvents {
&self.events
}

Expand Down Expand Up @@ -752,7 +752,7 @@ macro_rules! define_components {
pub struct $name {
pub logger : Logger,
pub display_object : display::object::Instance,
pub shape_view_events : Rc<Vec<PointerTarget>>,
pub shape_view_events : Rc<Vec<ShapeViewEvents>>,
shape_type_map : Rc<HashMap<display::object::Id,ShapeRole>>,
$(pub $field : $field_type),*
}
Expand All @@ -764,7 +764,7 @@ macro_rules! define_components {
let display_object = display::object::Instance::new(&logger);
$(let $field = <$field_type>::new(Logger::new_sub(&logger,stringify!($field)));)*
$(display_object.add_child(&$field);)*
let mut shape_view_events:Vec<PointerTarget> = Vec::default();
let mut shape_view_events:Vec<ShapeViewEvents> = Vec::default();
$(shape_view_events.push($field.events.clone_ref());)*
let shape_view_events = Rc::new(shape_view_events);

Expand Down Expand Up @@ -1021,7 +1021,7 @@ impl SemanticSplit {
/// emit events via th internal `on_mouse_down`/`on_mouse_over`/`on_mouse_out` sources.
#[derive(Clone, CloneRef, Debug)]
#[allow(missing_docs)]
pub struct PointerTargetProxy {
pub struct ShapeViewEventsProxy {
pub mouse_down: frp::Stream,
pub mouse_over: frp::Stream,
pub mouse_out: frp::Stream,
Expand All @@ -1032,7 +1032,7 @@ pub struct PointerTargetProxy {
}

#[allow(missing_docs)]
impl PointerTargetProxy {
impl ShapeViewEventsProxy {
pub fn new(network: &frp::Network) -> Self {
frp::extend! { network
on_mouse_over <- source();
Expand Down Expand Up @@ -1063,7 +1063,7 @@ pub struct Frp {
pub set_color: frp::Source<color::Lcha>,

pub hover_position: frp::Source<Option<Vector2<f32>>>,
pub shape_events: PointerTargetProxy,
pub shape_events: ShapeViewEventsProxy,
}

impl Frp {
Expand All @@ -1080,7 +1080,7 @@ impl Frp {
def set_disabled = source();
def set_color = source();
}
let shape_events = PointerTargetProxy::new(network);
let shape_events = ShapeViewEventsProxy::new(network);
Self {
source_width,
source_height,
Expand Down
2 changes: 1 addition & 1 deletion app/gui/view/graph-editor/src/component/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ impl Node {

// === Background Press ===

out.background_press <+ model.drag_area.events.mouse_down.constant(());
out.background_press <+ model.drag_area.events.mouse_down;
out.background_press <+ model.input.on_background_press;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ use ensogl::prelude::*;

use crate::GraphEditorModelWithNetwork;
use crate::NodeId;

use enso_frp as frp;
use ensogl::animation::easing::EndStatus::Normal;
use ensogl::display::Scene;
use ensogl::Animation;
use ensogl::Easing;



/// Describes the "speed" of growth/shrink animation.
///
/// To determine the duration of the blending animation, we divide the length of the camera path by
Expand Down
2 changes: 1 addition & 1 deletion app/gui/view/graph-editor/src/component/node/input/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ impl Area {

let mouse_over_raw = port_shape.hover.events.mouse_over.clone_ref();
let mouse_out = port_shape.hover.events.mouse_out.clone_ref();
mouse_down_raw <- port_shape.hover.events.mouse_down.constant(());
let mouse_down_raw = port_shape.hover.events.mouse_down.clone_ref();


// === Body Hover ===
Expand Down
4 changes: 2 additions & 2 deletions app/gui/view/graph-editor/src/component/node/output/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ impl PortShapeView {
set_padding_right (this,t:f32) { this.padding_right.set(t) }
}

fn events(&self) -> &component::PointerTarget {
fn events(&self) -> &component::ShapeViewEvents {
match self {
Self::Single(t) => &t.events,
Self::Multi(t) => &t.events,
Expand Down Expand Up @@ -525,7 +525,7 @@ impl Model {
// === Mouse Event Handling ===

frp.source.on_hover <+ bool(&events.mouse_out,&events.mouse_over);
frp.source.on_press <+ events.mouse_down.constant(());
frp.source.on_press <+ events.mouse_down;


// === Opacity ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl ContainerModel {
}

/// Check if given mouse-event-target means this visualization.
fn is_this_target(&self, target: scene::PointerTargetId) -> bool {
fn is_this_target(&self, target: scene::PointerTarget) -> bool {
self.view.overlay.is_this_target(target)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,15 @@ impl ActionBar {
frp.source.visualisation_selection <+ visualization_chooser.chosen_entry;

let reset_position_icon = &model.icons.reset_position_icon.events;
reset_position_icon_down <- reset_position_icon.mouse_down.constant(());
frp.source.on_container_reset_position <+ reset_position_icon_down;
frp.source.on_container_reset_position <+ reset_position_icon.mouse_down;

let drag_icon = &model.icons.drag_icon.events;
start_dragging <- drag_icon.mouse_down.constant(());
let start_dragging = drag_icon.mouse_down.clone_ref();
end_dragging <- mouse.up.gate(&frp.source.container_drag_state);
should_drag <- bool(&end_dragging,&start_dragging);
frp.source.container_drag_state <+ should_drag;

show_reset_icon <- bool(&reset_position_icon_down,&start_dragging);
show_reset_icon <- bool(&reset_position_icon.mouse_down,&start_dragging);
eval show_reset_icon((visibility) model.icons.set_reset_icon_visibility(*visibility));
}
self
Expand Down
31 changes: 25 additions & 6 deletions app/gui/view/graph-editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2623,14 +2623,33 @@ fn new_graph_editor(app: &Application) -> GraphEditor {
// === Selection Target Redirection ===

frp::extend! { network
let scene = model.scene();

mouse_up_target <- mouse.up_primary.map(f_!(model.scene().mouse.target.get()));
background_up <= mouse_up_target.map(
|t| (t==&display::scene::PointerTargetId::Background).as_some(())
mouse_down_target <- mouse.down_primary.map(f_!(model.scene().mouse.target.get()));
mouse_up_target <- mouse.up_primary.map(f_!(model.scene().mouse.target.get()));
background_up <= mouse_up_target.map(
|t| (t==&display::scene::PointerTarget::Background).as_some(())
);

eval_ scene.background.mouse_down (touch.background.down.emit(()));
eval mouse_down_target([touch,model](target) {
match target {
display::scene::PointerTarget::Background => touch.background.down.emit(()),
display::scene::PointerTarget::Symbol {..} => {
if let Some(target) = model.scene().shapes.get_mouse_target(*target) {
target.mouse_down().emit(());
}
}
}
});

eval mouse_up_target([model](target) {
match target {
display::scene::PointerTarget::Background => {} // touch.background.up.emit(()),
display::scene::PointerTarget::Symbol {..} => {
if let Some(target) = model.scene().shapes.get_mouse_target(*target) {
target.mouse_up().emit(());
}
}
}
});
}


Expand Down
6 changes: 3 additions & 3 deletions lib/rust/ensogl/component/selector/src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ pub mod right_overflow {

use enso_frp::Network;
use ensogl_core::frp::io::Mouse;
use ensogl_core::gui::component::PointerTarget;
use ensogl_core::gui::component::ShapeView;
use ensogl_core::gui::component::ShapeViewEvents;

pub use super::frp::*;
pub use super::model::*;
Expand All @@ -208,7 +208,7 @@ use ensogl_core::display::Scene;
/// Dragging is ended by a mouse up.
pub fn shape_is_dragged(
network: &Network,
shape: &PointerTarget,
shape: &ShapeViewEvents,
mouse: &Mouse,
) -> enso_frp::Stream<bool> {
enso_frp::extend! { network
Expand Down Expand Up @@ -259,7 +259,7 @@ mod tests {
fn test_shape_is_dragged() {
let network = enso_frp::Network::new("TestNetwork");
let mouse = enso_frp::io::Mouse::default();
let shape = PointerTarget::default();
let shape = ShapeViewEvents::default();

let is_dragged = shape_is_dragged(&network, &shape, &mouse);
let _watch = is_dragged.register_watch();
Expand Down
2 changes: 1 addition & 1 deletion lib/rust/ensogl/component/toggle-button/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl<Shape: ColorableShape + 'static> ToggleButton<Shape> {

// === State ===

toggle <- any_(frp.toggle,icon.mouse_down);
toggle <- any(frp.toggle,icon.mouse_down);
frp.source.state <+ frp.state.not().sample(&toggle);
frp.source.state <+ frp.set_state;

Expand Down
5 changes: 2 additions & 3 deletions lib/rust/ensogl/core/src/debug/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,15 @@ macro_rules! gen_stats {
self.[<set _ $field>](value);
}

// FIXME: saturating_add is proper solution, but even without it it should not crash, but it does. To be investigated.
emit_if_integer!($field_type,
/// Increments field's value.
pub fn [<inc _ $field>](&self) {
self.[<mod _ $field>](|t| t.saturating_add(1));
self.[<mod _ $field>](|t| t + 1);
}

/// Decrements field's value.
pub fn [<dec _ $field>](&self) {
self.[<mod _ $field>](|t| t.saturating_sub(1));
self.[<mod _ $field>](|t| t - 1);
}
);

Expand Down
27 changes: 0 additions & 27 deletions lib/rust/ensogl/core/src/display/object/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,33 +1188,6 @@ impl<Host> Object<Host> for Any<Host> {



// =========================
// === UnsetParentOnDrop ===
// =========================

/// Wrapper that unsets parent of a display object when dropped. Please note that [`Instance`]
/// implements [`CloneRef`], so it can still be alive even if this struct is dropped.
#[derive(Debug, NoCloneBecauseOfCustomDrop)]
pub struct UnsetParentOnDrop {
instance: Instance,
}

impl UnsetParentOnDrop {
/// Constructor.
pub fn new(instance: impl Into<Instance>) -> Self {
let instance = instance.into();
Self { instance }
}
}

impl Drop for UnsetParentOnDrop {
fn drop(&mut self) {
self.instance.unset_parent()
}
}



// =============
// === Tests ===
// =============
Expand Down
Loading

0 comments on commit 7152e0d

Please sign in to comment.