From 44ca9c348093bd75e815be0830c8e6dbfba76fc0 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 15 Sep 2025 18:40:16 +0800 Subject: [PATCH] Use wrap text warpping & set max width of all children --- .../Plugin/JsonRPCPluginSettings.cs | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 598c2debb..0306bb29e 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -202,7 +202,7 @@ namespace Flow.Launcher.Core.Plugin { Text = attributes.Label, VerticalAlignment = VerticalAlignment.Center, - TextWrapping = TextWrapping.WrapWithOverflow + TextWrapping = TextWrapping.Wrap }; // Create a text block for description @@ -213,7 +213,7 @@ namespace Flow.Launcher.Core.Plugin { Text = attributes.Description, VerticalAlignment = VerticalAlignment.Center, - TextWrapping = TextWrapping.WrapWithOverflow + TextWrapping = TextWrapping.Wrap }; desc.SetResourceReference(TextBlock.StyleProperty, "SettingPanelTextBlockDescriptionStyle"); // for theme change @@ -249,7 +249,8 @@ namespace Flow.Launcher.Core.Plugin VerticalAlignment = VerticalAlignment.Center, Margin = SettingPanelItemLeftTopBottomMargin, Text = Settings[attributes.Name] as string ?? string.Empty, - ToolTip = attributes.Description + ToolTip = attributes.Description, + TextWrapping = TextWrapping.Wrap }; textBox.TextChanged += (_, _) => @@ -271,7 +272,8 @@ namespace Flow.Launcher.Core.Plugin VerticalAlignment = VerticalAlignment.Center, Margin = SettingPanelItemLeftMargin, Text = Settings[attributes.Name] as string ?? string.Empty, - ToolTip = attributes.Description + ToolTip = attributes.Description, + TextWrapping = TextWrapping.Wrap }; textBox.TextChanged += (_, _) => @@ -335,7 +337,7 @@ namespace Flow.Launcher.Core.Plugin HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Margin = SettingPanelItemLeftTopBottomMargin, - TextWrapping = TextWrapping.WrapWithOverflow, + TextWrapping = TextWrapping.Wrap, AcceptsReturn = true, Text = Settings[attributes.Name] as string ?? string.Empty, ToolTip = attributes.Description @@ -508,7 +510,21 @@ namespace Flow.Launcher.Core.Plugin if (workingWidth <= 0) return; - grid.ColumnDefinitions[0].MaxWidth = MainGridColumn0MaxWidthRatio * workingWidth; + var constrainedWidth = MainGridColumn0MaxWidthRatio * workingWidth; + + // Set MaxWidth of column 0 and its childrens + // We must set MaxWidth of its childrens to make text wrapping work correctly + grid.ColumnDefinitions[0].MaxWidth = constrainedWidth; + foreach (var child in grid.Children) + { + if (child is FrameworkElement element && Grid.GetColumn(element) == 0 && Grid.GetColumnSpan(element) == 1) + { + if (element.MaxWidth < constrainedWidth) + continue; + + element.MaxWidth = constrainedWidth; + } + } } private static bool NeedSaveInSettings(string type)