RonenNess / GeonBit.UI

UI system for MonoGame projects.
MIT License
478 stars 64 forks source link

Dropdown Issue #65

Closed MrCapitalG closed 6 years ago

MrCapitalG commented 6 years ago

I've got an issue with a dropdown control; upon clicking and opening up the drop down component, it is rendering the list behind another control, a button. I looked around and I don't see any way to control to render order of the controls themselves, I only saw BringToFront() which works if I use it on the left or right panel, but if I do it to both, then the button shows up at the top so I'm not understanding something here.

Is this a bug or am I just missing something? :) I'm just looking to get the dropdown to render over any other controls that might be below it, when it's opened.

dropdown

RonenNess commented 6 years ago

Hi @MrCapitalG , long time no see :)

Its a priority-related issue, when the dropdown is opened it gets the top priority to be rendered above everything else, however, it only affects its siblings inside the container panel. The button in your example is above the whole parent panel, which makes it override the dropdown.

You could solve it by changing the order you're adding the panel and button (add button first), but that would mess up auto-anchoring and overall suck. So I added a new property, PriorityBonus, to allow users to affect the order in which things are drawn / updated, without affecting anchoring.

You can get latest version and either add negative bonus to the button (PriorityBonus = -10 for example) or increase the priority of the panels above it.

Note that you need to increase / decrease it based on how many entities there are in the hierarchy. For example, PriorityBonus = 1, will make the entity pass a single entity in the drawing queue. but if there are two buttons, it means that the second button would still be above the panel. Since in your example I only see one button PriorityBonus = 1 should be enough, but just in case give it PriorityBonus = 50, wouldn't hurt :)

If it doesn't work for whatever reason please feel free to reopen ticket (tested it locally, should be OK).

Thanks!