From ae494894ca5763ada083bc0df96762e465104842 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:32:11 +0900 Subject: [PATCH 1/6] Update label.rs --- crates/egui/src/widgets/label.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index d2085d4fb496..730a3198ae4f 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -26,6 +26,7 @@ pub struct Label { wrap_mode: Option, sense: Option, selectable: Option, + align: Option, } impl Label { @@ -35,6 +36,7 @@ impl Label { wrap_mode: None, sense: None, selectable: None, + align: None, } } @@ -76,6 +78,13 @@ impl Label { self } + /// Set [`Self::align`] to [`Align`]. + #[inline] + pub fn align(mut self, align: Align) -> Self { + self.align = Some(align); + self + } + /// Can the user select the text with the mouse? /// /// Overrides [`crate::style::Interaction::selectable_labels`]. @@ -211,7 +220,7 @@ impl Label { layout_job.halign = Align::LEFT; layout_job.justify = false; } else { - layout_job.halign = ui.layout().horizontal_placement(); + layout_job.halign = self.align.unwrap_or(ui.layout().horizontal_placement()); layout_job.justify = ui.layout().horizontal_justify(); }; From 94bf12f552f2778a732b2ca44d228d9f16343867 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:48:09 +0900 Subject: [PATCH 2/6] Update label.rs --- crates/egui/src/widgets/label.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index 730a3198ae4f..a9c86a8c1442 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -78,9 +78,11 @@ impl Label { self } + /// Sets the horizontal alignment of the Label to the given `Align` value. + /// /// Set [`Self::align`] to [`Align`]. #[inline] - pub fn align(mut self, align: Align) -> Self { + pub fn halign(mut self, align: Align) -> Self { self.align = Some(align); self } From 529da079c67a484f23cda8b08e09e0ec396b3d26 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:50:48 +0900 Subject: [PATCH 3/6] Update label.rs --- crates/egui/src/widgets/label.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index a9c86a8c1442..220616346066 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -79,7 +79,7 @@ impl Label { } /// Sets the horizontal alignment of the Label to the given `Align` value. - /// + /// /// Set [`Self::align`] to [`Align`]. #[inline] pub fn halign(mut self, align: Align) -> Self { From 69bec424647c853c78a90420b092480497b05ffe Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:54:57 +0900 Subject: [PATCH 4/6] Update label.rs --- crates/egui/src/widgets/label.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index 220616346066..2c77bad3d0ef 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -26,7 +26,7 @@ pub struct Label { wrap_mode: Option, sense: Option, selectable: Option, - align: Option, + halign: Option, } impl Label { @@ -36,7 +36,7 @@ impl Label { wrap_mode: None, sense: None, selectable: None, - align: None, + halign: None, } } @@ -83,7 +83,7 @@ impl Label { /// Set [`Self::align`] to [`Align`]. #[inline] pub fn halign(mut self, align: Align) -> Self { - self.align = Some(align); + self.halign = Some(align); self } @@ -222,7 +222,7 @@ impl Label { layout_job.halign = Align::LEFT; layout_job.justify = false; } else { - layout_job.halign = self.align.unwrap_or(ui.layout().horizontal_placement()); + layout_job.halign = self.halign.unwrap_or(ui.layout().horizontal_placement()); layout_job.justify = ui.layout().horizontal_justify(); }; From 8c5b8b36da8426d79e6edbd3c2be627b6b0af53a Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:55:44 +0900 Subject: [PATCH 5/6] Update label.rs --- crates/egui/src/widgets/label.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index 2c77bad3d0ef..56b6bb0d5b61 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -80,7 +80,7 @@ impl Label { /// Sets the horizontal alignment of the Label to the given `Align` value. /// - /// Set [`Self::align`] to [`Align`]. + /// Set [`Self::halign`] to [`Align`]. #[inline] pub fn halign(mut self, align: Align) -> Self { self.halign = Some(align); From 41ad7c503f50a0b5e69957767cbb47698cdf83b9 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 26 Aug 2024 15:32:06 +0200 Subject: [PATCH 6/6] shorten docstring --- crates/egui/src/widgets/label.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index 56b6bb0d5b61..55e20136379e 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -79,8 +79,6 @@ impl Label { } /// Sets the horizontal alignment of the Label to the given `Align` value. - /// - /// Set [`Self::halign`] to [`Align`]. #[inline] pub fn halign(mut self, align: Align) -> Self { self.halign = Some(align);