2024-08-09 13:52:49 +00:00
|
|
|
|
|
|
|
using Godot;
|
|
|
|
using Rokojori;
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
|
|
|
|
|
|
|
[Tool]
|
|
|
|
[GlobalClass]
|
2024-08-11 17:38:06 +00:00
|
|
|
public partial class UIStyle:Resource, UIStylePropertyContainer
|
2024-08-09 13:52:49 +00:00
|
|
|
{
|
|
|
|
[Export]
|
2024-08-11 17:38:06 +00:00
|
|
|
public UIStyle parentStyle;
|
|
|
|
|
|
|
|
[ExportCategory( "Layout" )]
|
|
|
|
[Export]
|
|
|
|
public UILayout layout;
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public UINumber horizontalAlignment;
|
2024-08-09 13:52:49 +00:00
|
|
|
[Export]
|
2024-08-11 17:38:06 +00:00
|
|
|
public UINumber verticalAlignment;
|
2024-08-09 13:52:49 +00:00
|
|
|
|
|
|
|
[Export]
|
2024-08-11 17:38:06 +00:00
|
|
|
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;
|
2024-08-09 13:52:49 +00:00
|
|
|
[Export]
|
2024-08-11 17:38:06 +00:00
|
|
|
public UIColor fontColor;
|
2024-08-09 13:52:49 +00:00
|
|
|
|
|
|
|
[Export]
|
2024-08-11 17:38:06 +00:00
|
|
|
public UINumber outlineSize;
|
2024-08-09 13:52:49 +00:00
|
|
|
[Export]
|
2024-08-11 17:38:06 +00:00
|
|
|
public UIColor outlineColor;
|
2024-08-09 13:52:49 +00:00
|
|
|
|
|
|
|
[Export]
|
2024-08-11 17:38:06 +00:00
|
|
|
public UINumber shadowSize;
|
2024-08-09 13:52:49 +00:00
|
|
|
[Export]
|
2024-08-11 17:38:06 +00:00
|
|
|
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;
|
2024-08-09 13:52:49 +00:00
|
|
|
|
2024-08-11 17:38:06 +00:00
|
|
|
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 );
|
|
|
|
}
|
2024-08-09 13:52:49 +00:00
|
|
|
|
|
|
|
public static UINumber Left( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Left );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber Right( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Right );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber Top( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Top );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber Bottom( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Bottom );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber Margin( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Margin );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber MarginLeft( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.MarginLeft );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber MarginRight( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.MarginRight );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber MarginTop( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.MarginTop );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber MarginBottom( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.MarginBottom );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber PivotX( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.PivotX );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber PivotY( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.PivotY );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber Rotation( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Rotation );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber Scale( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.Scale );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber ScaleX( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
return GetReferenceableNumberProperty( container, UIStyleNumberProperty.ScaleX );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static UINumber ScaleY( UIStylePropertyContainer container )
|
|
|
|
{
|
2024-08-11 17:38:06 +00:00
|
|
|
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 );
|
2024-08-09 13:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|