Skip to content

Commit

Permalink
Add TextWrapMode in Style ui (#4994)
Browse files Browse the repository at this point in the history
Add `TextWrapMode` in `Style ui`

I think this would be useful for debugging.
  • Loading branch information
rustbasic authored Aug 26, 2024
1 parent 0c528fb commit fd0ce5f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions crates/egui/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<Option<TextWrapMode>> = 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)
Expand Down

0 comments on commit fd0ce5f

Please sign in to comment.