feat: ellipsize text (#1132)

This commit is contained in:
Hojjat Abdollahi 2026-02-19 10:06:45 -07:00 committed by GitHub
parent 1f6086e5ea
commit b9bd773940
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 20 additions and 2 deletions

2
iced

@ -1 +1 @@
Subproject commit ecc29a83982839f628e2ed1c01605c694a1fd3ac
Subproject commit d36e4df47f2e277fafcd3505229d53438c7f128d

View file

@ -682,6 +682,7 @@ where
vertical_alignment: alignment::Vertical::Center,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
},
bounds.position(),
color,

View file

@ -594,6 +594,7 @@ where
vertical_alignment: alignment::Vertical::Center,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
},
bounds.position(),
color,
@ -643,6 +644,7 @@ where
vertical_alignment: alignment::Vertical::Center,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
},
bounds.position(),
appearance.description_color,

View file

@ -279,6 +279,7 @@ pub fn layout(
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
});
paragraph.min_width().round()
};
@ -423,6 +424,7 @@ pub fn overlay<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
});
paragraph.min_width().round()
};
@ -555,6 +557,7 @@ pub fn draw<'a, S, Item: Clone + PartialEq + 'static>(
vertical_alignment: alignment::Vertical::Center,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
},
bounds.position(),
style.text_color,

View file

@ -212,6 +212,7 @@ where
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
});
}
@ -478,6 +479,7 @@ pub fn layout(
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
};
let paragraph = match paragraph {
Some(p) => {
@ -934,6 +936,7 @@ pub fn draw<'a, S>(
vertical_alignment: alignment::Vertical::Center,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
},
bounds.position(),
style.text_color,

View file

@ -23,7 +23,7 @@ use iced::{
event, keyboard, mouse, touch, window,
};
use iced_core::mouse::ScrollDelta;
use iced_core::text::{LineHeight, Renderer as TextRenderer, Shaping, Wrapping};
use iced_core::text::{Ellipsize, LineHeight, Renderer as TextRenderer, Shaping, Wrapping};
use iced_core::widget::operation::Focusable;
use iced_core::widget::{self, operation, tree};
use iced_core::{Border, Point, Renderer as IcedRenderer, Shadow, Text};
@ -274,6 +274,7 @@ where
vertical_alignment: alignment::Vertical::Center,
shaping: Shaping::Advanced,
wrapping: Wrapping::None,
ellipsize: Ellipsize::None,
line_height: self.line_height,
};
@ -602,6 +603,7 @@ where
vertical_alignment: alignment::Vertical::Center,
shaping: Shaping::Advanced,
wrapping: Wrapping::default(),
ellipsize: Ellipsize::default(),
line_height: self.line_height,
})
});

View file

@ -728,6 +728,7 @@ where
line_height: text::LineHeight::default(),
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::None,
ellipsize: text::Ellipsize::None,
});
let Size { width, height } =
@ -1160,6 +1161,7 @@ pub fn layout<Message>(
line_height,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::None,
ellipsize: text::Ellipsize::None,
});
let label_size = label_paragraph.min_bounds();
@ -1297,6 +1299,7 @@ pub fn layout<Message>(
line_height: helper_text_line_height,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::None,
ellipsize: text::Ellipsize::None,
});
let helper_text_size = helper_text_paragraph.min_bounds();
let helper_text_node = layout::Node::new(helper_text_size).translate(helper_pos);
@ -2260,6 +2263,7 @@ pub fn draw<'a, Message>(
line_height,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::None,
ellipsize: text::Ellipsize::None,
},
label_layout.bounds().position(),
appearance.label_color,
@ -2449,6 +2453,7 @@ pub fn draw<'a, Message>(
line_height: text::LineHeight::default(),
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::None,
ellipsize: text::Ellipsize::None,
},
bounds.position(),
color,
@ -2497,6 +2502,7 @@ pub fn draw<'a, Message>(
line_height: helper_line_height,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::None,
ellipsize: text::Ellipsize::None,
},
helper_text_layout.bounds().position(),
text_color,
@ -2877,6 +2883,7 @@ fn replace_paragraph(
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::None,
ellipsize: text::Ellipsize::None,
});
}