feat: add Ellipsize to widgets
This commit is contained in:
parent
f2ef716ad5
commit
cc670e1966
18 changed files with 181 additions and 9 deletions
|
|
@ -4,7 +4,8 @@ use crate::core::mouse;
|
|||
use crate::core::renderer;
|
||||
use crate::core::text::{Paragraph, Span};
|
||||
use crate::core::widget::text::{
|
||||
self, Alignment, Catalog, LineHeight, Shaping, Style, StyleFn, Wrapping,
|
||||
self, Alignment, Catalog, Ellipsize, LineHeight, Shaping, Style, StyleFn,
|
||||
Wrapping,
|
||||
};
|
||||
use crate::core::widget::tree::{self, Tree};
|
||||
use crate::core::{
|
||||
|
|
@ -33,6 +34,7 @@ pub struct Rich<
|
|||
align_x: Alignment,
|
||||
align_y: alignment::Vertical,
|
||||
wrapping: Wrapping,
|
||||
ellipsize: Ellipsize,
|
||||
class: Theme::Class<'a>,
|
||||
hovered_link: Option<usize>,
|
||||
on_link_click: Option<Box<dyn Fn(Link) -> Message + 'a>>,
|
||||
|
|
@ -58,6 +60,7 @@ where
|
|||
align_x: Alignment::Default,
|
||||
align_y: alignment::Vertical::Top,
|
||||
wrapping: Wrapping::default(),
|
||||
ellipsize: Ellipsize::default(),
|
||||
class: Theme::default(),
|
||||
hovered_link: None,
|
||||
on_link_click: None,
|
||||
|
|
@ -145,6 +148,12 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the [`Ellipsize`] strategy of the [`Rich`] text.
|
||||
pub fn ellipsize(mut self, ellipsize: Ellipsize) -> Self {
|
||||
self.ellipsize = ellipsize;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the default style of the [`Rich`] text.
|
||||
#[must_use]
|
||||
pub fn style(mut self, style: impl Fn(&Theme) -> Style + 'a) -> Self
|
||||
|
|
@ -247,6 +256,7 @@ where
|
|||
self.align_x,
|
||||
self.align_y,
|
||||
self.wrapping,
|
||||
self.ellipsize,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -476,6 +486,7 @@ fn layout<Link, Renderer>(
|
|||
align_x: Alignment,
|
||||
align_y: alignment::Vertical,
|
||||
wrapping: Wrapping,
|
||||
ellipsize: Ellipsize,
|
||||
) -> layout::Node
|
||||
where
|
||||
Link: Clone,
|
||||
|
|
@ -497,6 +508,7 @@ where
|
|||
align_y,
|
||||
shaping: Shaping::Advanced,
|
||||
wrapping,
|
||||
ellipsize,
|
||||
};
|
||||
|
||||
if state.spans != spans {
|
||||
|
|
@ -514,6 +526,7 @@ where
|
|||
align_y,
|
||||
shaping: Shaping::Advanced,
|
||||
wrapping,
|
||||
ellipsize,
|
||||
}) {
|
||||
core::text::Difference::None => {}
|
||||
core::text::Difference::Bounds => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue