Skip to content

Commit aaa61b8

Browse files
committed
add break_anywhere param to wrapping
add checkbox for it to demo
1 parent 9f5abd0 commit aaa61b8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

examples/demo/src/apps/wrapping.rs

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ impl WrappingExample {
2020
wrap: JsonTreeWrapping {
2121
max_rows: 1,
2222
max_width: JsonTreeMaxWidth::UiAvailableWidth,
23+
break_anywhere: true,
2324
},
2425
use_maximum_max_rows: false,
2526
}
@@ -59,6 +60,7 @@ impl Show for WrappingExample {
5960
{
6061
self.wrap.max_rows = usize::MAX;
6162
}
63+
ui.add_space(10.0);
6264

6365
ui.label(egui::RichText::new("Max Width:").monospace());
6466
ui.horizontal(|ui| {
@@ -86,6 +88,13 @@ impl Show for WrappingExample {
8688
{
8789
self.wrap.max_width = JsonTreeMaxWidth::UiAvailableWidth;
8890
}
91+
ui.add_space(10.0);
92+
93+
ui.horizontal(|ui| {
94+
ui.label(egui::RichText::new("Break anywhere:").monospace());
95+
ui.checkbox(&mut self.wrap.break_anywhere, "");
96+
});
97+
ui.separator();
8998

9099
JsonTree::new(self.title(), &self.value)
91100
.style(JsonTreeStyle::new().wrap(JsonTreeWrappingParams {

src/style.rs

+3
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl JsonTreeStyle {
9292
egui::text::TextWrapping {
9393
max_width,
9494
max_rows: wrap.max_rows,
95+
break_anywhere: wrap.break_anywhere,
9596
..Default::default()
9697
}
9798
}
@@ -161,6 +162,7 @@ pub struct JsonTreeWrappingParams {
161162
pub struct JsonTreeWrapping {
162163
pub max_rows: usize,
163164
pub max_width: JsonTreeMaxWidth,
165+
pub break_anywhere: bool,
164166
}
165167

166168
impl Default for JsonTreeWrapping {
@@ -170,6 +172,7 @@ impl Default for JsonTreeWrapping {
170172
Self {
171173
max_rows: usize::MAX,
172174
max_width: JsonTreeMaxWidth::UiAvailableWidth,
175+
break_anywhere: false,
173176
}
174177
}
175178
}

0 commit comments

Comments
 (0)