From c15ec79462549768d039a3334a199adf1f18859d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 19 May 2022 13:18:41 +0100 Subject: [PATCH] TextOptions: break out y_adjust Signed-off-by: Ian Jackson --- src/dice.rs | 2 +- src/ui.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dice.rs b/src/dice.rs index 79833f6f..22682941 100644 --- a/src/dice.rs +++ b/src/dice.rs @@ -512,7 +512,7 @@ impl InertPieceTrait for Die { let tc = OverlayTemplateContext { label_text: label, label_options: &self.text_options, - label_y_adjust: self.text_options.size * SVG_FONT_Y_ADJUST_OF_FONT_SIZE, + label_y_adjust: self.text_options.y_adjust(), cooldown_active, radius: self.cooldown_radius, diff --git a/src/ui.rs b/src/ui.rs index e31cc484..1275c84b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -135,12 +135,15 @@ impl Display for AbbrevPresentationLayout { } impl TextOptions { + pub fn y_adjust(&self) -> f64 { + self.size * SVG_FONT_Y_ADJUST_OF_FONT_SIZE + } + pub fn start_element(&self) -> Html { - let y_adj = self.size * SVG_FONT_Y_ADJUST_OF_FONT_SIZE; hformat!{ r##"{} text-align="center" text-anchor="middle" x="0" y="{}" fill="{}" font-size="{}px""##, HTML_TEXT_LABEL_ELEM_START, - y_adj, &self.colour, self.size, + self.y_adjust(), &self.colour, self.size, } } } -- 2.30.2