Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only initialise visualisation chooser if it is used. #6758

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,8 @@ impl Container {
selected_definition <- action_bar.visualisation_selection.map(f!([registry](path)
path.as_ref().and_then(|path| registry.definition_from_path(path))
));
action_bar.hide_icons <+ selected_definition.constant(());
action_bar.set_vis_input_type <+ frp.set_vis_input_type;
frp.source.vis_input_type <+ frp.set_vis_input_type;
let chooser = &model.action_bar.visualization_chooser();
chooser.frp.set_vis_input_type <+ frp.set_vis_input_type;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ensogl::display::traits::*;
use crate::component::node;
use crate::component::visualization;
use crate::component::visualization::container::visualization_chooser::VisualizationChooser;
use crate::data::enso;

use enso_frp as frp;
use enso_frp;
Expand Down Expand Up @@ -234,6 +235,7 @@ ensogl::define_endpoints! {
show_icons (),
hide_icons (),
set_selected_visualization (Option<visualization::Path>),
set_vis_input_type (Option<enso::Type>),
}

Output {
Expand Down Expand Up @@ -389,7 +391,11 @@ impl ActionBar {
hide <- any(mouse_out_no_menu,remote_click);
eval_ hide (model.hide());

frp.source.visualisation_selection <+ visualization_chooser.chosen_entry;
// The action bar does not allow to deselect the visualisation, so we prohibit these
// events, which can occur on re-initialization.
has_selection <- visualization_chooser.chosen_entry.is_some();
frp.source.visualisation_selection
<+ visualization_chooser.chosen_entry.gate(&has_selection);

let reset_position_icon = &model.icons.reset_position_icon.events_deprecated;
let reset_position_icon_down = reset_position_icon.mouse_down_primary.clone_ref();
Expand All @@ -403,14 +409,26 @@ impl ActionBar {

show_reset_icon <- bool(&reset_position_icon_down,start_dragging);
eval show_reset_icon((visibility) model.icons.set_reset_icon_visibility(*visibility));


// === Visualisation Chooser ===

// Note: we only want to update the chooser if it is visible, or when it becomes
// visible. Thus we avoid many simultaneous updates during initialisation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment. What do you mean by "many simultaneous updates during initialization"? Why updating the chosen while it is invisible would cause many simultaneous updates?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We update all choosers upon first receiving types from the engine (the initialization), which is mostly pointless given they are not visible (and they content may easily be changed again before it will be actually shown).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, @MichaelMauderer, would you be able to add this (^^^) information to the comment there as well, please? It would make (at least for me) it way more understandable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

visible <- any(&frp.show_icons, &any_component_over);
hidden <- any(&frp.hide_icons, &hide);

is_visible <- bool(&hidden, &visible);
on_show <- is_visible.on_change().on_true();

set_vis_input_while_visible <- frp.input.set_vis_input_type.gate(&is_visible);
set_vis_input_on_show <- frp.input.set_vis_input_type.sample(&on_show);
set_vis_input <- any(&set_vis_input_while_visible, &set_vis_input_on_show).on_change();
visualization_chooser.input.set_vis_input_type <+ set_vis_input;
}
self
}

/// Visualization Chooser component getter.
pub fn visualization_chooser(&self) -> &VisualizationChooser {
&self.model.visualization_chooser
}
}

impl display::Object for ActionBar {
Expand Down