| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- using System;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- namespace BansheeEngine
- {
- /** @addtogroup GUI_Engine
- * @{
- */
- /// <summary>
- /// Rectangle represented in the form of offsets from some parent rectangle.
- /// </summary>
- [StructLayout(LayoutKind.Sequential)]
- public struct RectOffset // Note: Must match the C++ struct RectOffset
- {
- public int left, right, top, bottom;
- };
- /// <summary>
- /// Possible positions used for positioning content image within a GUI element.
- /// </summary>
- public enum GUIImagePosition // Note: Must match the C++ enum GUIImagePosition.
- {
- Left, Right
- };
- /// <summary>
- /// Specifies how is text horizontally aligned within its bounds.
- /// </summary>
- public enum TextHorzAlign // Note: Must match the C++ enum TextHorzAlign.
- {
- Left, Center, Right
- };
- /// <summary>
- /// Specifies how is text vertically aligned within its bounds.
- /// </summary>
- public enum TextVertAlign // Note: Must match the C++ enum TextVertAlign
- {
- Top, Center, Bottom
- };
- /// <summary>
- /// GUI element style that determines the look of a GUI element, as well as the element's default layout options.
- /// Different looks can be provided for different element states.
- /// </summary>
- [SerializeObject]
- public sealed class GUIElementStyle : ScriptObject
- {
- // Constructor for runtime use only (dummy parameter to differentiate from the normal constructor)
- private GUIElementStyle(bool dummy)
- { }
- /// <summary>
- /// Constructs a new GUI element style with default values.
- /// </summary>
- public GUIElementStyle()
- {
- Internal_CreateInstance(this);
- }
- /// <summary>
- /// Font to use for all text within the GUI element.
- /// </summary>
- public Font Font
- {
- get { Font value; Internal_GetFont(mCachedPtr, out value); return value; }
- set { Internal_SetFont(mCachedPtr, value); }
- }
- /// <summary>
- /// Font size to use for all text within the GUI element.
- /// </summary>
- public int FontSize
- {
- get { int value; Internal_GetFontSize(mCachedPtr, out value); return value; }
- set { Internal_SetFontSize(mCachedPtr, value); }
- }
- /// <summary>
- /// Horizontal alignment of text within the GUI element.
- /// </summary>
- public TextHorzAlign TextHorzAlign
- {
- get { TextHorzAlign value; Internal_GetTextHorzAlign(mCachedPtr, out value); return value; }
- set { Internal_SetTextHorzAlign(mCachedPtr, value); }
- }
- /// <summary>
- /// Vertical alignment of text within the GUI element.
- /// </summary>
- public TextVertAlign TextVertAlign
- {
- get { TextVertAlign value; Internal_GetTextVertAlign(mCachedPtr, out value); return value; }
- set { Internal_SetTextVertAlign(mCachedPtr, value); }
- }
- /// <summary>
- /// Position of content image relative to text.
- /// </summary>
- public GUIImagePosition ImagePosition
- {
- get { GUIImagePosition value; Internal_GetImagePosition(mCachedPtr, out value); return value; }
- set { Internal_SetImagePosition(mCachedPtr, value); }
- }
- /// <summary>
- /// Determines should the text word wrap if it doesn't fit in its element's bounds.
- /// </summary>
- public bool WordWrap
- {
- get { bool value; Internal_GetWordWrap(mCachedPtr, out value); return value; }
- set { Internal_SetWordWrap(mCachedPtr, value); }
- }
- /// <summary>
- /// Style used when element is in normal state and off.
- /// </summary>
- public GUIElementStateStyle Normal
- {
- get { GUIElementStateStyle value; Internal_GetNormal(mCachedPtr, out value); return value; }
- set { Internal_SetNormal(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Style used when element is in hover state and off.
- /// </summary>
- public GUIElementStateStyle Hover
- {
- get { GUIElementStateStyle value; Internal_GetHover(mCachedPtr, out value); return value; }
- set { Internal_SetHover(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Style used when element is in active state and off.
- /// </summary>
- public GUIElementStateStyle Active
- {
- get { GUIElementStateStyle value; Internal_GetActive(mCachedPtr, out value); return value; }
- set { Internal_SetActive(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Style used when element is in focused state and off.
- /// </summary>
- public GUIElementStateStyle Focused
- {
- get { GUIElementStateStyle value; Internal_GetFocused(mCachedPtr, out value); return value; }
- set { Internal_SetFocused(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Style used when element is in normal state and on.
- /// </summary>
- public GUIElementStateStyle NormalOn
- {
- get { GUIElementStateStyle value; Internal_GetNormalOn(mCachedPtr, out value); return value; }
- set { Internal_SetNormalOn(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Style used when element is in hover state and on.
- /// </summary>
- public GUIElementStateStyle HoverOn
- {
- get { GUIElementStateStyle value; Internal_GetHoverOn(mCachedPtr, out value); return value; }
- set { Internal_SetHoverOn(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Style used when element is in active state and on.
- /// </summary>
- public GUIElementStateStyle ActiveOn
- {
- get { GUIElementStateStyle value; Internal_GetActiveOn(mCachedPtr, out value); return value; }
- set { Internal_SetActiveOn(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Style used when element is in focused state and on.
- /// </summary>
- public GUIElementStateStyle FocusedOn
- {
- get { GUIElementStateStyle value; Internal_GetFocusedOn(mCachedPtr, out value); return value; }
- set { Internal_SetFocusedOn(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Determines how the element is scaled (using the typical Scale9Grid approach).
- /// </summary>
- public RectOffset Border
- {
- get { RectOffset value; Internal_GetBorder(mCachedPtr, out value); return value; }
- set { Internal_SetBorder(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Determines offset from the background graphics to the content. Input uses bounds offset by this value.
- /// </summary>
- public RectOffset Margins
- {
- get { RectOffset value; Internal_GetMargins(mCachedPtr, out value); return value; }
- set { Internal_SetMargins(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Additional offset to the content, that doesn't effect the bounds. Applied on top of the margins offsets.
- /// </summary>
- public RectOffset ContentOffset
- {
- get { RectOffset value; Internal_GetContentOffset(mCachedPtr, out value); return value; }
- set { Internal_SetContentOffset(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Wanted width of the GUI element in pixels. Only used if <see cref="FixedWidth"/> is enabled.
- /// </summary>
- public int Width
- {
- get { int value; Internal_GetWidth(mCachedPtr, out value); return value; }
- set { Internal_SetWidth(mCachedPtr, value); }
- }
- /// <summary>
- /// Wanted height of the GUI element in pixels. Only used if <see cref="FixedHeight"/> is enabled.
- /// </summary>
- public int Height
- {
- get { int value; Internal_GetHeight(mCachedPtr, out value); return value; }
- set { Internal_SetHeight(mCachedPtr, value); }
- }
- /// <summary>
- /// Minimum width allowed for the GUI element. Used by the layout only when exact width is not specified.
- /// </summary>
- public int MinWidth
- {
- get { int value; Internal_GetMinWidth(mCachedPtr, out value); return value; }
- set { Internal_SetMinWidth(mCachedPtr, value); }
- }
- /// <summary>
- /// Maximum width allowed for the GUI element. Used by the layout only when exact width is not specified.
- /// </summary>
- public int MaxWidth
- {
- get { int value; Internal_GetMaxWidth(mCachedPtr, out value); return value; }
- set { Internal_SetMaxWidth(mCachedPtr, value); }
- }
- /// <summary>
- /// Minimum height allowed for the GUI element. Used by the layout only when exact height is not specified.
- /// </summary>
- public int MinHeight
- {
- get { int value; Internal_GetMinHeight(mCachedPtr, out value); return value; }
- set { Internal_SetMinHeight(mCachedPtr, value); }
- }
- /// <summary>
- /// Maximum height allowed for the GUI element. Used by the layout only when exact height is not specified.
- /// </summary>
- public int MaxHeight
- {
- get { int value; Internal_GetMaxHeight(mCachedPtr, out value); return value; }
- set { Internal_SetMaxHeight(mCachedPtr, value); }
- }
- /// <summary>
- /// Determines should the layout resize the element depending on available size. If true no resizing will be done.
- /// </summary>
- public bool FixedWidth
- {
- get { bool value; Internal_GetFixedWidth(mCachedPtr, out value); return value; }
- set { Internal_SetFixedWidth(mCachedPtr, value); }
- }
- /// <summary>
- /// Determines should the layout resize the element depending on available size. If true no resizing will be done.
- /// </summary>
- public bool FixedHeight
- {
- get { bool value; Internal_GetFixedHeight(mCachedPtr, out value); return value; }
- set { Internal_SetFixedHeight(mCachedPtr, value); }
- }
- /// <summary>
- /// Registers a new sub-style that is used by complex GUI elements that contain one or multiple sub-elements.
- /// </summary>
- /// <param name="guiType">Name of the sub-element this style is to be used for. This depends on GUI element the
- /// style is applied to.</param>
- /// <param name="styleName">Name of the style in GUI skin to use for the sub-element.</param>
- public void AddSubStyle(string guiType, string styleName)
- {
- if (guiType == null || styleName == null)
- return;
- Internal_AddSubStyle(mCachedPtr, guiType, styleName);
- }
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_CreateInstance(GUIElementStyle instance);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetFont(IntPtr nativeInstance, out Font value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetFont(IntPtr nativeInstance, Font value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetFontSize(IntPtr nativeInstance, out int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetFontSize(IntPtr nativeInstance, int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetTextHorzAlign(IntPtr nativeInstance, out TextHorzAlign value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetTextHorzAlign(IntPtr nativeInstance, TextHorzAlign value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetTextVertAlign(IntPtr nativeInstance, out TextVertAlign value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetTextVertAlign(IntPtr nativeInstance, TextVertAlign value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetImagePosition(IntPtr nativeInstance, out GUIImagePosition value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetImagePosition(IntPtr nativeInstance, GUIImagePosition value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetWordWrap(IntPtr nativeInstance, out bool value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetWordWrap(IntPtr nativeInstance, bool value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetNormal(IntPtr nativeInstance, out GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetNormal(IntPtr nativeInstance, ref GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetHover(IntPtr nativeInstance, out GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetHover(IntPtr nativeInstance, ref GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetActive(IntPtr nativeInstance, out GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetActive(IntPtr nativeInstance, ref GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetFocused(IntPtr nativeInstance, out GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetFocused(IntPtr nativeInstance, ref GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetNormalOn(IntPtr nativeInstance, out GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetNormalOn(IntPtr nativeInstance, ref GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetHoverOn(IntPtr nativeInstance, out GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetHoverOn(IntPtr nativeInstance, ref GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetActiveOn(IntPtr nativeInstance, out GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetActiveOn(IntPtr nativeInstance, ref GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetFocusedOn(IntPtr nativeInstance, out GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetFocusedOn(IntPtr nativeInstance, ref GUIElementStateStyle value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetBorder(IntPtr nativeInstance, out RectOffset value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetBorder(IntPtr nativeInstance, ref RectOffset value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetMargins(IntPtr nativeInstance, out RectOffset value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetMargins(IntPtr nativeInstance, ref RectOffset value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetContentOffset(IntPtr nativeInstance, out RectOffset value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetContentOffset(IntPtr nativeInstance, ref RectOffset value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetWidth(IntPtr nativeInstance, out int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetWidth(IntPtr nativeInstance, int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetHeight(IntPtr nativeInstance, out int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetHeight(IntPtr nativeInstance, int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetMinWidth(IntPtr nativeInstance, out int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetMinWidth(IntPtr nativeInstance, int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetMaxWidth(IntPtr nativeInstance, out int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetMaxWidth(IntPtr nativeInstance, int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetMinHeight(IntPtr nativeInstance, out int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetMinHeight(IntPtr nativeInstance, int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetMaxHeight(IntPtr nativeInstance, out int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetMaxHeight(IntPtr nativeInstance, int value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetFixedWidth(IntPtr nativeInstance, out bool value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetFixedWidth(IntPtr nativeInstance, bool value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetFixedHeight(IntPtr nativeInstance, out bool value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetFixedHeight(IntPtr nativeInstance, bool value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_AddSubStyle(IntPtr nativeInstance, string guiType, string styleName);
- }
- /** @} */
- }
|