mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 00:12:57 +00:00
Merge branch 'fx/tabs' into fx/all-1117
# Conflicts: # crates/ui-widgets/src/tabs/tab.rs
This commit is contained in:
@@ -21,6 +21,9 @@ pub enum Wrap {
|
||||
Line,
|
||||
/// Wraps at the room's width.
|
||||
Wrap,
|
||||
/// One line, cut at the room's edge with no ellipsis, as many characters as fit: tabs that shrink to their first
|
||||
/// letters. The full text is the tooltip and accessible name, as for an elided run.
|
||||
Clip,
|
||||
/// One line, cut with an ellipsis at the end: names, titles, labels beside fixed controls.
|
||||
Elide,
|
||||
/// One line, cut with an ellipsis at the start: anything whose end says the most.
|
||||
@@ -267,14 +270,16 @@ impl TextRun<'_> {
|
||||
|
||||
fn job<'s>(&self, env: &TextEnv<'_>, parts: impl Iterator<Item = (&'s Span<'s>, &'s str)>, max_width: f32) -> LayoutJob {
|
||||
let elide = self.wrap.cuts();
|
||||
let clip = self.wrap == Wrap::Clip;
|
||||
let wrap = TextWrapping {
|
||||
max_width: if self.wrap == Wrap::Line { f32::INFINITY } else { max_width },
|
||||
max_rows: match self.wrap {
|
||||
Wrap::Clamp(lines) => usize::from(lines.max(1)),
|
||||
_ if elide => 1,
|
||||
_ if elide || clip => 1,
|
||||
_ => usize::MAX,
|
||||
},
|
||||
break_anywhere: elide,
|
||||
break_anywhere: elide || clip,
|
||||
overflow_character: if clip { None } else { TextWrapping::default().overflow_character },
|
||||
..TextWrapping::default()
|
||||
};
|
||||
let mut job = paragraph_job(env.direction, self.ltr, wrap);
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::contract::{
|
||||
Styled as _, WordSetCx as _,
|
||||
};
|
||||
use crate::display::Progress;
|
||||
use crate::primitives::{IconSpec, PaintShape, RectSide, StrokeWidth, TextRun};
|
||||
use crate::primitives::{IconSpec, PaintShape, RectSide, StrokeWidth, TextRun, Wrap};
|
||||
use crate::runtime::env::Label;
|
||||
use crate::style::{ComponentStyle, Flags, IconLook, RuleKind, StyleColor, StyleCx, SurfaceLook, TextLook};
|
||||
use craft_behavior::{Flow, IconId, Insets, Metrics, PartKey, PointerButton, PressPhase, Proposal, Sense};
|
||||
@@ -418,13 +418,7 @@ impl Component for Tab<'_> {
|
||||
draw.stroke(&line, StrokeWidth::Thick, style.underline);
|
||||
}
|
||||
let label = self.label_run(style, cx.resolved.label).color(cx.resolve(&style.label.color));
|
||||
if self.kind.clips_label() {
|
||||
draw.clipped(placed.label, |draw| {
|
||||
draw.text(placed.label, &label);
|
||||
});
|
||||
} else {
|
||||
draw.text(placed.label, &label.elide());
|
||||
}
|
||||
draw.text(placed.label, &if self.kind.clips_label() { label.wrap(Wrap::Clip) } else { label.elide() });
|
||||
if let (Some(at), Some(detail)) = (placed.detail, self.detail_text()) {
|
||||
draw.text(at, &TextRun::new(detail).role(style.detail.role).color(cx.resolve(&style.detail.color)).elide());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user