pub struct CosmicTextMeasurer { /* private fields */ }Implementations§
Source§impl CosmicTextMeasurer
impl CosmicTextMeasurer
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/showcase.rs (line 928)
923 fn measured_open_window_sizes(&self, desktop_size: UiSize) -> Vec<ShowcaseWindowMeasurement> {
924 let measure_height = desktop_size.height.max(SHOWCASE_ORGANIZE_MEASURE_HEIGHT);
925 let viewport = UiSize::new(desktop_size.width + RIGHT_PANEL_WIDTH, measure_height);
926 let mut document = self.view(viewport);
927 #[cfg(feature = "text-cosmic")]
928 let mut measurer = CosmicTextMeasurer::new();
929 #[cfg(not(feature = "text-cosmic"))]
930 let mut measurer = ApproxTextMeasurer;
931 if document.compute_layout(viewport, &mut measurer).is_err() {
932 return Vec::new();
933 }
934 let options = showcase_desktop_options(desktop_size);
935 SHOWCASE_WIDGET_WINDOW_IDS
936 .into_iter()
937 .filter(|id| self.windows.is_visible(id))
938 .filter_map(|id| {
939 let name = format!("showcase.windows.window.{id}");
940 let collapsed_size = showcase_collapsed_window_size(id, &options);
941 document
942 .nodes()
943 .iter()
944 .find(|node| node.name() == name)
945 .map(|node| {
946 let min_size = node.style().layout_style().min_size();
947 ShowcaseWindowMeasurement {
948 id: id.to_string(),
949 size: UiSize::new(node.layout().rect.width, node.layout().rect.height),
950 min_size: UiSize::new(
951 min_size
952 .and_then(|size| size.width.points_value())
953 .unwrap_or(node.layout().rect.width),
954 min_size
955 .and_then(|size| size.height.points_value())
956 .unwrap_or(node.layout().rect.height),
957 ),
958 collapsed_size,
959 }
960 })
961 })
962 .collect()
963 }Trait Implementations§
Source§impl Default for CosmicTextMeasurer
Available on crate feature text-cosmic only.
impl Default for CosmicTextMeasurer
Available on crate feature
text-cosmic only.Source§impl TextMeasurer for CosmicTextMeasurer
Available on crate feature text-cosmic only.
impl TextMeasurer for CosmicTextMeasurer
Available on crate feature
text-cosmic only.fn measure( &mut self, text: &TextContent, known: KnownSize, available: AvailableSize, ) -> UiSize
Auto Trait Implementations§
impl !Freeze for CosmicTextMeasurer
impl !RefUnwindSafe for CosmicTextMeasurer
impl Send for CosmicTextMeasurer
impl Sync for CosmicTextMeasurer
impl Unpin for CosmicTextMeasurer
impl UnsafeUnpin for CosmicTextMeasurer
impl !UnwindSafe for CosmicTextMeasurer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.