diff --git a/app/gui/view/graph-editor/src/component/visualization/container.rs b/app/gui/view/graph-editor/src/component/visualization/container.rs index 183fd6c7c10f..5d713495cca5 100644 --- a/app/gui/view/graph-editor/src/component/visualization/container.rs +++ b/app/gui/view/graph-editor/src/component/visualization/container.rs @@ -526,6 +526,19 @@ impl Container { } + // === Visualisation Chooser 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)) + )); + action_bar.hide_icons <+ selected_definition.constant(()); + 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 @@ -538,7 +551,12 @@ impl Container { // === Switching Visualizations === frp::extend! { network - new_vis_definition <- any(frp.set_visualization,vis_after_cycling,default_visualisation); + vis_definition_set <- any( + frp.set_visualization, + selected_definition, + vis_after_cycling, + default_visualisation); + new_vis_definition <- vis_definition_set.on_change(); let preprocessor = &frp.source.preprocessor; frp.source.visualisation <+ new_vis_definition.map(f!( [model,action_bar,app,preprocessor](vis_definition) { @@ -625,32 +643,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 diff --git a/app/gui/view/graph-editor/src/component/visualization/container/action_bar.rs b/app/gui/view/graph-editor/src/component/visualization/container/action_bar.rs index 2fdeb1dedb58..f9e2cd28ea5e 100644 --- a/app/gui/view/graph-editor/src/component/visualization/container/action_bar.rs +++ b/app/gui/view/graph-editor/src/component/visualization/container/action_bar.rs @@ -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 === diff --git a/app/gui/view/graph-editor/src/component/visualization/container/visualization_chooser.rs b/app/gui/view/graph-editor/src/component/visualization/container/visualization_chooser.rs index d7dea48fcca9..de4deabf70e2 100644 --- a/app/gui/view/graph-editor/src/component/visualization/container/visualization_chooser.rs +++ b/app/gui/view/graph-editor/src/component/visualization/container/visualization_chooser.rs @@ -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));