using Godot; using Rokojori; namespace Rokojori { [Tool] [GlobalClass] public partial class UIStyle:Resource, UIStylePropertyContainer { [Export] public UIStyle parentStyle; [ExportCategory( "Layout" )] [Export] public UILayout layout; [Export] public UINumber horizontalAlignment; [Export] public UINumber verticalAlignment; [Export] public UINumber elementSpacing; [Export] public UINumber lineSpacing; [ExportCategory( "Size & Margins" )] [Export] public UINumber width; [Export] public UINumber height; [Export] public UINumber margin; [Export] public UINumber marginLeft; [Export] public UINumber marginTop; [Export] public UINumber marginRight; [Export] public UINumber marginBottom; [ExportCategory( "Font" )] [Export] public Font font; [Export] public UINumber fontSize; [Export] public UIColor fontColor; [Export] public UINumber outlineSize; [Export] public UIColor outlineColor; [Export] public UINumber shadowSize; [Export] public UIColor shadowColor; [ExportCategory( "Position" )] [Export] public UIPosition position; [Export] public UINumber left; [Export] public UINumber top; [Export] public UINumber right; [Export] public UINumber bottom; public UIStyle GetUIStyleParent() { return parentStyle; } public UIPosition GetUIPosition() { return position; } public UINumber GetUIStyleNumberProperty( UIStyleNumberProperty property ) { switch ( property ) { case UIStyleNumberProperty.Left: return left; case UIStyleNumberProperty.Right: return right; case UIStyleNumberProperty.Top: return top; case UIStyleNumberProperty.Bottom: return bottom; case UIStyleNumberProperty.ElementSpacing: return elementSpacing; case UIStyleNumberProperty.LineSpacing: return lineSpacing; case UIStyleNumberProperty.Width: return width; case UIStyleNumberProperty.Height: return height; case UIStyleNumberProperty.Margin: return margin; case UIStyleNumberProperty.MarginLeft: return marginLeft; case UIStyleNumberProperty.MarginRight: return marginRight; case UIStyleNumberProperty.MarginTop: return marginTop; case UIStyleNumberProperty.MarginBottom: return marginBottom; } return null; } public static UINumber GetReferenceableNumberProperty( UIStylePropertyContainer container, UIStyleNumberProperty property ) { if ( container == null ) { return null; } var ownProperty = container.GetUIStyleNumberProperty( property ); if ( ownProperty != null ) { return ownProperty; } var style = container.GetUIStyleParent(); return GetReferenceableNumberProperty( style, property ); } public static UIPosition Position( UIStylePropertyContainer container ) { var ownProperty = container.GetUIPosition(); if ( ownProperty != UIPosition.___ ) { return ownProperty; } return container.GetUIPosition(); } public static UINumber Width( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Width ); } public static UINumber Height( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Height ); } public static UINumber Left( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Left ); } public static UINumber Right( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Right ); } public static UINumber Top( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Top ); } public static UINumber Bottom( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Bottom ); } public static UINumber Margin( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Margin ); } public static UINumber MarginLeft( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.MarginLeft ); } public static UINumber MarginRight( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.MarginRight ); } public static UINumber MarginTop( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.MarginTop ); } public static UINumber MarginBottom( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.MarginBottom ); } public static UINumber PivotX( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.PivotX ); } public static UINumber PivotY( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.PivotY ); } public static UINumber Rotation( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Rotation ); } public static UINumber Scale( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Scale ); } public static UINumber ScaleX( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.ScaleX ); } public static UINumber ScaleY( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.ScaleY ); } public static UINumber ElementSpacing( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.ElementSpacing ); } public static UINumber LineSpacing( UIStylePropertyContainer container ) { return GetReferenceableNumberProperty( container, UIStyleNumberProperty.LineSpacing ); } } }