Skip to content

Commit

Permalink
Searcher Fixes (enso-org/ide#1577)
Browse files Browse the repository at this point in the history
Original commit: enso-org/ide@de6e145
  • Loading branch information
farmaazon authored May 26, 2021
1 parent 9245880 commit 4c9f990
Show file tree
Hide file tree
Showing 19 changed files with 237 additions and 143 deletions.
5 changes: 5 additions & 0 deletions ide/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@

#### Visual Environment

- [Nodes in graph no longer overlap panels][1577]. The Searcher, project name,
breadcrumbs and status bar are displayed "above" nodes.

#### Enso Compiler

[1577]: https://github.com/enso-org/ide/pull/1577

# Enso 2.0.0-alpha.5 (2021-05-14)

<br/>![New Features](/docs/assets/tags/new_features.svg)
Expand Down
6 changes: 3 additions & 3 deletions ide/src/rust/ensogl/lib/components/src/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ impl Model {
// FIXME[MM/WD]: Depth sorting of labels to in front of everything else in the scene.
// Temporary solution. The depth management needs to allow defining relative position of
// the text and background and let the whole component to be set to am an arbitrary layer.
label.remove_from_scene_layer_DEPRECATED(&scene.layers.main);
label.add_to_scene_layer_DEPRECATED(&scene.layers.tooltip_text);
scene.layers.tooltip_background.add_exclusive(&background);
label.remove_from_scene_layer(&scene.layers.main);
label.add_to_scene_layer(&scene.layers.tooltip_text);
scene.layers.tooltip.add_exclusive(&background);

display_object.add_child(&background);
display_object.add_child(&label);
Expand Down
6 changes: 6 additions & 0 deletions ide/src/rust/ensogl/lib/components/src/list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use ensogl_core::application;
use ensogl_core::application::Application;
use ensogl_core::application::shortcut;
use ensogl_core::display;
use ensogl_core::display::scene::layer::LayerId;
use ensogl_core::display::shape::*;
use ensogl_core::DEPRECATED_Animation;
use ensogl_theme as theme;
Expand Down Expand Up @@ -412,6 +413,11 @@ impl ListView {

self
}

/// Sets the scene layer where the labels will be placed.
pub fn set_label_layer(&self, layer:LayerId) {
self.model.entries.set_label_layer(layer);
}
}

impl display::Object for ListView {
Expand Down
36 changes: 30 additions & 6 deletions ide/src/rust/ensogl/lib/components/src/list_view/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::prelude::*;

use ensogl_core::application::Application;
use ensogl_core::display;
use ensogl_core::display::scene::layer::LayerId;
use ensogl_core::display::shape::StyleWatch;
use ensogl_text as text;
use ensogl_theme;
Expand Down Expand Up @@ -315,18 +316,20 @@ pub struct List {
entries : Rc<RefCell<Vec<Entry>>>,
entries_range : Rc<CloneCell<Range<Id>>>,
provider : Rc<CloneRefCell<AnyModelProvider>>,
label_layer : Rc<Cell<LayerId>>,
}

impl List {
/// Entry List View constructor.
pub fn new(parent:impl AnyLogger, app:&Application) -> Self {
let app = app.clone_ref();
let logger = Logger::sub(parent,"entry::List");
let entries = default();
let entries_range = Rc::new(CloneCell::new(default()..default()));
let app = app.clone_ref();
let logger = Logger::sub(parent,"entry::List");
let entries = default();
let entries_range = Rc::new(CloneCell::new(default()..default()));
let display_object = display::object::Instance::new(&logger);
let provider = default();
List {logger,app,display_object,entries,entries_range,provider}
let provider = default();
let label_layer = Rc::new(Cell::new(app.display.scene().layers.label.id));
List {logger,app,display_object,entries,entries_range,provider,label_layer}
}

/// The number of all entries in List, including not displayed.
Expand Down Expand Up @@ -414,8 +417,29 @@ impl List {
self.provider.set(provider);
}

/// Sets the scene layer where the labels will be placed.
pub fn set_label_layer(&self, label_layer:LayerId) {
if let Some(layer) = self.app.display.scene().layers.get(self.label_layer.get()) {
for entry in &*self.entries.borrow() {
entry.label.remove_from_scene_layer(&self.app.display.scene().layers.label);
entry.label.add_to_scene_layer(&layer);
}
} else {
error!(self.logger, "Cannot set layer {label_layer:?} for labels: the layer does not \
exist in the scene");
}
self.label_layer.set(label_layer);
}

fn create_new_entry(&self) -> Entry {
let entry = Entry::new(&self.logger,&self.app);
if let Some(layer) = self.app.display.scene().layers.get(self.label_layer.get()) {
entry.label.remove_from_scene_layer(&self.app.display.scene().layers.label);
entry.label.add_to_scene_layer(&layer);
} else {
error!(self.logger, "Cannot set layer {self.label_layer:?} for labels: the layer does \
not exist in the scene");
}
self.add_child(&entry);
entry
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ impl component::Model for Model {
let label_full = app.new_view::<text::Area>();
let label_left = app.new_view::<text::Area>();

label_full.remove_from_scene_layer_DEPRECATED(&app.display.scene().layers.main);
label_full.add_to_scene_layer_DEPRECATED(&app.display.scene().layers.label);
label_full.remove_from_scene_layer(&app.display.scene().layers.main);
label_full.add_to_scene_layer(&app.display.scene().layers.label);

root.add_child(&label_full);
root.add_child(&label_left);
Expand Down
16 changes: 8 additions & 8 deletions ide/src/rust/ensogl/lib/components/src/selector/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ impl component::Model for Model {
root.add_child(&track);
root.add_child(&right_overflow);

label_left.remove_from_scene_layer_DEPRECATED(&scene.layers.main);
label_left.add_to_scene_layer_DEPRECATED(&scene.layers.label);
label_right.remove_from_scene_layer_DEPRECATED(&scene.layers.main);
label_right.add_to_scene_layer_DEPRECATED(&scene.layers.label);
caption_left.remove_from_scene_layer_DEPRECATED(&scene.layers.main);
caption_left.add_to_scene_layer_DEPRECATED(&scene.layers.label);
caption_center.remove_from_scene_layer_DEPRECATED(&scene.layers.main);
caption_center.add_to_scene_layer_DEPRECATED(&scene.layers.label);
label_left.remove_from_scene_layer(&scene.layers.main);
label_left.add_to_scene_layer(&scene.layers.label);
label_right.remove_from_scene_layer(&scene.layers.main);
label_right.add_to_scene_layer(&scene.layers.label);
caption_left.remove_from_scene_layer(&scene.layers.main);
caption_left.add_to_scene_layer(&scene.layers.label);
caption_center.remove_from_scene_layer(&scene.layers.main);
caption_center.add_to_scene_layer(&scene.layers.label);

Self{background,track,track_handle_left,track_handle_right,left_overflow,right_overflow,
label,label_left,label_right,caption_left,caption_center,root}
Expand Down
66 changes: 37 additions & 29 deletions ide/src/rust/ensogl/lib/core/src/display/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,15 +615,17 @@ pub struct HardcodedLayers {
pub viz : Layer,
pub below_main : Layer,
// main <- here is the 'main` layer inserted.
pub cursor : Layer,
pub port_selection : Layer,
pub label : Layer,

pub tooltip_background : Layer,
pub above_nodes : Layer,
pub above_nodes_text : Layer,
/// Layer containing all panels with fixed position (not moving with the panned scene):
/// like status bar, breadcrumbs or similar.
pub panel : Layer,
pub panel_text : Layer,
pub tooltip : Layer,
pub tooltip_text : Layer,

pub viz_fullscreen : Layer,
pub breadcrumbs_background : Layer,
pub breadcrumbs_text : Layer,
pub cursor : Layer,
layers : Layers,
}

Expand All @@ -636,32 +638,38 @@ impl Deref for HardcodedLayers {

impl HardcodedLayers {
pub fn new(logger:impl AnyLogger) -> Self {
let layers = Layers::new(logger);
let viz = layers.new_layer();
let cursor = layers.new_layer();
let label = layers.new_layer();
let tooltip_background = layers.new_layer();
let tooltip_text = layers.new_layer();
let viz_fullscreen = layers.new_layer();
let below_main = layers.new_layer();
let breadcrumbs_background = layers.new_layer();
let breadcrumbs_text = layers.new_layer();
let layers = Layers::new(logger);
let viz = layers.new_layer();
let below_main = layers.new_layer();
let port_selection = layers.new_layer();
let label = layers.new_layer();
let above_nodes = layers.new_layer();
let above_nodes_text = layers.new_layer();
let panel = layers.new_layer();
let panel_text = layers.new_layer();
let tooltip = layers.new_layer();
let tooltip_text = layers.new_layer();
let cursor = layers.new_layer();
viz.set_camera(layers.main.camera());
below_main.set_camera(layers.main.camera());
label.set_camera(layers.main.camera());
tooltip_background.set_camera(layers.main.camera());
above_nodes.set_camera(layers.main.camera());
above_nodes_text.set_camera(layers.main.camera());
tooltip.set_camera(layers.main.camera());
tooltip_text.set_camera(layers.main.camera());
below_main.set_camera(layers.main.camera());
layers.add_layers_order_dependency(&breadcrumbs_background,&breadcrumbs_text);
layers.add_layers_order_dependency(&breadcrumbs_text,&viz);
layers.add_layers_order_dependency(&viz,&below_main);
layers.add_layers_order_dependency(&below_main,&layers.main);
layers.add_layers_order_dependency(&layers.main,&cursor);
layers.add_layers_order_dependency(&cursor,&label);
layers.add_layers_order_dependency(&label,&tooltip_background);
layers.add_layers_order_dependency(&tooltip_background,&tooltip_text);
layers.add_layers_order_dependency(&tooltip_text,&viz_fullscreen);
Self {viz,below_main,cursor,label,tooltip_background,tooltip_text,viz_fullscreen
,breadcrumbs_background,breadcrumbs_text,layers}
layers.add_layers_order_dependency(&layers.main,&port_selection);
layers.add_layers_order_dependency(&port_selection,&label);
layers.add_layers_order_dependency(&label,&above_nodes);
layers.add_layers_order_dependency(&above_nodes,&above_nodes_text);
layers.add_layers_order_dependency(&above_nodes_text,&panel);
layers.add_layers_order_dependency(&panel,&panel_text);
layers.add_layers_order_dependency(&panel_text,&tooltip);
layers.add_layers_order_dependency(&tooltip,&tooltip_text);
layers.add_layers_order_dependency(&tooltip_text,&cursor);
Self {viz,below_main,port_selection,label,above_nodes,above_nodes_text,panel,panel_text
,tooltip,tooltip_text,cursor,layers}
}
}

Expand Down Expand Up @@ -862,7 +870,7 @@ impl SceneData {
// Updating camera for DOM layers. Please note that DOM layers cannot use multi-camera
// setups now, so we are using here the main camera only.
let camera = self.camera();
let fullscreen_vis_camera = self.layers.viz_fullscreen.camera();
let fullscreen_vis_camera = self.layers.panel.camera();
let changed = camera.update(scene);
if changed {
self.frp.camera_changed_source.emit(());
Expand Down
Loading

0 comments on commit 4c9f990

Please sign in to comment.