diff options
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; |