Skip to content

Commit

Permalink
The EnsoGL Component abstraction with special dropping behavior (#3322)
Browse files Browse the repository at this point in the history
In this branch:
* The workaround for cursor-not-being-updated-after-closing-searcher bug (discovered while testing #3278) is reverted.
* The proper fix was introduced: created an abstraction for EnsoGL component, which, when dropping, will not immediately drop the FRP network and model, but instead put it into the Garbage Collector. The Collector ensures, that all "component hiding" effects and events will be handled, and drops FRP network and model only after that.
* I run clippy for wasm32 target out of curiosity. There was one warning, and I fixed it on this branch.
  • Loading branch information
farmaazon authored Apr 4, 2022
1 parent a4dbc9a commit e5a7420
Show file tree
Hide file tree
Showing 21 changed files with 416 additions and 147 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,4 @@ debug-assertions = true

[profile.integration-test]
inherits = "test"
# The integration-test profile was created to be able run integration tests with optimizations (as they took a lot of
# time). There is, however, an issue with running them with optimizations #181740444.
# opt-level = 2
opt-level = 0
opt-level = 2
2 changes: 1 addition & 1 deletion app/gui/language/parser/src/jsclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Client {
) -> api::Result<api::ParsedSourceFile<M>> {
let result = || {
let json = &parse_with_metadata(program)?;
let module = from_json_str_without_recursion_limit(&json)?;
let module = from_json_str_without_recursion_limit(json)?;
Result::Ok(module)
};
Ok(result()?)
Expand Down
23 changes: 16 additions & 7 deletions app/gui/view/graph-editor/src/component/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use ensogl::application::Application;
use ensogl::data::color;
use ensogl::display;
use ensogl::display::scene::Layer;
use ensogl::gui;
use ensogl::Animation;
use ensogl_component::shadow;
use ensogl_component::text;
Expand Down Expand Up @@ -385,12 +386,11 @@ ensogl::define_endpoints_2! {
/// complex logically (the events are emitted from node to graph, then processed there and
/// emitted back to the right node).
///
/// Currently, the solution "C" (most optimal) is implemented here.
/// Currently, the solution "C" (nearest to optimal) is implemented here.
#[derive(Clone, CloneRef, Debug)]
#[allow(missing_docs)]
pub struct Node {
pub model: Rc<NodeModel>,
pub frp: Frp,
widget: gui::Widget<NodeModel, Frp>,
}

impl AsRef<Node> for Node {
Expand All @@ -399,10 +399,17 @@ impl AsRef<Node> for Node {
}
}

impl AsRef<gui::Widget<NodeModel, Frp>> for Node {
fn as_ref(&self) -> &gui::Widget<NodeModel, Frp> {
&self.widget
}
}


impl Deref for Node {
type Target = Frp;
type Target = gui::Widget<NodeModel, Frp>;
fn deref(&self) -> &Self::Target {
&self.frp
&self.widget
}
}

Expand Down Expand Up @@ -949,7 +956,9 @@ impl Node {
frp.set_disabled.emit(false);
frp.show_quick_action_bar_on_hover.emit(true);

Self { model, frp }
let display_object = model.display_object.clone_ref();
let widget = gui::Widget::new(app, frp, model, display_object);
Node { widget }
}

fn error_color(error: &Option<Error>, style: &StyleWatch) -> color::Lcha {
Expand All @@ -969,7 +978,7 @@ impl Node {

impl display::Object for Node {
fn display_object(&self) -> &display::object::Instance {
&self.model.display_object
self.deref().display_object()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ impl GraphEditorModelWithNetwork {
/// Move node to the `edited_node` scene layer, so that it is rendered by the separate camera.
fn move_node_to_edited_node_layer(&self, node_id: NodeId) {
if let Some(node) = self.nodes.get_cloned(&node_id) {
node.model.move_to_edited_node_layer();
node.model().move_to_edited_node_layer();
}
}

/// Move node to the `main` scene layer, so that it is rendered by the main camera.
fn move_node_to_main_layer(&self, node_id: NodeId) {
if let Some(node) = self.nodes.get_cloned(&node_id) {
node.model.move_to_main_layer();
node.model().move_to_main_layer();
}
}
}
1 change: 0 additions & 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 @@ -676,7 +676,6 @@ impl Area {

eval_ mouse_down ([crumbs,frp] frp.source.on_port_press.emit(&crumbs));


// === Hover ===

hovered <- bool(&mouse_out,&mouse_over);
Expand Down
Loading

0 comments on commit e5a7420

Please sign in to comment.