Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit c0032c8

Browse files
committed
[NuGet] Switch back to native toolkit to display license dialog
Use Xwt.Toolkit.NativeEngine to show the License Acceptance dialog. Briefly switched to not using this because complicated license expressions cannot have their hyperlinks clicked. However these do not seem to be used in practice. The native version fixes odd tearing of the list view in the UI, also the list scrolling to the end, and not being able to resize the UI without displaying it first. Downside to this change is that hyperlinks in complicated license expressions cannot be clicked since this is not supported by XWT's Xamarin.Mac implementation of the Label.
1 parent 8de3648 commit c0032c8

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/LicenseAcceptanceDialog.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public LicenseAcceptanceDialog (LicenseAcceptanceViewModel viewModel)
6767
packagesList.Spacing = 0;
6868

6969
scroll = new ScrollView (packagesList);
70-
scroll.HorizontalScrollPolicy = ScrollPolicy.Automatic;
70+
scroll.HorizontalScrollPolicy = ScrollPolicy.Never;
7171
scroll.VerticalScrollPolicy = ScrollPolicy.Automatic;
7272
scroll.BorderVisible = false;
7373
scroll.BackgroundColor = Ide.Gui.Styles.BackgroundColor;
@@ -107,6 +107,23 @@ void AddPackages ()
107107
}
108108
}
109109

110+
protected override void OnShown ()
111+
{
112+
var count = packagesList.Children.Count ();
113+
if (count > 0 && count < 4) {
114+
scroll.VerticalScrollPolicy = ScrollPolicy.Never;
115+
var firstRow = packagesList.Children.First ();
116+
var rowHeight = firstRow.Size.Height;
117+
Height -= (rowHeight + firstRow.MarginTop + firstRow.MarginBottom) * (4 - count);
118+
} else if (count == 4) {
119+
scroll.VerticalScrollPolicy = ScrollPolicy.Never;
120+
} else if (count > 4) {
121+
scroll.VerticalScrollPolicy = ScrollPolicy.Automatic;
122+
Height += rowMargin.Top + rowMargin.Bottom;
123+
}
124+
base.OnShown ();
125+
}
126+
110127
void AddPackage (PackageLicenseViewModel package)
111128
{
112129
var titleBox = new VBox ();

main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ Task<bool> ShowLicenseAcceptanceDialog (IEnumerable<NuGetPackageLicense> license
5151
{
5252
var res = new TaskCompletionSource<bool> ();
5353
IdeApp.RunWhenIdle (() => {
54-
// Disable use of native toolkit since hyperlinks cannot be clicked with the Xamarin.Mac LabelBackend
55-
// Also scrollbars are always visible even when they are not needed.
56-
//Xwt.Toolkit.NativeEngine.Invoke (delegate {
54+
// Note that using native toolkit means hyperlinks from complicated license expressions cannot be
55+
// clicked with the Xamarin.Mac LabelBackend
56+
Xwt.Toolkit.NativeEngine.Invoke (delegate {
5757
using (LicenseAcceptanceDialog dialog = CreateLicenseAcceptanceDialog (licenses)) {
5858
res.SetResult (dialog.Run (MessageService.RootWindow));
5959
}
60-
//});
60+
});
6161
});
6262
return res.Task;
6363
}

0 commit comments

Comments
 (0)