Define BaseLine offset for ButtonWidget.

This commit is contained in:
Paul Chote
2014-10-12 18:40:15 +13:00
parent 6556cfc667
commit d117faa48d
2 changed files with 3 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Widgets
public string Background = "button"; public string Background = "button";
public bool Depressed = false; public bool Depressed = false;
public int VisualHeight = ChromeMetrics.Get<int>("ButtonDepth"); public int VisualHeight = ChromeMetrics.Get<int>("ButtonDepth");
public int BaseLine = 0;
public string Font = ChromeMetrics.Get<string>("ButtonFont"); public string Font = ChromeMetrics.Get<string>("ButtonFont");
public Color TextColor = ChromeMetrics.Get<Color>("ButtonTextColor"); public Color TextColor = ChromeMetrics.Get<Color>("ButtonTextColor");
public Color TextColorDisabled = ChromeMetrics.Get<Color>("ButtonTextColorDisabled"); public Color TextColorDisabled = ChromeMetrics.Get<Color>("ButtonTextColorDisabled");
@@ -78,6 +79,7 @@ namespace OpenRA.Widgets
Text = other.Text; Text = other.Text;
Font = other.Font; Font = other.Font;
BaseLine = other.BaseLine;
TextColor = other.TextColor; TextColor = other.TextColor;
TextColorDisabled = other.TextColorDisabled; TextColorDisabled = other.TextColorDisabled;
Contrast = other.Contrast; Contrast = other.Contrast;
@@ -202,7 +204,7 @@ namespace OpenRA.Widgets
var contrast = GetContrastColor(); var contrast = GetContrastColor();
var s = font.Measure(text); var s = font.Measure(text);
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0); var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
var position = new int2(rb.X + (UsableWidth - s.X) / 2, rb.Y + (Bounds.Height - s.Y) / 2); var position = new int2(rb.X + (UsableWidth - s.X) / 2, rb.Y - BaseLine + (Bounds.Height - s.Y) / 2);
DrawBackground(rb, disabled, Depressed, Ui.MouseOverWidget == this, highlighted); DrawBackground(rb, disabled, Depressed, Ui.MouseOverWidget == this, highlighted);
if (Contrast) if (Contrast)

View File

@@ -19,7 +19,6 @@ namespace OpenRA.Widgets
public string CheckType = "checked"; public string CheckType = "checked";
public Func<string> GetCheckType; public Func<string> GetCheckType;
public Func<bool> IsChecked = () => false; public Func<bool> IsChecked = () => false;
public int BaseLine = 1;
public int CheckOffset = 2; public int CheckOffset = 2;
public bool HasPressedState = ChromeMetrics.Get<bool>("CheckboxPressedState"); public bool HasPressedState = ChromeMetrics.Get<bool>("CheckboxPressedState");
@@ -36,7 +35,6 @@ namespace OpenRA.Widgets
CheckType = other.CheckType; CheckType = other.CheckType;
GetCheckType = other.GetCheckType; GetCheckType = other.GetCheckType;
IsChecked = other.IsChecked; IsChecked = other.IsChecked;
BaseLine = other.BaseLine;
CheckOffset = other.CheckOffset; CheckOffset = other.CheckOffset;
HasPressedState = other.HasPressedState; HasPressedState = other.HasPressedState;
} }