ferroui_diagnostics/diagnostics/
hot_key_configuration.rs1use ferroui_base::input::{Key, KeyGesture, KeyModifiers};
4use std::cell::Cell;
5use std::rc::Rc;
6
7#[derive(Debug)]
12pub struct HotKeyConfiguration {
13 value_frames_freeze: Cell<KeyGesture>,
14 value_frames_unfreeze: Cell<KeyGesture>,
15 inspect_hovered_control: Cell<KeyGesture>,
16 toggle_popup_freeze: Cell<KeyGesture>,
17 screenshot_selected_control: Cell<KeyGesture>,
18}
19
20impl PartialEq for HotKeyConfiguration {
21 fn eq(&self, other: &Self) -> bool {
22 std::ptr::eq(self, other)
23 }
24}
25
26impl Default for HotKeyConfiguration {
27 fn default() -> Self {
28 Self {
29 value_frames_freeze: Cell::new(KeyGesture::new(Key::S, KeyModifiers::ALT)),
30 value_frames_unfreeze: Cell::new(KeyGesture::new(Key::D, KeyModifiers::ALT)),
31 inspect_hovered_control: Cell::new(KeyGesture::new(
32 Key::None,
33 KeyModifiers::SHIFT.union(KeyModifiers::CONTROL),
34 )),
35 toggle_popup_freeze: Cell::new(KeyGesture::new(Key::F, KeyModifiers::ALT.union(KeyModifiers::CONTROL))),
36 screenshot_selected_control: Cell::new(KeyGesture::from_key(Key::F8)),
37 }
38 }
39}
40
41impl HotKeyConfiguration {
42 pub fn new() -> Rc<Self> {
44 Rc::new(Self::default())
45 }
46
47 pub fn value_frames_freeze(&self) -> KeyGesture {
49 self.value_frames_freeze.get()
50 }
51
52 pub fn with_value_frames_freeze(self: Rc<Self>, value: KeyGesture) -> Rc<Self> {
54 self.value_frames_freeze.set(value);
55 self
56 }
57
58 pub fn value_frames_unfreeze(&self) -> KeyGesture {
60 self.value_frames_unfreeze.get()
61 }
62
63 pub fn with_value_frames_unfreeze(self: Rc<Self>, value: KeyGesture) -> Rc<Self> {
65 self.value_frames_unfreeze.set(value);
66 self
67 }
68
69 pub fn inspect_hovered_control(&self) -> KeyGesture {
71 self.inspect_hovered_control.get()
72 }
73
74 pub fn with_inspect_hovered_control(self: Rc<Self>, value: KeyGesture) -> Rc<Self> {
76 self.inspect_hovered_control.set(value);
77 self
78 }
79
80 pub fn toggle_popup_freeze(&self) -> KeyGesture {
82 self.toggle_popup_freeze.get()
83 }
84
85 pub fn with_toggle_popup_freeze(self: Rc<Self>, value: KeyGesture) -> Rc<Self> {
87 self.toggle_popup_freeze.set(value);
88 self
89 }
90
91 pub fn screenshot_selected_control(&self) -> KeyGesture {
93 self.screenshot_selected_control.get()
94 }
95
96 pub fn with_screenshot_selected_control(self: Rc<Self>, value: KeyGesture) -> Rc<Self> {
98 self.screenshot_selected_control.set(value);
99 self
100 }
101}