Skip to content

Commit 44ca9c3

Browse files
committed
Use wrap text warpping & set max width of all children
1 parent b5c860d commit 44ca9c3

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public Control CreateSettingPanel()
202202
{
203203
Text = attributes.Label,
204204
VerticalAlignment = VerticalAlignment.Center,
205-
TextWrapping = TextWrapping.WrapWithOverflow
205+
TextWrapping = TextWrapping.Wrap
206206
};
207207

208208
// Create a text block for description
@@ -213,7 +213,7 @@ public Control CreateSettingPanel()
213213
{
214214
Text = attributes.Description,
215215
VerticalAlignment = VerticalAlignment.Center,
216-
TextWrapping = TextWrapping.WrapWithOverflow
216+
TextWrapping = TextWrapping.Wrap
217217
};
218218

219219
desc.SetResourceReference(TextBlock.StyleProperty, "SettingPanelTextBlockDescriptionStyle"); // for theme change
@@ -249,7 +249,8 @@ public Control CreateSettingPanel()
249249
VerticalAlignment = VerticalAlignment.Center,
250250
Margin = SettingPanelItemLeftTopBottomMargin,
251251
Text = Settings[attributes.Name] as string ?? string.Empty,
252-
ToolTip = attributes.Description
252+
ToolTip = attributes.Description,
253+
TextWrapping = TextWrapping.Wrap
253254
};
254255

255256
textBox.TextChanged += (_, _) =>
@@ -271,7 +272,8 @@ public Control CreateSettingPanel()
271272
VerticalAlignment = VerticalAlignment.Center,
272273
Margin = SettingPanelItemLeftMargin,
273274
Text = Settings[attributes.Name] as string ?? string.Empty,
274-
ToolTip = attributes.Description
275+
ToolTip = attributes.Description,
276+
TextWrapping = TextWrapping.Wrap
275277
};
276278

277279
textBox.TextChanged += (_, _) =>
@@ -335,7 +337,7 @@ public Control CreateSettingPanel()
335337
HorizontalAlignment = HorizontalAlignment.Stretch,
336338
VerticalAlignment = VerticalAlignment.Center,
337339
Margin = SettingPanelItemLeftTopBottomMargin,
338-
TextWrapping = TextWrapping.WrapWithOverflow,
340+
TextWrapping = TextWrapping.Wrap,
339341
AcceptsReturn = true,
340342
Text = Settings[attributes.Name] as string ?? string.Empty,
341343
ToolTip = attributes.Description
@@ -508,7 +510,21 @@ private void MainPanel_SizeChanged(object sender, SizeChangedEventArgs e)
508510

509511
if (workingWidth <= 0) return;
510512

511-
grid.ColumnDefinitions[0].MaxWidth = MainGridColumn0MaxWidthRatio * workingWidth;
513+
var constrainedWidth = MainGridColumn0MaxWidthRatio * workingWidth;
514+
515+
// Set MaxWidth of column 0 and its childrens
516+
// We must set MaxWidth of its childrens to make text wrapping work correctly
517+
grid.ColumnDefinitions[0].MaxWidth = constrainedWidth;
518+
foreach (var child in grid.Children)
519+
{
520+
if (child is FrameworkElement element && Grid.GetColumn(element) == 0 && Grid.GetColumnSpan(element) == 1)
521+
{
522+
if (element.MaxWidth < constrainedWidth)
523+
continue;
524+
525+
element.MaxWidth = constrainedWidth;
526+
}
527+
}
512528
}
513529

514530
private static bool NeedSaveInSettings(string type)

0 commit comments

Comments
 (0)