feat: ellipsize text (#1132)

This commit is contained in:
Hojjat Abdollahi 2026-02-19 10:06:45 -07:00 • committed by Ashley Wulber
parent 55d6fff12c
commit eb6a263e3f
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
7 changed files with 22 additions and 2 deletions

2
iced

@ -1 +1 @@
Subproject commit c1edb8108430973c6fda79950c611398a990f144
Subproject commit cc670e1966b2b732e732a020e416f6cfae5bafea

View file

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

View file

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

View file

@ -280,6 +280,7 @@ pub fn layout(
align_y: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
});
paragraph.min_width().round()
};
@ -418,6 +419,7 @@ pub fn overlay<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static
align_y: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
});
paragraph.min_width().round()
};
@ -548,6 +550,7 @@ pub fn draw<'a, S, Item: Clone + PartialEq + 'static>(
align_y: 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
align_y: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
});
}
@ -482,6 +483,7 @@ pub fn layout(
align_y: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
};
p.update(text);
p
@ -497,6 +499,7 @@ pub fn layout(
align_y: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::default(),
ellipsize: text::Ellipsize::default(),
};
&mut crate::Plain::new(text)
}
@ -940,6 +943,7 @@ pub fn draw<'a, S>(
align_y: 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::{self, LineHeight, Renderer as TextRenderer, Shaping, Wrapping};
use iced_core::text::{self, 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};
@ -276,6 +276,7 @@ where
shaping: Shaping::Advanced,
wrapping: Wrapping::None,
line_height: self.line_height,
ellipsize: Ellipsize::None,
};
paragraph.update(text);
} else {
@ -289,6 +290,7 @@ where
shaping: Shaping::Advanced,
wrapping: Wrapping::None,
line_height: self.line_height,
ellipsize: Ellipsize::None,
};
state.paragraphs.insert(key, crate::Plain::new(text));
}
@ -620,6 +622,7 @@ where
align_y: 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 } =
@ -1161,6 +1162,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();
@ -1298,6 +1300,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);
@ -2280,6 +2283,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,
@ -2471,6 +2475,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,
@ -2519,6 +2524,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,
@ -2907,6 +2913,7 @@ fn replace_paragraph(
align_y: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
wrapping: text::Wrapping::None,
ellipsize: text::Ellipsize::None,
});
}