Rename TooltipButton -> ToggleButton and add an active state. Use for production group icons.

This commit is contained in:
Paul Chote
2011-07-14 22:22:15 +12:00
parent fef8008c87
commit 8f4c2371c7
9 changed files with 125 additions and 27 deletions

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Widgets
public override int2 ChildOrigin { get { return RenderOrigin +
((Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0)); } }
public override void Draw()
{
var rb = RenderBounds;
@@ -128,7 +128,7 @@ namespace OpenRA.Widgets
var s = font.Measure(text);
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
DrawBackground("button", rb, disabled, Depressed, Widget.MouseOverWidget == this);
DrawBackground(rb, disabled, Depressed, Widget.MouseOverWidget == this);
font.DrawText(text, new int2(rb.X + (UsableWidth - s.X)/ 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset,
disabled ? Color.Gray : Color.White);
}
@@ -136,6 +136,11 @@ namespace OpenRA.Widgets
public override Widget Clone() { return new ButtonWidget(this); }
public virtual int UsableWidth { get { return Bounds.Width; } }
public virtual void DrawBackground(Rectangle rect, bool disabled, bool pressed, bool hover)
{
ButtonWidget.DrawBackground("button", rect, disabled, pressed, hover);
}
public static void DrawBackground(string baseName, Rectangle rect, bool disabled, bool pressed, bool hover)
{
var state = disabled ? "-disabled" :