Skip to content
This repository was archived by the owner on Sep 25, 2024. It is now read-only.

Commit 3afcf89

Browse files
committed
[Mac] Tweaks for a more consistent UX
1 parent c381468 commit 3afcf89

11 files changed

+40
-31
lines changed

Diff for: Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ public CollectionInlineEditorControl (IHostResourceProvider hostResources)
3232
AddSubview (this.openCollection);
3333

3434
AddConstraints (new[] {
35-
NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0),
35+
NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1, 0),
3636
NSLayoutConstraint.Create (this.label, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1, 0),
3737
NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, 0),
38-
NSLayoutConstraint.Create (this.openCollection, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this.label, NSLayoutAttribute.Trailing, 1, 12),
38+
NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.openCollection, NSLayoutAttribute.Left, 1, -4),
39+
40+
NSLayoutConstraint.Create (this.openCollection, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0),
3941
NSLayoutConstraint.Create (this.openCollection, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1, 0),
40-
NSLayoutConstraint.Create (this.openCollection, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, 1, 70),
41-
NSLayoutConstraint.Create (this.openCollection, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, -6)
42+
NSLayoutConstraint.Create (this.openCollection, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, DefaultButtonWidth),
4243
});
4344

4445
AppearanceChanged ();

Diff for: Xamarin.PropertyEditing.Mac/Controls/Custom/FocusablePopupButton.cs

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ internal class FocusablePopUpButton : NSPopUpButton
88
{
99
public override bool CanBecomeKeyView { get { return Enabled; } }
1010

11+
public FocusablePopUpButton ()
12+
{
13+
Cell.LineBreakMode = NSLineBreakMode.TruncatingMiddle;
14+
}
15+
1116
public override bool BecomeFirstResponder ()
1217
{
1318
var willBecomeFirstResponder = base.BecomeFirstResponder ();

Diff for: Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTextField.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal class PropertyTextField : NSTextField
88
public PropertyTextField ()
99
{
1010
AllowsExpansionToolTips = true;
11-
Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
11+
Cell.LineBreakMode = NSLineBreakMode.TruncatingMiddle;
1212
Cell.UsesSingleLineMode = true;
1313
}
1414

@@ -26,7 +26,7 @@ internal class PropertyTextFieldCell : NSTextFieldCell
2626
{
2727
public PropertyTextFieldCell ()
2828
{
29-
LineBreakMode = NSLineBreakMode.TruncatingTail;
29+
LineBreakMode = NSLineBreakMode.TruncatingMiddle;
3030
UsesSingleLineMode = true;
3131
}
3232
}

Diff for: Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,11 @@ protected override void OnViewModelChanged (PropertyViewModel oldModel)
136136

137137
AddSubview (this.inputModePopup);
138138
this.editorInputModeConstraint = NSLayoutConstraint.Create (NumericEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.inputModePopup, NSLayoutAttribute.Left, 1, -4);
139-
this.AddConstraints (new[] {
139+
AddConstraints (new[] {
140140
this.editorInputModeConstraint,
141141
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
142142
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0f),
143-
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, 80f),
144-
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Height, NSLayoutRelation.Equal, NumericEditor, NSLayoutAttribute.Height, 1f, 0),
143+
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, DefaultButtonWidth),
145144
});
146145
}
147146

Diff for: Xamarin.PropertyEditing.Mac/Controls/ObjectEditorControl.cs

+7-9
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ public ObjectEditorControl (IHostResourceProvider hostResources)
2626
this.createObject.Activated += OnNewPressed;
2727
AddSubview (this.createObject);
2828

29-
this.buttonConstraint = NSLayoutConstraint.Create (this.createObject, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this.typeLabel, NSLayoutAttribute.Trailing, 1f, 12);
29+
//this.buttonConstraint = NSLayoutConstraint.Create (this.createObject, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this.typeLabel, NSLayoutAttribute.Trailing, 1f, 12);
3030

3131
AddConstraints (new[] {
32-
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1f, 0f),
32+
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f),
3333
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
3434
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, 0),
35-
this.buttonConstraint,
36-
NSLayoutConstraint.Create (this.createObject, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0).WithPriority (NSLayoutPriority.DefaultLow),
35+
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.createObject, NSLayoutAttribute.Left, 1, -4),
36+
37+
NSLayoutConstraint.Create (this.createObject, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0),
3738
NSLayoutConstraint.Create (this.createObject, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
38-
NSLayoutConstraint.Create (this.createObject, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, 1f, 70f),
39+
NSLayoutConstraint.Create (this.createObject, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, DefaultButtonWidth),
3940
});
4041
}
4142

