diff options
author | Dominique Louis <dominique@yen-x1-31.fareast.corp.microsoft.com> | 2018-12-02 11:36:19 +0300 |
---|---|---|
committer | Dominique Louis <dominique@yen-x1-31.fareast.corp.microsoft.com> | 2018-12-02 11:52:09 +0300 |
commit | 2f16fd1451e3e7c9adcca9fe852fe767834468be (patch) | |
tree | 071efa534ea30fa170ea1201bde9c01f053ad496 /Xamarin.PropertyEditing.Mac/Controls/Custom | |
parent | 794123986062cb0a8ab2885bbb449bb62f9f13ad (diff) |
[Mac] Remove DoConstraints dependency and use NSLayoutConstraint.Create calls directly. Should be slightly faster on startup.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom')
3 files changed, 29 insertions, 23 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs index 809da6d..f8f3c54 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs @@ -34,16 +34,17 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (viewTitle); - this.DoConstraints (new[] { - iconView.ConstraintTo (this, (iv, c) => iv.Top == c.Top + 5), - iconView.ConstraintTo (this, (iv, c) => iv.Left == c.Left + 5), - iconView.ConstraintTo (this, (iv, c) => iv.Width == DefaultIconButtonSize), - iconView.ConstraintTo (this, (iv, c) => iv.Height == DefaultIconButtonSize), - - viewTitle.ConstraintTo (this, (vt, c) => vt.Top == c.Top + 8), - viewTitle.ConstraintTo (this, (vt, c) => vt.Left == c.Left + 38), - viewTitle.ConstraintTo (this, (vt, c) => vt.Width == 120), - viewTitle.ConstraintTo (this, (vt, c) => vt.Height == 24), + this.AddConstraints (new[] { + NSLayoutConstraint.Create (iconView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 5f), + NSLayoutConstraint.Create (iconView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 5f), + NSLayoutConstraint.Create (iconView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, DefaultIconButtonSize), + NSLayoutConstraint.Create (iconView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultIconButtonSize), + + NSLayoutConstraint.Create (viewTitle, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 7f), + 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), }); Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs index 8707e6b..f1c3c7c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs @@ -215,19 +215,19 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (incrementButton); AddSubview (decrementButton); - this.DoConstraints (new[] { - numericEditor.ConstraintTo (this, (n, c) => n.Width == c.Width - (stepperWidth + stepperSpace + 1)), - numericEditor.ConstraintTo (this, (n, c) => n.Height == PropertyEditorControl.DefaultControlHeight - 3), - - incrementButton.ConstraintTo (numericEditor, (s, n) => s.Left == n.Right + stepperSpace), - incrementButton.ConstraintTo (numericEditor, (s, n) => s.Top == n.Top), - incrementButton.ConstraintTo (numericEditor, (s, n) => s.Width == stepperWidth), - incrementButton.ConstraintTo (numericEditor, (s, n) => s.Height == stepperTopHeight), - - decrementButton.ConstraintTo (numericEditor, (s, n) => s.Left == n.Right + stepperSpace), - decrementButton.ConstraintTo (numericEditor, (s, n) => s.Top == n.Top + stepperTopHeight), - decrementButton.ConstraintTo (numericEditor, (s, n) => s.Width == stepperWidth), - decrementButton.ConstraintTo (numericEditor, (s, n) => s.Height == stepperBotHeight), + 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.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.Width, NSLayoutRelation.Equal, 1f, stepperWidth), + 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.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), }); PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs index 5636bc8..d3abc2a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs @@ -33,6 +33,11 @@ namespace Xamarin.PropertyEditing.Mac internal set { this.label.StringValue = value; } } + public NSColor TextColor { + get { return this.label.TextColor; } + internal set { this.label.TextColor = value; } + } + public UnfocusableTextField () { SetDefaultTextProperties (); |