// This sets up a NSOutlineView for demonstration internal static NSView SetupOutlineView (CGRect frame) { // Create our NSOutlineView and set it's frame to a reasonable size. It will be autosized via the NSClipView NSOutlineView outlineView = new NSOutlineView () { Frame = frame }; // Every NSOutlineView must have at least one column or your Delegate will not be called. NSTableColumn column = new NSTableColumn ("Values"); outlineView.AddColumn (column); // You must set OutlineTableColumn or the arrows showing children/expansion will not be drawn outlineView.OutlineTableColumn = column; // Setup the Delegate/DataSource instances to be interrogated for data and view information // In Unified, these take an interface instead of a base class and you can combine these into // one instance. outlineView.Delegate = new OutlineViewDelegate (); outlineView.DataSource = new OutlineViewDataSource (); // NSOutlineView expects to be hosted inside an NSClipView and won't draw correctly otherwise NSClipView clipView = new NSClipView (frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; clipView.DocumentView = outlineView; return clipView; }
// This sets up a NSOutlineView for demonstration internal static NSView SetupOutlineView(CGRect frame) { // Create our NSOutlineView and set it's frame to a reasonable size. It will be autosized via the NSClipView NSOutlineView outlineView = new NSOutlineView() { Frame = frame }; // Every NSOutlineView must have at least one column or your Delegate will not be called. NSTableColumn column = new NSTableColumn("Values"); outlineView.AddColumn(column); // You must set OutlineTableColumn or the arrows showing children/expansion will not be drawn outlineView.OutlineTableColumn = column; // Setup the Delegate/DataSource instances to be interrogated for data and view information // In Unified, these take an interface instead of a base class and you can combine these into // one instance. outlineView.Delegate = new OutlineViewDelegate(); outlineView.DataSource = new OutlineViewDataSource(); // NSOutlineView expects to be hosted inside an NSClipView and won't draw correctly otherwise NSClipView clipView = new NSClipView(frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; clipView.DocumentView = outlineView; return(clipView); }
//public override CoreGraphics.CGSize IntrinsicContentSize => new CGSize (150, 100); public PlaylistsView() { TranslatesAutoresizingMaskIntoConstraints = false; var scrollView = new NSScrollView(); scrollView.TranslatesAutoresizingMaskIntoConstraints = false; OutlineView = new NSOutlineView(); OutlineView.HeaderView = null; OutlineView.FloatsGroupRows = false; OutlineView.BackgroundColor = NSColor.FromRgb(245, 245, 245); OutlineView.IndentationPerLevel = 4; var outlineColumn = new NSTableColumn(); outlineColumn.Editable = false; outlineColumn.MinWidth = 100; OutlineView.AddColumn(outlineColumn); OutlineView.OutlineTableColumn = outlineColumn; outlineColumn.Dispose(); outlineColumn = null; scrollView.DocumentView = OutlineView; AddSubview(scrollView); AddConstraints(NSLayoutExtensions.FillHorizontal(scrollView, false)); AddConstraints(NSLayoutExtensions.FillVertical(scrollView, false)); AddConstraint(NSLayoutExtensions.MinimumWidth(this, 100)); }
// Shared initialization code private void Initialize() { AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable; NSControlSize controlSize = NSControlSize.Small; propertyFilter = new NSSearchField(new CGRect(10, Frame.Height - 25, 170, 24)) { TranslatesAutoresizingMaskIntoConstraints = false, PlaceholderString = LocalizationResources.PropertyFilterLabel, ControlSize = controlSize, Font = NSFont.FromFontName(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize), }; AddSubview(propertyFilter); this.propertyArrangeModeLabel = new NSTextField(new CGRect(245, Frame.Height - 28, 150, 24)) { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = NSColor.Clear, TextColor = NSColor.Black, Editable = false, Bezeled = false, StringValue = LocalizationResources.ArrangeByLabel, ControlSize = controlSize, }; propertyArrangeMode = new NSComboBox(new CGRect(320, Frame.Height - 25, 153, 24)) { TranslatesAutoresizingMaskIntoConstraints = false, Editable = false, ControlSize = controlSize, Font = NSFont.FromFontName(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize), }; var enumValues = Enum.GetValues(typeof(PropertyArrangeMode)); foreach (var item in enumValues) { propertyArrangeMode.Add(new NSString(item.ToString())); // TODO May need translating } propertyArrangeMode.SelectItem(0); if (IsArrangeEnabled) { AddSubview(this.propertyArrangeMode); AddSubview(this.propertyArrangeModeLabel); } // If either the Filter Mode or PropertySearchFilter Change Filter the Data propertyArrangeMode.SelectionChanged += OnArrageModeChanged; propertyFilter.Changed += OnPropertyFilterChanged; propertyTable = new FirstResponderOutlineView { RefusesFirstResponder = true, AutoresizingMask = NSViewResizingMask.WidthSizable, SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.None, HeaderView = null, }; #if DESIGNER_DEBUG propertyTable.GridStyleMask = NSTableViewGridStyle.SolidHorizontalLine | NSTableViewGridStyle.SolidVerticalLine; #endif NSTableColumn propertiesList = new NSTableColumn(PropertyListColId) { Title = LocalizationResources.PropertyColumnTitle }; NSTableColumn propertyEditors = new NSTableColumn(PropertyEditorColId) { Title = LocalizationResources.ValueColumnTitle }; propertiesList.Width = 158; propertyEditors.Width = 250; propertyTable.AddColumn(propertiesList); propertyTable.AddColumn(propertyEditors); // Set OutlineTableColumn or the arrows showing children/expansion will not be drawn propertyTable.OutlineTableColumn = propertiesList; // create a table view and a scroll view var tableContainer = new NSScrollView(new CGRect(10, Frame.Height - 210, propertiesList.Width + propertyEditors.Width, Frame.Height - 55)) { TranslatesAutoresizingMaskIntoConstraints = false, }; // add the panel to the window tableContainer.DocumentView = propertyTable; AddSubview(tableContainer); this.DoConstraints(new NSLayoutConstraint[] { propertyFilter.ConstraintTo(this, (pf, c) => pf.Top == c.Top + 3), propertyFilter.ConstraintTo(this, (pf, c) => pf.Left == c.Left + 10), propertyArrangeModeLabel.ConstraintTo(this, (pl, c) => pl.Top == c.Top + 5), propertyArrangeModeLabel.ConstraintTo(propertyArrangeMode, (pl, pa) => pl.Left == pa.Left - 71), propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Top == c.Top + 4), propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Left == c.Left + 280), propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Width == c.Width - 291), tableContainer.ConstraintTo(this, (t, c) => t.Top == c.Top + 30), tableContainer.ConstraintTo(this, (t, c) => t.Width == c.Width - 20), tableContainer.ConstraintTo(this, (t, c) => t.Height == c.Height - 40), }); ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; UpdateTheme(); }
protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService) { var frame = (FigmaFrame)currentNode; var outlineView = new NSOutlineView(); var columnNodes = frame.FirstChild(s => s.name == ComponentString.COLUMNS && s.visible); NSScrollView scrollView = new NSScrollView(); scrollView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable; scrollView.BorderType = NSBorderType.BezelBorder; scrollView.DrawsBackground = true; scrollView.DocumentView = outlineView; outlineView.DataSource = new OutlineDataSource(); outlineView.Delegate = new OutlineDelegate(); if (columnNodes == null) { outlineView.HeaderView = null; return(new View(scrollView)); } // TODO: Parse options layers outlineView.UsesAlternatingRowBackgroundColors = false; outlineView.AllowsMultipleSelection = false; outlineView.AllowsColumnResizing = true; outlineView.AllowsColumnReordering = false; outlineView.AllowsEmptySelection = false; int columnCount = 1; foreach (FigmaNode tableColumNode in columnNodes.GetChildren(t => t.visible)) { FigmaText text = tableColumNode.FirstChild(s => s.name == ComponentString.TITLE) as FigmaText; if (text == null) { continue; } string title = text.characters; NSTableColumn column = new NSTableColumn(); column.HeaderCell.Alignment = Helpers.ViewHelper.GetNSTextAlignment(text); column.Identifier = "Column" + columnCount; column.Title = rendererService.GetTranslatedText(text); column.Width = (tableColumNode as FigmaFrame).absoluteBoundingBox.Width; if (columnCount == 1) { outlineView.OutlineTableColumn = column; } outlineView.AddColumn(column); columnCount++; } var rectangle = (RectangleVector)frame.FirstChild(s => s.name == ComponentString.BACKGROUND && s.visible); if (rectangle != null) { foreach (var styleMap in rectangle.styles) { if (rendererService.NodeProvider.TryGetStyle(styleMap.Value, out FigmaStyle style) && styleMap.Key == "fill") { outlineView.BackgroundColor = ColorService.GetNSColor(style.name); } } } return(new View(scrollView)); }