integrate scrollbar and checkbox art. fixes #215.
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace OpenRA.Widgets
|
||||
public ImageWidget()
|
||||
: base()
|
||||
{
|
||||
GetImageName = () => { return ImageName; };
|
||||
GetImageCollection = () => { return ImageCollection; };
|
||||
GetImageName = () => ImageName;
|
||||
GetImageCollection = () => ImageCollection;
|
||||
}
|
||||
|
||||
protected ImageWidget(ImageWidget other)
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace OpenRA.Widgets
|
||||
public LabelWidget()
|
||||
: base()
|
||||
{
|
||||
GetText = () => { return Text; };
|
||||
GetBackground = () => { return Background; };
|
||||
GetText = () => Text;
|
||||
GetBackground = () => Background;
|
||||
}
|
||||
|
||||
protected LabelWidget(LabelWidget other)
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
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)
|
||||
|
||||
@@ -8,14 +8,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
[Flags]
|
||||
@@ -33,9 +27,9 @@ namespace OpenRA.Widgets
|
||||
public int EdgeScrollThreshold = 15;
|
||||
|
||||
ScrollDirection Keyboard;
|
||||
ScrollDirection Edge;
|
||||
|
||||
public ViewportScrollControllerWidget() : base() {}
|
||||
ScrollDirection Edge;
|
||||
|
||||
public ViewportScrollControllerWidget() : base() { }
|
||||
protected ViewportScrollControllerWidget(ViewportScrollControllerWidget widget) : base(widget) {}
|
||||
public override void DrawInner( World world ) {}
|
||||
|
||||
|
||||
@@ -6,15 +6,14 @@
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Orders;
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user