Skip to content

Commit 2f20192

Browse files
author
Miklos Juhasz
committed
Restructure Fix Common Errors step 2 layout
Move navigation buttons (Back, Done, Cancel) alongside the edit panel in the bottom row so they align with the subtitle text controls rather than floating at the window bottom. Move the fixes-applied label next to the step title with a separator that hides when no fixes have been applied. Raise MinWidth to prevent buttons being clipped on narrow windows.
1 parent cbe086b commit 2f20192

1 file changed

Lines changed: 57 additions & 26 deletions

File tree

src/ui/Features/Tools/FixCommonErrors/FixCommonErrorsWindow.cs

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public FixCommonErrorsWindow(FixCommonErrorsViewModel vm)
2727
Title = Se.Language.Tools.FixCommonErrors.Title;
2828
Width = 1024;
2929
Height = 720;
30-
MinWidth = 800;
30+
MinWidth = 920;
3131
MinHeight = 600;
3232
CanResize = true;
3333

@@ -45,9 +45,32 @@ public FixCommonErrorsWindow(FixCommonErrorsViewModel vm)
4545
var labelStep2 = new Label
4646
{
4747
VerticalAlignment = VerticalAlignment.Center,
48+
Padding = new Thickness(0),
4849
};
4950
labelStep2.Bind(Label.ContentProperty, new Binding(nameof(vm.Step2Title)));
50-
labelStep2.Bind(IsVisibleProperty, new Binding(nameof(vm.Step2IsVisible)));
51+
52+
var labelFixesApplied = UiUtil.MakeTextBlock(string.Empty);
53+
labelFixesApplied.Bind(TextBlock.TextProperty, new Binding(nameof(vm.FixesAppliedText)));
54+
labelFixesApplied.VerticalAlignment = VerticalAlignment.Center;
55+
56+
var appliedPanel = new StackPanel
57+
{
58+
Orientation = Orientation.Horizontal,
59+
Margin = new Thickness(12, 0, 0, 0),
60+
Children = { UiUtil.MakeVerticalSeparator(1, 0.4, new Thickness(0, 4, 12, 4)), labelFixesApplied },
61+
};
62+
appliedPanel.Bind(IsVisibleProperty, new Binding(nameof(vm.FixesAppliedText))
63+
{
64+
Converter = new Avalonia.Data.Converters.FuncValueConverter<string?, bool>(s => !string.IsNullOrEmpty(s))
65+
});
66+
67+
var step2HeaderPanel = new StackPanel
68+
{
69+
Orientation = Orientation.Horizontal,
70+
VerticalAlignment = VerticalAlignment.Center,
71+
Children = { labelStep2, appliedPanel },
72+
};
73+
step2HeaderPanel.Bind(IsVisibleProperty, new Binding(nameof(vm.Step2IsVisible)));
5174

5275
var textBoxSearch = UiUtil.MakeTextBox(250, vm, nameof(vm.SearchText)).WithMarginRight(25);
5376
textBoxSearch.PlaceholderText = Se.Language.Tools.FixCommonErrors.SearchRulesDotDotDot;
@@ -120,8 +143,6 @@ public FixCommonErrorsWindow(FixCommonErrorsViewModel vm)
120143
new DataGridCheckboxMultiSelect<FixRuleDisplayItem>(rulesGrid,
121144
item => item.IsSelected, (item, v) => item.IsSelected = v);
122145

