diff --git a/app/gui/docs/product/shortcuts.md b/app/gui/docs/product/shortcuts.md
index bf2a77c009e5..1d7a7edd64e4 100644
--- a/app/gui/docs/product/shortcuts.md
+++ b/app/gui/docs/product/shortcuts.md
@@ -123,7 +123,7 @@ broken and require further investigation.
#### Debug
| Shortcut | Action |
-| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
+| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------- |
| ctrl + shift + d | Toggle Debug Mode. All actions below are only possible when it is activated. |
| ctrl + alt + shift + i | Open the developer console. |
| ctrl + alt + shift + r | Reload the visual interface. |
@@ -134,3 +134,4 @@ broken and require further investigation.
| ctrl + shift + enter | Push a hardcoded breadcrumb without navigating. |
| ctrl + shift + arrow up | Pop a breadcrumb without navigating. |
| cmd + i | Reload visualizations. To see the effect in the currently shown visualizations, you need to switch to another and switch back. |
+| ctrl + shift + b | | Toggle read-only mode. |
diff --git a/app/gui/src/presenter/project.rs b/app/gui/src/presenter/project.rs
index e45ad2dd4397..b9490454c7a4 100644
--- a/app/gui/src/presenter/project.rs
+++ b/app/gui/src/presenter/project.rs
@@ -199,10 +199,13 @@ impl Model {
self.ide_controller.set_component_browser_private_entries_visibility(!visibility);
}
- fn toggle_read_only(&self) {
- let read_only = self.controller.model.read_only();
- self.controller.model.set_read_only(!read_only);
- info!("New read only state: {}.", self.controller.model.read_only());
+ /// Toggle the read-only mode, return the new state.
+ fn toggle_read_only(&self) -> bool {
+ let current_state = self.controller.model.read_only();
+ let new_state = !current_state;
+ self.controller.model.set_read_only(new_state);
+ info!("New read only state: {}.", new_state);
+ new_state
}
fn restore_project_snapshot(&self) {
@@ -381,7 +384,7 @@ impl Project {
eval_ view.execution_context_restart(model.execution_context_restart());
- eval_ view.toggle_read_only(model.toggle_read_only());
+ view.set_read_only <+ view.toggle_read_only.map(f_!(model.toggle_read_only()));
}
let graph_controller = self.model.graph_controller.clone_ref();
diff --git a/app/gui/view/graph-editor/src/component/breadcrumbs.rs b/app/gui/view/graph-editor/src/component/breadcrumbs.rs
index dacbd089e094..83f3aac288af 100644
--- a/app/gui/view/graph-editor/src/component/breadcrumbs.rs
+++ b/app/gui/view/graph-editor/src/component/breadcrumbs.rs
@@ -105,6 +105,8 @@ ensogl::define_endpoints! {
gap_width (f32),
/// Set whether the project was changed since the last snapshot save.
set_project_changed(bool),
+ /// Set read-only mode for this component.
+ set_read_only(bool),
}
Output {
/// Signalizes when a new breadcrumb is pushed.
@@ -124,6 +126,8 @@ ensogl::define_endpoints! {
project_name_hovered (bool),
/// Indicates whether the project name was clicked.
project_mouse_down (),
+ /// Indicates if the read-only mode is enabled.
+ read_only(bool),
}
}
@@ -521,6 +525,11 @@ impl Breadcrumbs {
frp.source.pointer_style <+ model.project_name.frp.output.pointer_style;
+
+ // === Read-only mode ===
+
+ frp.source.read_only <+ frp.input.set_read_only;
+ model.project_name.set_read_only <+ frp.input.set_read_only;
}
Self { model, frp }
diff --git a/app/gui/view/graph-editor/src/component/breadcrumbs/project_name.rs b/app/gui/view/graph-editor/src/component/breadcrumbs/project_name.rs
index fdfc35ab2fa3..2f5e39beb61f 100644
--- a/app/gui/view/graph-editor/src/component/breadcrumbs/project_name.rs
+++ b/app/gui/view/graph-editor/src/component/breadcrumbs/project_name.rs
@@ -78,6 +78,8 @@ ensogl::define_endpoints_2! {
ide_text_edit_mode (bool),
/// Set whether the project was changed since the last snapshot save.
set_project_changed(bool),
+ /// Set the read-only mode for this component.
+ set_read_only(bool),
}
Output {
@@ -88,6 +90,7 @@ ensogl::define_endpoints_2! {
edit_mode (bool),
selected (bool),
is_hovered (bool),
+ read_only (bool),
}
}
@@ -265,6 +268,10 @@ impl ProjectName {
let input = &frp.private.input;
let output = &frp.private.output;
frp::extend! { network
+ // === Read-only mode ===
+
+ output.read_only <+ input.set_read_only;
+
// === Mouse IO ===
@@ -402,9 +409,9 @@ impl View for ProjectName {
fn default_shortcuts() -> Vec {
use shortcut::ActionType::*;
[
- (Press, "", "enter", "commit"),
+ (Press, "!read_only", "enter", "commit"),
(Release, "", "escape", "cancel_editing"),
- (DoublePress, "is_hovered", "left-mouse-button", "start_editing"),
+ (DoublePress, "is_hovered & !read_only", "left-mouse-button", "start_editing"),
]
.iter()
.map(|(a, b, c, d)| Self::self_shortcut_when(*a, *c, *d, *b))
diff --git a/app/gui/view/graph-editor/src/component/node.rs b/app/gui/view/graph-editor/src/component/node.rs
index 9aacd9f7aac6..a1e096ff3ebb 100644
--- a/app/gui/view/graph-editor/src/component/node.rs
+++ b/app/gui/view/graph-editor/src/component/node.rs
@@ -332,6 +332,7 @@ ensogl::define_endpoints_2! {
/// Indicate whether on hover the quick action icons should appear.
show_quick_action_bar_on_hover (bool),
set_execution_environment (ExecutionEnvironment),
+ set_read_only (bool),
}
Output {
/// Press event. Emitted when user clicks on non-active part of the node, like its
@@ -827,6 +828,12 @@ impl Node {
model.vcs_indicator.set_visibility <+ input.set_view_mode.map(|&mode| {
!matches!(mode,view::Mode::Profiling {..})
});
+
+
+ // === Read-only mode ===
+
+ action_bar.set_read_only <+ input.set_read_only;
+ model.input.set_read_only <+ input.set_read_only;
}
diff --git a/app/gui/view/graph-editor/src/component/node/action_bar.rs b/app/gui/view/graph-editor/src/component/node/action_bar.rs
index 43dafc537866..b0ac9343b380 100644
--- a/app/gui/view/graph-editor/src/component/node/action_bar.rs
+++ b/app/gui/view/graph-editor/src/component/node/action_bar.rs
@@ -79,6 +79,8 @@ ensogl::define_endpoints! {
set_action_context_switch_state (Option),
show_on_hover (bool),
set_execution_environment (ExecutionEnvironment),
+ /// Set the read-only mode for the buttons.
+ set_read_only (bool),
}
Output {
@@ -129,6 +131,12 @@ impl Icons {
self.skip.frp.set_visibility(visible);
}
+ fn set_read_only(&self, read_only: bool) {
+ self.context_switch.set_read_only(read_only);
+ self.freeze.frp.set_read_only(read_only);
+ self.skip.frp.set_read_only(read_only);
+ }
+
fn set_color_scheme(&self, color_scheme: &toggle_button::ColorScheme) {
self.visibility.frp.set_color_scheme(color_scheme);
self.context_switch.set_color_scheme(color_scheme);
@@ -207,6 +215,11 @@ impl ContextSwitchButton {
self.enable_button.set_visibility(visible);
}
+ fn set_read_only(&self, read_only: bool) {
+ self.disable_button.set_read_only(read_only);
+ self.enable_button.set_read_only(read_only);
+ }
+
fn set_color_scheme(&self, color_scheme: &toggle_button::ColorScheme) {
self.disable_button.set_color_scheme(color_scheme);
self.enable_button.set_color_scheme(color_scheme);
@@ -375,6 +388,10 @@ impl ActionBar {
let model = &self.model;
frp::extend! { network
+ // === Read-only mode ===
+
+ eval frp.set_read_only((read_only) model.icons.set_read_only(*read_only));
+
// === Input Processing ===
diff --git a/app/gui/view/graph-editor/src/component/node/input/area.rs b/app/gui/view/graph-editor/src/component/node/input/area.rs
index af7d93195eab..57116779425f 100644
--- a/app/gui/view/graph-editor/src/component/node/input/area.rs
+++ b/app/gui/view/graph-editor/src/component/node/input/area.rs
@@ -597,6 +597,7 @@ impl Model {
}));
area_frp.source.on_port_code_update <+ code_update;
area_frp.source.request_import <+ widget.request_import;
+ widget.set_read_only <+ area_frp.set_read_only;
}
}
@@ -936,6 +937,8 @@ ensogl::define_endpoints! {
set_view_mode (view::Mode),
set_profiling_status (profiling::Status),
+ /// Set read-only mode for input ports.
+ set_read_only (bool),
}
Output {
diff --git a/app/gui/view/graph-editor/src/component/node/input/widget.rs b/app/gui/view/graph-editor/src/component/node/input/widget.rs
index 360897849606..ee9fadb63e1d 100644
--- a/app/gui/view/graph-editor/src/component/node/input/widget.rs
+++ b/app/gui/view/graph-editor/src/component/node/input/widget.rs
@@ -42,6 +42,7 @@ ensogl::define_endpoints_2! {
set_current_value (Option),
set_focused (bool),
set_visible (bool),
+ set_read_only (bool),
}
Output {
value_changed(Option),
@@ -148,6 +149,7 @@ pub struct SampledFrp {
set_focused: frp::Sampler,
out_value_changed: frp::Any