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.Linq;
using OpenRA.Graphics;
using OpenRA.Primitives;
using OpenRA.Widgets;
@@ -33,7 +34,6 @@ namespace OpenRA.Mods.Common.Widgets
public string Background = "button";
public bool Depressed = false;
public int VisualHeight = ChromeMetrics.Get<int>("ButtonDepth");
public int BaseLine = ChromeMetrics.Get<int>("ButtonBaseLine");
public string Font = ChromeMetrics.Get<string>("ButtonFont");
public Color TextColor = ChromeMetrics.Get<Color>("ButtonTextColor");
public Color TextColorDisabled = ChromeMetrics.Get<Color>("ButtonTextColorDisabled");
@@ -102,7 +102,6 @@ namespace OpenRA.Mods.Common.Widgets
LeftMargin = other.LeftMargin;
RightMargin = other.RightMargin;
Font = other.Font;
BaseLine = other.BaseLine;
TextColor = other.TextColor;
TextColorDisabled = other.TextColorDisabled;
Contrast = other.Contrast;
@@ -243,10 +242,10 @@ namespace OpenRA.Mods.Common.Widgets
var colordisabled = GetColorDisabled();
var bgDark = GetContrastColorDark();
var bgLight = GetContrastColorLight();
var textSize = font.Measure(text);
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);
DrawBackground(rb, disabled, Depressed, hover, highlighted);
@@ -260,9 +259,10 @@ namespace OpenRA.Mods.Common.Widgets
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)
{

View File

@@ -61,7 +61,9 @@ namespace OpenRA.Mods.Common.Widgets
"checkbox";
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)
font.DrawTextWithContrast(text, position,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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