ps-blitz-traits 0.3.0-beta.4

Shared traits and types for Blitz
Documentation
//! Types configure developer inspection and debug tools

use crate::node_id::NodeId;

/// Configuration for debug overlays and other debugging tools
#[derive(Debug, Default, Clone, Copy)]
pub struct DevtoolSettings {
    /// Outline elements with different border colors depending on
    /// inner display style of that element
    pub show_layout: bool,
    /// Render browser-style colored overlay showing the content-box,
    /// padding, border, and margin of the hovered element
    pub highlight_hover: bool,
    /// Render browser-style colored overlay showing the content-box,
    /// padding, border, and margin of a specific node (set by e.g. a
    /// remote devtools inspector)
    pub highlight_node: Option<NodeId>,
    /// Element picker mode: mouse events are intercepted (not delivered to
    /// the page) and reported to a remote devtools inspector so the user
    /// can pick an element by hovering/clicking it
    pub element_picker: bool,
}

impl DevtoolSettings {
    /// Toggle the [`show_layout`](Self::show_layout) setting
    pub fn toggle_show_layout(&mut self) {
        self.show_layout = !self.show_layout
    }

    /// Toggle the [`highlight_hover`](Self::highlight_hover) setting
    pub fn toggle_highlight_hover(&mut self) {
        self.highlight_hover = !self.highlight_hover
    }
}