1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
using System;
using AppKit;
using CoreGraphics;
namespace Xamarin.PropertyEditing.Mac
{
internal class BasePopOverControl : NSView
{
const int DefaultIconButtonSize = 32;
private readonly UnfocusableTextField viewTitle;
public BasePopOverControl (IHostResourceProvider hostResources, string title, string imageNamed) : base ()
{
if (title == null)
throw new ArgumentNullException (nameof (title));
if (imageNamed == null)
throw new ArgumentNullException (nameof (imageNamed));
if (hostResources == null)
throw new ArgumentNullException (nameof (hostResources));
TranslatesAutoresizingMaskIntoConstraints = false;
WantsLayer = true;
HostResources = hostResources;
var iconView = new NSImageView {
Image = hostResources.GetNamedImage (imageNamed),
ImageScaling = NSImageScale.None,
TranslatesAutoresizingMaskIntoConstraints = false,
};
AddSubview (iconView);
this.viewTitle = new UnfocusableTextField {
Font = NSFont.BoldSystemFontOfSize (11),
StringValue = title,
TranslatesAutoresizingMaskIntoConstraints = false,
};
AddSubview (this.viewTitle);
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 (this.viewTitle, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 7f),
NSLayoutConstraint.Create (this.viewTitle, NSLayoutAttribute.Left, NSLayoutRelation.Equal, iconView, NSLayoutAttribute.Right, 1f, 5f),
NSLayoutConstraint.Create (this.viewTitle, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, 120),
NSLayoutConstraint.Create (this.viewTitle, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight),
});
this.SetAppearance (hostResources.GetVibrantAppearance (EffectiveAppearance));
ViewDidChangeEffectiveAppearance ();
}
protected IHostResourceProvider HostResources
{
get;
private set;
}
public override void ViewDidChangeEffectiveAppearance ()
{
this.viewTitle.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor);
}
}
}
|