Fix node name visibility by removing remaining view-mode logic fron node output port (#7269)

Fixes #7259

Node label (and output port in general) used to depend on view-mode logic, which is currently not fully functional. Since we have removed profiling mode from the application, It's best to remove some remaining parts of it to avoid them from interfering.

Labels now work as they used to, being shown on hover or when ctrl is held down.

![image](https://github.com/enso-org/enso/assets/919491/5e6996a4-6d84-4d36-a624-03a53f7e6e8a)
This commit is contained in:
Paweł Grabarz 2023-07-13 14:07:07 +02:00 committed by GitHub
parent fe80ccecac
commit 4be2c7b65b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 44 deletions

View File

@ -711,7 +711,6 @@ impl Node {
// === View Mode ===
model.input.set_view_mode <+ input.set_view_mode;
model.output.set_view_mode <+ input.set_view_mode;
model.input.set_edit_ready_mode <+ input.set_edit_ready_mode;
model.profiling_label.set_view_mode <+ input.set_view_mode;
model.vcs_indicator.set_visibility <+ input.set_view_mode.map(|&mode| {

View File

@ -7,7 +7,6 @@ use crate::component::node;
use crate::component::node::input;
use crate::component::node::output::port;
use crate::tooltip;
use crate::view;
use crate::Type;
use enso_config::ARGS;
@ -18,7 +17,6 @@ use ensogl::application::Application;
use ensogl::data::color;
use ensogl::display;
use ensogl::display::shape::StyleWatch;
use ensogl::display::shape::StyleWatchFrp;
use ensogl_component::text;
use ensogl_hardcoded_theme as theme;
@ -114,7 +112,6 @@ ensogl::define_endpoints! {
set_expression (node::Expression),
set_expression_visibility (bool),
set_type_label_visibility (bool),
set_view_mode (view::Mode),
/// Set the expression USAGE type. This is not the definition type, which can be set with
/// `set_expression` instead. In case the usage type is set to None, ports still may be
@ -130,7 +127,6 @@ ensogl::define_endpoints! {
type_label_visibility (bool),
expression_label_visibility (bool),
tooltip (tooltip::Style),
view_mode (view::Mode),
size (Vector2),
}
}
@ -146,7 +142,6 @@ pub struct Model {
expression: RefCell<Expression>,
id_ports_map: RefCell<HashMap<ast::Id, usize>>,
styles: StyleWatch,
styles_frp: StyleWatchFrp,
frp: FrpEndpoints,
}
@ -161,7 +156,6 @@ impl Model {
let id_ports_map = default();
let expression = default();
let styles = StyleWatch::new(&app.display.default_scene.style_sheet);
let styles_frp = StyleWatchFrp::new(&app.display.default_scene.style_sheet);
let frp = frp.output.clone_ref();
display_object.add_child(&label);
display_object.add_child(&ports);
@ -174,7 +168,6 @@ impl Model {
expression,
id_ports_map,
styles,
styles_frp,
frp,
}
.init(app)
@ -300,13 +293,8 @@ impl Model {
model.index = span.start.into();
model.length = span.size();
let (port_shape, port_frp) = model.init_shape(
&self.app,
&self.styles,
&self.styles_frp,
port_index,
port_count,
);
let (port_shape, port_frp) =
model.init_shape(&self.app, &self.styles, port_index, port_count);
let port_network = &port_frp.network;
let source = &self.frp.source;
@ -315,14 +303,12 @@ impl Model {
port_frp.set_size_multiplier <+ self.frp.port_size_multiplier;
port_frp.set_type_label_visibility <+ self.frp.type_label_visibility;
source.tooltip <+ port_frp.tooltip;
port_frp.set_view_mode <+ self.frp.view_mode;
port_frp.set_size <+ self.frp.size;
source.on_port_hover <+ port_frp.on_hover.map(move |&t| Switch::new(port_id,t));
source.on_port_press <+ port_frp.on_press.constant(port_id);
}
port_frp.set_type_label_visibility.emit(self.frp.type_label_visibility.value());
port_frp.set_view_mode.emit(self.frp.view_mode.value());
port_frp.set_size.emit(self.frp.size.value());
port_frp.set_definition_type.emit(node_tp);
self.ports.add_child(&port_shape);
@ -412,8 +398,6 @@ impl Area {
port_hover <- frp.on_port_hover.map(|t| t.is_on());
frp.source.body_hover <+ frp.set_hover || port_hover;
expr_vis <- frp.body_hover || frp.set_expression_visibility;
in_normal_mode <- frp.set_view_mode.map(|m| m.is_normal());
expr_vis <- expr_vis && in_normal_mode;
frp.source.expression_label_visibility <+ expr_vis;
let label_vis_color = color::Lcha::from(model.styles.get_color(theme::graph_editor::node::text));
@ -423,11 +407,6 @@ impl Area {
label_color_on_change <- label_color.value.sample(&frp.set_expression);
new_label_color <- any(&label_color.value,&label_color_on_change);
eval new_label_color ((color) model.label.set_property(.., color::Rgba::from(color)));
// === View Mode ===
frp.source.view_mode <+ frp.set_view_mode;
}
label_color.target_alpha(0.0);

View File

@ -7,7 +7,6 @@ use crate::application::tooltip;
use crate::application::tooltip::Placement;
use crate::component::node;
use crate::component::type_coloring;
use crate::view;
use crate::Type;
use enso_frp as frp;
@ -22,7 +21,6 @@ use ensogl::display::shape::PixelDistance;
use ensogl::display::shape::Pixels;
use ensogl::display::shape::Rect;
use ensogl::display::shape::StyleWatch;
use ensogl::display::shape::StyleWatchFrp;
use ensogl::display::shape::Var;
use ensogl::gui::text;
use ensogl::Animation;
@ -432,7 +430,6 @@ ensogl::define_endpoints! {
set_usage_type (Option<Type>),
set_type_label_visibility (bool),
set_size (Vector2),
set_view_mode (view::Mode),
}
Output {
@ -463,7 +460,6 @@ impl Model {
&mut self,
app: &Application,
styles: &StyleWatch,
styles_frp: &StyleWatchFrp,
port_index: usize,
port_count: usize,
) -> (display::object::Instance, Frp) {
@ -493,17 +489,11 @@ impl Model {
self.port_count = max(port_count, 1);
self.port_index = port_index;
self.init_frp(&shape, &type_label, styles, styles_frp);
self.init_frp(&shape, &type_label, styles);
(display_object, self.frp.as_ref().unwrap().clone_ref())
}
fn init_frp(
&mut self,
shape: &PortShapeView,
type_label: &text::Text,
styles: &StyleWatch,
styles_frp: &StyleWatchFrp,
) {
fn init_frp(&mut self, shape: &PortShapeView, type_label: &text::Text, styles: &StyleWatch) {
let frp = Frp::new();
let network = &frp.network;
let opacity = Animation::<f32>::new(network);
@ -560,14 +550,8 @@ impl Model {
|usage_tp,def_tp| usage_tp.clone().or_else(|| def_tp.clone())
);
normal_color <- frp.tp.map(f!([styles](t)
color.target <+ frp.tp.map(f!([styles](t)
type_coloring::compute_for_selection(t.as_ref(),&styles)));
init_color <- source::<()>();
let profiling_color = styles_frp.get_color(ensogl_hardcoded_theme::code::types::any::selection);
profiling_color <- all_with(&profiling_color,&init_color,|c,_|color::Lcha::from(c));
in_profiling_mode <- frp.set_view_mode.map(|mode| mode.is_profiling());
color_tgt <- in_profiling_mode.switch(&normal_color,&profiling_color);
color.target <+ color_tgt;
eval color.value ((t) shape.set_color(t.into()));
full_type_timer.start <+ frp.on_hover.on_true();
@ -579,7 +563,6 @@ impl Model {
})
});
}
init_color.emit(());
if SHOW_TYPE_AS_LABEL {
frp::extend! { network