Removed BaseLine and updated ButtonWidget and CheckboxWidget to use Font.TopOffset

This commit is contained in:
teinarss
2019-05-27 18:53:08 +02:00
committed by abcdefg30
parent 9982b01642
commit ab382ce4d6
10 changed files with 9 additions and 37 deletions

View File

@@ -11,6 +11,7 @@
using System; using System;
using System.Linq; using System.Linq;
using OpenRA.Graphics;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -33,7 +34,6 @@ namespace OpenRA.Mods.Common.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 = ChromeMetrics.Get<int>("ButtonBaseLine");
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");
@@ -102,7 +102,6 @@ namespace OpenRA.Mods.Common.Widgets
LeftMargin = other.LeftMargin; LeftMargin = other.LeftMargin;
RightMargin = other.RightMargin; RightMargin = other.RightMargin;
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;
@@ -243,10 +242,10 @@ namespace OpenRA.Mods.Common.Widgets
var colordisabled = GetColorDisabled(); var colordisabled = GetColorDisabled();
var bgDark = GetContrastColorDark(); var bgDark = GetContrastColorDark();
var bgLight = GetContrastColorLight(); var bgLight = GetContrastColorLight();
var textSize = 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 = GetTextPosition(textSize, rb); var position = GetTextPosition(text, font, rb);
var hover = Ui.MouseOverWidget == this || Children.Any(c => c == Ui.MouseOverWidget); var hover = Ui.MouseOverWidget == this || Children.Any(c => c == Ui.MouseOverWidget);
DrawBackground(rb, disabled, Depressed, hover, highlighted); DrawBackground(rb, disabled, Depressed, hover, highlighted);
@@ -260,9 +259,10 @@ namespace OpenRA.Mods.Common.Widgets
disabled ? colordisabled : color); disabled ? colordisabled : color);
} }
int2 GetTextPosition(int2 textSize, Rectangle rb) int2 GetTextPosition(string text, SpriteFont font, Rectangle rb)
{ {
var y = rb.Y - BaseLine + (Bounds.Height - textSize.Y) / 2; var textSize = font.Measure(text);
var y = rb.Y + (Bounds.Height - textSize.Y - font.TopOffset) / 2;
switch (Align) switch (Align)
{ {

View File

@@ -61,7 +61,9 @@ namespace OpenRA.Mods.Common.Widgets
"checkbox"; "checkbox";
WidgetUtils.DrawPanel(state, check); WidgetUtils.DrawPanel(state, check);
var position = new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y) / 2);
var topOffset = font.TopOffset;
var position = new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y + (Bounds.Height - textSize.Y - topOffset) / 2);
if (Contrast) if (Contrast)
font.DrawTextWithContrast(text, position, font.DrawTextWithContrast(text, position,

View File

@@ -190,7 +190,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 36 Width: 36
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedSlow Key: ReplaySpeedSlow
TooltipText: Slow speed TooltipText: Slow speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -202,7 +201,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedRegular Key: ReplaySpeedRegular
TooltipText: Regular speed TooltipText: Regular speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -214,7 +212,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedFast Key: ReplaySpeedFast
TooltipText: Fast speed TooltipText: Fast speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -226,7 +223,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedMax Key: ReplaySpeedMax
TooltipText: Maximum speed TooltipText: Maximum speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER

View File

@@ -26,7 +26,6 @@ Container@LOCAL_PROFILE_PANEL:
Width: 60 Width: 60
Height: 20 Height: 20
Font: TinyBold Font: TinyBold
BaseLine: 1
Text: Logout Text: Logout
Background@BADGES_CONTAINER: Background@BADGES_CONTAINER:
Width: PARENT_RIGHT Width: PARENT_RIGHT
@@ -65,7 +64,6 @@ Container@LOCAL_PROFILE_PANEL:
Width: 240 Width: 240
Height: 20 Height: 20
Font: TinyBold Font: TinyBold
BaseLine: 1
Text: Connect to an OpenRA forum account Text: Connect to an OpenRA forum account
Background@GENERATING_KEYS: Background@GENERATING_KEYS:
Width: PARENT_RIGHT Width: PARENT_RIGHT
@@ -123,7 +121,6 @@ Container@LOCAL_PROFILE_PANEL:
Y: 70 Y: 70
Width: 70 Width: 70
Height: 20 Height: 20
BaseLine: 1
Font: TinyBold Font: TinyBold
Text: Cancel Text: Cancel
Button@CHECK_KEY: Button@CHECK_KEY:
@@ -131,7 +128,6 @@ Container@LOCAL_PROFILE_PANEL:
Y: 70 Y: 70
Width: 70 Width: 70
Height: 20 Height: 20
BaseLine: 1
Font: TinyBold Font: TinyBold
Text: Continue Text: Continue
Background@CHECKING_FINGERPRINT: Background@CHECKING_FINGERPRINT:
@@ -183,7 +179,6 @@ Container@LOCAL_PROFILE_PANEL:
Y: 70 Y: 70
Width: 70 Width: 70
Height: 20 Height: 20
BaseLine: 1
Font: TinyBold Font: TinyBold
Text: Back Text: Back
Background@CONNECTION_ERROR: Background@CONNECTION_ERROR:
@@ -210,7 +205,6 @@ Container@LOCAL_PROFILE_PANEL:
Y: 70 Y: 70
Width: 70 Width: 70
Height: 20 Height: 20
BaseLine: 1
Font: TinyBold Font: TinyBold
Text: Retry Text: Retry

View File

@@ -125,7 +125,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 36 Width: 36
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedSlow Key: ReplaySpeedSlow
TooltipText: Slow speed TooltipText: Slow speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -136,7 +135,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedRegular Key: ReplaySpeedRegular
TooltipText: Regular speed TooltipText: Regular speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -147,7 +145,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedFast Key: ReplaySpeedFast
TooltipText: Fast speed TooltipText: Fast speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -158,7 +155,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedMax Key: ReplaySpeedMax
TooltipText: Maximum speed TooltipText: Maximum speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER

View File

@@ -26,7 +26,6 @@ Container@LOCAL_PROFILE_PANEL:
Width: 60 Width: 60
Height: 20 Height: 20
Font: TinyBold Font: TinyBold
BaseLine: 1
Text: Logout Text: Logout
Background@BADGES_CONTAINER: Background@BADGES_CONTAINER:
Width: PARENT_RIGHT Width: PARENT_RIGHT
@@ -65,7 +64,6 @@ Container@LOCAL_PROFILE_PANEL:
Width: 240 Width: 240
Height: 20 Height: 20
Font: TinyBold Font: TinyBold
BaseLine: 1
Text: Connect to an OpenRA forum account Text: Connect to an OpenRA forum account
Background@GENERATING_KEYS: Background@GENERATING_KEYS:
Width: PARENT_RIGHT Width: PARENT_RIGHT
@@ -123,7 +121,6 @@ Container@LOCAL_PROFILE_PANEL:
Y: 70 Y: 70
Width: 70 Width: 70
Height: 20 Height: 20
BaseLine: 1
Font: TinyBold Font: TinyBold
Text: Cancel Text: Cancel
Button@CHECK_KEY: Button@CHECK_KEY:
@@ -131,7 +128,6 @@ Container@LOCAL_PROFILE_PANEL:
Y: 70 Y: 70
Width: 70 Width: 70
Height: 20 Height: 20
BaseLine: 1
Font: TinyBold Font: TinyBold
Text: Continue Text: Continue
Background@CHECKING_FINGERPRINT: Background@CHECKING_FINGERPRINT:
@@ -183,7 +179,6 @@ Container@LOCAL_PROFILE_PANEL:
Y: 70 Y: 70
Width: 70 Width: 70
Height: 20 Height: 20
BaseLine: 1
Font: TinyBold Font: TinyBold
Text: Back Text: Back
Background@CONNECTION_ERROR: Background@CONNECTION_ERROR:
@@ -210,7 +205,6 @@ Container@LOCAL_PROFILE_PANEL:
Y: 70 Y: 70
Width: 70 Width: 70
Height: 20 Height: 20
BaseLine: 1
Font: TinyBold Font: TinyBold
Text: Retry Text: Retry

View File

@@ -1,5 +1,4 @@
Metrics: Metrics:
ButtonBaseLine: 0
ButtonDepth: 1 ButtonDepth: 1
ButtonFont: Regular ButtonFont: Regular
ButtonTextColor: FFFFFF ButtonTextColor: FFFFFF

View File

@@ -1,7 +1,6 @@
# General dumping-ground for UI element sizes, etc. # General dumping-ground for UI element sizes, etc.
Metrics: Metrics:
ButtonBaseLine: 2
ButtonDepth: 0 ButtonDepth: 0
ButtonFont: Bold ButtonFont: Bold
CheckboxPressedState: true CheckboxPressedState: true

View File

@@ -150,7 +150,6 @@ Container@OBSERVER_WIDGETS:
Y: 8 Y: 8
Width: 42 Width: 42
Height: 22 Height: 22
BaseLine: 1
Background: sidebar-button-observer Background: sidebar-button-observer
Key: ReplaySpeedSlow Key: ReplaySpeedSlow
TooltipText: Slow speed TooltipText: Slow speed
@@ -163,7 +162,6 @@ Container@OBSERVER_WIDGETS:
Y: 8 Y: 8
Width: 42 Width: 42
Height: 22 Height: 22
BaseLine: 1
Background: sidebar-button-observer Background: sidebar-button-observer
Key: ReplaySpeedRegular Key: ReplaySpeedRegular
TooltipText: Regular speed TooltipText: Regular speed
@@ -176,7 +174,6 @@ Container@OBSERVER_WIDGETS:
Y: 8 Y: 8
Width: 42 Width: 42
Height: 22 Height: 22
BaseLine: 1
Background: sidebar-button-observer Background: sidebar-button-observer
Key: ReplaySpeedFast Key: ReplaySpeedFast
TooltipText: Fast speed TooltipText: Fast speed
@@ -189,7 +186,6 @@ Container@OBSERVER_WIDGETS:
Y: 8 Y: 8
Width: 42 Width: 42
Height: 22 Height: 22
BaseLine: 1
Background: sidebar-button-observer Background: sidebar-button-observer
Key: ReplaySpeedMax Key: ReplaySpeedMax
TooltipText: Maximum speed TooltipText: Maximum speed

View File

@@ -125,7 +125,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 36 Width: 36
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedSlow Key: ReplaySpeedSlow
TooltipText: Slow speed TooltipText: Slow speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -136,7 +135,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedRegular Key: ReplaySpeedRegular
TooltipText: Regular speed TooltipText: Regular speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -147,7 +145,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedFast Key: ReplaySpeedFast
TooltipText: Fast speed TooltipText: Fast speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
@@ -158,7 +155,6 @@ Container@OBSERVER_WIDGETS:
Y: 13 Y: 13
Width: 38 Width: 38
Height: 20 Height: 20
BaseLine: 1
Key: ReplaySpeedMax Key: ReplaySpeedMax
TooltipText: Maximum speed TooltipText: Maximum speed
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER