Skip to content

Commit

Permalink
Polish: Offset button children by pressed state.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Nov 27, 2010
1 parent 306bece commit 7884cb3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions OpenRA.Game/Widgets/ButtonWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public override bool HandleInputInner(MouseInput mi)
return Depressed;
}

public override int2 ChildOrigin { get { return RenderOrigin +
((Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0)); } }

public override void DrawInner( WorldRenderer wr )
{
var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
Expand Down Expand Up @@ -97,13 +100,15 @@ protected DropDownButtonWidget(DropDownButtonWidget widget)
public override void DrawInner(WorldRenderer wr)
{
base.DrawInner(wr);
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);

var image = ChromeProvider.GetImage("scrollbar", "down_arrow");
WidgetUtils.DrawRGBA( image,
new float2( RenderBounds.Right - RenderBounds.Height + 4,
stateOffset + new float2( RenderBounds.Right - RenderBounds.Height + 4,
RenderBounds.Top + (RenderBounds.Height - image.bounds.Height) / 2 ));

WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.Right - RenderBounds.Height,
RenderBounds.Top + 3, 1, RenderBounds.Height - 6),
WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + RenderBounds.Right - RenderBounds.Height,
stateOffset.Y + RenderBounds.Top + 3, 1, RenderBounds.Height - 6),
Color.White);
}

Expand Down

0 comments on commit 7884cb3

Please sign in to comment.