diff --git a/LemonUI/Menus/NativeMenu.cs b/LemonUI/Menus/NativeMenu.cs index f983ceec..f7e4c62d 100644 --- a/LemonUI/Menus/NativeMenu.cs +++ b/LemonUI/Menus/NativeMenu.cs @@ -1019,12 +1019,10 @@ private void UpdateItems() // Set the position of the rectangle that marks the current item selectedRect.Position = new PointF(pos.X, pos.Y + ((index - firstItem) * itemHeight)); // And then do the description background and text - descriptionText.Text = Items.Count == 0 || SelectedIndex == -1 ? NoItemsText : SelectedItem.Description; float description = pos.Y + ((Items.Count > maxItems ? maxItems : Items.Count) * itemHeight) + heightDiffDescImg; - int lineCount = descriptionText.LineCount; - descriptionRect.Size = new SizeF(width, (lineCount * (descriptionText.LineHeight + 5)) + (lineCount - 1) + 10); descriptionRect.Position = new PointF(pos.X, description); descriptionText.Position = new PointF(pos.X + posXDescTxt, description + heightDiffDescTxt); + UpdateDescription(); // Save the size of the items SizeF size = new SizeF(width, itemHeight); @@ -1043,6 +1041,15 @@ private void UpdateItems() RecalculatePanel(); } /// + /// Updates the size and text of the description. + /// + private void UpdateDescription() + { + descriptionText.Text = Items.Count == 0 || SelectedIndex == -1 ? NoItemsText : SelectedItem.Description; + int lineCount = descriptionText.LineCount; + descriptionRect.Size = new SizeF(width, (lineCount * (descriptionText.LineHeight + 5)) + (lineCount - 1) + 10); + } + /// /// Processes the button presses. /// private void ProcessControls() @@ -1525,17 +1532,19 @@ public void Clear() /// public void Process() { - // If the menu is not visible, return if (!visible) { return; } - // Otherwise, draw the elements + NativeItem selected = SelectedItem; + if (selected != null && descriptionText.Text != selected.Description) + { + UpdateDescription(); + } + Draw(); - // And then work on the controls ProcessControls(); - // And finish by drawing the instructional buttons Buttons.Draw(); } /// diff --git a/LemonUI/Menus/NativeSubmenuItem.cs b/LemonUI/Menus/NativeSubmenuItem.cs index 2483cbd4..973c591b 100644 --- a/LemonUI/Menus/NativeSubmenuItem.cs +++ b/LemonUI/Menus/NativeSubmenuItem.cs @@ -42,13 +42,28 @@ public NativeSubmenuItem(NativeMenu menu, NativeMenu parent, string endlabel) : #endregion + #region Functions + + /// + public override void Draw() + { + // There is no Process(), so let's use draw to update the description + if (Description != Menu.Description) + { + Description = Menu.Description; + } + + base.Draw(); + } + + #endregion + #region Local Events private void NativeSubmenuItem_Activated(object sender, EventArgs e) { - // Try to close the parent menu Menu.Parent.Visible = false; - // And show the menu only if the parent menu is closed + if (!Menu.Parent.Visible) { Menu.Visible = true;