integrate scrollbar and checkbox art. fixes #215.

This commit is contained in:
Chris Forbes
2010-07-28 18:16:47 +12:00
parent 72d6a211af
commit 5ca7218eb6
12 changed files with 81 additions and 66 deletions

View File

@@ -10,6 +10,7 @@
using System;
using System.Drawing;
using OpenRA.Graphics;
namespace OpenRA.Widgets
{
@@ -18,11 +19,11 @@ namespace OpenRA.Widgets
public string Text = "";
public int baseLine = 1;
public bool Bold = false;
public Func<bool> Checked = () => {return false;};
public Func<bool> Checked = () => false;
public override void DrawInner(World world)
{
var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
var font = Bold ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
var pos = RenderOrigin;
var rect = RenderBounds;
var check = new Rectangle(rect.Location,
@@ -31,14 +32,13 @@ namespace OpenRA.Widgets
var textSize = font.Measure(Text);
font.DrawText(Text,
new float2(rect.Left + rect.Height * 1.5f, pos.Y - baseLine + (Bounds.Height - textSize.Y)/2), Color.White);
new float2(rect.Left + rect.Height * 1.5f,
pos.Y - baseLine + (Bounds.Height - textSize.Y)/2), Color.White);
if (Checked())
{
Game.Renderer.RgbaSpriteRenderer.Flush();
WidgetUtils.FillRectWithColor(check.InflateBy(-4,-5,-4,-5),Color.White);
Game.Renderer.LineRenderer.Flush();
}
WidgetUtils.DrawRGBA(
ChromeProvider.GetImage("checkbox", "checked"),
new float2(rect.Left + 2, rect.Top + 2));
}
public override bool HandleInputInner(MouseInput mi) { return true; }

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Widgets
public ImageWidget()
: base()
{
GetImageName = () => { return ImageName; };
GetImageCollection = () => { return ImageCollection; };
GetImageName = () => ImageName;
GetImageCollection = () => ImageCollection;
}
protected ImageWidget(ImageWidget other)

View File

@@ -27,8 +27,8 @@ namespace OpenRA.Widgets
public LabelWidget()
: base()
{
GetText = () => { return Text; };
GetBackground = () => { return Background; };
GetText = () => Text;
GetBackground = () => Background;
}
protected LabelWidget(LabelWidget other)

View File

@@ -9,6 +9,7 @@
#endregion
using System.Drawing;
using OpenRA.Graphics;
namespace OpenRA.Widgets
{
@@ -63,6 +64,15 @@ namespace OpenRA.Widgets
WidgetUtils.DrawPanel(downButtonBg, downButtonRect);
WidgetUtils.DrawPanel(scrollbarBg, scrollbarRect);
var upOffset = UpPressed ? 4 : 3;
var downOffset = DownPressed ? 4 : 3;
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", "up_arrow"),
new float2(upButtonRect.Left + upOffset, upButtonRect.Top + upOffset));
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", "down_arrow"),
new float2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset));
Game.Renderer.RgbaSpriteRenderer.Flush();
Game.Renderer.Device.EnableScissor(backgroundRect.X, backgroundRect.Y + HeaderHeight, backgroundRect.Width, backgroundRect.Height - HeaderHeight);
foreach (var child in Children)

View File

@@ -9,12 +9,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Orders;
using OpenRA.Traits;
using OpenRA.FileFormats;
namespace OpenRA.Widgets
{

View File

@@ -9,12 +9,11 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Orders;
using OpenRA.Traits;
using OpenRA.FileFormats;
namespace OpenRA.Widgets
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -13,11 +13,8 @@
<image name="bg" x="306" y="31" width="192" height="192" />
<image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection>
<collection name="power-gdi" src="chrome-gdi.png">
<image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection>
<collection name="palette-gdi" src="chrome-gdi.png">
<image name="top" x="297" y="288" width="201" height="9" />
@@ -59,11 +56,8 @@
<image name="bg" x="306" y="31" width="192" height="192" />
<image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection>
<collection name="power-nod" src="chrome-nod.png">
<image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection>
<collection name="palette-nod" src="chrome-nod.png">
<image name="top" x="297" y="288" width="201" height="9" />
@@ -208,4 +202,11 @@
<image name="next" x="84" y="0" width="25" height="25" />
<image name="prev" x="112" y="0" width="25" height="25" />
</collection>
<collection name="scrollbar" src="buttons.png">
<image name="down_arrow" x="16" y="112" width="16" height="16" />
<image name="up_arrow" x="32" y="112" width="16" height="16" />
</collection>
<collection name="checkbox" src="buttons.png">
<image name="checked" x="0" y="112" width="16" height="16" />
</collection>
</chrome>

View File

@@ -96,8 +96,9 @@ Container@ROOT:
Checkbox@STATUS:
Id:STATUS
X:455
Width:25
Height:25
Y:2
Width:20
Height:20
Container@TEMPLATE_REMOTE:
Id:TEMPLATE_REMOTE
X:0
@@ -151,8 +152,9 @@ Container@ROOT:
Checkbox@STATUS:
Id:STATUS
X:455
Width:25
Height:25
Y:2
Width:20
Height:20
Container@LABEL_CONTAINER:
X:30
Y:45

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -201,4 +201,11 @@
<image name="next" x="84" y="0" width="25" height="25" />
<image name="prev" x="112" y="0" width="25" height="25" />
</collection>
<collection name="scrollbar" src="buttons.png">
<image name="down_arrow" x="16" y="112" width="16" height="16" />
<image name="up_arrow" x="32" y="112" width="16" height="16" />
</collection>
<collection name="checkbox" src="buttons.png">
<image name="checked" x="0" y="112" width="16" height="16" />
</collection>
</chrome>

View File

@@ -96,8 +96,9 @@ Container@ROOT:
Checkbox@STATUS:
Id:STATUS
X:455
Width:25
Height:25
Y:2
Width:20
Height:20
Container@TEMPLATE_REMOTE:
Id:TEMPLATE_REMOTE
X:0
@@ -151,8 +152,9 @@ Container@ROOT:
Checkbox@STATUS:
Id:STATUS
X:455
Width:25
Height:25
Y:2
Width:20
Height:20
Container@LABEL_CONTAINER:
X:30
Y:45