// Copyright (c) Wojciech Figat. All rights reserved. using System; namespace FlaxEngine.GUI { /// /// Asset with that can be reused in different UI controls. /// /// /// public class UIBrushAsset { /// /// Brush object. /// public IBrush Brush; } /// /// Implementation of for frame displaying. /// /// /// public sealed class UIBrush : IBrush, IEquatable { /// /// The UI Brush asset to use. /// public JsonAssetReference Asset; /// /// Initializes a new instance of the class. /// public UIBrush() { } /// /// Initializes a new instance of the struct. /// /// The UI Brush asset to use. public UIBrush(JsonAssetReference asset) { Asset = asset; } /// /// Initializes a new instance of the struct. /// /// The UI Brush asset to use. public UIBrush(JsonAsset asset) { Asset = asset; } /// public Float2 Size { get { var asset = (UIBrushAsset)Asset.Asset?.Instance; if (asset != null && asset.Brush != null) return asset.Brush.Size; return Float2.Zero; } } /// public void Draw(Rectangle rect, Color color) { var asset = (UIBrushAsset)Asset.Asset?.Instance; if (asset != null && asset.Brush != null) asset.Brush.Draw(rect, color); } /// public bool Equals(UIBrush other) { return other != null && Asset == other.Asset; } /// public override bool Equals(object obj) { return obj is UIBrush other && Equals(other); } /// public override int GetHashCode() { return HashCode.Combine(Asset); } /// public int CompareTo(object obj) { return Equals(obj) ? 1 : 0; } } }