1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2025 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0
use std::any::TypeId;
use crate::core::{Property, UpdateCtx};
/// Options for handling lines of text that are too wide for the available space.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LineBreaking {
/// Lines are broken at word boundaries.
WordWrap,
/// Lines are truncated to the width of the label.
Clip,
/// Lines overflow the label.
Overflow,
}
impl Property for LineBreaking {
fn static_default() -> &'static Self {
&Self::Overflow
}
}
impl Default for LineBreaking {
fn default() -> Self {
*Self::static_default()
}
}
impl LineBreaking {
/// Helper function to be called in [`Widget::property_changed`](crate::core::Widget::property_changed).
pub fn prop_changed(ctx: &mut UpdateCtx<'_>, property_type: TypeId) {
if property_type != TypeId::of::<Self>() {
return;
}
ctx.request_layout();
}
}