diff options
author | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-11-15 00:41:58 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2019-11-15 00:44:25 +0300 |
commit | 836ff635cf0cd0ce7da5006fd7476bf393b50475 (patch) | |
tree | 55f83bb59a1045c4d2098b7c569c61ac87e0480d /main/src/addins | |
parent | bf3e808dec4a21ef6a9e6bbe13aaba93c3c8ad12 (diff) |
[Debugger] Fixed calculation for NSTextField width as used by the treeview cells
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1006468/
Diffstat (limited to 'main/src/addins')
3 files changed, 25 insertions, 6 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectCellViewBase.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectCellViewBase.cs index 880e3961fe..b179e894b9 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectCellViewBase.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectCellViewBase.cs @@ -171,7 +171,23 @@ namespace MonoDevelop.Debugger modified?.Dispose (); - return NMath.Ceiling (width + 2); + width = NMath.Ceiling (width); + + // Note: All code-paths that use sizeDelta == 0 are for NSTextField labels and the only code-path + // that uses sizeDelta != 0 is for the Show More label in an NSButton. + if (sizeDelta == 0) { + // Note: In order to match NSTextField.Frame.Width after calling TextField.SizeToFit(), add 4px. + width += 4; + + // Note: NSTextField also seems to need an extra 8px to actually fit the entire text w/o clipping. + width += 8; + } else { + // Oddly enough, NSButton padding around the label is also +12px (matched after button.SizeToFit() + // and checking the resulting button.Frame.Width). + width += 12; + } + + return width; } protected void UpdateFont (NSControl control, int sizeDelta = 0) diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs index b2ed813b45..74ab6a4434 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs @@ -53,6 +53,7 @@ namespace MonoDevelop.Debugger TextField = new MacDebuggerTextField (this) { TranslatesAutoresizingMaskIntoConstraints = false, + LineBreakMode = NSLineBreakMode.Clipping, MaximumNumberOfLines = 1, DrawsBackground = false, Bordered = false, @@ -167,9 +168,11 @@ namespace MonoDevelop.Debugger TextField.TextColor = textColor; TextField.Editable = editable; UpdateFont (TextField); + TextField.SizeToFit (); var value = editable && string.IsNullOrEmpty (name) ? placeholder : name; - OptimalWidth += GetWidthForString (TextField.Font, value); + var textWidth = GetWidthForString (TextField.Font, value); + OptimalWidth += textWidth; constraints.Add (TextField.CenterYAnchor.ConstraintEqualToAnchor (CenterYAnchor)); constraints.Add (TextField.LeadingAnchor.ConstraintEqualToAnchor (firstView.TrailingAnchor, RowCellSpacing)); @@ -182,7 +185,7 @@ namespace MonoDevelop.Debugger previewIconVisible = true; } - constraints.Add (TextField.WidthAnchor.ConstraintGreaterThanOrEqualToConstant (TextField.Frame.Width)); + constraints.Add (TextField.WidthAnchor.ConstraintGreaterThanOrEqualToConstant (textWidth)); constraints.Add (PreviewButton.CenterYAnchor.ConstraintEqualToAnchor (CenterYAnchor)); constraints.Add (PreviewButton.LeadingAnchor.ConstraintEqualToAnchor (TextField.TrailingAnchor, RowCellSpacing)); constraints.Add (PreviewButton.WidthAnchor.ConstraintEqualToConstant (ImageSize)); diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs index 1ed8e95423..ceef417d80 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs @@ -91,6 +91,7 @@ namespace MonoDevelop.Debugger TextField = new MacDebuggerTextField (this) { TranslatesAutoresizingMaskIntoConstraints = false, + LineBreakMode = NSLineBreakMode.Clipping, MaximumNumberOfLines = 1, DrawsBackground = false, Bordered = false, @@ -291,6 +292,7 @@ namespace MonoDevelop.Debugger TextField.TextColor = textColor; TextField.Editable = editable; UpdateFont (TextField); + TextField.SizeToFit (); OptimalWidth += GetWidthForString (TextField.Font, strval); @@ -391,8 +393,7 @@ namespace MonoDevelop.Debugger // Third Item: Value Button if (valueButtonText != null && !hideValueButton) { - // FIXME: what left/right padding do we need to add for the button around the button label? 4px? - optimalWidth += GetWidthForString (treeView.CustomFont, valueButtonText, -3) + 4; + optimalWidth += GetWidthForString (treeView.CustomFont, valueButtonText, -3); optimalWidth += RowCellSpacing; } @@ -404,7 +405,6 @@ namespace MonoDevelop.Debugger // Fifth Item: Text Value optimalWidth += GetWidthForString (treeView.CustomFont, strval); - optimalWidth += MarginSize; return optimalWidth; |