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

CategoryContainerControl.cs « Controls « Xamarin.PropertyEditing.Mac - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dfec28ed274fd694b43167d829110888a287f0cf (plain)
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
using System;
using AppKit;

namespace Xamarin.PropertyEditing.Mac
{
	internal class CategoryContainerControl
		: PropertyEditorControl
	{
		private NSOutlineView outlineView;
		private NSButton disclosure;

		public CategoryContainerControl (IHostResourceProvider hostResources, NSOutlineView outlineView) : base (hostResources)
		{
			if (outlineView == null)
				throw new ArgumentNullException (nameof (outlineView));

			this.outlineView = outlineView;

			this.disclosure = this.outlineView.MakeView ("NSOutlineViewDisclosureButtonKey", outlineView) as NSButton;
			this.disclosure.TranslatesAutoresizingMaskIntoConstraints = false;
			AddSubview (this.disclosure);

			var label = new UnfocusableTextField {
				TranslatesAutoresizingMaskIntoConstraints = false
			};
			AddSubview (label);

			AddConstraints (new[] {
				NSLayoutConstraint.Create (this.disclosure, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1, 0),
				NSLayoutConstraint.Create (this.disclosure, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1, 4),
				NSLayoutConstraint.Create (label, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.disclosure, NSLayoutAttribute.Right, 1, 0),
				NSLayoutConstraint.Create (label, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, 0),
			});
		}

		public override bool IsDynamicallySized => false;

		public override bool NeedsPropertyButton => false;

		public override NSView FirstKeyView => this.disclosure;

		public override NSView LastKeyView => this.disclosure;
	}
}