From 1a01a22dce588b6ad41bf37e6ec1f5171ec93e0e Mon Sep 17 00:00:00 2001 From: Lee Richardson Date: Fri, 30 Sep 2022 00:56:55 +0100 Subject: [PATCH 1/2] Allow newlines in unwrapped Labels --- src/Eto.Gtk/Forms/Controls/LabelHandler.cs | 3 --- src/Eto.WinForms/Forms/Controls/LabelHandler.cs | 1 - .../Sections/Layouts/TableLayoutSection/ScalingSection.cs | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Eto.Gtk/Forms/Controls/LabelHandler.cs b/src/Eto.Gtk/Forms/Controls/LabelHandler.cs index 48b4c59ab7..7e6db3b7d5 100644 --- a/src/Eto.Gtk/Forms/Controls/LabelHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/LabelHandler.cs @@ -152,21 +152,18 @@ void SetWrap(WrapMode mode) case WrapMode.None: Control.Wrap = false; Control.LineWrap = false; - Control.SingleLineMode = true; break; case WrapMode.Word: Control.Wrap = true; Control.Layout.Wrap = Pango.WrapMode.WordChar; Control.LineWrapMode = Pango.WrapMode.WordChar; Control.LineWrap = true; - Control.SingleLineMode = false; break; case WrapMode.Character: Control.Wrap = true; Control.Layout.Wrap = Pango.WrapMode.Char; Control.LineWrapMode = Pango.WrapMode.Char; Control.LineWrap = true; - Control.SingleLineMode = false; break; default: throw new NotSupportedException(); diff --git a/src/Eto.WinForms/Forms/Controls/LabelHandler.cs b/src/Eto.WinForms/Forms/Controls/LabelHandler.cs index 70573fbab0..ca3d9cde2e 100644 --- a/src/Eto.WinForms/Forms/Controls/LabelHandler.cs +++ b/src/Eto.WinForms/Forms/Controls/LabelHandler.cs @@ -195,7 +195,6 @@ void SetStringFormat() switch (Wrap) { case WrapMode.None: - textFormat |= swf.TextFormatFlags.SingleLine; break; case WrapMode.Word: textFormat |= swf.TextFormatFlags.WordBreak; diff --git a/test/Eto.Test/Sections/Layouts/TableLayoutSection/ScalingSection.cs b/test/Eto.Test/Sections/Layouts/TableLayoutSection/ScalingSection.cs index f1989b9fb1..3c6530c5fa 100644 --- a/test/Eto.Test/Sections/Layouts/TableLayoutSection/ScalingSection.cs +++ b/test/Eto.Test/Sections/Layouts/TableLayoutSection/ScalingSection.cs @@ -50,7 +50,7 @@ public ScalingSection() tableLayout.SetColumnScale(2); tableLayout.SetRowScale(0); tableLayout.SetRowScale(2); - tableLayout.Add(new Label { Text = "2x2, should not scale and be centered", BackgroundColor = Colors.Red }, 1, 1); + tableLayout.Add(new Label { Text = "3x3, should not scale and be centered", BackgroundColor = Colors.Red }, 1, 1); layout.Add(tableLayout, yscale: true); Content = layout; From 59ce0c0d356241caa26198003a640fd21081df37 Mon Sep 17 00:00:00 2001 From: Lee Richardson Date: Fri, 30 Sep 2022 01:16:03 +0100 Subject: [PATCH 2/2] Add a test --- .../UnitTests/Forms/Controls/LabelTests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/Eto.Test/UnitTests/Forms/Controls/LabelTests.cs b/test/Eto.Test/UnitTests/Forms/Controls/LabelTests.cs index 562f9b7cad..ba3b18222c 100644 --- a/test/Eto.Test/UnitTests/Forms/Controls/LabelTests.cs +++ b/test/Eto.Test/UnitTests/Forms/Controls/LabelTests.cs @@ -23,5 +23,24 @@ public void ChangingTextAfterCreationShouldUpdateSize() return layout; }); } + + [Test, ManualTest] + public void WrapModeNoneShouldAllowNewLines() + { + ManualForm("Label should have two lines of text", form => + { + var label = new Label + { + Text = Utility.LoremTextWithTwoParagraphs, + Wrap = WrapMode.None + }; + var layout = new PixelLayout + { + Size = new Size(300, 200) + }; + layout.Add(label, 0, 0); + return layout; + }); + } } }