Skip to content
Snippets Groups Projects
Commit 674c0f50 authored by Federico Lolli's avatar Federico Lolli
Browse files

Fixed issue with composition/operation button

The buttons vanishes if the user press on a valve on a valve controller,
now it is fixed
parent 85aace1a
No related branches found
No related tags found
No related merge requests found
...@@ -262,7 +262,7 @@ impl eframe::App for App { ...@@ -262,7 +262,7 @@ impl eframe::App for App {
} }
// Shortcut mode switcher // Shortcut mode switcher
if self.shortcut_handler.lock().log_unwrap().is_active(ShortcutMode::operation())&&ui if self.shortcut_handler.lock().log_unwrap().is_in_operation() && ui
.add( .add(
Button::new("Switch to composition mode") Button::new("Switch to composition mode")
.stroke(Stroke::NONE) .stroke(Stroke::NONE)
...@@ -277,7 +277,7 @@ impl eframe::App for App { ...@@ -277,7 +277,7 @@ impl eframe::App for App {
.lock() .lock()
.log_unwrap().activate_mode(ShortcutMode::composition()); .log_unwrap().activate_mode(ShortcutMode::composition());
} }
if self.shortcut_handler.lock().log_unwrap().is_active(ShortcutMode::composition())&&ui if self.shortcut_handler.lock().log_unwrap().is_in_composition() && ui
.add( .add(
Button::new("Switch to operation mode") Button::new("Switch to operation mode")
.stroke(Stroke::NONE) .stroke(Stroke::NONE)
......
...@@ -83,6 +83,14 @@ impl ShortcutHandler { ...@@ -83,6 +83,14 @@ impl ShortcutHandler {
pub fn is_active(&self, mode: ShortcutMode) -> bool { pub fn is_active(&self, mode: ShortcutMode) -> bool {
self.mode_stack.is_active(mode) self.mode_stack.is_active(mode)
} }
pub fn is_in_composition(&self) -> bool {
self.mode_stack.is_first_layer(FirstLayerModes::Composition)
}
pub fn is_in_operation(&self) -> bool {
self.mode_stack.is_first_layer(FirstLayerModes::Operation)
}
} }
/// Stack layers of keyboard shortcuts. Controls which shortcuts are active at any given time. /// Stack layers of keyboard shortcuts. Controls which shortcuts are active at any given time.
...@@ -104,6 +112,10 @@ impl ShortcutModeStack { ...@@ -104,6 +112,10 @@ impl ShortcutModeStack {
} }
} }
fn is_first_layer(&self, mode: FirstLayerModes) -> bool {
self.first == mode
}
fn activate(&mut self, mode: ShortcutMode) { fn activate(&mut self, mode: ShortcutMode) {
match mode { match mode {
ShortcutMode::FirstLayer(first) => { ShortcutMode::FirstLayer(first) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment