From fd0ce5fb65297ae33391b8cf945ef09f09bc5923 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:41:54 +0900 Subject: [PATCH] Add `TextWrapMode` in `Style ui` (#4994) Add `TextWrapMode` in `Style ui` I think this would be useful for debugging. --- crates/egui/src/style.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 2ed9f03f7c9..a610820e99a 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -8,7 +8,7 @@ use epaint::{Rounding, Shadow, Stroke}; use crate::{ ecolor::*, emath::*, ComboBox, CursorIcon, FontFamily, FontId, Grid, Margin, Response, - RichText, WidgetText, + RichText, TextWrapMode, WidgetText, }; /// How to format numbers in e.g. a [`crate::DragValue`]. @@ -1501,7 +1501,7 @@ impl Style { drag_value_text_style, number_formatter: _, // can't change callbacks in the UI wrap: _, - wrap_mode: _, + wrap_mode, spacing, interaction, visuals, @@ -1561,6 +1561,23 @@ impl Style { }); ui.end_row(); + ui.label("Text Wrap Mode"); + crate::ComboBox::from_id_source("text_wrap_mode") + .selected_text(format!("{wrap_mode:?}")) + .show_ui(ui, |ui| { + let all_wrap_mode: Vec> = vec![ + None, + Some(TextWrapMode::Extend), + Some(TextWrapMode::Wrap), + Some(TextWrapMode::Truncate), + ]; + for style in all_wrap_mode { + let text = crate::RichText::new(format!("{style:?}")); + ui.selectable_value(wrap_mode, style, text); + } + }); + ui.end_row(); + ui.label("Animation duration"); ui.add( DragValue::new(animation_time)