Skip to main content

ass_editor/core/builders/
style.rs

1//! Style builder type and constructors.
2
3#[cfg(not(feature = "std"))]
4use alloc::string::{String, ToString};
5
6/// Builder for creating ASS styles with fluent API
7#[derive(Debug, Default, Clone)]
8pub struct StyleBuilder {
9    pub(super) name: Option<String>,
10    pub(super) fontname: Option<String>,
11    pub(super) fontsize: Option<u32>,
12    pub(super) primary_colour: Option<String>,
13    pub(super) secondary_colour: Option<String>,
14    pub(super) outline_colour: Option<String>,
15    pub(super) back_colour: Option<String>,
16    pub(super) bold: Option<bool>,
17    pub(super) italic: Option<bool>,
18    pub(super) underline: Option<bool>,
19    pub(super) strikeout: Option<bool>,
20    pub(super) scale_x: Option<f32>,
21    pub(super) scale_y: Option<f32>,
22    pub(super) spacing: Option<f32>,
23    pub(super) angle: Option<f32>,
24    pub(super) border_style: Option<u32>,
25    pub(super) outline: Option<f32>,
26    pub(super) shadow: Option<f32>,
27    pub(super) alignment: Option<u32>,
28    pub(super) margin_l: Option<u32>,
29    pub(super) margin_r: Option<u32>,
30    pub(super) margin_v: Option<u32>,
31    pub(super) margin_t: Option<u32>,
32    pub(super) margin_b: Option<u32>,
33    pub(super) encoding: Option<u32>,
34    pub(super) alpha_level: Option<u32>,
35    pub(super) relative_to: Option<String>,
36}
37
38impl StyleBuilder {
39    /// Create a new style builder
40    pub fn new() -> Self {
41        Self::default()
42    }
43
44    /// Create a style builder with default values
45    pub fn default_style() -> Self {
46        Self {
47            fontname: Some("Arial".to_string()),
48            fontsize: Some(20),
49            primary_colour: Some("&Hffffff".to_string()),
50            secondary_colour: Some("&Hff0000".to_string()),
51            outline_colour: Some("&H0".to_string()),
52            back_colour: Some("&H0".to_string()),
53            bold: Some(false),
54            italic: Some(false),
55            underline: Some(false),
56            strikeout: Some(false),
57            scale_x: Some(100.0),
58            scale_y: Some(100.0),
59            spacing: Some(0.0),
60            angle: Some(0.0),
61            border_style: Some(1),
62            outline: Some(2.0),
63            shadow: Some(0.0),
64            alignment: Some(2),
65            margin_l: Some(10),
66            margin_r: Some(10),
67            margin_v: Some(10),
68            encoding: Some(1),
69            ..Self::default()
70        }
71    }
72}