Skip to content

Commit

Permalink
Add an option to set overflow character to None in text wrapping demo
Browse files Browse the repository at this point in the history
  • Loading branch information
awaken1ng committed Mar 7, 2022
1 parent 1f7bc2a commit a6b4809
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions egui_demo_lib/src/apps/demo/misc_demo_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct MiscDemoWindow {

break_anywhere: bool,
max_rows: usize,
overflow_character: char,
overflow_character: Option<char>,

widgets: Widgets,
colors: ColorWidgets,
Expand All @@ -25,7 +25,7 @@ impl Default for MiscDemoWindow {

max_rows: 2,
break_anywhere: false,
overflow_character: '…',
overflow_character: Some('…'),

widgets: Default::default(),
colors: Default::default(),
Expand Down Expand Up @@ -419,7 +419,7 @@ fn text_layout_ui(
ui: &mut egui::Ui,
max_rows: &mut usize,
break_anywhere: &mut bool,
overflow_character: &mut char,
overflow_character: &mut Option<char>,
) {
use egui::text::LayoutJob;

Expand Down Expand Up @@ -583,17 +583,18 @@ fn text_layout_ui(
});
ui.checkbox(break_anywhere, "Break anywhere");
ui.horizontal(|ui| {
ui.selectable_value(overflow_character, '…', "…");
ui.selectable_value(overflow_character, '—', "—");
ui.selectable_value(overflow_character, '-', " - ");
ui.selectable_value(overflow_character, None, "None");
ui.selectable_value(overflow_character, Some('…'), "…");
ui.selectable_value(overflow_character, Some('—'), "—");
ui.selectable_value(overflow_character, Some('-'), " - ");
ui.label("Overflow character");
});

let mut job = LayoutJob::single_section(LOREM_IPSUM.to_string(), TextFormat::default());
job.wrap = TextWrapping {
max_rows: *max_rows,
break_anywhere: *break_anywhere,
overflow_character: Some(*overflow_character),
overflow_character: *overflow_character,
..Default::default()
};
ui.label(job);
Expand Down

0 comments on commit a6b4809

Please sign in to comment.