Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vitvakatu committed Apr 25, 2023
1 parent ee097fb commit c87ab85
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
26 changes: 10 additions & 16 deletions app/gui/src/presenter/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,22 +289,16 @@ impl Model {
})
}

fn execution_environment_changed(
&self,
execution_environment: &ide_view::execution_environment_selector::ExecutionEnvironment,
) {
if let Ok(execution_environment) = execution_environment.as_str().try_into() {
let graph_controller = self.graph_controller.clone_ref();
executor::global::spawn(async move {
if let Err(err) =
graph_controller.set_execution_environment(execution_environment).await
{
error!("Error setting execution environment: {err}");
}
});
} else {
error!("Invalid execution environment: {execution_environment:?}");
}
fn execution_environment_changed(&self, execution_environment: &ExecutionEnvironment) {
let execution_environment = *execution_environment;
let graph_controller = self.graph_controller.clone_ref();
executor::global::spawn(async move {
if let Err(err) =
graph_controller.set_execution_environment(execution_environment).await
{
error!("Error setting execution environment: {err}");
}
});
}
}

Expand Down
12 changes: 7 additions & 5 deletions app/gui/view/graph-editor/src/execution_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;

use crate::Frp;

use ide_view_execution_environment_selector::ExecutionEnvironment;
use ide_view_execution_environment_selector::ExecutionEnvironment as ViewExecutionEnvironment;



Expand All @@ -14,9 +14,10 @@ use ide_view_execution_environment_selector::ExecutionEnvironment;

fn get_next_execution_environment(
current: &ExecutionEnvironment,
available: &[ExecutionEnvironment],
) -> Option<ExecutionEnvironment> {
let index = available.iter().position(|mode| mode == current)?;
available: &[ViewExecutionEnvironment],
) -> Option<ViewExecutionEnvironment> {
let current = ViewExecutionEnvironment::from(*current);
let index = available.iter().position(|mode| *mode == current)?;
let next_index = (index + 1) % available.len();
Some(available[next_index].clone())
}
Expand Down Expand Up @@ -47,7 +48,8 @@ pub fn init_frp(frp: &Frp, model: &GraphEditorModelWithNetwork) {

execution_environment_update
<- any(selector.selected_execution_environment,external_update);
out.execution_environment <+ execution_environment_update;
new_execution_environment <- execution_environment_update.map(|e| ExecutionEnvironment::try_from(e.as_str()).unwrap());
out.execution_environment <+ new_execution_environment;
out.execution_environment_play_button_pressed <+ selector.play_press;


Expand Down
4 changes: 2 additions & 2 deletions app/gui/view/graph-editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ ensogl::define_endpoints_2! {
min_x_spacing_for_new_nodes (f32),

/// The selected environment mode.
execution_environment (execution_environment_selector::ExecutionEnvironment),
execution_environment (ExecutionEnvironment),
/// A press of the execution environment selector play button.
execution_environment_play_button_pressed (),
}
Expand Down Expand Up @@ -1730,7 +1730,7 @@ impl GraphEditorModelWithNetwork {

// === Execution Environment ===

node.set_execution_environment <+ self.model.frp.set_execution_environment;
node.set_execution_environment <+ self.model.frp.execution_environment;
}


Expand Down

0 comments on commit c87ab85

Please sign in to comment.