integrate scrollbar and checkbox art. fixes #215.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -18,11 +19,11 @@ namespace OpenRA.Widgets
|
|||||||
public string Text = "";
|
public string Text = "";
|
||||||
public int baseLine = 1;
|
public int baseLine = 1;
|
||||||
public bool Bold = false;
|
public bool Bold = false;
|
||||||
public Func<bool> Checked = () => {return false;};
|
public Func<bool> Checked = () => false;
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
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 pos = RenderOrigin;
|
||||||
var rect = RenderBounds;
|
var rect = RenderBounds;
|
||||||
var check = new Rectangle(rect.Location,
|
var check = new Rectangle(rect.Location,
|
||||||
@@ -31,14 +32,13 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
var textSize = font.Measure(Text);
|
var textSize = font.Measure(Text);
|
||||||
font.DrawText(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())
|
if (Checked())
|
||||||
{
|
WidgetUtils.DrawRGBA(
|
||||||
Game.Renderer.RgbaSpriteRenderer.Flush();
|
ChromeProvider.GetImage("checkbox", "checked"),
|
||||||
WidgetUtils.FillRectWithColor(check.InflateBy(-4,-5,-4,-5),Color.White);
|
new float2(rect.Left + 2, rect.Top + 2));
|
||||||
Game.Renderer.LineRenderer.Flush();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleInputInner(MouseInput mi) { return true; }
|
public override bool HandleInputInner(MouseInput mi) { return true; }
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ namespace OpenRA.Widgets
|
|||||||
public ImageWidget()
|
public ImageWidget()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
GetImageName = () => { return ImageName; };
|
GetImageName = () => ImageName;
|
||||||
GetImageCollection = () => { return ImageCollection; };
|
GetImageCollection = () => ImageCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ImageWidget(ImageWidget other)
|
protected ImageWidget(ImageWidget other)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace OpenRA.Widgets
|
|||||||
public LabelWidget()
|
public LabelWidget()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
GetText = () => { return Text; };
|
GetText = () => Text;
|
||||||
GetBackground = () => { return Background; };
|
GetBackground = () => Background;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LabelWidget(LabelWidget other)
|
protected LabelWidget(LabelWidget other)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -63,6 +64,15 @@ namespace OpenRA.Widgets
|
|||||||
WidgetUtils.DrawPanel(downButtonBg, downButtonRect);
|
WidgetUtils.DrawPanel(downButtonBg, downButtonRect);
|
||||||
WidgetUtils.DrawPanel(scrollbarBg, scrollbarRect);
|
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);
|
Game.Renderer.Device.EnableScissor(backgroundRect.X, backgroundRect.Y + HeaderHeight, backgroundRect.Width, backgroundRect.Height - HeaderHeight);
|
||||||
|
|
||||||
foreach (var child in Children)
|
foreach (var child in Children)
|
||||||
|
|||||||
@@ -9,12 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Orders;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -35,7 +29,7 @@ namespace OpenRA.Widgets
|
|||||||
ScrollDirection Keyboard;
|
ScrollDirection Keyboard;
|
||||||
ScrollDirection Edge;
|
ScrollDirection Edge;
|
||||||
|
|
||||||
public ViewportScrollControllerWidget() : base() {}
|
public ViewportScrollControllerWidget() : base() { }
|
||||||
protected ViewportScrollControllerWidget(ViewportScrollControllerWidget widget) : base(widget) {}
|
protected ViewportScrollControllerWidget(ViewportScrollControllerWidget widget) : base(widget) {}
|
||||||
public override void DrawInner( World world ) {}
|
public override void DrawInner( World world ) {}
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,11 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Orders;
|
using OpenRA.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.FileFormats;
|
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
@@ -13,11 +13,8 @@
|
|||||||
<image name="bg" x="306" y="31" width="192" height="192" />
|
<image name="bg" x="306" y="31" width="192" height="192" />
|
||||||
<image name="power-indicator" x="187" y="4" width="4" height="7" />
|
<image name="power-indicator" x="187" y="4" width="4" height="7" />
|
||||||
</collection>
|
</collection>
|
||||||
|
|
||||||
<collection name="power-gdi" src="chrome-gdi.png">
|
<collection name="power-gdi" src="chrome-gdi.png">
|
||||||
|
|
||||||
<image name="power-indicator" x="187" y="4" width="4" height="7" />
|
<image name="power-indicator" x="187" y="4" width="4" height="7" />
|
||||||
|
|
||||||
</collection>
|
</collection>
|
||||||
<collection name="palette-gdi" src="chrome-gdi.png">
|
<collection name="palette-gdi" src="chrome-gdi.png">
|
||||||
<image name="top" x="297" y="288" width="201" height="9" />
|
<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="bg" x="306" y="31" width="192" height="192" />
|
||||||
<image name="power-indicator" x="187" y="4" width="4" height="7" />
|
<image name="power-indicator" x="187" y="4" width="4" height="7" />
|
||||||
</collection>
|
</collection>
|
||||||
|
|
||||||
<collection name="power-nod" src="chrome-nod.png">
|
<collection name="power-nod" src="chrome-nod.png">
|
||||||
|
|
||||||
<image name="power-indicator" x="187" y="4" width="4" height="7" />
|
<image name="power-indicator" x="187" y="4" width="4" height="7" />
|
||||||
|
|
||||||
</collection>
|
</collection>
|
||||||
<collection name="palette-nod" src="chrome-nod.png">
|
<collection name="palette-nod" src="chrome-nod.png">
|
||||||
<image name="top" x="297" y="288" width="201" height="9" />
|
<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="next" x="84" y="0" width="25" height="25" />
|
||||||
<image name="prev" x="112" y="0" width="25" height="25" />
|
<image name="prev" x="112" y="0" width="25" height="25" />
|
||||||
</collection>
|
</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>
|
</chrome>
|
||||||
|
|||||||
@@ -96,8 +96,9 @@ Container@ROOT:
|
|||||||
Checkbox@STATUS:
|
Checkbox@STATUS:
|
||||||
Id:STATUS
|
Id:STATUS
|
||||||
X:455
|
X:455
|
||||||
Width:25
|
Y:2
|
||||||
Height:25
|
Width:20
|
||||||
|
Height:20
|
||||||
Container@TEMPLATE_REMOTE:
|
Container@TEMPLATE_REMOTE:
|
||||||
Id:TEMPLATE_REMOTE
|
Id:TEMPLATE_REMOTE
|
||||||
X:0
|
X:0
|
||||||
@@ -151,8 +152,9 @@ Container@ROOT:
|
|||||||
Checkbox@STATUS:
|
Checkbox@STATUS:
|
||||||
Id:STATUS
|
Id:STATUS
|
||||||
X:455
|
X:455
|
||||||
Width:25
|
Y:2
|
||||||
Height:25
|
Width:20
|
||||||
|
Height:20
|
||||||
Container@LABEL_CONTAINER:
|
Container@LABEL_CONTAINER:
|
||||||
X:30
|
X:30
|
||||||
Y:45
|
Y:45
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@@ -201,4 +201,11 @@
|
|||||||
<image name="next" x="84" y="0" width="25" height="25" />
|
<image name="next" x="84" y="0" width="25" height="25" />
|
||||||
<image name="prev" x="112" y="0" width="25" height="25" />
|
<image name="prev" x="112" y="0" width="25" height="25" />
|
||||||
</collection>
|
</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>
|
</chrome>
|
||||||
|
|||||||
@@ -96,8 +96,9 @@ Container@ROOT:
|
|||||||
Checkbox@STATUS:
|
Checkbox@STATUS:
|
||||||
Id:STATUS
|
Id:STATUS
|
||||||
X:455
|
X:455
|
||||||
Width:25
|
Y:2
|
||||||
Height:25
|
Width:20
|
||||||
|
Height:20
|
||||||
Container@TEMPLATE_REMOTE:
|
Container@TEMPLATE_REMOTE:
|
||||||
Id:TEMPLATE_REMOTE
|
Id:TEMPLATE_REMOTE
|
||||||
X:0
|
X:0
|
||||||
@@ -151,8 +152,9 @@ Container@ROOT:
|
|||||||
Checkbox@STATUS:
|
Checkbox@STATUS:
|
||||||
Id:STATUS
|
Id:STATUS
|
||||||
X:455
|
X:455
|
||||||
Width:25
|
Y:2
|
||||||
Height:25
|
Width:20
|
||||||
|
Height:20
|
||||||
Container@LABEL_CONTAINER:
|
Container@LABEL_CONTAINER:
|
||||||
X:30
|
X:30
|
||||||
Y:45
|
Y:45
|
||||||
|
|||||||
Reference in New Issue
Block a user