diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-02-25 23:24:06 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2019-03-06 21:49:07 +0300 |
commit | 2eda0b68da408715ec7241b266e2f003d483e8ff (patch) | |
tree | 016898816614ad54c851697fc0a65ce9d10b56ca /Xamarin.PropertyEditing.Mac/Controls/Custom | |
parent | b6687a4b3eff21909c3316d7e8509ac69b296052 (diff) |
[mac] Overhaul some layout
DefaultControlHeight had ended up everywhere with no real meaning attached to it,
used in some places with manual offsets. It was never clear whether it was the row
size or a control size. Given the design doesn't always have matching heights for
controls, we should just do away with this illusion.
Additionally each editor had a manual offset trying to account for the property
button and associated spacing on the right and wasn't consistent between 32 or 33.
We do away with all that by moving the property button into the EditorContainer
with a new flag on IEditorView denoting whether we should have a property button
or not. Now all editors should not concern themselves with right inset and match
width fully.
Unfortunately the design sometimes has inconsistent top/bottom insets that vary
from 3/3 to 3.5/3.5. I'd like to make them consistent, so we can set them at
the EditorContainer level but for now the best thing that can be done is inset
on a per editor basis.
This also attempts to address labels and sometimes the property button not being
vertically centered on the first editors. Now, the label is CenterY on the
FirstKeyView which should center it vertically against the topmost input. The
property button is now also CenterYd to the label, so it similarlly should auto
center against the first row of input. If this proves to be not flexible enough
we can revisit.
This also makes more controls consistent with a control size of Small and uses
the system provided mechanism for making sure the font matches so it fits
correctly.
These new guidelines should be used:
- Rows have a height of 24
- Editors should match width
- Single-row editors should CenterY on the parent, match width -6
- Multi-row editors should inset appropriately at -3/-3
- We should avoid so many manually calculated offsets going forward
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom')
7 files changed, 23 insertions, 21 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs index 76868b6..708a832 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs @@ -48,7 +48,7 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (viewTitle, NSLayoutAttribute.Left, NSLayoutRelation.Equal, iconView, NSLayoutAttribute.Right, 1f, 5f), //NSLayoutConstraint.Create (viewTitle, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 38f), NSLayoutConstraint.Create (viewTitle, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, 120), - NSLayoutConstraint.Create (viewTitle, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight), + NSLayoutConstraint.Create (viewTitle, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 24), }); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index 6fa2dd5..bde2128 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -25,7 +25,7 @@ namespace Xamarin.PropertyEditing.Mac this.filterResource = new NSSearchField {
ControlSize = NSControlSize.Mini,
- Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
+ Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Mini)),
PlaceholderString = Properties.Resources.SearchResourcesTitle,
};
@@ -46,7 +46,8 @@ namespace Xamarin.PropertyEditing.Mac NSView IEditorView.NativeView => View; - public bool IsDynamicallySized => false; + public bool IsDynamicallySized => false;
+ public bool NeedsPropertyButton => false; public nint GetHeight (EditorViewModel viewModel) { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs index 219fb95..f8ed20d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs @@ -14,7 +14,7 @@ namespace Xamarin.PropertyEditing.Mac Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; Cell.UsesSingleLineMode = true; ControlSize = NSControlSize.Small; - Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize); + Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)); Title = string.Empty; TranslatesAutoresizingMaskIntoConstraints = false; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs index 5dba23c..9e3366d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs @@ -14,7 +14,7 @@ namespace Xamarin.PropertyEditing.Mac Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; Cell.UsesSingleLineMode = true; ControlSize = NSControlSize.Small; - Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize); + Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)); Title = string.Empty; TranslatesAutoresizingMaskIntoConstraints = false; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs index 30dd7a0..aa5c648 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs @@ -18,12 +18,6 @@ namespace Xamarin.PropertyEditing.Mac internal class NumericSpinEditor : NSView, INSAccessibilityGroup { - internal const int StepperSpace = 2; - internal const int StepperWidth = 11; - const int stepperTopHeight = 9; - const int stepperBotHeight = 10; - const int inputModeWidth = 60; - private NumericTextField numericEditor; public NumericTextField NumericEditor { get { return this.numericEditor; } @@ -203,7 +197,7 @@ namespace Xamarin.PropertyEditing.Mac this.numericEditor = new NumericTextField { Alignment = NSTextAlignment.Right, TranslatesAutoresizingMaskIntoConstraints = false, - Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize), + Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)), ControlSize = NSControlSize.Small, Formatter = this.formatter }; @@ -221,18 +215,20 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (this.decrementButton); this.AddConstraints (new[] { - NSLayoutConstraint.Create (this.numericEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, -(StepperWidth + StepperSpace + 1)), - NSLayoutConstraint.Create (this.numericEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight - 3), + NSLayoutConstraint.Create (this.numericEditor, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0), + NSLayoutConstraint.Create (this.numericEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), - NSLayoutConstraint.Create (this.incrementButton, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.numericEditor, NSLayoutAttribute.Top, 1f, 0f), - NSLayoutConstraint.Create (this.incrementButton, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.numericEditor, NSLayoutAttribute.Right, 1f, StepperSpace), + NSLayoutConstraint.Create (this.incrementButton, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.numericEditor, NSLayoutAttribute.Top, 1f, 0f), + NSLayoutConstraint.Create (this.incrementButton, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.numericEditor, NSLayoutAttribute.Right, 1f, StepperSpace), + NSLayoutConstraint.Create (this.incrementButton, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0), NSLayoutConstraint.Create (this.incrementButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, StepperWidth), - NSLayoutConstraint.Create (this.incrementButton, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, stepperTopHeight), + NSLayoutConstraint.Create (this.incrementButton, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, StepperTopHeight), - NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.numericEditor, NSLayoutAttribute.Top, 1f, stepperTopHeight), + NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.numericEditor, NSLayoutAttribute.Top, 1f, StepperTopHeight), + NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0), NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.numericEditor, NSLayoutAttribute.Right, 1f, StepperSpace), NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, StepperWidth), - NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, stepperBotHeight), + NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, StepperBotHeight), }); } @@ -296,6 +292,11 @@ namespace Xamarin.PropertyEditing.Mac return (double)Decimal.Round ((decimal)(value < MinimumValue ? MinimumValue : value > MaximumValue ? MaximumValue : value), Digits); } + private const int StepperSpace = 2; + private const int StepperWidth = 11; + private const int StepperTopHeight = 9; + private const int StepperBotHeight = 10; + private readonly IHostResourceProvider hostResources; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs index 012fbc7..31055ab 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs @@ -9,7 +9,7 @@ namespace Xamarin.PropertyEditing.Mac public class PropertyButton : UnfocusableButton { - public const int DefaultSize = 20; + public const int DefaultSize = 6; NSMenu popUpContextMenu; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs index 5f9dfab..c449d66 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs @@ -65,7 +65,7 @@ namespace Xamarin.PropertyEditing.Mac Bordered = false, ControlSize = NSControlSize.Small, Editable = false, - Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultPropertyLabelFontSize), + Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)), Selectable = false, TranslatesAutoresizingMaskIntoConstraints = false, }; |