//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System;
using System.Runtime.CompilerServices;
namespace BansheeEngine
{
/** @addtogroup GUI_Engine
* @{
*/
///
/// Type of scaling modes for GUI images.
///
public enum GUITextureScaleMode // Note: Must match C++ enum TextureScaleMode
{
///
/// Image will stretch non-uniformly in all dimensions in order to cover the assigned area fully.
///
StretchToFit,
///
/// Image will scale uniformly until one dimension is aligned with the assigned area. Remaining dimension might have empty space.
///
ScaleToFit,
///
/// Image will scale uniformly until both dimensions are larger or aligned with the assigned area. Remaining dimension might be cropped.
///
CropToFit,
///
/// Image will keep its original size, but will repeat in order to fill the assigned area.
///
RepeatToFit
};
///
/// A GUI element that displays a texture.
///
public sealed class GUITexture : GUIElement
{
///
/// Creates a new texture element.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
/// Scale mode to use when sizing the texture.
/// Determines should the texture be rendered with transparency active.
/// Optional style to use for the element. Style controls the look of the element, as well as
/// default layout options. Style will be retrieved from the active GUISkin. If not specified
/// default element style is used.
/// Options that allow you to control how is the element positioned and sized. This will
/// override any similar options set by style.
public GUITexture(SpriteTexture texture, GUITextureScaleMode scale, bool transparent, string style, params GUIOption[] options)
{
Internal_CreateInstance(this, texture, scale, transparent, style, options);
}
///
/// Creates a new texture element.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
/// Scale mode to use when sizing the texture.
/// Determines should the texture be rendered with transparency active.
/// Options that allow you to control how is the element positioned and sized. This will
/// override any similar options set by style.
public GUITexture(SpriteTexture texture, GUITextureScaleMode scale, bool transparent, params GUIOption[] options)
{
Internal_CreateInstance(this, texture, scale, transparent, "", options);
}
///
/// Creates a new texture element. Texture will use the default StretchToFit scaling.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
/// Determines should the texture be rendered with transparency active.
/// Optional style to use for the element. Style controls the look of the element, as well as
/// default layout options. Style will be retrieved from the active GUISkin. If not specified
/// default element style is used.
/// Options that allow you to control how is the element positioned and sized. This will
/// override any similar options set by style.
public GUITexture(SpriteTexture texture, bool transparent, string style, params GUIOption[] options)
{
Internal_CreateInstance(this, texture, GUITextureScaleMode.StretchToFit, transparent, style, options);
}
///
/// Creates a new texture element. Texture will use the default StretchToFit scaling.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
/// Determines should the texture be rendered with transparency active.
/// Options that allow you to control how is the element positioned and sized. This will
/// override any similar options set by style.
public GUITexture(SpriteTexture texture, bool transparent, params GUIOption[] options)
{
Internal_CreateInstance(this, texture, GUITextureScaleMode.StretchToFit, transparent, "", options);
}
///
/// Creates a new texture element with transparency active.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
/// Scale mode to use when sizing the texture.
/// Optional style to use for the element. Style controls the look of the element, as well as
/// default layout options. Style will be retrieved from the active GUISkin. If not specified
/// default element style is used.
/// Options that allow you to control how is the element positioned and sized. This will
/// override any similar options set by style.
public GUITexture(SpriteTexture texture, GUITextureScaleMode scale, string style, params GUIOption[] options)
{
Internal_CreateInstance(this, texture, scale, true, style, options);
}
///
/// Creates a new texture element with transparency active.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
/// Scale mode to use when sizing the texture.
/// Options that allow you to control how is the element positioned and sized. This will
/// override any similar options set by style.
public GUITexture(SpriteTexture texture, GUITextureScaleMode scale, params GUIOption[] options)
{
Internal_CreateInstance(this, texture, scale, true, "", options);
}
///
/// Creates a new texture element with transparency active. Texture will use the default StretchToFit scaling.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
/// Optional style to use for the element. Style controls the look of the element, as well as
/// default layout options. Style will be retrieved from the active GUISkin. If not specified
/// default element style is used.
/// Options that allow you to control how is the element positioned and sized. This will
/// override any similar options set by style.
public GUITexture(SpriteTexture texture, string style, params GUIOption[] options)
{
Internal_CreateInstance(this, texture, GUITextureScaleMode.StretchToFit, true, style, options);
}
///
/// Creates a new texture element with transparency active. Texture will use the default StretchToFit scaling.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
/// Options that allow you to control how is the element positioned and sized. This will
/// override any similar options set by style.
public GUITexture(SpriteTexture texture, params GUIOption[] options)
{
Internal_CreateInstance(this, texture, GUITextureScaleMode.StretchToFit, true, "", options);
}
///
/// Sets the texture to display.
///
/// Texture to display. If this is null then the texture specified by the style will
/// be used.
public void SetTexture(SpriteTexture texture)
{
Internal_SetTexture(mCachedPtr, texture);
}
///
/// Colors the element with a specific tint.
///
/// Tint to apply to the element.
public void SetTint(Color color)
{
Internal_SetTint(mCachedPtr, ref color);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_CreateInstance(GUITexture instance, SpriteTexture texture,
GUITextureScaleMode scale, bool transparent, string style, GUIOption[] options);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetTexture(IntPtr nativeInstance, SpriteTexture texture);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetTint(IntPtr nativeInstance, ref Color color);
}
/** @} */
}