//********************************** 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
* @{
*/
///
/// GUI element representing an element with a draggable handle of a variable size.
///
public class GUIScrollBar : GUIElement
{
///
/// Position of the scroll handle in percent (ranging [0, 1]).
///
public float Position
{
get { return Internal_GetPosition(mCachedPtr); }
set { Internal_SetPosition(mCachedPtr, value); }
}
///
/// Size of the scroll handle in percent (ranging [0, 1]) of the total scroll bar area.
///
public float HandleSize
{
get { return Internal_GetHandleSize(mCachedPtr); }
set { Internal_SetHandleSize(mCachedPtr, value); }
}
///
/// 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 float Internal_GetPosition(IntPtr nativeInstance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetPosition(IntPtr nativeInstance, float percent);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_GetHandleSize(IntPtr nativeInstance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetHandleSize(IntPtr nativeInstance, float percent);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetTint(IntPtr nativeInstance, ref Color color);
}
///
/// GUI element representing a horizontal scroll bar.
///
public sealed class GUIScrollBarH : GUIScrollBar
{
///
/// Event triggered whenever the user moves the scroll bar. Value reported is the position of the scroll bar handle
/// in percent, in [0, 1] range.
///
public event Action OnScroll;
///
/// Creates a new horizontal scroll bar element.
///
/// 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 GUIScrollBarH(string style, params GUIOption[] options)
{
Internal_CreateInstance(this, style, options);
}
///
/// Creates a new horizontal scroll bar element.
///
/// 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.
public GUIScrollBarH(string style = "")
{
Internal_CreateInstance(this, style, new GUIOption[0]);
}
private void Internal_DoOnScroll(float position)
{
if (OnScroll != null)
OnScroll(position);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_CreateInstance(GUIScrollBarH instance, string style, GUIOption[] options);
}
///
/// GUI element representing a vertical scroll bar.
///
public sealed class GUIScrollBarV : GUIScrollBar
{
///
/// Event triggered whenever the user moves the scroll bar. Value reported is the position of the scroll bar handle
/// in percent, in [0, 1] range.
///
public event Action OnScroll;
///
/// Creates a new vertical scroll bar element.
///
/// 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 GUIScrollBarV(string style, params GUIOption[] options)
{
Internal_CreateInstance(this, style, options);
}
///
/// Creates a new vertical scroll bar element.
///
/// 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.
public GUIScrollBarV(string style = "")
{
Internal_CreateInstance(this, style, new GUIOption[0]);
}
private void Internal_DoOnScroll(float position)
{
if (OnScroll != null)
OnScroll(position);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_CreateInstance(GUIScrollBarV instance, string style, GUIOption[] options);
}
///
/// GUI element representing a horizontal scroll bar, with resize handles that allow the user to resize the visible
/// scroll area.
///
public sealed class GUIResizeableScrollBarH : GUIScrollBar
{
///
/// Event triggered whenever the user moves or resizes the scroll bar. Value reported is the position and size of
/// the scroll bar handle in percent, in [0, 1] range.
///
public event Action OnScrollOrResize;
///
/// Creates a new resizeable horizontal scroll bar element.
///
/// 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 GUIResizeableScrollBarH(string style, params GUIOption[] options)
{
Internal_CreateInstance(this, style, options);
}
///
/// Creates a new resizeable horizontal scroll bar element.
///
/// 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.
public GUIResizeableScrollBarH(string style = "")
{
Internal_CreateInstance(this, style, new GUIOption[0]);
}
private void Internal_DoOnScrollOrResize(float percent, float size)
{
if (OnScrollOrResize != null)
OnScrollOrResize(percent, size);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_CreateInstance(GUIResizeableScrollBarH instance, string style, GUIOption[] options);
}
///
/// GUI element representing a vertical scroll bar, with resize handles that allow the user to resize the visible
/// scroll area.
///
public sealed class GUIResizeableScrollBarV : GUIScrollBar
{
///
/// Event triggered whenever the user moves or resizes the scroll bar. Value reported is the position and size of
/// the scroll bar handle in percent, in [0, 1] range.
///
public event Action OnScrollOrResize;
///
/// Creates a new resizeable vertical scroll bar element.
///
/// 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 GUIResizeableScrollBarV(string style, params GUIOption[] options)
{
Internal_CreateInstance(this, style, options);
}
///
/// Creates a new resizeable vertical scroll bar element.
///
/// 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.
public GUIResizeableScrollBarV(string style = "")
{
Internal_CreateInstance(this, style, new GUIOption[0]);
}
private void Internal_DoOnScrollOrResize(float percent, float size)
{
if (OnScrollOrResize != null)
OnScrollOrResize(percent, size);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_CreateInstance(GUIResizeableScrollBarV instance, string style, GUIOption[] options);
}
/** @} */
}