use crate::{Axis, Default, Display, Grid, Script};
#[derive(Clone, Copy)]
pub struct Properties {
hidden: bool,
}
impl Default for Properties {
fn default() -> Properties {
Properties { hidden: true }
}
}
impl Properties {
pub fn hide(&mut self) -> &mut Properties {
self.hidden = true;
self
}
pub fn show(&mut self) -> &mut Properties {
self.hidden = false;
self
}
}
impl<'a> Script for (Axis, Grid, &'a Properties) {
fn script(&self) -> String {
let &(axis, grid, properties) = self;
let axis = axis.display();
let grid = grid.display();
if properties.hidden {
String::new()
} else {
format!("set grid {}{}tics\n", grid, axis)
}
}
}