Skip to content

Commit f3fc21a

Browse files
committed
Rename TextWrapping::max_lines to max_rows
1 parent c1cb619 commit f3fc21a

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

egui_demo_lib/src/apps/demo/misc_demo_window.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct MiscDemoWindow {
99
num_columns: usize,
1010

1111
break_anywhere: bool,
12-
max_lines: usize,
12+
max_rows: usize,
1313
overflow_character: char,
1414

1515
widgets: Widgets,
@@ -23,7 +23,7 @@ impl Default for MiscDemoWindow {
2323
MiscDemoWindow {
2424
num_columns: 2,
2525

26-
max_lines: 2,
26+
max_rows: 2,
2727
break_anywhere: false,
2828
overflow_character: '…',
2929

@@ -64,7 +64,7 @@ impl View for MiscDemoWindow {
6464
.show(ui, |ui| {
6565
text_layout_ui(
6666
ui,
67-
&mut self.max_lines,
67+
&mut self.max_rows,
6868
&mut self.break_anywhere,
6969
&mut self.overflow_character,
7070
);
@@ -417,7 +417,7 @@ impl SubTree {
417417

418418
fn text_layout_ui(
419419
ui: &mut egui::Ui,
420-
max_lines: &mut usize,
420+
max_rows: &mut usize,
421421
break_anywhere: &mut bool,
422422
overflow_character: &mut char,
423423
) {
@@ -578,8 +578,8 @@ fn text_layout_ui(
578578
ui.separator();
579579

580580
ui.horizontal(|ui| {
581-
ui.add(DragValue::new(max_lines));
582-
ui.label("Max lines");
581+
ui.add(DragValue::new(max_rows));
582+
ui.label("Max rows");
583583
});
584584
ui.checkbox(break_anywhere, "Break anywhere");
585585
ui.horizontal(|ui| {
@@ -591,7 +591,7 @@ fn text_layout_ui(
591591

592592
let mut job = LayoutJob::single_section(LOREM_IPSUM.to_string(), TextFormat::default());
593593
job.wrap = TextWrapping {
594-
max_lines: *max_lines,
594+
max_rows: *max_rows,
595595
break_anywhere: *break_anywhere,
596596
overflow_character: Some(*overflow_character),
597597
..Default::default()

epaint/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ All notable changes to the epaint crate will be documented in this file.
77
* Added `TextWrapping` struct containing all wrapping options.
88
* Added `LayoutJob::wrap` field containing these options.
99
* Moved `LayoutJob::wrap_width` to `TextWrapping::max_width`.
10-
* Added `TextWrapping::max_lines` to limit amount of lines the text should have.
10+
* Added `TextWrapping::max_rows` to limit amount of rows the text should have.
1111
* Added `TextWrapping::break_anywhere` to control should the text break at appropriate places or not.
1212
* Added `TextWrapping::overflow_character` to specify what character should be used to represent clipped text.
1313

epaint/src/text/text_layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fn line_break(
197197
for (i, glyph) in paragraph.glyphs.iter().enumerate() {
198198
let potential_row_width = glyph.max_x() - row_start_x;
199199

200-
if job.wrap.max_lines > 0 && non_empty_rows >= job.wrap.max_lines {
200+
if job.wrap.max_rows > 0 && non_empty_rows >= job.wrap.max_rows {
201201
break;
202202
}
203203

@@ -247,7 +247,7 @@ fn line_break(
247247
}
248248

249249
if row_start_idx < paragraph.glyphs.len() {
250-
if non_empty_rows == job.wrap.max_lines {
250+
if non_empty_rows == job.wrap.max_rows {
251251
if let (Some(overflow_character), Some(row)) =
252252
(job.wrap.overflow_character, out_rows.last_mut())
253253
{

epaint/src/text/text_layout_types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub struct TextWrapping {
267267

268268
/// Maximum amount of rows the text should have.
269269
/// Set to `0` to disable this.
270-
pub max_lines: usize,
270+
pub max_rows: usize,
271271

272272
/// Don't try to break text at an appropriate place.
273273
pub break_anywhere: bool,
@@ -281,12 +281,12 @@ impl std::hash::Hash for TextWrapping {
281281
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
282282
let Self {
283283
max_width,
284-
max_lines,
284+
max_rows,
285285
break_anywhere,
286286
overflow_character,
287287
} = self;
288288
crate::f32_hash(state, *max_width);
289-
max_lines.hash(state);
289+
max_rows.hash(state);
290290
break_anywhere.hash(state);
291291
overflow_character.hash(state);
292292
}
@@ -296,7 +296,7 @@ impl Default for TextWrapping {
296296
fn default() -> Self {
297297
Self {
298298
max_width: f32::INFINITY,
299-
max_lines: 0,
299+
max_rows: 0,
300300
break_anywhere: false,
301301
overflow_character: None,
302302
}

0 commit comments

Comments
 (0)