openpine_vm/visuals/hline.rs
1use num_enum::TryFromPrimitive;
2use openpine_compiler::instructions::Color;
3use serde::{Deserialize, Serialize};
4
5use crate::visuals::PlotDisplay;
6
7/// Line style for a horizontal line.
8#[derive(Debug, Copy, Clone, TryFromPrimitive, Serialize, Deserialize)]
9#[repr(i32)]
10pub enum HlineStyle {
11 /// Solid stroke.
12 Solid = 0,
13 /// Dashed stroke.
14 Dashed = 1,
15 /// Dotted stroke.
16 Dotted = 2,
17}
18
19/// A horizontal line visual primitive.
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct Hline {
22 /// Y-axis value.
23 pub value: f64,
24 /// Optional line color.
25 pub color: Option<Color>,
26 /// Optional label.
27 pub title: Option<String>,
28 /// Stroke style.
29 pub line_style: HlineStyle,
30 /// Stroke width.
31 pub line_width: i32,
32 /// Whether the line is user-editable.
33 pub editable: bool,
34 /// Display targets.
35 pub display: PlotDisplay,
36 /// If `true`, draw on the main (price) pane regardless of the script's
37 /// `overlay` setting. Set to `true` when the enclosing `indicator()` has
38 /// `overlay = true` so that the line follows the script into the main pane.
39 pub force_overlay: bool,
40}