123-
var step2Grid = MakeStep2Grid();
124-
step2Grid.Bind(IsVisibleProperty, new Binding(nameof(_vm.Step2IsVisible)));
125146
var comboProfile = UiUtil.MakeComboBox(vm.Profiles, vm, nameof(vm.SelectedProfile));
126147
var buttonPanelRules = UiUtil.MakeButtonBar(
127148
UiUtil.MakeButton(Se.Language.General.SelectAll, vm.RulesSelectAllCommand),
@@ -137,20 +158,25 @@ public FixCommonErrorsWindow(FixCommonErrorsViewModel vm)
137158
.BindIsVisible(vm, nameof(vm.Step1IsVisible));
138159

139160
var buttonBackToFixList = UiUtil.MakeButton(Se.Language.Tools.FixCommonErrors.BackToFixList, vm.BackToFixListCommand)
140-
.WithIconLeft("fa-solid fa-arrow-left")
141-
.BindIsVisible(vm, nameof(vm.Step2IsVisible));
161+
.WithIconLeft("fa-solid fa-arrow-left");
142162

143-
var buttonDone = UiUtil.MakeButton(Se.Language.General.Done, vm.OkCommand)
144-
.BindIsVisible(vm, nameof(vm.Step2IsVisible));
163+
var buttonDone = UiUtil.MakeButton(Se.Language.General.Done, vm.OkCommand);
145164
buttonDone.IsDefault = true;
146165

147-
var buttonPanelRight = UiUtil.MakeButtonBar(
166+
var step2NavButtons = UiUtil.MakeButtonBar(
148167
buttonBackToFixList,
149-
buttonToApplyFixes,
150168
buttonDone,
151169
UiUtil.MakeButtonCancel(vm.CancelCommand)
152170
);
153171

172+
var buttonPanelRight = UiUtil.MakeButtonBar(
173+
buttonToApplyFixes,
174+
UiUtil.MakeButtonCancel(vm.CancelCommand)
175+
).BindIsVisible(vm, nameof(vm.Step1IsVisible));
176+
177+
var step2Grid = MakeStep2Grid(step2NavButtons);
178+
step2Grid.Bind(IsVisibleProperty, new Binding(nameof(_vm.Step2IsVisible)));
179+
154180
var grid = new Grid
155181
{
156182
RowDefinitions =
@@ -174,9 +200,9 @@ public FixCommonErrorsWindow(FixCommonErrorsViewModel vm)
174200
grid.Children.Add(labelStep1);
175201
Grid.SetRow(labelStep1, 0);
176202
Grid.SetColumn(labelStep1, 0);
177-
grid.Children.Add(labelStep2);
178-
Grid.SetRow(labelStep2, 0);
179-
Grid.SetColumn(labelStep2, 0);
203+
grid.Children.Add(step2HeaderPanel);
204+
Grid.SetRow(step2HeaderPanel, 0);
205+
Grid.SetColumn(step2HeaderPanel, 0);
180206

181207
grid.Children.Add(panelTopRight);
182208
Grid.SetRow(panelTopRight, 0);
@@ -197,15 +223,6 @@ public FixCommonErrorsWindow(FixCommonErrorsViewModel vm)
197223
Grid.SetRow(buttonPanelRules, 2);
198224
Grid.SetColumn(buttonPanelRules, 0);
199225

200-
var labelFixesApplied = UiUtil.MakeTextBlock(string.Empty);
201-
labelFixesApplied.Bind(TextBlock.TextProperty, new Binding(nameof(vm.FixesAppliedText)));
202-
labelFixesApplied.Bind(IsVisibleProperty, new Binding(nameof(vm.Step2IsVisible)));
203-
labelFixesApplied.HorizontalAlignment = HorizontalAlignment.Left;
204-
labelFixesApplied.VerticalAlignment = VerticalAlignment.Center;
205-
grid.Children.Add(labelFixesApplied);
206-
Grid.SetRow(labelFixesApplied, 2);
207-
Grid.SetColumn(labelFixesApplied, 0);
208-
209226
grid.Children.Add(buttonPanelRight);
210227
Grid.SetRow(buttonPanelRight, 2);
211228
Grid.SetColumn(buttonPanelRight, 1);
@@ -218,7 +235,7 @@ public FixCommonErrorsWindow(FixCommonErrorsViewModel vm)
218235
Loaded += delegate { UiUtil.RestoreWindowPosition(this); };
219236
}
220237

221-
private Grid MakeStep2Grid()
238+
private Grid MakeStep2Grid(Control navButtons)
222239
{
223240
// top
224241
var dataGridFixes = new DataGrid
@@ -479,9 +496,9 @@ private Grid MakeStep2Grid()
479496
{
480497
RowDefinitions =
481498
{
482-
new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
499+
new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = 80 },
483500
new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) },
484-
new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
501+
new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = 80 },
485502
new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) },
486503
},
487504
ColumnDefinitions =
@@ -493,10 +510,24 @@ private Grid MakeStep2Grid()
493510
Width = double.NaN,
494511
HorizontalAlignment = HorizontalAlignment.Stretch,
495512
};
513+
514+
var bottomRow = new Grid
515+
{
516+
ColumnDefinitions =
517+
{
518+
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) },
519+
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
520+
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) },
521+
},
522+
};
523+
navButtons.VerticalAlignment = VerticalAlignment.Bottom;
524+
bottomRow.Add(gridCurrentSubtbtitle, 0, 0);
525+
bottomRow.Add(navButtons, 0, 2);
526+
496527
grid.Add(borderFixes, 0, 0);
497528
grid.Add(buttonBarFixes, 1, 0);
498529
grid.Add(borderSubtitles, 2, 0);
499-
grid.Add(gridCurrentSubtbtitle, 3, 0);
530+
grid.Add(bottomRow, 3, 0);
500531

501532
return grid;
502533
}

0 commit comments

Comments
 (0)