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.
This commit is contained in:
Paul Chote
2017-12-09 21:47:31 +00:00
committed by reaperrr
parent 3f67feab0e
commit 3ad6a87920
3 changed files with 14 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Widget optionsContainer; readonly Widget optionsContainer;
readonly Widget checkboxRowTemplate; readonly Widget checkboxRowTemplate;
readonly Widget dropdownRowTemplate; readonly Widget dropdownRowTemplate;
readonly int yMargin;
readonly Func<MapPreview> getMap; readonly Func<MapPreview> getMap;
readonly OrderManager orderManager; readonly OrderManager orderManager;
@@ -40,6 +41,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
panel = (ScrollPanelWidget)widget; panel = (ScrollPanelWidget)widget;
optionsContainer = widget.Get("LOBBY_OPTIONS"); optionsContainer = widget.Get("LOBBY_OPTIONS");
yMargin = optionsContainer.Bounds.Y;
optionsContainer.IsVisible = () => validOptions; optionsContainer.IsVisible = () => validOptions;
checkboxRowTemplate = optionsContainer.Get("CHECKBOX_ROW_TEMPLATE"); checkboxRowTemplate = optionsContainer.Get("CHECKBOX_ROW_TEMPLATE");
dropdownRowTemplate = optionsContainer.Get("DROPDOWN_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();
} }
} }
} }

View File

@@ -16,12 +16,11 @@ Container@LOBBY_OPTIONS_BIN:
Children: Children:
Container@LOBBY_OPTIONS: Container@LOBBY_OPTIONS:
X: 18 X: 18
Y: 30 Y: 9
Width: PARENT_RIGHT - 24 - 18 Width: PARENT_RIGHT - 24 - 18
Height: PARENT_BOTTOM - 75
Children: Children:
Container@CHECKBOX_ROW_TEMPLATE: Container@CHECKBOX_ROW_TEMPLATE:
Height: 35 Height: 34
Children: Children:
Checkbox@A: Checkbox@A:
Width: 175 Width: 175
@@ -44,7 +43,7 @@ Container@LOBBY_OPTIONS_BIN:
Visible: False Visible: False
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
Container@DROPDOWN_ROW_TEMPLATE: Container@DROPDOWN_ROW_TEMPLATE:
Height: 35 Height: 34
Width: PARENT_RIGHT Width: PARENT_RIGHT
Children: Children:
Label@A_DESC: Label@A_DESC:

View File

@@ -16,12 +16,11 @@ Container@LOBBY_OPTIONS_BIN:
Children: Children:
Container@LOBBY_OPTIONS: Container@LOBBY_OPTIONS:
X: 18 X: 18
Y: 30 Y: 9
Width: PARENT_RIGHT - 18 - 24 Width: PARENT_RIGHT - 18 - 24
Height: PARENT_BOTTOM - 75
Children: Children:
Container@CHECKBOX_ROW_TEMPLATE: Container@CHECKBOX_ROW_TEMPLATE:
Height: 35 Height: 34
Children: Children:
Checkbox@A: Checkbox@A:
Width: 175 Width: 175
@@ -41,7 +40,7 @@ Container@LOBBY_OPTIONS_BIN:
Visible: False Visible: False
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
Container@DROPDOWN_ROW_TEMPLATE: Container@DROPDOWN_ROW_TEMPLATE:
Height: 35 Height: 34
Width: PARENT_RIGHT Width: PARENT_RIGHT
Children: Children:
Label@A_DESC: Label@A_DESC: