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

Fix: when default visualization is displayed, its entry is not present in the chooser list. #6209

Merged
merged 5 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -526,6 +526,20 @@ impl Container {
}


// === Visualisation Chooser Bindings ===

frp::extend! { network
selected_definition <- action_bar.visualisation_selection.map(f!([registry](path)
Copy link
Member

Choose a reason for hiding this comment

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

double space

path.as_ref().and_then(|path| registry.definition_from_path(path))
));
on_selected <- selected_definition.map(|d|d.as_ref().map(|_|())).unwrap();
farmaazon marked this conversation as resolved.
Show resolved Hide resolved
eval_ on_selected ( action_bar.hide_icons.emit(()) );
Copy link
Member

Choose a reason for hiding this comment

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

action_bar.hide_icons <+ on_selected

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;
}


// === Cycling Visualizations ===

frp::extend! { network
Expand All @@ -538,7 +552,7 @@ impl Container {
// === Switching Visualizations ===

frp::extend! { network
new_vis_definition <- any(frp.set_visualization,vis_after_cycling,default_visualisation);
new_vis_definition <- any(frp.set_visualization, selected_definition, vis_after_cycling, default_visualisation).on_change();
Copy link
Member

Choose a reason for hiding this comment

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

100 chars

let preprocessor = &frp.source.preprocessor;
frp.source.visualisation <+ new_vis_definition.map(f!(
[model,action_bar,app,preprocessor](vis_definition) {
Expand Down Expand Up @@ -625,32 +639,6 @@ impl Container {
}


// === Visualisation chooser frp bindings ===

frp::extend! { network
selected_definition <- action_bar.visualisation_selection.map(f!([registry](path)
path.as_ref().and_then(|path| registry.definition_from_path(path))
));
eval selected_definition([app,model,preprocessor](definition) {
let vis = definition.as_ref().map(|d| d.new_instance(&app));
match vis {
Some(Ok(vis)) => model.set_visualization(vis,&preprocessor),
Some(Err(err)) => {
warn!("Failed to instantiate visualisation: {err:?}");
},
None => warn!("Invalid visualisation selected."),
};
});
frp.source.visualisation <+ selected_definition;
on_selected <- selected_definition.map(|d|d.as_ref().map(|_|())).unwrap();
eval_ on_selected ( action_bar.hide_icons.emit(()) );
frp.source.vis_input_type <+ frp.set_vis_input_type;
eval frp.set_vis_input_type (
(tp) model.action_bar.visualization_chooser().frp.set_vis_input_type(tp)
);
}


// === Action bar actions ===

frp::extend! { network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,7 @@ impl ActionBar {
eval_ frp.hide_icons ( model.hide() );
eval_ frp.show_icons ( model.show() );

eval frp.input.set_selected_visualization ((vis){
visualization_chooser.input.set_selected.emit(vis);
});
visualization_chooser.input.set_selected <+ frp.input.set_selected_visualization;


// === Mouse Interactions ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl VisualizationChooser {
eval_ frp.hide_selection_menu ( menu.hide_selection_menu.emit(()) );
eval frp.set_menu_offset_y ((offset) menu.set_menu_offset_y.emit(offset) );

set_selected_ix <= frp.input.set_selected.map2(&frp.output.entries,|selected,entries|
set_selected_ix <= all_with(&frp.input.set_selected, &frp.output.entries, |selected,entries|
selected.as_ref().map(|s| entries.iter().position(|item| item == s))
);
eval set_selected_ix ((ix) menu.set_selected.emit(ix));
Expand Down