openpine_vm/visuals/box.rs
1use serde::{Deserialize, Serialize};
2
3use crate::visuals::{
4 Color, Extend, FontFamily, HorizontalAlign, LineStyle, TextFormatting, TextWrap, VerticalAlign,
5 XLocation,
6};
7
8/// A rectangular box annotation with optional text.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct Box {
11 /// Left x-coordinate (interpretation depends on [`Self::xloc`]).
12 pub left: i64,
13 /// Top y-coordinate.
14 pub top: f64,
15 /// Right x-coordinate (interpretation depends on [`Self::xloc`]).
16 pub right: i64,
17 /// Bottom y-coordinate.
18 pub bottom: f64,
19 /// Box border color.
20 pub border_color: Option<Color>,
21 /// Box border width in pixels.
22 pub border_width: i32,
23 /// Box border style.
24 pub border_style: LineStyle,
25 /// Extension mode for the box edges.
26 pub extend: Extend,
27 /// X-axis coordinate system used by [`Self::left`] and [`Self::right`].
28 pub xloc: XLocation,
29 /// Box background fill color.
30 pub background_color: Option<Color>,
31 /// Text displayed inside the box.
32 pub text: String,
33 /// Text size in points.
34 pub text_size: u32,
35 /// Text color.
36 pub text_color: Option<Color>,
37 /// Horizontal alignment for [`Self::text`].
38 pub text_halign: HorizontalAlign,
39 /// Vertical alignment for [`Self::text`].
40 pub text_valign: VerticalAlign,
41 /// Wrapping behavior for [`Self::text`].
42 pub text_wrap: TextWrap,
43 /// Font family used to render [`Self::text`].
44 pub text_font_family: FontFamily,
45 /// Whether to force drawing on the chart overlay.
46 pub force_overlay: bool,
47 /// Text formatting (e.g. bold/italic).
48 pub text_formatting: TextFormatting,
49}