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

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Ewing <lewing@microsoft.com>2018-07-14 05:48:36 +0300
committerLarry Ewing <lewing@microsoft.com>2018-07-16 22:05:49 +0300
commitdccfe8d8808a21f5af393f5c165ff31bdbc502d1 (patch)
tree5d10748c229e8ef67ac5bd26ae01ee0fe16035f3 /Xamarin.PropertyEditing.Mac/Controls
parent4fae4441c00171a4ddecf9045d383e8732a83790 (diff)
Draw icons if the image is set
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs12
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs1
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs8
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs109
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs56
10 files changed, 160 insertions, 36 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs
index c47f88a..c9f04d6 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs
@@ -12,7 +12,7 @@ namespace Xamarin.PropertyEditing.Mac
{
public BrushTabViewController ()
{
- PreferredContentSize = new CGSize (300, 230);
+ PreferredContentSize = new CGSize (430, 230);
TransitionOptions = NSViewControllerTransitionOptions.None;
}
@@ -42,28 +42,32 @@ namespace Xamarin.PropertyEditing.Mac
var solid = new SolidColorBrushEditorViewController ();
solid.ViewModel = ViewModel;
item.ViewController = solid;
+ item.Image = NSImage.ImageNamed ("property-brush-solid-16");
break;
case CommonBrushType.MaterialDesign:
var material = new MaterialBrushEditorViewController ();
material.ViewModel = ViewModel;
item.ViewController = material;
+ item.Image = NSImage.ImageNamed ("property-brush-none-16");
break;
case CommonBrushType.Resource:
var resource = new ResourceBrushViewController ();
resource.ViewModel = ViewModel;
item.ViewController = resource;
+ item.Image = NSImage.ImageNamed ("property-brush-resources-16");
break;
case CommonBrushType.Gradient:
var gradient = new EmptyBrushEditorViewController ();
gradient.ViewModel = ViewModel;
item.ViewController = gradient;
+ item.Image = NSImage.ImageNamed ("property-brush-gradient-16");
break;
case CommonBrushType.NoBrush:
var none = new EmptyBrushEditorViewController ();
none.ViewModel = ViewModel;
item.ViewController = none;
+ item.Image = NSImage.ImageNamed ("property-brush-none-16");
break;
-
}
if (item.ViewController != null) {
BrushTypeTable [brushType] = TabViewItems.Length;
@@ -112,9 +116,7 @@ namespace Xamarin.PropertyEditing.Mac
public override void ViewDidLoad ()
{
- var old = View.Frame;
- old.Height = 230;
- View.Frame = old;
+ View.Frame = new CGRect (0, 0, 430,230);
this.inhibitSelection = true;
base.ViewDidLoad ();
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs
index 900635f..aefe3a0 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs
@@ -132,7 +132,7 @@ namespace Xamarin.PropertyEditing.Mac
};
}
- public override CGSize IntrinsicContentSize => new CGSize (100, 200);
+ public override CGSize IntrinsicContentSize => new CGSize (100, 300);
void UpdateComponent (object sender, EventArgs args)
{
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs
index 9680752..1b3e93b 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs
@@ -12,7 +12,7 @@ namespace Xamarin.PropertyEditing.Mac
public ColorComponentViewController (ChannelEditorType type) : base ()
{
- PreferredContentSize = new CGSize (200, 220);
+ PreferredContentSize = new CGSize (100, 400);
EditorType = type;
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs
index e206dfa..1137072 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs
@@ -19,7 +19,6 @@ namespace Xamarin.PropertyEditing.Mac
public static NSImage CreateSwatch (this CommonColor color, CGSize size, CIColor c0, CIColor c1)
=> new NSImage (GenerateCheckerboard (new CGRect (0, 0, size.Width, size.Height), c0, c1), size);
-
public static CGImage GenerateCheckerboard (CGRect frame)
=> GenerateCheckerboard (frame, CIColor.WhiteColor, CIColor.BlackColor);
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs
index 24273e1..14e5bbc 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs
@@ -9,7 +9,7 @@ namespace Xamarin.PropertyEditing.Mac
{
public EmptyBrushEditorViewController ()
{
- PreferredContentSize = new CGSize (100, 100);
+ PreferredContentSize = new CGSize (430, 230);
}
private NSButton brushEditor;
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs
index 933eeef..d1af213 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs
@@ -11,7 +11,7 @@ namespace Xamarin.PropertyEditing.Mac
{
public MaterialBrushEditorViewController ()
{
- PreferredContentSize = new CGSize (200, 230);
+ PreferredContentSize = new CGSize (430, 230);
}
private MaterialView materialEditor;
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs
index 95b44c8..41a517b 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs
@@ -145,11 +145,11 @@ namespace Xamarin.PropertyEditing.Mac
AddColumn (previewColumn);
}
- ResourceSelectorViewModel viewModel;
+ private ResourceSelectorViewModel viewModel;
public ResourceSelectorViewModel ViewModel {
- get => viewModel;
+ get => this.viewModel;
set {
- viewModel = value;
+ this.viewModel = value;
DataSource = new ResourceDataSource (viewModel);
}
}
@@ -162,7 +162,7 @@ namespace Xamarin.PropertyEditing.Mac
public ResourceBrushViewController ()
{
- PreferredContentSize = new CGSize (100, 200);
+ PreferredContentSize = new CGSize (430, 230);
viewDelegate = new ResourceBrushPropertyViewDelegate ();
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs
index 965ac0d..a024dcc 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs
@@ -11,7 +11,7 @@ namespace Xamarin.PropertyEditing.Mac
public SolidColorBrushEditorViewController ()
{
- PreferredContentSize = new CGSize (300, 230);
+ PreferredContentSize = new CGSize (430, 230);
}
public override void OnPropertyChanged (object sender, PropertyChangedEventArgs e)
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs
index 8225319..3526287 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs
@@ -3,40 +3,111 @@ using AppKit;
namespace Xamarin.PropertyEditing.Mac
{
+ internal class SegmentStack : NSView
+ {
+ class SegmentItem
+ {
+ public NSImage Image { get; set; }
+ public string Label { get; set; }
+ public NSView View { get; set; }
+ }
+
+
+ private SegmentItem[] segments = new SegmentItem[0];
+ private NSStackView stackView = new NSStackView () {
+ Spacing = 3
+ };
+
+ public void SetImage (NSImage image, int segment)
+ {
+ var item = this.segments[segment];
+
+ item.Image = image;
+ if (item.Image != null)
+ return;
+
+ item.View = new UnderlinedImageView (image.Name) {
+ // Image = image
+ };
+ this.stackView.AddView (item.View, NSStackViewGravity.Leading);
+ }
+
+ public NSImage GetImage (int segment)
+ {
+ return this.segments[segment].Image;
+ }
+
+ public void SetLabel (string label, int segment)
+ {
+ var item = this.segments[segment];
+ item.Label = label;
+ if (item.Image != null)
+ return;
+
+ item.View = new UnderlinedTextField () {
+ BackgroundColor = NSColor.Clear,
+ Editable = false,
+ Bezeled = false,
+ StringValue = label
+ };
+ this.stackView.AddView (item.View, NSStackViewGravity.Leading);
+ }
+
+ public string GetLabel (int segment)
+ {
+ return this.segments[segment].Label;
+ }
+
+ public int SegmentCount
+ {
+ get => this.segments.Length;
+ set
+ {
+ this.segments = new SegmentItem[value];
+ }
+ }
+ }
+
internal class UnderlinedTabViewController<TViewModel> : NotifyingTabViewController<TViewModel> where TViewModel : NotifyingObject
{
- private NSStackView labelStack = new NSStackView () {
+ private NSStackView tabStack = new NSStackView () {
Spacing = 4f,
};
public override void NumberOfItemsChanged (NSTabView tabView)
{
base.NumberOfItemsChanged (tabView);
- var items = this.labelStack.Views.ToList ();
+ var items = this.tabStack.Views.ToList ();
foreach (var view in items) {
- this.labelStack.RemoveView (view);
+ this.tabStack.RemoveView (view);
}
var i = 0;
foreach (var item in TabViewItems) {
- this.labelStack.AddView (new UnderlinedTextField () {
- BackgroundColor = NSColor.Clear,
- Editable = false,
- Bezeled = false,
- StringValue = item.Label,
- Selected = i == SelectedTabViewItemIndex,
- }, NSStackViewGravity.Leading);
+ if (item.Image != null) {
+ this.tabStack.AddView (new UnderlinedImageView (item.Image.Name) {
+ Selected = i == SelectedTabViewItemIndex
+ }, NSStackViewGravity.Leading);
+ } else {
+ this.tabStack.AddView (new UnderlinedTextField () {
+ BackgroundColor = NSColor.Clear,
+ Editable = false,
+ Bezeled = false,
+ StringValue = item.Label,
+ Selected = i == SelectedTabViewItemIndex,
+ }, NSStackViewGravity.Leading);
+ }
i++;
}
}
public override void MouseDown (NSEvent theEvent)
{
- var hit = View.HitTest (View.Superview.ConvertPointFromView (theEvent.LocationInWindow, null));
- if (!(hit is UnderlinedTextField))
+ NSView hit = View.HitTest (View.Superview.ConvertPointFromView (theEvent.LocationInWindow, null));
+ if (!(hit is ISelectable))
return;
int i = 0;
- foreach (var label in labelStack.Views) {
+ foreach (var label in tabStack.Views) {
if (hit == label) {
SelectedTabViewItemIndex = i;
break;
@@ -48,10 +119,10 @@ namespace Xamarin.PropertyEditing.Mac
public override void DidSelect (NSTabView tabView, NSTabViewItem item)
{
base.DidSelect (tabView, item);
- for (int i = 0; i < this.labelStack.Views.Length; i++) {
- var underlined = this.labelStack.Views[i] as UnderlinedTextField;
- if (underlined != null)
- underlined.Selected = SelectedTabViewItemIndex == i;
+ for (int i = 0; i < this.tabStack.Views.Length; i++) {
+ var tabItem = this.tabStack.Views[i] as ISelectable;
+ if (tabItem != null)
+ tabItem.Selected = SelectedTabViewItemIndex == i;
}
}
@@ -59,11 +130,11 @@ namespace Xamarin.PropertyEditing.Mac
{
var stack = new NSStackView () {
Spacing = 0,
- Alignment = NSLayoutAttribute.Width,
+ Alignment = NSLayoutAttribute.Left,
Orientation = NSUserInterfaceLayoutOrientation.Vertical
};
- stack.AddView (this.labelStack, NSStackViewGravity.Leading);
+ stack.AddView (this.tabStack, NSStackViewGravity.Top);
stack.AddView (TabView, NSStackViewGravity.Bottom);
View = stack;
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs
index 2bc17f3..39deb43 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs
@@ -3,7 +3,59 @@ using CoreGraphics;
namespace Xamarin.PropertyEditing.Mac
{
- internal class UnderlinedTextField : NSTextField
+
+ internal interface ISelectable {
+ bool Selected { get; set; }
+ }
+
+ internal class UnderlinedImageView : NSImageView, ISelectable
+ {
+ public UnderlinedImageView (string name)
+ {
+ this.name = name;
+ }
+
+ private string name;
+
+ private bool selected;
+ public bool Selected
+ {
+ get => selected;
+ set {
+ //if (selected == value)
+ // return;
+ selected = value;
+
+ var version = PropertyEditorPanel.ThemeManager.Theme == Themes.PropertyEditorTheme.Dark ? $"{name}~dark" : name;
+ Image = NSImage.ImageNamed (selected ? $"{version}~sel" : version);
+
+ //Enabled = value;
+ NeedsDisplay = true;
+ }
+ }
+
+ public override void DrawRect (CGRect dirtyRect)
+ {
+ base.DrawRect (dirtyRect);
+ if (!Selected)
+ return;
+
+ NSBezierPath path = new NSBezierPath ();
+ path.AppendPathWithRect (new CGRect (Bounds.X + 1, Bounds.Top + 3, Bounds.Width - 2, 3));
+ (selected? NSColor.Text: NSColor.DisabledControlText).Set ();
+ path.Fill ();
+ }
+
+ public override CGSize IntrinsicContentSize
+ {
+ get {
+ var size = base.IntrinsicContentSize;
+ return new CGSize (size.Width + 2, size.Height + 12);
+ }
+ }
+ }
+
+ internal class UnderlinedTextField : NSTextField, ISelectable
{
public UnderlinedTextField ()
{
@@ -22,7 +74,7 @@ namespace Xamarin.PropertyEditing.Mac
// return;
selected = value;
TextColor = selected ? NSColor.Text : NSColor.DisabledControlText;
-
+
//Enabled = value;
NeedsDisplay = true;
}