Skip to content

Commit 19f53ec

Browse files
committed
Improve the size in which the subtitle is hidden when the titlebar gets resized (fix #3862)
1 parent c9dc95e commit 19f53ec

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
66
<!-- IF BUILD FAILS DUE TO MISSING Microsoft.Management.Deployment NAMESPACE,
77
TOGGLE THE LAST NUMBER OF THE LINE BELOW 1 UNIT UP OR DOWN, AND REBUILD-->
8-
<WindowsSdkPackageVersion>10.0.26100.57</WindowsSdkPackageVersion>
8+
<WindowsSdkPackageVersion>10.0.26100.56</WindowsSdkPackageVersion>
99

1010
<SdkVersion>8.0.407</SdkVersion>
1111
<Authors>Martí Climent and the contributors</Authors>

src/UniGetUI/MainWindow.xaml.cs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public XamlRoot XamlRoot
4646
public bool BlockLoading;
4747
public readonly TextBlock LoadingSthDalogText;
4848
public readonly ContentDialog LoadingSthDalog;
49+
private string _currentSubtitle = "";
50+
private int _currentSubtitlePxLength;
4951

5052
public int LoadingDialogCount;
5153

@@ -215,16 +217,19 @@ public static void ApplyProxyVariableToProcess()
215217

216218
private void AddToSubtitle(string line)
217219
{
218-
if (subtitleBackup.Length > 0)
219-
subtitleBackup += " - ";
220-
subtitleBackup += line;
221-
Title = "UniGetUI - " + subtitleBackup;
222-
TitleBar.Subtitle = subtitleCollapsed is true? "": subtitleBackup;
220+
if (_currentSubtitle.Length > 0)
221+
_currentSubtitle += " - ";
222+
_currentSubtitle += line;
223+
_currentSubtitlePxLength = _currentSubtitle.Length * 4;
224+
Title = "UniGetUI - " + _currentSubtitle;
225+
TitleBar.Subtitle = subtitleCollapsed is true? "": _currentSubtitle;
223226
}
224227

225228
private void ClearSubtitle()
226229
{
227230
TitleBar.Subtitle = "";
231+
_currentSubtitle = "";
232+
_currentSubtitlePxLength = 0;
228233
Title = "UniGetUI";
229234
}
230235

@@ -1005,39 +1010,40 @@ private void TitleBar_OnBackRequested(TitleBar sender, object args)
10051010

10061011
private bool? subtitleCollapsed;
10071012
private bool? titleCollapsed;
1008-
private string subtitleBackup = "";
1013+
private const int DYNAMIC_SEARCHBOX_LIMIT = 750;
1014+
private const int HIDE_TITLE_LIMIT = 870;
1015+
private const int MIN_SEARCHBOX_W = 50;
1016+
private const int MAX_SEARCHBOX_W = 400;
10091017
private void TitleBar_SizeChanged(object sender, SizeChangedEventArgs e)
10101018
{
1011-
if(TitleBar.ActualWidth <= 750)
1019+
if(TitleBar.ActualWidth <= DYNAMIC_SEARCHBOX_LIMIT)
10121020
{
1013-
GlobalSearchBox.Width = Math.Max(50, 400 - (750 - TitleBar.ActualWidth));
1021+
GlobalSearchBox.Width = Math.Max(MIN_SEARCHBOX_W, MAX_SEARCHBOX_W - (DYNAMIC_SEARCHBOX_LIMIT - TitleBar.ActualWidth));
10141022
}
10151023

1016-
if (TitleBar.ActualWidth < 870 && titleCollapsed is not true)
1024+
if (titleCollapsed is not true && TitleBar.ActualWidth < HIDE_TITLE_LIMIT)
10171025
{
10181026
TitleBar.Title = "";
10191027
titleCollapsed = true;
10201028
}
1021-
else if (TitleBar.ActualWidth > 870 && titleCollapsed is not false)
1029+
else if (titleCollapsed is not false && TitleBar.ActualWidth > HIDE_TITLE_LIMIT)
10221030
{
10231031
TitleBar.Title = "UniGetUI";
1024-
GlobalSearchBox.Width = 400;
1032+
GlobalSearchBox.Width = MAX_SEARCHBOX_W;
10251033
titleCollapsed = false;
10261034
}
10271035

1028-
if (TitleBar.ActualWidth < 1200 && subtitleCollapsed is not true)
1036+
if (subtitleCollapsed is not true && TitleBar.ActualWidth < (HIDE_TITLE_LIMIT + _currentSubtitlePxLength))
10291037
{
1030-
subtitleBackup = TitleBar.Subtitle;
10311038
TitleBar.Subtitle = "";
10321039
subtitleCollapsed = true;
10331040
}
1034-
else if (TitleBar.ActualWidth > 1200 && subtitleCollapsed is not false)
1041+
else if (subtitleCollapsed is not false && TitleBar.ActualWidth > (HIDE_TITLE_LIMIT + _currentSubtitlePxLength))
10351042
{
1036-
TitleBar.Subtitle = subtitleBackup;
1037-
GlobalSearchBox.Width = 400;
1043+
TitleBar.Subtitle = _currentSubtitle;
1044+
GlobalSearchBox.Width = MAX_SEARCHBOX_W;
10381045
subtitleCollapsed = false;
10391046
}
1040-
// Debug.WriteLine(TitleBar.ActualWidth);
10411047
}
10421048
}
10431049

src/UniGetUI/Pages/DialogPages/DialogHelper_Generic.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,6 @@ public static int ShowLoadingDialog(string title, string description)
8787
_loadingDialogQueue.Add(dialogData);
8888
_showNextLoadingDialogIfPossible();
8989
return dialogData.Id;
90-
91-
/*while (Window.LoadingDialogCount == 0 && Window.DialogQueue.Count != 0) await Task.Delay(100);
92-
93-
if (Window.LoadingDialogCount == 0 && Window.DialogQueue.Count == 0)
94-
{
95-
Window.LoadingSthDalog.Title = title;
96-
Window.LoadingSthDalogText.Text = description;
97-
Window.LoadingSthDalog.XamlRoot = Window.NavigationPage.XamlRoot;
98-
_ = Window.ShowDialogAsync(Window.LoadingSthDalog, HighPriority: true);
99-
}
100-
101-
Window.LoadingDialogCount++;*/
10290
}
10391

10492
public static void _showNextLoadingDialogIfPossible()

0 commit comments

Comments
 (0)