public override NSTableRowView GetRowView(NSTableView tableView, int row) { var rowView = new XTableRowView(); rowView.CustomBackgroundColor = (row % 2 == 0) ? NSColor.FromDeviceWhite(0.8f, 1f) : NSColor.LightGray; return(rowView); }
public SearchResultsTabView(bool darkTheme) { this.darkTheme = darkTheme; TranslatesAutoresizingMaskIntoConstraints = false; ImageView = new NSImageView(); ImageView.TranslatesAutoresizingMaskIntoConstraints = false; AddSubview(ImageView); TextField = NSLabel.CreateWithFont("SF UI Text", 14); TextField.TextColor = darkTheme ? NSColor.FromDeviceWhite(1.0f, 0.0f) : NSColor.FromDeviceWhite(0, 1); AddSubview(TextField); var hFormat = "H:|-(16)-[image(16)]-[text]-(16)-|"; var objects = new object [] { "image", ImageView, "text", TextField }; AddConstraints(NSLayoutConstraint.FromVisualFormat(hFormat, NSLayoutFormatOptions.AlignAllCenterY, objects)); AddConstraint(NSLayoutConstraint.Create(ImageView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1.0f, 0.0f)); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row) { if (NSObject.Equals(tableColumn.Identifier, MainWindowController._idImageColumn)) { NSImageView imageView = tableView.MakeView("GlyphView", this) as NSImageView; if (imageView == null) { imageView = new XImageView(); SetIdentifierToView(imageView, "GlyphView"); } var img = new NSImage(glyphInfos[row].GlyphImage, new SizeF(rowHeight - 2f, rowHeight - 2f)); imageView.Image = img; return(imageView); } else if (NSObject.Equals(tableColumn.Identifier, MainWindowController._idNameColumn)) { NSTextField textfield = tableView.MakeView("NameView", this) as NSTextField; if (textfield == null) { textfield = new NSTextField(); //textfield.BackgroundColor = NSColor.DarkGray; textfield.BackgroundColor = NSColor.FromDeviceWhite(0f, 0.5f); textfield.Bordered = false; SetIdentifierToView(textfield, "NameView"); //textfield.Alignment = NSTextAlignment.Center; textfield.Cell = new XTextFieldCell(textfield); } textfield.StringValue = glyphInfos[row].GlyphName; return(textfield); } else if (NSObject.Equals(tableColumn.Identifier, MainWindowController._idDetailColumn)) { NSTextField textfield = tableView.MakeView("DetailView", this) as NSTextField; if (textfield == null) { textfield = new NSTextField(); //textfield.BackgroundColor = NSColor.DarkGray; textfield.BackgroundColor = NSColor.FromDeviceWhite(0f, 0.5f); textfield.Bordered = false; SetIdentifierToView(textfield, "DetailView"); textfield.Cell = new XTextFieldCell(textfield); } textfield.StringValue = String.Format("\"{0}\" 0x{1:x}", glyphInfos[row].RawName, glyphInfos[row].GlyphId); return(textfield); } return(null); }
private SCNMaterial[] FloorMaterials() { var lightGrayMaterial = SCNMaterial.Create(); lightGrayMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/shapeMap", "png")); lightGrayMaterial.LocksAmbientWithDiffuse = true; var darkGrayMaterial = SCNMaterial.Create(); darkGrayMaterial.Diffuse.Contents = NSColor.FromDeviceWhite(0.8f, 1.0f); darkGrayMaterial.LocksAmbientWithDiffuse = true; return(new SCNMaterial[] { lightGrayMaterial, lightGrayMaterial, darkGrayMaterial }); }
public override void DrawRect(CGRect dirtyRect) { /* * Things look good no matter where the view is located; either a vibrant appearance or * a non-vibrant appearance. Since the view says YES to allowsVibrancy, everything drawn in * drawRect will be vibrant; all colors, images, etc. */ NSColor.FromDeviceWhite(0f, 0.85f).Set(); NSBezierPath path = NSBezierPath.FromOvalInRect(Bounds.Inset(5f, 5f)); path.LineWidth = 5; path.Stroke(); NSColor.FromDeviceWhite(0f, 0.48f).Set(); path = NSBezierPath.FromOvalInRect(Bounds.Inset(10f, 10f)); path.Fill(); }
private void DrawBaselineSeparator(CGRect separatorFrame) { var window = (AppStoreWindow)Window; var drawsAsMainWindow = window.DrawsAsMainWindow(); var bottomColor = drawsAsMainWindow ? window.BaselineSeparatorColor : window.InactiveBaselineSeparatorColor; if (bottomColor == default(NSColor)) { bottomColor = AppStoreWindow.DefaultBaselineSeparatorColor(drawsAsMainWindow); } bottomColor.Set(); NSGraphics.RectFill(separatorFrame); separatorFrame.Y += separatorFrame.Height; separatorFrame.Height = 1.0f; NSColor.FromDeviceWhite(1.0f, 0.12f).SetFill(); NSBezierPath.FromRect(separatorFrame).Fill(); }
public static NSColor DefaultTitleTextColor(bool drawsAsMainWindow) { return(drawsAsMainWindow ? NSColor.FromDeviceWhite(56.0f / 255.0f, 1.0f) : (NSColor.FromDeviceWhite(56.0f / 255.0f, 0.5f))); }
public static NSColor DefaultBaselineSeparatorColor(bool drawsAsMainWindow) { return(drawsAsMainWindow ? NSColor.FromDeviceWhite(0.408f, 1.0f) : (NSColor.FromDeviceWhite(0.655f, 1.0f))); }
public static NSColor DefaultTitleBarEndColor(bool drawsAsMainWindow) { return(drawsAsMainWindow ? NSColor.FromDeviceWhite(0.9f, 1.0f) : (NSColor.FromDeviceWhite(0.976f, 1.0f))); }
public static NSColor DefaultTitleBarStartColor(bool drawsAsMainWindow) { return(drawsAsMainWindow ? NSColor.FromDeviceWhite(0.66f, 1.0f) : (NSColor.FromDeviceWhite(0.878f, 1.0f))); }
private CGRect GetTitleFrame(out NSDictionary titleTextStyles, AppStoreWindow window) { var drawsAsMainWindow = window.DrawsAsMainWindow(); var titleTextShadow = drawsAsMainWindow ? window.TitleTextShadow : window.InactiveTitleTextShadow; if (titleTextShadow == null) { titleTextShadow = new NSShadow { ShadowBlurRadius = 0f, ShadowOffset = new CGSize(0f, -1.0f), ShadowColor = NSColor.FromDeviceWhite(1.0f, 0.5f), }; } var titleTextColor = drawsAsMainWindow ? window.TitleTextColor : window.InactiveTitleTextColor; if (titleTextColor == default(NSColor)) { titleTextColor = AppStoreWindow.DefaultTitleTextColor(drawsAsMainWindow); } var titleFont = window.TitleFont ?? NSFont.TitleBarFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Regular)); var titleParagraphStyle = (NSParagraphStyle)NSParagraphStyle.DefaultParagraphStyle.MutableCopy();//new NSParagraphStyle { LineBreakMode = NSLineBreakMode.TruncatingTail }; titleParagraphStyle.LineBreakMode = NSLineBreakMode.TruncatingTail; titleTextStyles = NSDictionary.FromObjectsAndKeys( new object[] { titleFont, titleTextColor, titleTextShadow, titleParagraphStyle }, new object[] { NSStringAttributeKey.Font, NSStringAttributeKey.ForegroundColor, NSStringAttributeKey.Shadow, NSStringAttributeKey.ParagraphStyle }); var titleSize = new NSAttributedString(window.Title, titleTextStyles).Size; var titleTextRect = new CGRect(0, 0, titleSize.Width, titleSize.Height); var docIconButton = window.StandardWindowButton(NSWindowButton.DocumentIconButton); var versionButton = window.StandardWindowButton(NSWindowButton.DocumentVersionsButton); var closeButton = window.ButtonToLayout(NSWindowButton.CloseButton); var minimizeButton = window.ButtonToLayout(NSWindowButton.MiniaturizeButton); var zoomButton = window.ButtonToLayout(NSWindowButton.ZoomButton); if (docIconButton != null) { var docIconButtonFrame = ConvertRectFromView(docIconButton.Frame, docIconButton.Superview); titleTextRect.X = docIconButtonFrame.GetMaxX() + TITLE_DOCUMENT_BUTTON_OFFSET.Width; titleTextRect.Y = docIconButtonFrame.GetMidY() - titleSize.Height / 2f + TITLE_DOCUMENT_BUTTON_OFFSET.Height; } else if (versionButton != null) { var versionsButtonFrame = ConvertRectFromView(versionButton.Frame, versionButton.Superview); titleTextRect.X = versionsButtonFrame.GetMinX() - titleSize.Width + TITLE_VERSIONS_BUTTON_OFFSET; var document = ((NSWindowController)window.WindowController).Document; if (document.HasUnautosavedChanges || document.IsDocumentEdited) { titleTextRect.X += TITLE_DOCUMENT_STATUS_X_OFFSET; } } else if (closeButton != null || minimizeButton != null || zoomButton != null) { var closeMaxX = closeButton == null ? 0f : closeButton.Frame.GetMaxX(); var minimizeMaxX = minimizeButton == null ? 0f : minimizeButton.Frame.GetMaxX(); var zoomMaxX = zoomButton == null ? 0f : zoomButton.Frame.GetMaxX(); var adjustedX = NMath.Max(NMath.Max(closeMaxX, minimizeMaxX), zoomMaxX) + TITLE_MARGINS.Width; var proposedX = Bounds.GetMidX() - titleSize.Width / 2f; titleTextRect.X = NMath.Max(proposedX, adjustedX); } else { titleTextRect.X = Bounds.GetMidX() - titleSize.Width / 2f; } var fullScreenButton = window.ButtonToLayout(NSWindowButton.FullScreenButton); if (fullScreenButton != null) { var fullScreenX = fullScreenButton.Frame.X; var maxTitleX = titleTextRect.GetMaxX(); if ((fullScreenX - TITLE_MARGINS.Width) < titleTextRect.GetMaxX()) { titleTextRect.Width = titleTextRect.Size.Width - (maxTitleX - fullScreenX) - TITLE_MARGINS.Width; } } titleTextRect.Y = Bounds.GetMaxY() - titleSize.Height - TITLE_MARGINS.Height; return(titleTextRect); }
public void EnableShadows(bool castsShadows) { Lights [(int)Light.Spot].Light.ShadowColor = NSColor.FromDeviceWhite(0, castsShadows ? 0.75f : 0.0f); Lights [(int)Light.Spot].Light.CastsShadow = castsShadows; }
public override void DrawRect(RectangleF dirtyRect) { var contentRect = new RectangleF(Bounds.X + LineThickness, Bounds.Y + LineThickness, Bounds.Width - (LineThickness * 2), Bounds.Height - (LineThickness * 2)); // Mac coords are reversed vs. .Net / MonoTouch coords, so we just reverse the top/bottom coords to compensate var top = contentRect.Bottom; var bottom = contentRect.Top; var left = contentRect.Left; var right = contentRect.Right; var path = new NSBezierPath(); // Draw the 'arrow' at the top path.MoveTo(new PointF(ArrowX, top)); path.LineTo(new PointF(ArrowX + ArrowWidth / 2, top - ArrowHeight)); path.LineTo(new PointF(right - CornerRadius, top - ArrowHeight)); // Right right var topRightCorner = new PointF(right, top - ArrowHeight); path.CurveTo(new PointF(right, top - ArrowHeight - CornerRadius), topRightCorner, topRightCorner); // Right line path.LineTo(new PointF(right, bottom + CornerRadius)); // Bottom right var bottomRightCorner = new PointF(right, bottom); path.CurveTo(new PointF(right - CornerRadius, bottom), bottomRightCorner, bottomRightCorner); // Bottom line path.LineTo(new PointF(left + CornerRadius, bottom)); // Bottom left var bottomLeftCorner = new PointF(left, bottom); path.CurveTo(new PointF(left, bottom + CornerRadius), bottomLeftCorner, bottomLeftCorner); // Left line path.LineTo(new PointF(left, top - ArrowHeight - CornerRadius)); // Top left var topLeftCorner = new PointF(left, top - ArrowHeight); path.CurveTo(new PointF(left + CornerRadius, top - ArrowHeight), topLeftCorner, topLeftCorner); // Line up to start of 'arrow' & finish path.LineTo(new PointF(ArrowX - ArrowWidth / 2, top - ArrowHeight)); path.ClosePath(); // Fill the path with a semi-transparent white NSColor.FromDeviceWhite(1.0f, FillOpacity).SetFill(); path.Fill(); NSGraphicsContext.GlobalSaveGraphicsState(); // Clip all rendering of controls within view to within the path outline we specified earlier var clip = NSBezierPath.FromRect(Bounds); clip.AppendPath(path); clip.AddClip(); // Draw the border path.LineWidth = LineThickness * 2; NSColor.White.SetStroke(); path.Stroke(); NSGraphicsContext.GlobalRestoreGraphicsState(); }
public static SCNNode SCBoxNode(string title, CGRect frame, NSColor color, float cornerRadius, bool centered) { NSMutableDictionary titleAttributes = null; NSMutableDictionary centeredTitleAttributes = null; // create and extrude a bezier path to build the box var path = NSBezierPath.FromRoundedRect(frame, cornerRadius, cornerRadius); path.Flatness = 0.05f; var shape = SCNShape.Create(path, 20); shape.ChamferRadius = 0.0f; var node = SCNNode.Create(); node.Geometry = shape; // create an image and fill with the color and text var textureSize = new CGSize(); textureSize.Width = (float)Math.Ceiling((double)frame.Size.Width * 1.5); textureSize.Height = (float)Math.Ceiling((double)frame.Size.Height * 1.5); var texture = new NSImage(textureSize); texture.LockFocus(); var drawFrame = new CGRect(0, 0, textureSize.Width, textureSize.Height); nfloat hue, saturation, brightness, alpha; (color.UsingColorSpace(NSColorSpace.DeviceRGBColorSpace)).GetHsba(out hue, out saturation, out brightness, out alpha); var lightColor = NSColor.FromDeviceHsba(hue, saturation - 0.2f, brightness + 0.3f, alpha); lightColor.Set(); NSGraphics.RectFill(drawFrame); NSBezierPath fillpath = null; if (cornerRadius == 0 && centered == false) { //special case for the "labs" slide drawFrame.Offset(0, -2); fillpath = NSBezierPath.FromRoundedRect(drawFrame, cornerRadius, cornerRadius); } else { drawFrame.Inflate(-3, -3); fillpath = NSBezierPath.FromRoundedRect(drawFrame, cornerRadius, cornerRadius); } color.Set(); fillpath.Fill(); // draw the title if any if (title != null) { if (titleAttributes == null) { var paraphStyle = new NSMutableParagraphStyle(); paraphStyle.LineBreakMode = NSLineBreakMode.ByWordWrapping; paraphStyle.Alignment = NSTextAlignment.Center; paraphStyle.MinimumLineHeight = 38; paraphStyle.MaximumLineHeight = 38; var font = NSFont.FromFontName("Myriad Set Semibold", 34) != null?NSFont.FromFontName("Myriad Set Semibold", 34) : NSFont.FromFontName("Avenir Medium", 34); var shadow = new NSShadow(); shadow.ShadowOffset = new CGSize(0, -2); shadow.ShadowBlurRadius = 4; shadow.ShadowColor = NSColor.FromDeviceWhite(0.0f, 0.5f); titleAttributes = new NSMutableDictionary(); titleAttributes.SetValueForKey(font, NSAttributedString.FontAttributeName); titleAttributes.SetValueForKey(NSColor.White, NSAttributedString.ForegroundColorAttributeName); titleAttributes.SetValueForKey(shadow, NSAttributedString.ShadowAttributeName); titleAttributes.SetValueForKey(paraphStyle, NSAttributedString.ParagraphStyleAttributeName); var centeredParaphStyle = (NSMutableParagraphStyle)paraphStyle.MutableCopy(); centeredParaphStyle.Alignment = NSTextAlignment.Center; centeredTitleAttributes = new NSMutableDictionary(); centeredTitleAttributes.SetValueForKey(font, NSAttributedString.FontAttributeName); centeredTitleAttributes.SetValueForKey(NSColor.White, NSAttributedString.ForegroundColorAttributeName); centeredTitleAttributes.SetValueForKey(shadow, NSAttributedString.ShadowAttributeName); centeredTitleAttributes.SetValueForKey(paraphStyle, NSAttributedString.ParagraphStyleAttributeName); } var attrString = new NSAttributedString(title, centered ? centeredTitleAttributes : titleAttributes); var textSize = attrString.Size; //check if we need two lines to draw the text var twoLines = title.Contains("\n"); if (!twoLines) { twoLines = textSize.Width > frame.Size.Width && title.Contains(" "); } //if so, we need to adjust the size to center vertically if (twoLines) { textSize.Height += 38; } if (!centered) { drawFrame.Inflate(-15, 0); } //center vertically var dy = (drawFrame.Size.Height - textSize.Height) * 0.5f; var drawFrameHeight = drawFrame.Size.Height; drawFrame.Size = new CGSize(drawFrame.Size.Width, drawFrame.Size.Height - dy); attrString.DrawString(drawFrame); } texture.UnlockFocus(); //set the created image as the diffuse texture of our 3D box var front = SCNMaterial.Create(); front.Diffuse.Contents = texture; front.LocksAmbientWithDiffuse = true; //use a lighter color for the chamfer and sides var sides = SCNMaterial.Create(); sides.Diffuse.Contents = lightColor; node.Geometry.Materials = new SCNMaterial[] { front, sides, sides, sides, sides }; return(node); }