blitz_traits/devtools.rs
1//! Types configure developer inspection and debug tools
2
3use crate::node_id::NodeId;
4
5/// Configuration for debug overlays and other debugging tools
6#[derive(Debug, Default, Clone, Copy)]
7pub struct DevtoolSettings {
8 /// Outline elements with different border colors depending on
9 /// inner display style of that element
10 pub show_layout: bool,
11 /// Render browser-style colored overlay showing the content-box,
12 /// padding, border, and margin of the hovered element
13 pub highlight_hover: bool,
14 /// Render browser-style colored overlay showing the content-box,
15 /// padding, border, and margin of a specific node (set by e.g. a
16 /// remote devtools inspector)
17 pub highlight_node: Option<NodeId>,
18 /// Element picker mode: mouse events are intercepted (not delivered to
19 /// the page) and reported to a remote devtools inspector so the user
20 /// can pick an element by hovering/clicking it
21 pub element_picker: bool,
22}
23
24impl DevtoolSettings {
25 /// Toggle the [`show_layout`](Self::show_layout) setting
26 pub fn toggle_show_layout(&mut self) {
27 self.show_layout = !self.show_layout
28 }
29
30 /// Toggle the [`highlight_hover`](Self::highlight_hover) setting
31 pub fn toggle_highlight_hover(&mut self) {
32 self.highlight_hover = !self.highlight_hover
33 }
34}