diff options
author | Dominique Louis <dominique@DIPRAJ1.northamerica.corp.microsoft.com> | 2019-04-29 13:06:38 +0300 |
---|---|---|
committer | Dominique Louis <dominique@DIPRAJ1.northamerica.corp.microsoft.com> | 2019-05-01 16:43:57 +0300 |
commit | 24f6af3d4526ba0c474fb4ea1664676a47bf7794 (patch) | |
tree | a7f9a53745172cd0fb56eff7985fb0e198c776b5 /Xamarin.PropertyEditing.Mac/Controls | |
parent | 40c2ea08e7c2796b73e464bda91353551a477e27 (diff) |
[Mac] Move appearance setting calls outside ViewDidChangeEffectiveApperance, so it works on earlier MacOS versions.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls')
13 files changed, 126 insertions, 59 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs index 142e9dd..dde6136 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs @@ -93,13 +93,6 @@ namespace Xamarin.PropertyEditing.Mac {
this.panel.BeginSheet (this.Window, HandleAction);
}
-
- public override void ViewDidChangeEffectiveAppearance () - {
- this.revealPathButton.Image = HostResources.GetNamedImage (PathRevealName);
- this.browsePathButton.Image = HostResources.GetNamedImage (PathBrowseName);
- base.ViewDidChangeEffectiveAppearance (); - }
protected abstract void OnRevealPathButtonActivated (object sender, EventArgs e); protected abstract void StoreCurrentValue ();
@@ -128,6 +121,14 @@ namespace Xamarin.PropertyEditing.Mac this.browsePathButton.Activated -= BrowsePathButton_Activated;
this.revealPathButton.Activated -= OnRevealPathButtonActivated; base.Dispose (disposing); + }
+
+ protected override void AppearanceChanged () + {
+ base.AppearanceChanged ();
+
+ this.revealPathButton.Image = HostResources.GetNamedImage (PathRevealName);
+ this.browsePathButton.Image = HostResources.GetNamedImage (PathBrowseName); } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs index e964340..e60f5f4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs @@ -68,13 +68,7 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (YLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, YEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), }); - ViewDidChangeEffectiveAppearance (); - } - - public override void ViewDidChangeEffectiveAppearance () - { - XLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); - YLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + AppearanceChanged (); } protected override void SetEnabled () @@ -96,5 +90,13 @@ namespace Xamarin.PropertyEditing.Mac { ViewModel.Value = (T)Activator.CreateInstance (typeof (T), XEditor.Value, YEditor.Value); } + + protected override void AppearanceChanged () + { + base.AppearanceChanged (); + + XLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + YLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs index d5e038c..005ef89 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs @@ -114,17 +114,7 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (HeightLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, HeightEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), }); - ViewDidChangeEffectiveAppearance (); - } - - public override void ViewDidChangeEffectiveAppearance () - { - XLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); - YLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); - WidthLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); - HeightLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); - - base.ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } protected virtual void OnInputUpdated (object sender, EventArgs e) @@ -154,5 +144,15 @@ namespace Xamarin.PropertyEditing.Mac HeightEditor.AccessibilityEnabled = HeightEditor.Enabled; HeightEditor.AccessibilityTitle = string.Format (Properties.Resources.AccessibilityHeightEditor, ViewModel.Property.Name); } + + protected override void AppearanceChanged () + { + base.AppearanceChanged (); + + XLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + YLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + WidthLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + HeightLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index cdae3b1..19b4750 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -69,15 +69,7 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.popUpButton, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0), }); - ViewDidChangeEffectiveAppearance (); - } - - public override void ViewDidChangeEffectiveAppearance () - { - base.ViewDidChangeEffectiveAppearance (); - - this.popover.SetAppearance (HostResources.GetVibrantAppearance (EffectiveAppearance)); - this.popover.ContentViewController.View.Appearance = EffectiveAppearance; + AppearanceChanged (); } readonly ColorPopUpButton popUpButton; @@ -132,5 +124,13 @@ namespace Xamarin.PropertyEditing.Mac } } } + + protected override void AppearanceChanged () + { + base.AppearanceChanged (); + + this.popover.SetAppearance (HostResources.GetVibrantAppearance (EffectiveAppearance)); + this.popover.ContentViewController.View.Appearance = EffectiveAppearance; + } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs index e300f08..285f47f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs @@ -162,7 +162,7 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (removeBorder, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, 22), }); - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } public override void OnViewModelChanged (CollectionPropertyViewModel oldModel) @@ -244,9 +244,9 @@ namespace Xamarin.PropertyEditing.Mac } } - public override void ViewDidChangeEffectiveAppearance () + protected override void AppearanceChanged () { - base.ViewDidChangeEffectiveAppearance (); + base.AppearanceChanged (); this.add.Image = this.hostResources.GetNamedImage ("pe-list-add-16"); this.remove.Image = this.hostResources.GetNamedImage ("pe-list-remove-16"); @@ -353,7 +353,7 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.label, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, 0) }); - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } public CollectionPropertyItemViewModel ViewModel @@ -372,8 +372,14 @@ namespace Xamarin.PropertyEditing.Mac public override void ViewDidChangeEffectiveAppearance () { - UpdateIcon (); base.ViewDidChangeEffectiveAppearance (); + + AppearanceChanged (); + } + + private void AppearanceChanged () + { + UpdateIcon (); } private readonly IIconProvider iconProvider; diff --git a/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs index bdb7bb4..54056ac 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs @@ -40,7 +40,7 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.openCollection, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, -6) }); - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } public override NSView FirstKeyView => this.openCollection; @@ -52,12 +52,6 @@ namespace Xamarin.PropertyEditing.Mac this.openCollection.Enabled = ViewModel?.Property.CanWrite ?? false; } - public override void ViewDidChangeEffectiveAppearance () - { - base.ViewDidChangeEffectiveAppearance (); - this.label.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); - } - protected override void UpdateAccessibilityValues () { base.UpdateAccessibilityValues (); @@ -66,6 +60,13 @@ namespace Xamarin.PropertyEditing.Mac } private readonly UnfocusableTextField label; - private readonly NSButton openCollection; + private readonly NSButton openCollection;
+
+ protected override void AppearanceChanged () + {
+ base.AppearanceChanged ();
+ + this.label.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs index aac2018..21f4753 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs @@ -43,6 +43,17 @@ namespace Xamarin.PropertyEditing.Mac public virtual void OnPropertyChanged (object sender, PropertyChangedEventArgs e) { } + + protected virtual void AppearanceChanged () + { + } + + public sealed override void ViewDidChangeEffectiveAppearance () + { + base.ViewDidChangeEffectiveAppearance (); + + AppearanceChanged (); + } } internal abstract class ColorEditorView : NotifyingView<SolidBrushViewModel> diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs index a3483a1..ff275ca 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs @@ -32,7 +32,7 @@ namespace Xamarin.PropertyEditing.Mac set { this.hostResources = value; - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } } @@ -45,7 +45,7 @@ namespace Xamarin.PropertyEditing.Mac if (value == null) FillColor = NSColor.Clear; - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } } @@ -58,12 +58,22 @@ namespace Xamarin.PropertyEditing.Mac if (value == null) BorderColor = NSColor.Clear; - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } } public override void ViewDidChangeEffectiveAppearance () { + base.ViewDidChangeEffectiveAppearance (); + + AppearanceChanged (); + } + + private IHostResourceProvider hostResources; + private string fillColor, borderColor; + + private void AppearanceChanged () + { if (this.fillColor != null) { NSColor color = this.hostResources.GetNamedColor (this.fillColor); if (color == null) @@ -80,8 +90,5 @@ namespace Xamarin.PropertyEditing.Mac BorderColor = color; } } - - private IHostResourceProvider hostResources; - private string fillColor, borderColor; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs index e8d908d..c1b7b44 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs @@ -54,11 +54,19 @@ namespace Xamarin.PropertyEditing.Mac OnMouseLeftDown += (sender, e) => { PopUpContextMenu (); }; + + AppearanceChanged (); } public override void ViewDidChangeEffectiveAppearance () { base.ViewDidChangeEffectiveAppearance (); + + AppearanceChanged (); + } + + private void AppearanceChanged () + { ToggleFocusImage (); } @@ -120,9 +128,9 @@ namespace Xamarin.PropertyEditing.Mac private void ToggleFocusImage (bool focused = false) { - if (viewModel != null) { + if (this.viewModel != null) { - switch (viewModel.ValueSource) { + switch (this.viewModel.ValueSource) { case ValueSource.Binding: Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-bound-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-bound-mac-10"); break; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs index d0d942c..bbd4248 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs @@ -27,7 +27,7 @@ namespace Xamarin.PropertyEditing.Mac this.hostResources = hostResource; this.imageBase += (isUp) ? "up" : "down"; - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } public override void MouseExited (NSEvent theEvent) @@ -44,6 +44,13 @@ namespace Xamarin.PropertyEditing.Mac public override void ViewDidChangeEffectiveAppearance () { + base.ViewDidChangeEffectiveAppearance (); + + AppearanceChanged (); + } + + private void AppearanceChanged () + { this.image = this.hostResources.GetNamedImage (this.imageBase); this.mouseOverImage = this.hostResources.GetNamedImage (this.imageBase + "-focus-blue"); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/TabButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/TabButton.cs index e185105..d66510f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/TabButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/TabButton.cs @@ -24,7 +24,7 @@ namespace Xamarin.PropertyEditing.Mac this.hostResource = hostResource; this.imageName = imageName; - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } public event EventHandler Clicked; @@ -51,7 +51,8 @@ namespace Xamarin.PropertyEditing.Mac public override void ViewDidChangeEffectiveAppearance () { base.ViewDidChangeEffectiveAppearance (); - Image = this.hostResource.GetNamedImage (this.imageName); + + AppearanceChanged (); } public override void DrawRect (CGRect dirtyRect) @@ -66,6 +67,11 @@ namespace Xamarin.PropertyEditing.Mac path.Fill (); } + private void AppearanceChanged () + { + Image = this.hostResource.GetNamedImage (this.imageName); + } + private readonly string imageName; private readonly IHostResourceProvider hostResource; private bool selected; diff --git a/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs index 7b6ada3..545cea4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs @@ -45,7 +45,7 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (this.container); - ViewDidChangeEffectiveAppearance (); + AppearanceChanged (); } NSView INativeContainer.NativeView => this; @@ -82,6 +82,13 @@ namespace Xamarin.PropertyEditing.Mac public override void ViewDidChangeEffectiveAppearance () { + base.ViewDidChangeEffectiveAppearance (); + + AppearanceChanged (); + } + + private void AppearanceChanged () + { this.table.BackgroundColor = this.hostResources.GetNamedColor (NamedResources.PadBackgroundColor); this.host.FillColor = this.hostResources.GetNamedColor (NamedResources.ValueBlockBackgroundColor); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs index 429d014..4b1e9b4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs @@ -128,6 +128,17 @@ namespace Xamarin.PropertyEditing.Mac protected virtual void UpdateAccessibilityValues () { } + + protected virtual void AppearanceChanged () + { + } + + public sealed override void ViewDidChangeEffectiveAppearance () + { + base.ViewDidChangeEffectiveAppearance (); + + AppearanceChanged (); + } } internal abstract class PropertyEditorControl<TViewModel> |