Layout/font weight polish

This commit is contained in:
Paul Chote
2010-07-10 23:19:55 +12:00
parent 56fb711fc6
commit a29198c237
5 changed files with 79 additions and 36 deletions

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Widgets
class ButtonWidget : Widget
{
public string Text = "";
public bool Bold = false;
public bool Depressed = false;
public int VisualHeight = 1;
public Func<string> GetText;
@@ -82,16 +83,16 @@ namespace OpenRA.Widgets
public override void DrawInner(World world)
{
var pos = DrawPosition();
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
WidgetUtils.DrawPanel(Depressed ? "dialog3" : "dialog2",
new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height ) );
var text = GetText();
Game.chrome.renderer.BoldFont.DrawText(text,
font.DrawText(text,
new int2( pos.X + Bounds.Width / 2, pos.Y + Bounds.Height / 2)
- new int2(Game.chrome.renderer.BoldFont.Measure(text).X / 2,
Game.chrome.renderer.BoldFont.Measure(text).Y / 2) + stateOffset, Color.White);
- new int2(font.Measure(text).X / 2,
font.Measure(text).Y / 2) + stateOffset, Color.White);
}
public override Widget Clone()

View File

@@ -26,17 +26,21 @@ namespace OpenRA.Widgets
class CheckboxWidget : Widget
{
public string Text = "";
public int baseLine = 1;
public bool Bold = false;
public Func<bool> Checked = () => {return false;};
public override void DrawInner(World world)
{
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
var pos = DrawPosition();
var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height);
WidgetUtils.DrawPanel("dialog3", new Rectangle(rect.Location,
new Size(Bounds.Height, Bounds.Height)));
Game.chrome.renderer.BoldFont.DrawText(Text,
new float2(rect.Left + rect.Height * 2, rect.Top), Color.White);
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);
if (Checked())
{

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Widgets
public string Text = "";
public TextAlign Align = TextAlign.Left;
public bool Bold = true;
public bool Bold = false;
public Func<string> GetText;
public LabelWidget()

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Widgets
class TextFieldWidget : Widget
{
public string Text = "";
public bool Bold = true;
public bool Bold = false;
public int VisualHeight = 1;
public Func<bool> OnEnterKey = () => {return false;};
public Func<bool> OnTabKey = () => {return false;};