use std::sync::Arc;
use crate::color::Color;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum LabelDisplay {
Always,
#[default]
Hover,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ScenePointPick {
pub scene: String,
pub mark: usize,
pub point: usize,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum LabelPlacement {
Center,
#[default]
Above,
Below,
Left,
Right,
}
#[derive(Clone, Debug, PartialEq)]
pub struct PointLabels {
pub text: Arc<[String]>,
pub display: LabelDisplay,
pub placement: LabelPlacement,
pub color: Option<Color>,
pub size: f32,
}
impl PointLabels {
pub fn new(text: impl IntoIterator<Item = impl Into<String>>) -> Self {
Self {
text: text.into_iter().map(Into::into).collect(),
display: LabelDisplay::default(),
placement: LabelPlacement::default(),
color: None,
size: 11.0,
}
}
pub fn always(mut self) -> Self {
self.display = LabelDisplay::Always;
self
}
pub fn on_hover(mut self) -> Self {
self.display = LabelDisplay::Hover;
self
}
pub fn placement(mut self, placement: LabelPlacement) -> Self {
self.placement = placement;
self
}
pub fn color(mut self, color: Color) -> Self {
self.color = Some(color);
self
}
pub fn size(mut self, size: f32) -> Self {
self.size = size;
self
}
pub fn get(&self, i: usize) -> Option<&str> {
self.text
.get(i)
.map(String::as_str)
.filter(|s| !s.is_empty())
}
}