Fix the issue where large sections of label do not wrap (#118)
This commit is contained in:
parent
340c5fef3d
commit
e07f551317
2 changed files with 8 additions and 4 deletions
|
|
@ -66,14 +66,12 @@ impl Render for TextStory {
|
||||||
.child(
|
.child(
|
||||||
Label::new("Font Size Label")
|
Label::new("Font Size Label")
|
||||||
.text_size(px(20.))
|
.text_size(px(20.))
|
||||||
.text_left()
|
|
||||||
.font_semibold()
|
.font_semibold()
|
||||||
.line_height(rems(1.8)),
|
.line_height(rems(1.8)),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
div().w(px(200.)).child(
|
div().w(px(200.)).child(
|
||||||
Label::new("Label should support text wrap in default, if the text is too long, it should wrap to the next line.")
|
Label::new("Label should support text wrap in default, if the text is too long, it should wrap to the next line.")
|
||||||
.text_left()
|
|
||||||
.line_height(rems(1.8)),
|
.line_height(rems(1.8)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use gpui::{
|
||||||
|
|
||||||
use crate::{h_flex, theme::ActiveTheme};
|
use crate::{h_flex, theme::ActiveTheme};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, PartialEq, Eq)]
|
||||||
pub enum TextAlign {
|
pub enum TextAlign {
|
||||||
#[default]
|
#[default]
|
||||||
Left,
|
Left,
|
||||||
|
|
@ -93,7 +93,13 @@ impl RenderOnce for Label {
|
||||||
TextAlign::Center => this.justify_center(),
|
TextAlign::Center => this.justify_center(),
|
||||||
TextAlign::Right => this.justify_end(),
|
TextAlign::Right => this.justify_end(),
|
||||||
})
|
})
|
||||||
.child(text_display),
|
.map(|this| {
|
||||||
|
if self.align == TextAlign::Left {
|
||||||
|
this.child(div().size_full().child(text_display))
|
||||||
|
} else {
|
||||||
|
this.child(text_display)
|
||||||
|
}
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue