summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'schist_desktop_gui/src/gui')
-rw-r--r--schist_desktop_gui/src/gui/components/text.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs
index 1760f4c..0cf9698 100644
--- a/schist_desktop_gui/src/gui/components/text.rs
+++ b/schist_desktop_gui/src/gui/components/text.rs
@@ -1,6 +1,6 @@
use std::borrow::Borrow;
-use iced::widget::container;
+use iced::{font, widget::container, Font};
use crate::{impl_focusable, style::*};
@@ -9,6 +9,7 @@ pub struct Text {
pub content: String,
align: Alignment,
colour: Option<Colour>,
+ font_style: font::Style,
overflow_strategy: OverflowStrategy,
size: Option<Size>,
strength: Option<Strength>,
@@ -54,6 +55,7 @@ impl Text {
align: Alignment::Left,
content: String::from(content),
colour: Some(Colour::Primary),
+ font_style: font::Style::Normal,
overflow_strategy: OverflowStrategy::Grow,
size: Some(Size::Base),
strength: Some(Strength::Base),
@@ -67,6 +69,7 @@ impl Text {
align: Alignment::Left,
content: String::from(content),
colour: None,
+ font_style: font::Style::Normal,
overflow_strategy: OverflowStrategy::Grow,
size: None,
strength: None,
@@ -150,6 +153,13 @@ impl Text {
..self.clone()
}
}
+
+ pub fn italic(&self) -> Self {
+ Self {
+ font_style: font::Style::Italic,
+ ..self.clone()
+ }
+ }
}
impl<'a, Message> From<Text> for iced::Element<'a, Message>
@@ -178,6 +188,10 @@ where
let overflow_strategy = &text.borrow().overflow_strategy.clone();
let text_elem: iced::widget::Text = iced::widget::text(text.borrow().content.clone())
+ .font(Font {
+ style: text.borrow().font_style,
+ ..Default::default()
+ })
.size(match text.borrow().size {
Some(Size::VSmall) => u32::from(TEXT_SIZE_V_SM),
Some(Size::Small) => u32::from(TEXT_SIZE_SM),