using System;
using Gwen.Control;
namespace Gwen.ControlInternal
{
///
/// Scrollbar bar.
///
public class ScrollBarBar : Dragger
{
private bool m_Horizontal;
///
/// Indicates whether the bar is horizontal.
///
public bool IsHorizontal { get { return m_Horizontal; } set { m_Horizontal = value; } }
///
/// Indicates whether the bar is vertical.
///
public bool IsVertical { get { return !m_Horizontal; } set { m_Horizontal = !value; } }
///
/// Initializes a new instance of the class.
///
/// Parent control.
public ScrollBarBar(Base parent)
: base(parent)
{
RestrictToParent = true;
Target = this;
}
///
/// Renders the control using specified skin.
///
/// Skin to use.
protected override void Render(Skin.Base skin)
{
skin.DrawScrollBarBar(this, m_Held, IsHovered, m_Horizontal);
base.Render(skin);
}
///
/// Handler invoked on mouse moved event.
///
/// X coordinate.
/// Y coordinate.
/// X change.
/// Y change.
protected override void OnMouseMoved(int x, int y, int dx, int dy)
{
base.OnMouseMoved(x, y, dx, dy);
if (!m_Held)
return;
InvalidateParent();
}
///
/// Handler invoked on mouse click (left) event.
///
/// X coordinate.
/// Y coordinate.
/// If set to true mouse button is down.
protected override void OnMouseClickedLeft(int x, int y, bool down)
{
base.OnMouseClickedLeft(x, y, down);
InvalidateParent();
}
///
/// Lays out the control's interior according to alignment, padding, dock etc.
///
/// Skin to use.
protected override void Layout(Skin.Base skin)
{
if (null == Parent)
return;
//Move to our current position to force clamping - is this a hack?
MoveTo(X, Y);
}
}
}