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
use crate::enums::trimming_granularity::TrimmingGranularity;

use checked_enum::UncheckedEnum;
use winapi::um::dwrite::DWRITE_TRIMMING;

#[repr(C)]
#[derive(Copy, Clone)]
/// Specifies the trimming option for text overflowing the layout box.
pub struct Trimming {
    /// Text granularity of which trimming applies.
    pub granularity: UncheckedEnum<TrimmingGranularity>,

    /// Character code used as the delimiter signaling the beginning of the portion of text to be
    /// preserved, most useful for path ellipsis, where the delimiter would be a slash. Leave this
    /// zero if there is no delimiter.
    pub delimiter: u32,
    
    /// How many occurrences of the delimiter to step back. Leave this zero if there is no
    /// delimiter.
    pub delimiter_count: u32,
}

#[cfg(test)]
dcommon::member_compat_test! {
    trimming_compat:
    Trimming <=> DWRITE_TRIMMING {
        granularity <=> granularity,
        delimiter <=> delimiter,
        delimiter_count <=> delimiterCount,
    }
}

impl From<DWRITE_TRIMMING> for Trimming {
    fn from(trim: DWRITE_TRIMMING) -> Trimming {
        unsafe { std::mem::transmute(trim) }
    }
}