From a534290dc5bd1b08a19edb71a0cf6d080e97f1be Mon Sep 17 00:00:00 2001 From: deniz1a Date: Wed, 29 Jul 2015 23:47:30 +0300 Subject: [PATCH] Removes spacing between dropdown menu items. --- OpenRA.Mods.Common/Widgets/ListLayout.cs | 9 ++++++--- OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/ListLayout.cs b/OpenRA.Mods.Common/Widgets/ListLayout.cs index 15c22681d5..d9f673fffd 100644 --- a/OpenRA.Mods.Common/Widgets/ListLayout.cs +++ b/OpenRA.Mods.Common/Widgets/ListLayout.cs @@ -21,22 +21,25 @@ namespace OpenRA.Mods.Common.Widgets public void AdjustChild(Widget w) { if (widget.Children.Count == 0) - widget.ContentHeight = widget.ItemSpacing; + widget.ContentHeight = 2 * widget.TopBottomSpacing - widget.ItemSpacing; - w.Bounds.Y = widget.ContentHeight; + w.Bounds.Y = widget.ContentHeight - widget.TopBottomSpacing + widget.ItemSpacing; if (!widget.CollapseHiddenChildren || w.IsVisible()) widget.ContentHeight += w.Bounds.Height + widget.ItemSpacing; } public void AdjustChildren() { - widget.ContentHeight = widget.ItemSpacing; + widget.ContentHeight = widget.TopBottomSpacing; foreach (var w in widget.Children) { w.Bounds.Y = widget.ContentHeight; if (!widget.CollapseHiddenChildren || w.IsVisible()) widget.ContentHeight += w.Bounds.Height + widget.ItemSpacing; } + + // The loop above appended an extra widget.ItemSpacing after the last item. Replace it with proper bottom spacing. + widget.ContentHeight += widget.TopBottomSpacing - widget.ItemSpacing; } } } diff --git a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs index 7031191a2a..79b78b5d33 100644 --- a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs @@ -33,7 +33,8 @@ namespace OpenRA.Mods.Common.Widgets { readonly Ruleset modRules; public int ScrollbarWidth = 24; - public int ItemSpacing = 2; + public int TopBottomSpacing = 2; + public int ItemSpacing = 0; public int ButtonDepth = ChromeMetrics.Get("ButtonDepth"); public string Background = "scrollpanel-bg"; public string Button = "scrollpanel-button";