Fix blink when adding node (#3448)

Fix blink when adding node
This commit is contained in:
Kaz Wesley 2022-05-12 16:17:29 -07:00 committed by GitHub
parent d24f0f7ebb
commit d4d725ade6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 64 additions and 94 deletions

View File

@ -189,6 +189,7 @@ impl BreadcrumbsModel {
/// Constructor. /// Constructor.
/// The `gap_width` describes an empty space on the left of all the content. This space will be /// The `gap_width` describes an empty space on the left of all the content. This space will be
/// covered by the background and is intended to make room for windows control buttons. /// covered by the background and is intended to make room for windows control buttons.
#[profile(Detail)]
pub fn new(app: Application, frp: &Frp) -> Self { pub fn new(app: Application, frp: &Frp) -> Self {
let scene = &app.display.default_scene; let scene = &app.display.default_scene;
let project_name = app.new_view(); let project_name = app.new_view();

View File

@ -73,6 +73,7 @@ mod icon {
use super::*; use super::*;
ensogl::define_shape_system! { ensogl::define_shape_system! {
pointer_events = false;
(red:f32,green:f32,blue:f32,alpha:f32) { (red:f32,green:f32,blue:f32,alpha:f32) {
let outer_circle = Circle((ICON_RADIUS).px()); let outer_circle = Circle((ICON_RADIUS).px());
let inner_circle = Circle((ICON_RADIUS - ICON_RING_WIDTH).px()); let inner_circle = Circle((ICON_RADIUS - ICON_RING_WIDTH).px());
@ -98,6 +99,7 @@ mod separator {
use super::*; use super::*;
ensogl::define_shape_system! { ensogl::define_shape_system! {
pointer_events = false;
(red:f32,green:f32,blue:f32,alpha:f32) { (red:f32,green:f32,blue:f32,alpha:f32) {
let size = SEPARATOR_SIZE; let size = SEPARATOR_SIZE;
let angle = PI/2.0; let angle = PI/2.0;
@ -273,6 +275,7 @@ pub struct BreadcrumbModel {
impl BreadcrumbModel { impl BreadcrumbModel {
/// Constructor. /// Constructor.
#[profile(Detail)]
pub fn new( pub fn new(
app: &Application, app: &Application,
frp: &Frp, frp: &Frp,
@ -302,28 +305,16 @@ impl BreadcrumbModel {
} }
scene.layers.panel.add_exclusive(&view); scene.layers.panel.add_exclusive(&view);
let shape_system = scene let background = &scene
.layers .layers
.panel .panel
.shape_system_registry .shape_system_registry
.shape_system(scene, PhantomData::<background::DynamicShape>); .shape_system(scene, PhantomData::<background::DynamicShape>)
scene.layers.panel.add_exclusive(&shape_system.shape_system.symbol); .shape_system
.symbol;
scene.layers.panel.add_exclusive(&background);
scene.layers.panel.add_exclusive(&icon); scene.layers.panel.add_exclusive(&icon);
let shape_system = scene
.layers
.panel
.shape_system_registry
.shape_system(scene, PhantomData::<icon::DynamicShape>);
shape_system.shape_system.set_pointer_events(false);
scene.layers.panel.add_exclusive(&separator); scene.layers.panel.add_exclusive(&separator);
let shape_system = scene
.layers
.panel
.shape_system_registry
.shape_system(scene, PhantomData::<separator::DynamicShape>);
shape_system.shape_system.set_pointer_events(false);
label.remove_from_scene_layer(&scene.layers.main); label.remove_from_scene_layer(&scene.layers.main);
label.add_to_scene_layer(&scene.layers.panel_text); label.add_to_scene_layer(&scene.layers.panel_text);

View File

@ -287,6 +287,7 @@ pub mod joint {
use super::*; use super::*;
ensogl::define_shape_system! { ensogl::define_shape_system! {
pointer_events = false;
(color_rgba:Vector4<f32>) { (color_rgba:Vector4<f32>) {
let radius = Var::<Pixels>::from("input_size.y"); let radius = Var::<Pixels>::from("input_size.y");
let joint = Circle((radius-PADDING.px())/2.0); let joint = Circle((radius-PADDING.px())/2.0);
@ -1075,6 +1076,7 @@ pub struct Frp {
impl Frp { impl Frp {
/// Constructor. /// Constructor.
#[profile(Debug)]
pub fn new(network: &frp::Network) -> Self { pub fn new(network: &frp::Network) -> Self {
frp::extend! { network frp::extend! { network
def source_width = source(); def source_width = source();
@ -1166,6 +1168,7 @@ impl display::Object for EdgeModelData {
impl Edge { impl Edge {
/// Constructor. /// Constructor.
#[profile(Detail)]
pub fn new(app: &Application) -> Self { pub fn new(app: &Application) -> Self {
let network = frp::Network::new("node_edge"); let network = frp::Network::new("node_edge");
let data = Rc::new(EdgeModelData::new(&app.display.default_scene, &network)); let data = Rc::new(EdgeModelData::new(&app.display.default_scene, &network));
@ -1277,6 +1280,7 @@ pub struct EdgeModelData {
impl EdgeModelData { impl EdgeModelData {
/// Constructor. /// Constructor.
#[profile(Debug)]
pub fn new(scene: &Scene, network: &frp::Network) -> Self { pub fn new(scene: &Scene, network: &frp::Network) -> Self {
let logger = Logger::new("edge"); let logger = Logger::new("edge");
let display_object = display::object::Instance::new(&logger); let display_object = display::object::Instance::new(&logger);
@ -1284,13 +1288,6 @@ impl EdgeModelData {
let back = Back::new(Logger::new_sub(&logger, "back")); let back = Back::new(Logger::new_sub(&logger, "back"));
let joint = joint::View::new(Logger::new_sub(&logger, "joint")); let joint = joint::View::new(Logger::new_sub(&logger, "joint"));
let shape_system = scene
.layers
.main
.shape_system_registry
.shape_system(scene, PhantomData::<joint::DynamicShape>);
shape_system.shape_system.set_pointer_events(false);
display_object.add_child(&front); display_object.add_child(&front);
display_object.add_child(&back); display_object.add_child(&back);
display_object.add_child(&joint); display_object.add_child(&joint);

View File

@ -127,6 +127,8 @@ pub mod backdrop {
use super::*; use super::*;
ensogl::define_shape_system! { ensogl::define_shape_system! {
// Disable to allow interaction with the output port.
pointer_events = false;
(style:Style, selection:f32) { (style:Style, selection:f32) {
let width = Var::<Pixels>::from("input_size.x"); let width = Var::<Pixels>::from("input_size.x");
@ -482,14 +484,6 @@ impl NodeModel {
display_object.add_child(&background); display_object.add_child(&background);
display_object.add_child(&vcs_indicator); display_object.add_child(&vcs_indicator);
// Disable shadows to allow interaction with the output port.
let shape_system = scene
.layers
.main
.shape_system_registry
.shape_system(scene, PhantomData::<backdrop::DynamicShape>);
shape_system.shape_system.set_pointer_events(false);
let input = input::Area::new(&logger, app); let input = input::Area::new(&logger, app);
let visualization = visualization::Container::new(&logger, app, registry); let visualization = visualization::Container::new(&logger, app, registry);

View File

@ -78,10 +78,10 @@ pub fn initialize_edited_node_animator(
}); });
// We want to: // We want to:
// 1. Smothly animate edited node camera from `main_cam` position to `searcher_cam` position when we // 1. Smoothly animate edited node camera from `main_cam` position to `searcher_cam` position when we
// start/finish node editing so that the edited node "grows" or "shrinks" to reach the correct // start/finish node editing so that the edited node "grows" or "shrinks" to reach the correct
// visible size. This is `growth_animation`. // visible size. This is `growth_animation`.
// 2. Keep `searcher_cam` and `edited_node_cam` at the same position everywhen else so that the // 2. Keep `searcher_cam` and `edited_node_cam` at the same position everywhere else so that the
// searcher and the edited node are at the same visible position at all times. This is // searcher and the edited node are at the same visible position at all times. This is
// `edited_node_cam_target`. // `edited_node_cam_target`.
// //
@ -114,6 +114,7 @@ pub fn initialize_edited_node_animator(
impl GraphEditorModelWithNetwork { impl GraphEditorModelWithNetwork {
/// Move node to the `edited_node` scene layer, so that it is rendered by the separate camera. /// Move node to the `edited_node` scene layer, so that it is rendered by the separate camera.
#[profile(Debug)]
fn move_node_to_edited_node_layer(&self, node_id: NodeId) { fn move_node_to_edited_node_layer(&self, node_id: NodeId) {
if let Some(node) = self.nodes.get_cloned(&node_id) { if let Some(node) = self.nodes.get_cloned(&node_id) {
node.model().move_to_edited_node_layer(); node.model().move_to_edited_node_layer();
@ -121,6 +122,7 @@ impl GraphEditorModelWithNetwork {
} }
/// Move node to the `main` scene layer, so that it is rendered by the main camera. /// Move node to the `main` scene layer, so that it is rendered by the main camera.
#[profile(Debug)]
fn move_node_to_main_layer(&self, node_id: NodeId) { fn move_node_to_main_layer(&self, node_id: NodeId) {
if let Some(node) = self.nodes.get_cloned(&node_id) { if let Some(node) = self.nodes.get_cloned(&node_id) {
node.model().move_to_main_layer(); node.model().move_to_main_layer();

View File

@ -19,7 +19,6 @@ use enso_text::text::Text;
use ensogl::application::Application; use ensogl::application::Application;
use ensogl::data::color; use ensogl::data::color;
use ensogl::display; use ensogl::display;
use ensogl::display::scene::Scene;
use ensogl::gui::cursor; use ensogl::gui::cursor;
use ensogl::Animation; use ensogl::Animation;
use ensogl_component::text; use ensogl_component::text;
@ -299,10 +298,6 @@ impl Model {
self.label.add_to_scene_layer(layer); self.label.add_to_scene_layer(layer);
} }
fn scene(&self) -> &Scene {
&self.app.display.default_scene
}
/// Run the provided function on the target port if exists. /// Run the provided function on the target port if exists.
fn with_port_mut(&self, crumbs: &Crumbs, f: impl FnOnce(PortRefMut)) { fn with_port_mut(&self, crumbs: &Crumbs, f: impl FnOnce(PortRefMut)) {
let mut expression = self.expression.borrow_mut(); let mut expression = self.expression.borrow_mut();
@ -613,8 +608,7 @@ impl Area {
let padded_size = Vector2(width_padded, height); let padded_size = Vector2(width_padded, height);
let size = Vector2(width, height); let size = Vector2(width, height);
let logger = &self.model.logger; let logger = &self.model.logger;
let scene = self.model.scene(); let port_shape = port.payload_mut().init_shape(logger, size, node::HEIGHT);
let port_shape = port.payload_mut().init_shape(logger, scene, size, node::HEIGHT);
port_shape.mod_position(|t| t.x = unit * i32::from(index) as f32); port_shape.mod_position(|t| t.x = unit * i32::from(index) as f32);
if DEBUG { if DEBUG {

View File

@ -9,7 +9,6 @@ use crate::Type;
use ensogl::data::color; use ensogl::data::color;
use ensogl::display; use ensogl::display;
use ensogl::display::scene::Scene;
@ -58,6 +57,7 @@ pub mod viz {
use super::*; use super::*;
ensogl::define_shape_system! { ensogl::define_shape_system! {
above = [hover]; above = [hover];
pointer_events = false;
(style:Style, color:Vector4) { (style:Style, color:Vector4) {
let width : Var<Pixels> = "input_size.x".into(); let width : Var<Pixels> = "input_size.x".into();
let height : Var<Pixels> = "input_size.y".into(); let height : Var<Pixels> = "input_size.y".into();
@ -95,7 +95,8 @@ pub struct Shape {
impl Shape { impl Shape {
/// Constructor. /// Constructor.
pub fn new(logger: &Logger, scene: &Scene, size: Vector2, hover_height: f32) -> Self { #[profile(Debug)]
pub fn new(logger: &Logger, size: Vector2, hover_height: f32) -> Self {
let root = display::object::Instance::new(logger); let root = display::object::Instance::new(logger);
let hover = hover::View::new(logger); let hover = hover::View::new(logger);
let viz = viz::View::new(logger); let viz = viz::View::new(logger);
@ -109,12 +110,6 @@ impl Shape {
root.add_child(&hover); root.add_child(&hover);
root.add_child(&viz); root.add_child(&viz);
let viz_shape_system = scene
.layers
.main
.shape_system_registry
.shape_system(scene, PhantomData::<viz::DynamicShape>);
viz_shape_system.shape_system.set_pointer_events(false);
Self { root, hover, viz } Self { root, hover, viz }
} }
@ -183,13 +178,12 @@ impl Model {
pub fn init_shape( pub fn init_shape(
&mut self, &mut self,
logger: impl AnyLogger, logger: impl AnyLogger,
scene: &Scene,
size: Vector2, size: Vector2,
hover_height: f32, hover_height: f32,
) -> Shape { ) -> Shape {
let logger_name = format!("port({},{})", self.index, self.length); let logger_name = format!("port({},{})", self.index, self.length);
let logger = Logger::new_sub(logger, logger_name); let logger = Logger::new_sub(logger, logger_name);
let shape = Shape::new(&logger, scene, size, hover_height); let shape = Shape::new(&logger, size, hover_height);
self.shape = Some(shape); self.shape = Some(shape);
self.shape.as_ref().unwrap().clone_ref() self.shape.as_ref().unwrap().clone_ref()
} }

View File

@ -80,6 +80,7 @@ struct AllPortsShape {
} }
impl AllPortsShape { impl AllPortsShape {
#[profile(Debug)]
fn new( fn new(
canvas_width: &Var<Pixels>, canvas_width: &Var<Pixels>,
canvas_height: &Var<Pixels>, canvas_height: &Var<Pixels>,
@ -381,6 +382,7 @@ macro_rules! fn_multi_only {
} }
impl PortShapeView { impl PortShapeView {
#[profile(Debug)]
fn new(number_of_ports: usize, logger: &Logger) -> Self { fn new(number_of_ports: usize, logger: &Logger) -> Self {
if number_of_ports <= 1 { if number_of_ports <= 1 {
Self::Single(SinglePortView::new(&logger)) Self::Single(SinglePortView::new(&logger))

View File

@ -2861,7 +2861,7 @@ fn new_graph_editor(app: &Application) -> GraphEditor {
out.node_editing_finished <+ node_being_edited.sample(&edit_switch); out.node_editing_finished <+ node_being_edited.sample(&edit_switch);
out.node_editing_started <+ edit_node; out.node_editing_started <+ edit_node;
out.node_being_edited <+ out.node_editing_started.map(|n| Some(*n));; out.node_being_edited <+ out.node_editing_started.map(|n| Some(*n));
out.node_being_edited <+ out.node_editing_finished.constant(None); out.node_being_edited <+ out.node_editing_finished.constant(None);
out.node_editing <+ out.node_being_edited.map(|t|t.is_some()); out.node_editing <+ out.node_being_edited.map(|t|t.is_some());
@ -2869,11 +2869,13 @@ fn new_graph_editor(app: &Application) -> GraphEditor {
out.nodes_labels_visible <+ out.node_edit_mode || node_in_edit_mode; out.nodes_labels_visible <+ out.node_edit_mode || node_in_edit_mode;
eval out.node_editing_started ([model] (id) { eval out.node_editing_started ([model] (id) {
let _profiler = profiler::start_debug!(profiler::APP_LIFETIME, "node_editing_started");
if let Some(node) = model.nodes.get_cloned_ref(id) { if let Some(node) = model.nodes.get_cloned_ref(id) {
node.model().input.frp.set_edit_mode(true); node.model().input.frp.set_edit_mode(true);
} }
}); });
eval out.node_editing_finished ([model](id) { eval out.node_editing_finished ([model](id) {
let _profiler = profiler::start_debug!(profiler::APP_LIFETIME, "node_editing_finished");
if let Some(node) = model.nodes.get_cloned_ref(id) { if let Some(node) = model.nodes.get_cloned_ref(id) {
node.model().input.set_edit_mode(false); node.model().input.set_edit_mode(false);
} }

View File

@ -1,4 +1,4 @@
//! Module that contains the logic sor selecting nodes. This includes selecting single nodes //! Module that contains the logic for selecting nodes. This includes selecting single nodes
//! by clicking on them separately, as well as click+drag for selecting with a selection area. //! by clicking on them separately, as well as click+drag for selecting with a selection area.

View File

@ -137,6 +137,7 @@ impl display::Object for ScrollArea {
impl ScrollArea { impl ScrollArea {
/// Create a new scroll area for use in the given application. /// Create a new scroll area for use in the given application.
#[profile(Detail)]
pub fn new(app: &Application) -> ScrollArea { pub fn new(app: &Application) -> ScrollArea {
let scene = &app.display.default_scene; let scene = &app.display.default_scene;
let logger = Logger::new("ScrollArea"); let logger = Logger::new("ScrollArea");

View File

@ -1,6 +1,5 @@
///! Frp of the number selector. ///! Frp of the number selector.
use crate::prelude::*; use crate::prelude::*;
use crate::shape::*;
use ensogl_core::display::shape::*; use ensogl_core::display::shape::*;
use crate::bounds::absolute_value; use crate::bounds::absolute_value;
@ -52,9 +51,6 @@ impl Frp {
let base_frp = super::Frp::new(model, style, network, frp.resize.clone().into(), mouse); let base_frp = super::Frp::new(model, style, network, frp.resize.clone().into(), mouse);
let track_shape_system = scene.shapes.shape_system(PhantomData::<track::Shape>);
track_shape_system.shape_system.set_pointer_events(false);
let background_click = relative_shape_down_position(network, scene, &model.background); let background_click = relative_shape_down_position(network, scene, &model.background);
let track_click = relative_shape_down_position(network, scene, &model.track); let track_click = relative_shape_down_position(network, scene, &model.track);
let style_track_color = style.get_color(theme::component::slider::track::color); let style_track_color = style.get_color(theme::component::slider::track::color);

View File

@ -100,6 +100,7 @@ pub mod track {
use super::*; use super::*;
ensogl_core::define_shape_system! { ensogl_core::define_shape_system! {
pointer_events = false;
(style:Style,left:f32,right:f32,corner_left:f32,corner_right:f32,corner_inner:f32, (style:Style,left:f32,right:f32,corner_left:f32,corner_right:f32,corner_inner:f32,
track_color:Vector4) { track_color:Vector4) {
let background = Background::new(&corner_left,&corner_right,style); let background = Background::new(&corner_left,&corner_right,style);

View File

@ -612,12 +612,8 @@ impl AreaModel {
let single_line = default(); let single_line = default();
let layer = Rc::new(CloneRefCell::new(scene.layers.main.clone_ref())); let layer = Rc::new(CloneRefCell::new(scene.layers.main.clone_ref()));
// FIXME[WD]: These settings should be managed wiser. They should be set up during
// initialization of the shape system, not for every area creation. To be improved during
// refactoring of the architecture some day.
let shape_system = scene.shapes.shape_system(PhantomData::<selection::shape::Shape>); let shape_system = scene.shapes.shape_system(PhantomData::<selection::shape::Shape>);
let symbol = &shape_system.shape_system.sprite_system.symbol; let symbol = &shape_system.shape_system.sprite_system.symbol;
shape_system.shape_system.set_pointer_events(false);
// FIXME[WD]: This is temporary sorting utility, which places the cursor in front of mouse // FIXME[WD]: This is temporary sorting utility, which places the cursor in front of mouse
// pointer and nodes. Should be refactored when proper sorting mechanisms are in place. // pointer and nodes. Should be refactored when proper sorting mechanisms are in place.

View File

@ -57,6 +57,7 @@ pub mod shape {
use super::*; use super::*;
ensogl_core::define_shape_system! { ensogl_core::define_shape_system! {
pointer_events = false;
(style:Style, selection:f32, start_time:f32, letter_width:f32, color_rgb:Vector3<f32>) { (style:Style, selection:f32, start_time:f32, letter_width:f32, color_rgb:Vector3<f32>) {
let width_abs = Var::<f32>::from("abs(input_size.x)"); let width_abs = Var::<f32>::from("abs(input_size.x)");
let height = Var::<f32>::from("input_size.y"); let height = Var::<f32>::from("input_size.y");

View File

@ -185,6 +185,7 @@ impl Layer {
} }
/// Constructor. /// Constructor.
#[profile(Detail)]
pub fn new_with_cam(logger: Logger, camera: &Camera2d) -> Self { pub fn new_with_cam(logger: Logger, camera: &Camera2d) -> Self {
let this = Self::new(logger); let this = Self::new(logger);
this.set_camera(camera); this.set_camera(camera);
@ -556,6 +557,7 @@ impl LayerModel {
} }
/// Consume all dirty flags and update the ordering of elements if needed. /// Consume all dirty flags and update the ordering of elements if needed.
#[profile(Debug)]
pub(crate) fn update_internal( pub(crate) fn update_internal(
&self, &self,
global_element_depth_order: Option<&DependencyGraph<LayerItem>>, global_element_depth_order: Option<&DependencyGraph<LayerItem>>,

View File

@ -48,19 +48,22 @@ pub struct ShapeSystem {
pub sprite_system: SpriteSystem, pub sprite_system: SpriteSystem,
pub shape: Rc<RefCell<def::AnyShape>>, pub shape: Rc<RefCell<def::AnyShape>>,
pub material: Rc<RefCell<Material>>, pub material: Rc<RefCell<Material>>,
pub pointer_events: Rc<Cell<bool>>, /// Enables or disables pointer events on this shape system. All shapes of a shape system which
/// has pointer events disabled would be completely transparent for the mouse (they would pass
/// through all mouse events).
pub pointer_events: Immutable<bool>,
} }
impl ShapeSystem { impl ShapeSystem {
/// Constructor. /// Constructor.
pub fn new<'t, S, Sh>(scene: S, shape: Sh) -> Self pub fn new<'t, S, Sh>(scene: S, shape: Sh, pointer_events: bool) -> Self
where where
S: Into<&'t Scene>, S: Into<&'t Scene>,
Sh: Into<def::AnyShape>, { Sh: Into<def::AnyShape>, {
let shape = shape.into(); let shape = shape.into();
let sprite_system = SpriteSystem::new(scene); let sprite_system = SpriteSystem::new(scene);
let material = Rc::new(RefCell::new(Self::surface_material())); let material = Rc::new(RefCell::new(Self::surface_material()));
let pointer_events = Rc::new(Cell::new(true)); let pointer_events = Immutable(pointer_events);
let shape = Rc::new(RefCell::new(shape)); let shape = Rc::new(RefCell::new(shape));
let this = Self { sprite_system, shape, material, pointer_events }; let this = Self { sprite_system, shape, material, pointer_events };
this.reload_shape(); this.reload_shape();
@ -81,14 +84,6 @@ impl ShapeSystem {
material material
} }
/// Enables or disables pointer events on this shape system. All shapes of a shape system which
/// has pointer events disabled would be completely transparent for the mouse (they would pass
/// through all mouse events).
pub fn set_pointer_events(&self, val: bool) {
self.pointer_events.set(val);
self.reload_shape();
}
/// Replaces the shape definition. /// Replaces the shape definition.
pub fn set_shape<S: Into<def::AnyShape>>(&self, shape: S) { pub fn set_shape<S: Into<def::AnyShape>>(&self, shape: S) {
let shape = shape.into(); let shape = shape.into();
@ -97,9 +92,9 @@ impl ShapeSystem {
} }
/// Generates the shape again. It is used after some parameters are changed, like setting new /// Generates the shape again. It is used after some parameters are changed, like setting new
/// `pointer_events` value. /// `shape`.
fn reload_shape(&self) { fn reload_shape(&self) {
let code = shader::builder::Builder::run(&*self.shape.borrow(), self.pointer_events.get()); let code = shader::builder::Builder::run(&*self.shape.borrow(), *self.pointer_events);
self.material.borrow_mut().set_code(code); self.material.borrow_mut().set_code(code);
self.reload_material(); self.reload_material();
} }
@ -326,24 +321,24 @@ macro_rules! define_shape_system {
( (
$(above = [$($always_above_1:tt $(::$always_above_2:tt)*),*];)? $(above = [$($always_above_1:tt $(::$always_above_2:tt)*),*];)?
$(below = [$($always_below_1:tt $(::$always_below_2:tt)*),*];)? $(below = [$($always_below_1:tt $(::$always_below_2:tt)*),*];)?
$(pointer_events = $pointer_events:tt;)?
($style:ident : Style $(,$gpu_param : ident : $gpu_param_type : ty)* $(,)?) {$($body:tt)*} ($style:ident : Style $(,$gpu_param : ident : $gpu_param_type : ty)* $(,)?) {$($body:tt)*}
) => { ) => {
$crate::_define_shape_system! { $crate::_define_shape_system! {
$(above = [$($always_above_1 $(::$always_above_2)*),*];)? $(above = [$($always_above_1 $(::$always_above_2)*),*];)?
$(below = [$($always_below_1 $(::$always_below_2)*),*];)? $(below = [$($always_below_1 $(::$always_below_2)*),*];)?
$(pointer_events = $pointer_events;)?
[$style] ($($gpu_param : $gpu_param_type),*){$($body)*} [$style] ($($gpu_param : $gpu_param_type),*){$($body)*}
} }
}; };
( (
$(above = [$($always_above_1:tt $(::$always_above_2:tt)*),*];)? $($arg:ident = $arg_val:tt;)*
$(below = [$($always_below_1:tt $(::$always_below_2:tt)*),*];)?
($($gpu_param : ident : $gpu_param_type : ty),* $(,)?) {$($body:tt)*} ($($gpu_param : ident : $gpu_param_type : ty),* $(,)?) {$($body:tt)*}
) => { ) => {
$crate::_define_shape_system! { $crate::define_shape_system! {
$(above = [$($always_above_1 $(::$always_above_2)*),*];)? $($arg = $arg_val;)*
$(below = [$($always_below_1 $(::$always_below_2)*),*];)? (style : Style, $($gpu_param : $gpu_param_type),*){$($body)*}
[style] ($($gpu_param : $gpu_param_type),*){$($body)*}
} }
} }
} }
@ -354,6 +349,7 @@ macro_rules! _define_shape_system {
( (
$(above = [$($always_above_1:tt $(::$always_above_2:tt)*),*];)? $(above = [$($always_above_1:tt $(::$always_above_2:tt)*),*];)?
$(below = [$($always_below_1:tt $(::$always_below_2:tt)*),*];)? $(below = [$($always_below_1:tt $(::$always_below_2:tt)*),*];)?
$(pointer_events = $pointer_events:tt;)?
[$style:ident] [$style:ident]
($($gpu_param : ident : $gpu_param_type : ty),* $(,)?) ($($gpu_param : ident : $gpu_param_type : ty),* $(,)?)
{$($body:tt)*} {$($body:tt)*}
@ -546,7 +542,9 @@ macro_rules! _define_shape_system {
fn new(scene:&display::scene::Scene) -> Self { fn new(scene:&display::scene::Scene) -> Self {
let style_watch = display::shape::StyleWatch::new(&scene.style_sheet); let style_watch = display::shape::StyleWatch::new(&scene.style_sheet);
let shape_def = Self::shape_def(&style_watch); let shape_def = Self::shape_def(&style_watch);
let shape_system = display::shape::ShapeSystem::new(scene,&shape_def); let _events = true;
$( let _events = $pointer_events; )?
let shape_system = display::shape::ShapeSystem::new(scene,&shape_def,_events);
$( $(
let name = stringify!($gpu_param); let name = stringify!($gpu_param);
let val = gpu::data::default::gpu_default::<$gpu_param_type>(); let val = gpu::data::default::gpu_default::<$gpu_param_type>();

View File

@ -99,6 +99,7 @@ impl<S> Drop for ShapeViewModel<S> {
} }
impl<S: DynamicShapeInternals> ShapeViewModel<S> { impl<S: DynamicShapeInternals> ShapeViewModel<S> {
#[profile(Debug)]
fn on_scene_layers_changed( fn on_scene_layers_changed(
&self, &self,
scene: &Scene, scene: &Scene,

View File

@ -136,6 +136,7 @@ impl Style {
pub mod shape { pub mod shape {
use super::*; use super::*;
crate::define_shape_system! { crate::define_shape_system! {
pointer_events = false;
( press : f32 ( press : f32
, radius : f32 , radius : f32
, color : Vector4 , color : Vector4
@ -210,12 +211,6 @@ impl CursorModel {
tgt_layer.add_exclusive(&view); tgt_layer.add_exclusive(&view);
port_selection_layer.add_exclusive(&port_selection); port_selection_layer.add_exclusive(&port_selection);
for layer in &[tgt_layer, port_selection_layer] {
let registry = &layer.shape_system_registry;
let shape_sys = registry.shape_system(&scene, PhantomData::<shape::DynamicShape>);
shape_sys.shape_system.set_pointer_events(false);
}
Self { logger, scene, display_object, view, port_selection, style } Self { logger, scene, display_object, view, port_selection, style }
} }

View File

@ -61,7 +61,7 @@ pub fn main() {
let scene = &world.default_scene; let scene = &world.default_scene;
let camera = scene.camera().clone_ref(); let camera = scene.camera().clone_ref();
let navigator = Navigator::new(scene, &camera); let navigator = Navigator::new(scene, &camera);
let sprite_system = ShapeSystem::new(&world, &shape()); let sprite_system = ShapeSystem::new(&world, &shape(), true);
let sprite = sprite_system.new_instance(); let sprite = sprite_system.new_instance();
sprite.size.set(Vector2::new(300.0, 300.0)); sprite.size.set(Vector2::new(300.0, 300.0));

View File

@ -4,6 +4,7 @@ use enso_web::prelude::*;
use crate as frp; use crate as frp;
use enso_profiler as profiler;
use enso_web as web; use enso_web as web;
@ -140,6 +141,7 @@ impl CurrentJsEvent {
{ {
let event_source = self.event_source.clone_ref(); let event_source = self.event_source.clone_ref();
move |event| { move |event| {
let _profiler = profiler::start_debug!(profiler::APP_LIFETIME, "event_handler");
let js_event = event.as_ref().clone(); let js_event = event.as_ref().clone();
event_source.emit(Some(js_event)); event_source.emit(Some(js_event));
processing_fn(event); processing_fn(event);

View File

@ -46,14 +46,14 @@ fn print_measurement<Metadata>(
indent.push_str(" "); indent.push_str(" ");
} }
println!("{}{}", indent, measurement.label); println!("{}{}", indent, measurement.label);
println!("{} intervals:", indent); print!("{}", indent);
for active in &measurement.intervals { for active in &measurement.intervals {
let interval = profile[*active].interval; let interval = profile[*active].interval;
println!("{} interval: {}", indent, fmt_interval(interval)); print!(" {}", fmt_interval(interval));
} }
println!("{} children:", indent); println!();
for child in &measurement.children { for child in &measurement.children {
print_measurement(profile, *child, i + 2); print_measurement(profile, *child, i + 1);
} }
} }