diff options
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
23 files changed, 152 insertions, 118 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs index 69cbb5f..dd32a50 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs @@ -17,33 +17,30 @@ namespace Xamarin.PropertyEditing.Mac public override NSView FirstKeyView => XEditor; public override NSView LastKeyView => YEditor.DecrementButton; - public BasePointEditorControl () + protected BasePointEditorControl () { XLabel = new UnfocusableTextField (); - XEditor = new NumericSpinEditor<T> (); - XEditor.BackgroundColor = NSColor.Clear; - XEditor.Value = 0.0f; + XEditor = new NumericSpinEditor<T> { + BackgroundColor = NSColor.Clear, + Value = 0.0f + }; XEditor.ValueChanged += OnInputUpdated; - XLabel.AccessibilityElement = false; - YLabel = new UnfocusableTextField (); - YEditor = new NumericSpinEditor<T> (); - YEditor.BackgroundColor = NSColor.Clear; - YEditor.Value = 0.0f; + YEditor = new NumericSpinEditor<T> { + BackgroundColor = NSColor.Clear, + Value = 0.0f + }; YEditor.ValueChanged += OnInputUpdated; - YLabel.AccessibilityElement = false; - AddSubview (XLabel); AddSubview (XEditor); AddSubview (YLabel); AddSubview (YEditor); this.DoConstraints (new[] { - XEditor.ConstraintTo (this, (xe, c) => xe.Left == xe.Left - 1), XEditor.ConstraintTo (this, (xe, c) => xe.Width == 90), XEditor.ConstraintTo (this, (xe, c) => xe.Height == DefaultControlHeight), YEditor.ConstraintTo (this, (ye, c) => ye.Width == 90), diff --git a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs index 1c57694..b9deb09 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs @@ -23,7 +23,7 @@ namespace Xamarin.PropertyEditing.Mac public override NSView FirstKeyView => XEditor; public override NSView LastKeyView => HeightEditor.DecrementButton; - public BaseRectangleEditorControl () + protected BaseRectangleEditorControl () { XLabel = new UnfocusableTextField (); XEditor = new NumericSpinEditor<T> (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs index a7d541f..b0d5986 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs @@ -35,7 +35,7 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (BooleanEditor); - this.DoConstraints (new[] { + this.DoConstraints (new[] { BooleanEditor.ConstraintTo (this, (be, c) => be.Width == c.Width - 50), BooleanEditor.ConstraintTo (this, (be, c) => be.Top == c.Top + 6), }); diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index 4d6f5d8..c64fd08 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -61,7 +61,6 @@ namespace Xamarin.PropertyEditing.Mac this.popUpButton.ConstraintTo (this, (pub, c) => pub.Width == c.Width - 33), this.popUpButton.ConstraintTo (this, (pub, c) => pub.Height == DefaultControlHeight), this.popUpButton.ConstraintTo (this, (pub, c) => pub.Top == c.Top + 0), - this.popUpButton.ConstraintTo (this, (pub, c) => pub.Left == c.Left - 1), }); AddSubview (this.popUpButton); diff --git a/Xamarin.PropertyEditing.Mac/Controls/ConstraintExtensions.cs b/Xamarin.PropertyEditing.Mac/Controls/ConstraintExtensions.cs index b08f48c..21ebe29 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/ConstraintExtensions.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/ConstraintExtensions.cs @@ -85,7 +85,7 @@ namespace Xamarin.PropertyEditing.Mac propRight = (NSLayoutAttribute)Enum.Parse (typeof (NSLayoutAttribute), member.Member.Name); } - //Console.WriteLine ("v1.{0} {1} v2.{2} * {3} + {4}", propLeft, relation, propRight, multiplier, constant); + // Console.WriteLine ("NSLayoutConstraint.Create ({0}, {1}, {2}, {3}, {4}, {5}, {6});", view1, propLeft, relation, view2, propRight, multiplier, constant); return NSLayoutConstraint.Create (view1, propLeft, relation, view2, propRight, multiplier, constant); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs index e519d21..809da6d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs @@ -26,10 +26,10 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (iconView); - var viewTitle = new UnfocusableTextField () { + var viewTitle = new UnfocusableTextField { + Font = NSFont.BoldSystemFontOfSize (11), StringValue = title, TranslatesAutoresizingMaskIntoConstraints = false, - Font = NSFont.BoldSystemFontOfSize (11) }; AddSubview (viewTitle); @@ -40,7 +40,7 @@ namespace Xamarin.PropertyEditing.Mac 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 + 10), + 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), diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs index 3349190..9171e2b 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs @@ -49,7 +49,6 @@ namespace Xamarin.PropertyEditing.Mac Label = new UnfocusableTextField { StringValue = $"{editor.Name}:", Alignment = NSTextAlignment.Right, - BackgroundColor = NSColor.Clear, ToolTip = editor.ToolTip }, Editor = new ComponentSpinEditor (editor) { @@ -116,14 +115,12 @@ namespace Xamarin.PropertyEditing.Mac this.hexLabel = new UnfocusableTextField { StringValue = "#:", Alignment = NSTextAlignment.Right, - BackgroundColor = NSColor.Clear, ToolTip = Properties.Resources.HexValue }; AddSubview (this.hexLabel); this.hexEditor = new NSTextField { Alignment = NSTextAlignment.Right, - BackgroundColor = NSColor.Clear }; AddSubview (this.hexEditor); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs index 786f148..4cf164f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs @@ -66,19 +66,12 @@ namespace Xamarin.PropertyEditing.Mac Orientation = NSUserInterfaceLayoutOrientation.Horizontal }; - var alphaLabel = new NSTextField { - Bordered = false, - Editable = false, - Selectable = false, - ControlSize = NSControlSize.Small, - Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultPropertyLabelFontSize), - AccessibilityElement = false, + var alphaLabel = new UnfocusableTextField { StringValue = $"{Properties.Resources.Alpha}:", Alignment = NSTextAlignment.Left, - BackgroundColor = NSColor.Clear, }; - alphaLabel.Cell.UsesSingleLineMode = true; alphaLabel.Cell.LineBreakMode = NSLineBreakMode.Clipping; + alphaStack.AddView (alphaLabel, NSStackViewGravity.Trailing); alphaStack.AddView (alphaSpinEditor, NSStackViewGravity.Trailing); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs index 4a29941..4df996b 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs @@ -37,7 +37,6 @@ namespace Xamarin.PropertyEditing.Mac var utf = (UnfocusableTextField)outlineView.MakeView (labelIdentifier, this); if (utf == null) { utf = new UnfocusableTextField { - BackgroundColor = NSColor.Clear, Identifier = labelIdentifier, }; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs index 97d26b9..5636bc8 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs @@ -1,35 +1,100 @@ using System; -using System.Collections; -using System.ComponentModel; using AppKit; using CoreGraphics; namespace Xamarin.PropertyEditing.Mac { - class UnfocusableTextField : NSTextField + internal class UnfocusableTextField : NSView { - public UnfocusableTextField () : base () + private NSTextField label; + + public NSTextAlignment Alignment { + get { return this.label.Alignment; } + internal set { this.label.Alignment = value; } + } + + public NSColor BackgroundColor { + get { return this.label.BackgroundColor; } + internal set { this.label.BackgroundColor = value; } + } + + public NSTextFieldCell Cell { + get { return this.label.Cell; } + internal set { this.label.Cell = value; } + } + + public NSFont Font { + get { return this.label.Font; } + internal set { this.label.Font = value; } + } + + public string StringValue { + get { return this.label.StringValue; } + internal set { this.label.StringValue = value; } + } + + public UnfocusableTextField () { - SetDefaultProperties (); + SetDefaultTextProperties (); + SetTheming (); } public UnfocusableTextField (CGRect frameRect, string text) : base (frameRect) { + SetDefaultTextProperties (); + SetTheming (); + StringValue = text; - SetDefaultProperties (); } - void SetDefaultProperties () + protected override void Dispose (bool disposing) + { + if (disposing) { + PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged; + } + } + + private void SetDefaultTextProperties () + { + this.label = new NSTextField { + AccessibilityElement = false, + BackgroundColor = NSColor.Clear, + Bordered = false, + Cell = { + LineBreakMode = NSLineBreakMode.TruncatingTail, + UsesSingleLineMode = true, + }, + ControlSize = NSControlSize.Small, + Editable = false, + Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultPropertyLabelFontSize), + Selectable = false, + TranslatesAutoresizingMaskIntoConstraints = false, + }; + + AddSubview (this.label); + + AddConstraints (new[] { + NSLayoutConstraint.Create (this, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this.label, NSLayoutAttribute.CenterY, 1f, 0f), + NSLayoutConstraint.Create (this, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this.label, NSLayoutAttribute.Leading, 1f, 0f), + NSLayoutConstraint.Create (this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this.label, NSLayoutAttribute.Trailing, 1f, 0f) + }); + } + + private void SetTheming () + { + PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; + + UpdateTheme (); + } + + private void ThemeManager_ThemeChanged (object sender, EventArgs e) + { + UpdateTheme (); + } + + protected void UpdateTheme () { - AccessibilityElement = false; - Bordered = false; - Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; - Cell.UsesSingleLineMode = true; - ControlSize = NSControlSize.Small; - Editable = false; - Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultPropertyLabelFontSize); - Selectable = false; - BackgroundColor = NSColor.Clear; + Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; } } }
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs b/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs index e91a3df..9b4dc19 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs @@ -11,10 +11,11 @@ namespace Xamarin.PropertyEditing.Mac EditorView = editorView; AddSubview (this.label); + this.AddConstraints (new[] { - NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 4f), + NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 0f), NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, Mac.Layout.GoldenRatioLeft, 0f), - NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f), + NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight), }); if (EditorView != null) { diff --git a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs index 27206d5..337cdf9 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs @@ -41,7 +41,6 @@ namespace Xamarin.PropertyEditing.Mac this.DoConstraints ( new[] { NumericEditor.ConstraintTo (this, (n, c) => n.Top == c.Top + 1), NumericEditor.ConstraintTo (this, (n, c) => n.Width == c.Width - 32), - NumericEditor.ConstraintTo (this, (n, c) => n.Left == c.Left - 1), }); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs index c183b6e..d1d9dfa 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs @@ -53,14 +53,14 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (this.propertyIcon); this.AddConstraints (new[] { - NSLayoutConstraint.Create (this.propertyIcon, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, 32), NSLayoutConstraint.Create (this.propertyIcon, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 32), NSLayoutConstraint.Create (this.propertyIcon, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 5), NSLayoutConstraint.Create (this.propertyIcon, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1, 32), - NSLayoutConstraint.Create (this.objectNameLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 5), + NSLayoutConstraint.Create (this.objectNameLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 0), NSLayoutConstraint.Create (this.objectNameLabel, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, Mac.Layout.GoldenRatioLeft, 0f), + NSLayoutConstraint.Create (this.objectNameLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight), NSLayoutConstraint.Create (this.propertyObjectName, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this.objectNameLabel, NSLayoutAttribute.CenterY, 1, 0), NSLayoutConstraint.Create (this.propertyObjectName, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.objectNameLabel, NSLayoutAttribute.Right, 1, 4.5f), @@ -68,10 +68,12 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.propertyObjectName, NSLayoutAttribute.Bottom, 1, 5), NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, Mac.Layout.GoldenRatioLeft, 0f), + NSLayoutConstraint.Create (this.typeLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight), NSLayoutConstraint.Create (this.typeDisplay, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.typeLabel, NSLayoutAttribute.Top, 1, 0), NSLayoutConstraint.Create (this.typeDisplay, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this.propertyObjectName, NSLayoutAttribute.Width, 1, 0), - NSLayoutConstraint.Create (this.typeDisplay, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.typeLabel, NSLayoutAttribute.Right, 1, 4) + NSLayoutConstraint.Create (this.typeDisplay, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.typeLabel, NSLayoutAttribute.Right, 1, 4), + NSLayoutConstraint.Create (this.typeDisplay, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight), }); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs index d087545..9c56a89 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs @@ -12,13 +12,13 @@ namespace Xamarin.PropertyEditing.Mac { public PointEditorControl () { - XLabel.Frame = new CGRect (34, -10, 25, 22); + XLabel.Frame = new CGRect (34, -5, 25, 22); XLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs XLabel.StringValue = "X"; // TODO Localise XEditor.Frame = new CGRect (0, 13, 90, 20); - YLabel.Frame = new CGRect (166, -10, 25, 22); + YLabel.Frame = new CGRect (166, -5, 25, 22); YLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs YLabel.StringValue = "Y"; // TODO Localise diff --git a/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs index 5c3b667..b44d516 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs @@ -95,10 +95,9 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (this.popUpButton); this.DoConstraints (new[] { - this.popUpButton.ConstraintTo (this, (pub, c) => pub.Width == c.Width - 34), + this.popUpButton.ConstraintTo (this, (pub, c) => pub.Width == c.Width - 33), this.popUpButton.ConstraintTo (this, (pub, c) => pub.Height == DefaultControlHeight + 1), this.popUpButton.ConstraintTo (this, (pub, c) => pub.Top == pub.Top + 0), - this.popUpButton.ConstraintTo (this, (pub, c) => pub.Left == pub.Left + 1), }); this.firstKeyView = this.popUpButton; @@ -117,7 +116,7 @@ namespace Xamarin.PropertyEditing.Mac this.comboBox.ConstraintTo (this, (cb, c) => cb.Width == c.Width - 34), this.comboBox.ConstraintTo (this, (cb, c) => cb.Height == DefaultControlHeight), this.comboBox.ConstraintTo (this, (cb, c) => cb.Top == cb.Top + 0), - this.comboBox.ConstraintTo (this, (cb, c) => cb.Left == cb.Left - 1), + this.comboBox.ConstraintTo (this, (cb, c) => cb.Left == cb.Left + 0), }); this.firstKeyView = this.comboBox; diff --git a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs index 8a724a7..ac305fd 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs @@ -33,7 +33,6 @@ namespace Xamarin.PropertyEditing.Mac this.DoConstraints (new[] { this.ratioEditor.ConstraintTo (this, (re, c) => re.Top == c.Top - 2), - this.ratioEditor.ConstraintTo (this, (re, c) => re.Left == c.Left - 1), this.ratioEditor.ConstraintTo (this, (re, c) => re.Width == c.Width - 32), this.ratioEditor.ConstraintTo (this, (re, c) => re.Height == DefaultControlHeight), }); diff --git a/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs index e91a76d..43a52e9 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs @@ -9,28 +9,28 @@ namespace Xamarin.PropertyEditing.Mac { internal abstract class RectangleEditorControl<T>: BaseRectangleEditorControl<T> { - public RectangleEditorControl () + protected RectangleEditorControl () { // TODO localize - XLabel.Frame = new CGRect (34, 23, 25, 22); + XLabel.Frame = new CGRect (34, 28, 25, 22); XLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs XLabel.StringValue = "X"; - XEditor.Frame = new CGRect (-1, 46, 90, 20); + XEditor.Frame = new CGRect (0, 46, 90, 20); - YLabel.Frame = new CGRect (166, 23, 25, 22); + YLabel.Frame = new CGRect (166, 28, 25, 22); YLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs YLabel.StringValue = "Y"; YEditor.Frame = new CGRect (132, 46, 90, 20); - WidthLabel.Frame = new CGRect (20, -10, 50, 22); + WidthLabel.Frame = new CGRect (20, -5, 50, 22); WidthLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs WidthLabel.StringValue = "WIDTH"; - WidthEditor.Frame = new CGRect (-1, 13, 90, 20); + WidthEditor.Frame = new CGRect (0, 13, 90, 20); - HeightLabel.Frame = new CGRect (150, -10, 50, 22); + HeightLabel.Frame = new CGRect (150, -5, 50, 22); HeightLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs HeightLabel.StringValue = "HEIGHT"; diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePreviewPanel.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePreviewPanel.cs index 8e46150..aab5ae5 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePreviewPanel.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePreviewPanel.cs @@ -8,33 +8,28 @@ namespace Xamarin.PropertyEditing.Mac { internal class RequestResourcePreviewPanel : NSView { - private NSTextField noPreviewAvailable; + private UnfocusableTextField noPreviewAvailable; private NSView previewView; private Resource selectedResource; - public Resource SelectedResource - { - internal get - { - return selectedResource; - } + public Resource SelectedResource { + internal get { return this.selectedResource; } - set - { - if (selectedResource != value) { - selectedResource = value; + set { + if (this.selectedResource != value) { + this.selectedResource = value; - if (selectedResource != null) { + if (this.selectedResource != null) { // Let's find the next View - var pView = GetPreviewView (selectedResource); + var pView = GetPreviewView (this.selectedResource); if (pView == null) { ShowNoPreviewText (); } else { - noPreviewAvailable.Hidden = true; - previewView.Hidden = false; + this.noPreviewAvailable.Hidden = true; + this.previewView.Hidden = false; - switch (selectedResource) { + switch (this.selectedResource) { case Resource<CommonColor> colour: if (pView is CommonBrushView cc) { cc.Brush = new CommonSolidBrush (colour.Value); @@ -55,11 +50,11 @@ namespace Xamarin.PropertyEditing.Mac } // Only 1 subview allowed (must be a better way to handle this??) - if (previewView.Subviews.Count () > 0) { - previewView.Subviews[0].RemoveFromSuperview (); + if (this.previewView.Subviews.Count () > 0) { + this.previewView.Subviews[0].RemoveFromSuperview (); } // Free up anything from the previous view - previewView.AddSubview (pView); + this.previewView.AddSubview (pView); } } else { ShowNoPreviewText (); @@ -70,8 +65,8 @@ namespace Xamarin.PropertyEditing.Mac private void ShowNoPreviewText () { - noPreviewAvailable.Hidden = false; - previewView.Hidden = true; + this.noPreviewAvailable.Hidden = false; + this.previewView.Hidden = true; } public RequestResourcePreviewPanel (CGRect frame) : base (frame) @@ -80,17 +75,17 @@ namespace Xamarin.PropertyEditing.Mac var FrameWidthHalf = (Frame.Width - 32) / 2; var FrameWidthThird = (Frame.Width - 32) / 3; - noPreviewAvailable = new UnfocusableTextField { - BackgroundColor = NSColor.Clear, + this.noPreviewAvailable = new UnfocusableTextField { StringValue = Properties.Resources.NoPreviewAvailable, Frame = new CGRect (50, FrameHeightHalf, 150, 50), }; - AddSubview (noPreviewAvailable); + AddSubview (this.noPreviewAvailable); - previewView = new NSView (new CGRect (20, 0, frame.Width - 30, frame.Height)); - previewView.Hidden = true; // Hidden until a resource is selected and a preview is available for it. - AddSubview (previewView); + this.previewView = new NSView (new CGRect (20, 0, frame.Width - 30, frame.Height)) { + Hidden = true // Hidden until a resource is selected and a preview is available for it. + }; + AddSubview (this.previewView); } NSView GetPreviewView (Resource resource) @@ -120,7 +115,7 @@ namespace Xamarin.PropertyEditing.Mac { var view = (NSView)Activator.CreateInstance (previewRenderType); view.Identifier = previewRenderType.Name; - view.Frame = new CGRect (0, 0, previewView.Frame.Width, previewView.Frame.Height); + view.Frame = new CGRect (0, 0, this.previewView.Frame.Width, this.previewView.Frame.Height); return view; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs index 387e516..9ea3a19 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs @@ -54,7 +54,6 @@ namespace Xamarin.PropertyEditing.Mac if (typeView == null) { typeView = new UnfocusableTextField { Identifier = typeIdentifier, - BackgroundColor = NSColor.Clear, }; } @@ -65,7 +64,6 @@ namespace Xamarin.PropertyEditing.Mac var nameView = (UnfocusableTextField)tableView.MakeView (nameIdentifier, this); if (nameView == null) { nameView = new UnfocusableTextField { - BackgroundColor = NSColor.Clear, Identifier = nameIdentifier, }; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs index 56700f5..66120f4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs @@ -13,13 +13,13 @@ namespace Xamarin.PropertyEditing.Mac { public SizeEditorControl () { - XLabel.Frame = new CGRect (20, -10, 50, 22); + XLabel.Frame = new CGRect (20, -5, 50, 22); XLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs XLabel.StringValue = "WIDTH"; // TODO Localise XEditor.Frame = new CGRect (0, 13, 90, 20); - YLabel.Frame = new CGRect (150, -10, 50, 22); + YLabel.Frame = new CGRect (150, -5, 50, 22); YLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs YLabel.StringValue = "HEIGHT"; // TODO Localise diff --git a/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs index dd7564e..8b530b0 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs @@ -30,7 +30,6 @@ namespace Xamarin.PropertyEditing.Mac StringEditor.ConstraintTo (this, (s, c) => s.Width == c.Width - 34), StringEditor.ConstraintTo (this, (s, c) => s.Height == DefaultControlHeight - 3), StringEditor.ConstraintTo (this, (s, c) => s.Top == s.Top + 1), - StringEditor.ConstraintTo (this, (s, c) => s.Left == s.Left - 1), }); UpdateTheme (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs index 5c196b5..50fed48 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs @@ -11,25 +11,25 @@ namespace Xamarin.PropertyEditing.Mac { public CommonThicknessEditorControl () { - XLabel.Frame = new CGRect (28, 23, 50, 22); + XLabel.Frame = new CGRect (28, 28, 50, 22); XLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); XLabel.StringValue = "LEFT"; - XEditor.Frame = new CGRect (-1, 46, 90, 20); + XEditor.Frame = new CGRect (0, 46, 90, 20); - YLabel.Frame = new CGRect (160, 23, 45, 22); + YLabel.Frame = new CGRect (160, 28, 45, 22); YLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); YLabel.StringValue = "TOP"; YEditor.Frame = new CGRect (132, 46, 90, 20); - WidthLabel.Frame = new CGRect (24, -10, 50, 22); + WidthLabel.Frame = new CGRect (24, -5, 50, 22); WidthLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); WidthLabel.StringValue = "RIGHT"; - WidthEditor.Frame = new CGRect (-1, 13, 90, 20); + WidthEditor.Frame = new CGRect (0, 13, 90, 20); - HeightLabel.Frame = new CGRect (150, -10, 50, 22); + HeightLabel.Frame = new CGRect (150, -5, 50, 22); HeightLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); HeightLabel.StringValue = "BOTTOM"; diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs index 818d4ae..471d1d4 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs @@ -46,22 +46,14 @@ namespace Xamarin.PropertyEditing.Mac GetVMGroupCellItendifiterFromFacade (item, out evm, out group, out cellIdentifier); if (group != null) { - var labelContainer = outlineView.MakeView (LabelIdentifier, this); + var labelContainer = (UnfocusableTextField)outlineView.MakeView (LabelIdentifier, this); if (labelContainer == null) { - labelContainer = new NSView { Identifier = LabelIdentifier }; - var label = new UnfocusableTextField { - TranslatesAutoresizingMaskIntoConstraints = false + labelContainer = new UnfocusableTextField { + Identifier = LabelIdentifier, }; - - labelContainer.AddSubview (label); - labelContainer.AddConstraints (new[] { - NSLayoutConstraint.Create (labelContainer, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, label, NSLayoutAttribute.CenterY, 1f, 0f), - NSLayoutConstraint.Create (labelContainer, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, label, NSLayoutAttribute.Leading, 1f, 0f), - NSLayoutConstraint.Create (labelContainer, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, label, NSLayoutAttribute.Trailing, 1f, 0f) - }); } - ((UnfocusableTextField)labelContainer.Subviews[0]).StringValue = group.Key; + labelContainer.StringValue = group.Key; if (this.dataSource.DataContext.GetIsExpanded (group.Key)) { SynchronizationContext.Current.Post (s => { |