🔧 Add vertical alignment for text shapes

This commit is contained in:
Elena Torro 2025-06-23 16:01:03 +02:00
parent 0010d61ae2
commit 134fb1ab4c
8 changed files with 2436 additions and 1 deletions

View file

@ -156,6 +156,24 @@ impl ConstraintH {
}
}
#[derive(Debug, Clone, PartialEq, Copy)]
pub enum VerticalAlign {
Top,
Center,
Bottom,
}
impl VerticalAlign {
pub fn from(value: u8) -> Self {
match value {
0 => Self::Top,
1 => Self::Center,
2 => Self::Bottom,
_ => Self::Top,
}
}
}
#[derive(Debug, Clone, PartialEq, Copy)]
pub enum ConstraintV {
Top,
@ -195,6 +213,7 @@ pub struct Shape {
pub fills: Vec<Fill>,
pub strokes: Vec<Stroke>,
pub blend_mode: BlendMode,
pub vertical_align: VerticalAlign,
pub blur: Blur,
pub opacity: f32,
pub hidden: bool,
@ -221,6 +240,7 @@ impl Shape {
fills: Vec::with_capacity(1),
strokes: Vec::with_capacity(1),
blend_mode: BlendMode::default(),
vertical_align: VerticalAlign::Top,
opacity: 1.,
hidden: false,
blur: Blur::default(),
@ -312,6 +332,14 @@ impl Shape {
self.opacity = opacity;
}
pub fn set_vertical_align(&mut self, align: VerticalAlign) {
self.vertical_align = align;
}
pub fn vertical_align(&self) -> VerticalAlign {
self.vertical_align
}
pub fn set_constraint_h(&mut self, constraint: Option<ConstraintH>) {
self.constraint_h = constraint;
}