diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7316032..eddb12d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ Fixes
### MLEM.Ui
Improvements
- Allow scrolling panels to contain other scrolling panels
+- Allow dropdowns to have scrolling panels (#8)
## 6.2.0
diff --git a/MLEM.Ui/Elements/Dropdown.cs b/MLEM.Ui/Elements/Dropdown.cs
index e9f080f..36f4447 100644
--- a/MLEM.Ui/Elements/Dropdown.cs
+++ b/MLEM.Ui/Elements/Dropdown.cs
@@ -36,12 +36,15 @@ namespace MLEM.Ui.Elements {
/// The dropdown button's size
/// The text displayed on the dropdown button
/// The text displayed as a tooltip when hovering over the dropdown button
- public Dropdown(Anchor anchor, Vector2 size, string text = null, string tooltipText = null) : base(anchor, size, text, tooltipText) {
- this.Panel = this.AddChild(new Panel(Anchor.TopCenter, Vector2.Zero, Vector2.Zero, true) {
+ /// The height of the . If this is 0, the panel will be set to .
+ /// Whether this dropdown's should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.
+ /// Whether this dropdown's 's scroll bar should be hidden automatically if the panel does not contain enough children to allow for scrolling. This only has an effect if is .
+ public Dropdown(Anchor anchor, Vector2 size, string text = null, string tooltipText = null, float panelHeight = 0, bool scrollPanel = false, bool autoHidePanelScrollbar = true) : base(anchor, size, text, tooltipText) {
+ this.Panel = this.AddChild(new Panel(Anchor.TopCenter, Vector2.Zero, Vector2.Zero, panelHeight == 0, scrollPanel, autoHidePanelScrollbar) {
IsHidden = true
});
this.OnAreaUpdated += e => {
- this.Panel.Size = new Vector2(e.Area.Width / e.Scale, 0);
+ this.Panel.Size = new Vector2(e.Area.Width / e.Scale, panelHeight);
this.Panel.PositionOffset = new Vector2(0, e.Area.Height / e.Scale);
};
this.OnOpenedOrClosed += e => this.Priority = this.IsOpen ? 10000 : 0;
@@ -63,6 +66,12 @@ namespace MLEM.Ui.Elements {
};
}
+ ///
+ protected override void OnChildAreaDirty(Element child, bool grandchild) {
+ if (child != this.Panel)
+ base.OnChildAreaDirty(child, grandchild);
+ }
+
///
/// Adds an element to this dropdown's
///