@@ -93,7 +94,6 @@ protected override void OnPropertyChanged (object sender, PropertyChangedEventAr
9394

9495
private readonly UnfocusableTextField typeLabel;
9596
private readonly NSButton createObject;
96-
private readonly NSLayoutConstraint buttonConstraint;
9797

9898
private void OnCreateInstanceExecutableChanged (object sender, EventArgs e)
9999
{
@@ -108,11 +108,9 @@ private void OnTypeRequested (object sender, TypeRequestedEventArgs e)
108108
private void UpdateTypeLabel ()
109109
{
110110
if (ViewModel.ValueType == null) {
111-
this.typeLabel.StringValue = String.Empty;
112-
this.buttonConstraint.Active = false;
111+
this.typeLabel.StringValue = $"({Properties.Resources.ObjectTypeLabelNone})";
113112
} else {
114113
this.typeLabel.StringValue = $"({ViewModel.ValueType.Name})";
115-
this.buttonConstraint.Active = true;
116114
}
117115
}
118116

Diff for: Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public IHostResourceProvider HostResources
3333
public const int DefaultPropertyLabelFontSize = 11;
3434
public const int DefaultDescriptionLabelFontSize = 9;
3535
public const string DefaultFontName = ".AppleSystemUIFont";
36+
public const float DefaultButtonWidth = 70f;
3637
public virtual bool IsDynamicallySized => false;
3738

3839
PropertyViewModel viewModel;

Diff for: Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected override void OnViewModelChanged (PropertyViewModel oldModel)
5959
this.editorInputModeConstraint,
6060
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
6161
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0),
62-
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, 80f),
62+
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, DefaultButtonWidth),
6363
NSLayoutConstraint.Create (this.inputModePopup, NSLayoutAttribute.Height, NSLayoutRelation.Equal, Entry, NSLayoutAttribute.Height, 1, 0),
6464
});
6565

Diff for: Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs

+7-11
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,21 @@ public TypeEditorControl (IHostResourceProvider hostResources)
2020
AddSubview (this.typeLabel);
2121

2222
this.selectType = new FocusableButton {
23+
BezelStyle = NSBezelStyle.Rounded,
2324
Title = Properties.Resources.Select,
24-
BezelStyle = NSBezelStyle.Rounded
2525
};
2626
this.selectType.Activated += OnSelectPressed;
2727
AddSubview (this.selectType);
2828

29-
this.buttonConstraint = NSLayoutConstraint.Create (this.selectType, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this.typeLabel, NSLayoutAttribute.Trailing, 1f, 12);
30-
3129
AddConstraints (new[] {
32-
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1f, 0f),
30+
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f),
3331
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
3432
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, 0),
35-
this.buttonConstraint,
36-
NSLayoutConstraint.Create (this.selectType, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0).WithPriority (NSLayoutPriority.DefaultLow),
33+
NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.selectType, NSLayoutAttribute.Left, 1, -4),
34+
35+
NSLayoutConstraint.Create (this.selectType, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0),
3736
NSLayoutConstraint.Create (this.selectType, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
38-
NSLayoutConstraint.Create (this.selectType, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, 1f, 70f),
37+
NSLayoutConstraint.Create (this.selectType, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, DefaultButtonWidth),
3938
});
4039
}
4140

@@ -91,7 +90,6 @@ protected override void OnPropertyChanged (object sender, PropertyChangedEventAr
9190

9291
private readonly UnfocusableTextField typeLabel;
9392
private readonly NSButton selectType;
94-
private readonly NSLayoutConstraint buttonConstraint;
9593

9694
private void OnTypeRequested (object sender, TypeRequestedEventArgs e)
9795
{
@@ -101,11 +99,9 @@ private void OnTypeRequested (object sender, TypeRequestedEventArgs e)
10199
private void UpdateTypeLabel ()
102100
{
103101
if (ViewModel.Value == null) {
104-
this.typeLabel.StringValue = String.Empty;
105-
this.buttonConstraint.Active = false;
102+
this.typeLabel.StringValue = $"({Properties.Resources.ObjectTypeLabelNone})";
106103
} else {
107104
this.typeLabel.StringValue = $"({ViewModel.Value.Name})";
108-
this.buttonConstraint.Active = true;
109105
}
110106
}
111107

Diff for: Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private void Initialize ()
191191
NSLayoutConstraint.Create (this.tabStack, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Bottom, 1, 0),
192192
NSLayoutConstraint.Create (this.tabStack, NSLayoutAttribute.Right, NSLayoutRelation.LessThanOrEqual, this.propertyFilter, NSLayoutAttribute.Left, 1, 0),
193193

194-
NSLayoutConstraint.Create (this.propertyFilter, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Right, 1, -15),
194+
NSLayoutConstraint.Create (this.propertyFilter, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Right, 1, -19),
195195
NSLayoutConstraint.Create (this.propertyFilter, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, 150),
196196
NSLayoutConstraint.Create (this.propertyFilter, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.CenterY, 1, 0),
197197

Diff for: Xamarin.PropertyEditing/Properties/Resources.Designer.cs

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Xamarin.PropertyEditing/Properties/Resources.resx

+3
Original file line numberDiff line numberDiff line change
@@ -1036,5 +1036,8 @@
10361036
<data name="AccessibilityBindingAddValueConverterCancel" xml:space="preserve">
10371037
<value>This button will cancel the changes you have made in the Add Value Converter Editor.</value>
10381038
<comment>Text to inform the user that this button will cancel the changes you have made in the Add Value Converter Editor</comment>
1039+
</data>
1040+
<data name="ObjectTypeLabelNone" xml:space="preserve">
1041+
<value>None</value>
10391042
</data>
10401043
</root>

0 commit comments

Comments
 (0)