diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2018-03-19 21:01:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-19 21:01:19 +0300 |
commit | ace1e107c88477db1abe5e807809650f064112c4 (patch) | |
tree | 2a37fc4e7a2a49672345bf96f9deff763df37a62 | |
parent | 2182b63b67825fe1472b9d845ef1670b97baaf77 (diff) | |
parent | 94fb438fe2a86b37e2b8e72249eea2dc9c260985 (diff) |
Merge pull request #4222 from mono/d15-7-bug585364monodevelop-7.5.0.933
[15.7][Mac] Fix Add Files dialog being broken on High Sierra
-rw-r--r-- | main/src/addins/MacPlatform/Dialogs/MacAddFileDialogHandler.cs | 70 |
1 files changed, 51 insertions, 19 deletions
diff --git a/main/src/addins/MacPlatform/Dialogs/MacAddFileDialogHandler.cs b/main/src/addins/MacPlatform/Dialogs/MacAddFileDialogHandler.cs index fb0e5fe557..d73b96461c 100644 --- a/main/src/addins/MacPlatform/Dialogs/MacAddFileDialogHandler.cs +++ b/main/src/addins/MacPlatform/Dialogs/MacAddFileDialogHandler.cs @@ -25,6 +25,8 @@ // THE SOFTWARE. using System; +using System.Collections.Generic; +using System.Linq; using AppKit; using CoreGraphics; @@ -44,38 +46,68 @@ namespace MonoDevelop.MacIntegration CanChooseFiles = true, }) { MacSelectFileDialogHandler.SetCommonPanelProperties (data, panel); - - var popup = new NSPopUpButton (new CGRect (0, 0, 200, 28), false); - var dropdownBox = new MDBox (LayoutDirection.Horizontal, 2, 0) { - { new MDLabel (GettextCatalog.GetString ("Override build action:")), true }, - { new MDAlignment (popup, true) { MinWidth = 200 } } - }; + + var labels = new List<MDAlignment> (); + var controls = new List<MDAlignment> (); var filterPopup = MacSelectFileDialogHandler.CreateFileFilterPopup (data, panel); + MDBox accessoryBox = new MDBox (LayoutDirection.Vertical, 2, 2); if (filterPopup != null) { - dropdownBox.Layout (); - var box = new MDBox (LayoutDirection.Vertical, 2, 2) { - dropdownBox.View, - filterPopup, + var filterLabel = new MDAlignment (new MDLabel (GettextCatalog.GetString ("Show Files:")) { Alignment = NSTextAlignment.Right }, true); + labels.Add (filterLabel); + + var filterPopupAlignment = new MDAlignment (filterPopup, true) { MinWidth = 200 }; + controls.Add (filterPopupAlignment); + var filterBox = new MDBox (LayoutDirection.Horizontal, 2, 0) { + { filterLabel }, + { filterPopupAlignment } }; - box.Layout (); - panel.AccessoryView = box.View; - if (box.View.Superview != null) - box.Layout (box.View.Superview.Frame.Size); - } else { - dropdownBox.Layout (); - panel.AccessoryView = dropdownBox.View; + + accessoryBox.Add (filterBox); } - + + var popup = new NSPopUpButton (new CGRect (0, 0, 200, 28), false); popup.AddItem (GettextCatalog.GetString ("(Default)")); popup.Menu.AddItem (NSMenuItem.SeparatorItem); - + foreach (var b in data.BuildActions) { if (b == "--") popup.Menu.AddItem (NSMenuItem.SeparatorItem); else popup.AddItem (b); } + + var dropdownLabel = new MDAlignment (new MDLabel (GettextCatalog.GetString ("Override build action:")) { Alignment = NSTextAlignment.Right }, true); + labels.Add (dropdownLabel); + + var dropdownAlignment = new MDAlignment (popup, true) { MinWidth = 200 }; + controls.Add (dropdownAlignment); + + var dropdownBox = new MDBox (LayoutDirection.Horizontal, 2, 0) { + dropdownLabel, + dropdownAlignment, + }; + + accessoryBox.Add (dropdownBox); + + if (labels.Count > 0) { + float w = labels.Max (l => l.MinWidth); + foreach (var l in labels) { + l.MinWidth = w; + l.XAlign = LayoutAlign.Begin; + } + } + + if (controls.Count > 0) { + float w = controls.Max (c => c.MinWidth); + foreach (var c in controls) { + c.MinWidth = w; + c.XAlign = LayoutAlign.Begin; + } + } + + accessoryBox.Layout (); + panel.AccessoryView = accessoryBox.View; if (panel.RunModal () == 0) { GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow); |