using System;
using Gwen.Control;
namespace Gwen.ControlInternal
{
///
/// Item in CollapsibleCategory.
///
public class CategoryButton : Button
{
internal bool m_Alt; // for alternate coloring
///
/// Initializes a new instance of the class.
///
/// Parent control.
public CategoryButton(Base parent) : base(parent)
{
Alignment = Pos.Left | Pos.CenterV;
m_Alt = false;
IsToggle = true;
TextPadding = new Padding(3, 0, 3, 0);
}
///
/// Renders the control using specified skin.
///
/// Skin to use.
protected override void Render(Skin.Base skin)
{
if (m_Alt)
{
if (IsDepressed || ToggleState)
Skin.Renderer.DrawColor = skin.Colors.Category.LineAlt.Button_Selected;
else if (IsHovered)
Skin.Renderer.DrawColor = skin.Colors.Category.LineAlt.Button_Hover;
else
Skin.Renderer.DrawColor = skin.Colors.Category.LineAlt.Button;
}
else
{
if (IsDepressed || ToggleState)
Skin.Renderer.DrawColor = skin.Colors.Category.Line.Button_Selected;
else if (IsHovered)
Skin.Renderer.DrawColor = skin.Colors.Category.Line.Button_Hover;
else
Skin.Renderer.DrawColor = skin.Colors.Category.Line.Button;
}
skin.Renderer.DrawFilledRect(RenderBounds);
}
///
/// Updates control colors.
///
public override void UpdateColors()
{
if (m_Alt)
{
if (IsDepressed || ToggleState)
{
TextColor = Skin.Colors.Category.LineAlt.Text_Selected;
return;
}
if (IsHovered)
{
TextColor = Skin.Colors.Category.LineAlt.Text_Hover;
return;
}
TextColor = Skin.Colors.Category.LineAlt.Text;
return;
}
if (IsDepressed || ToggleState)
{
TextColor = Skin.Colors.Category.Line.Text_Selected;
return;
}
if (IsHovered)
{
TextColor = Skin.Colors.Category.Line.Text_Hover;
return;
}
TextColor = Skin.Colors.Category.Line.Text;
}
}
}