From 3ad6a879203cd27310867f6988ab9d0489abd8ee 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 b062b0addd..7581c9105e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs @@ -24,6 +24,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic readonly Widget optionsContainer; readonly Widget checkboxRowTemplate; readonly Widget dropdownRowTemplate; + readonly int yMargin; readonly Func getMap; readonly OrderManager orderManager; @@ -40,6 +41,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic panel = (ScrollPanelWidget)widget; optionsContainer = widget.Get("LOBBY_OPTIONS"); + yMargin = optionsContainer.Bounds.Y; optionsContainer.IsVisible = () => validOptions; checkboxRowTemplate = optionsContainer.Get("CHECKBOX_ROW_TEMPLATE"); dropdownRowTemplate = optionsContainer.Get("DROPDOWN_ROW_TEMPLATE"); @@ -173,7 +175,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic } } - 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 e57c078268..40bceee2d6 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 7c1e68747f..f00946c7b3 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: