//! How nodes and lines are drawn: borders, line kinds, arrowheads, colors. //! //! Each field of [`NodeLook`] and [`LineLook`] is an override, and `None` //! means "whatever the theme says". The theme works a look out in layers: its //! default, then a style set by one of the node's tags, then a named style, //! then these fields. Each layer only states what it changes. //! //! The plain enums here derive serde, so document files can name them //! directly (`border: Dashed`). use serde::{Deserialize, Serialize}; use super::text::{ColorName, StyleName}; /// The border around a node's box. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Border { Rounded, Square, Double, Thick, Dashed, /// No border: just the text. Hidden, } /// What a line looks like along its length. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Stroke { Solid, Dashed, Dotted, Thick, Double, } /// Which ends of a line have an arrowhead. The end is where a cross-link /// points to; for a branch it's the child. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Arrows { Off, End, Start, Both, } /// The color of a line. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum LineColor { /// A color from the theme's palette. Named(ColorName), /// The color of the node the line comes from: a branch takes its /// parent's (so a node's color flows down the lines to its children, /// mind-map style), a cross-link its start's. FollowNode, } /// How a node is drawn, on top of what the theme says. #[derive(Debug, Clone, Default, PartialEq, Eq, Hash)] pub struct NodeLook { pub color: Option, pub border: Option, /// A named style from the theme, which can set the color and border. pub style: Option, } impl NodeLook { /// True when nothing is overridden: the node looks the way the theme says. pub fn is_default(&self) -> bool { *self == NodeLook::default() } } /// How a line is drawn (a branch or a cross-link), on top of what the theme /// says. #[derive(Debug, Clone, Default, PartialEq, Eq, Hash)] pub struct LineLook { pub arrows: Option, pub line: Option, pub color: Option, /// A named style from the theme, which can set all of the above. pub style: Option, } impl LineLook { /// True when nothing is overridden: the line looks the way the theme says. pub fn is_default(&self) -> bool { *self == LineLook::default() } }