Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs44
1 files changed, 25 insertions, 19 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs
index 7af5487..c049c42 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs
@@ -41,11 +41,13 @@ namespace Xamarin.PropertyEditing.Mac
AddSubview (NumericEditor);
- this.numericEditorWidthConstraint = NSLayoutConstraint.Create (NumericEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, -32f);
+ this.editorRightConstraint = NSLayoutConstraint.Create (NumericEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0);
this.AddConstraints (new[] {
- NSLayoutConstraint.Create (NumericEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 1f),
- this.numericEditorWidthConstraint,
+ NSLayoutConstraint.Create (NumericEditor, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0),
+ NSLayoutConstraint.Create (NumericEditor, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1, 0),
+ this.editorRightConstraint,
+ NSLayoutConstraint.Create (NumericEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, -6),
});
}
@@ -69,13 +71,6 @@ namespace Xamarin.PropertyEditing.Mac
}
}
- private Type underlyingType;
-
- internal NSPopUpButton inputModePopup;
- private IReadOnlyList<InputMode> viewModelInputModes;
-
- private NSLayoutConstraint numericEditorWidthConstraint;
-
protected override void UpdateErrorsDisplayed (IEnumerable errors)
{
if (ViewModel.HasErrors) {
@@ -140,9 +135,12 @@ namespace Xamarin.PropertyEditing.Mac
if (ViewModel == null)
return;
+ this.editorRightConstraint.Active = !ViewModel.HasInputModes;
if (ViewModel.HasInputModes) {
if (this.inputModePopup == null) {
this.inputModePopup = new FocusablePopUpButton {
+ ControlSize = NSControlSize.Small,
+ Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)),
Menu = new NSMenu (),
TranslatesAutoresizingMaskIntoConstraints = false,
};
@@ -153,12 +151,13 @@ namespace Xamarin.PropertyEditing.Mac
};
AddSubview (this.inputModePopup);
-
+ this.editorInputModeConstraint = NSLayoutConstraint.Create (NumericEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.inputModePopup, NSLayoutAttribute.Left, 1, -4);
this.AddConstraints (new[] {
- NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 1f),
- NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, -33f),
+ this.editorInputModeConstraint,
+ NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
+ NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0f),
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, 80f),
- NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultControlHeight - 3 ),
+ NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Height, NSLayoutRelation.Equal, NumericEditor, NSLayoutAttribute.Height, 1f, 0),
});
}
@@ -167,17 +166,24 @@ namespace Xamarin.PropertyEditing.Mac
foreach (InputMode item in this.viewModelInputModes) {
this.inputModePopup.Menu.AddItem (new NSMenuItem (item.Identifier));
}
-
- this.numericEditorWidthConstraint.Constant = -117f; // Shorten the stringEditor if we have Inputmodes Showing.
- } else {
- this.numericEditorWidthConstraint.Constant = -32f; // Lengthen the stringEditor if we have Inputmodes Hidden.
}
// If we are reusing the control we'll have to hid the inputMode if this doesn't have InputMode.
- if (this.inputModePopup != null)
+ if (this.inputModePopup != null) {
this.inputModePopup.Hidden = !ViewModel.HasInputModes;
+ this.editorInputModeConstraint.Active = ViewModel.HasInputModes;
+ }
SetEnabled ();
}
+
+ private Type underlyingType;
+
+ internal NSPopUpButton inputModePopup;
+ private IReadOnlyList<InputMode> viewModelInputModes;
+
+ private readonly NSLayoutConstraint editorRightConstraint;
+ private NSLayoutConstraint editorInputModeConstraint;
}
}
+