From 35275fb04978461c0679a461356a7d3b658b55e1 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 9 Dec 2017 21:47:31 +0000 Subject: [PATCH] Center the vertical alignment of lobby options if less than the panel height. This also enables an extra row to be shown before triggering the scroll bar. --- .../Widgets/Logic/Lobby/LobbyOptionsLogic.cs | 9 ++++++++- mods/cnc/chrome/lobby-options.yaml | 7 +++---- mods/common/chrome/lobby-options.yaml | 7 +++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs index b062b0addd25..7581c9105e35 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs @@ -24,6 +24,7 @@ public class LobbyOptionsLogic : ChromeLogic readonly Widget optionsContainer; readonly Widget checkboxRowTemplate; readonly Widget dropdownRowTemplate; + readonly int yMargin; readonly Func getMap; readonly OrderManager orderManager; @@ -40,6 +41,7 @@ internal LobbyOptionsLogic(Widget widget, OrderManager orderManager, Func validOptions; checkboxRowTemplate = optionsContainer.Get("CHECKBOX_ROW_TEMPLATE"); dropdownRowTemplate = optionsContainer.Get("DROPDOWN_ROW_TEMPLATE"); @@ -173,7 +175,12 @@ void RebuildOptions() } } - panel.ContentHeight = optionsContainer.Bounds.Y + optionsContainer.Bounds.Height; + panel.ContentHeight = yMargin + optionsContainer.Bounds.Height; + optionsContainer.Bounds.Y = yMargin; + if (panel.ContentHeight < panel.Bounds.Height) + optionsContainer.Bounds.Y += (panel.Bounds.Height - panel.ContentHeight) / 2; + + panel.ScrollToTop(); } } } diff --git a/mods/cnc/chrome/lobby-options.yaml b/mods/cnc/chrome/lobby-options.yaml index e57c07826803..40bceee2d6e7 100644 --- a/mods/cnc/chrome/lobby-options.yaml +++ b/mods/cnc/chrome/lobby-options.yaml @@ -16,12 +16,11 @@ Container@LOBBY_OPTIONS_BIN: Children: Container@LOBBY_OPTIONS: X: 18 - Y: 30 + Y: 9 Width: PARENT_RIGHT - 24 - 18 - Height: PARENT_BOTTOM - 75 Children: Container@CHECKBOX_ROW_TEMPLATE: - Height: 35 + Height: 34 Children: Checkbox@A: Width: 175 @@ -44,7 +43,7 @@ Container@LOBBY_OPTIONS_BIN: Visible: False TooltipContainer: TOOLTIP_CONTAINER Container@DROPDOWN_ROW_TEMPLATE: - Height: 35 + Height: 34 Width: PARENT_RIGHT Children: Label@A_DESC: diff --git a/mods/common/chrome/lobby-options.yaml b/mods/common/chrome/lobby-options.yaml index 7c1e68747f43..f00946c7b3cb 100644 --- a/mods/common/chrome/lobby-options.yaml +++ b/mods/common/chrome/lobby-options.yaml @@ -16,12 +16,11 @@ Container@LOBBY_OPTIONS_BIN: Children: Container@LOBBY_OPTIONS: X: 18 - Y: 30 + Y: 9 Width: PARENT_RIGHT - 18 - 24 - Height: PARENT_BOTTOM - 75 Children: Container@CHECKBOX_ROW_TEMPLATE: - Height: 35 + Height: 34 Children: Checkbox@A: Width: 175 @@ -41,7 +40,7 @@ Container@LOBBY_OPTIONS_BIN: Visible: False TooltipContainer: TOOLTIP_CONTAINER Container@DROPDOWN_ROW_TEMPLATE: - Height: 35 + Height: 34 Width: PARENT_RIGHT Children: Label@A_DESC: