Closed ghost closed 3 years ago
It's hard to understand how to fix problem using depth without seeing full code and hierarchy (and screenshot). But keep in mind, that setting depth works mostly when all widgets are on the same level and when any hierarchy is mixed into this things might look bad.
What I recommend (and what I usually do) is to always create highlight
widget and make it parent to the widget it highlights. And make it have no image, when you don't need it. It is better to always create child widgets instead of using depth, if some widget in supposed to be over another. The only (rare) exception is when widgets overlap partially.
Here is a video of what it looks like when I manually create the highlight imagebox in my resource widget, this is the goal. https://streamable.com/i4bfia
Here is the bugged version when I attempt to create the highlight through the means mentioned in my opening post. https://streamable.com/5falrq
The reason the latter method is preferable is because the widgets I am attempting to highlight are already existing, if there was a way to target->injectParent(highlight) which would place highlight in the same position as target in the hierarchy, then place target under it as a child, that would be great (presuming this didn't destroy siblings much the same way).
Resource widget:
<Resource type="ResourceLayout" name="MW_ItemIcon" version="3.2.0">
<Widget type="Widget" skin="" position="0 0 42 42" name="Root">
<Widget type="ImageBox" skin="ImageBox" position="0 0 42 42" align="Stretch" name="Frame">
<Widget type="TextBox" skin="CountText" position="5 19 32 18" align="Right Bottom" name="Text">
<Property key="TextAlign" value="Right"/>
<Property key="TextShadow" value="true"/>
</Widget>
<Widget type="ImageBox" skin="ImageBox" position="5 5 32 32" align="Stretch" name="Item"/>
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" align="Stretch" name="ItemShadow">
<Property key="Colour" value="0 0 0"/>
<Property key="Alpha" value="0.5"/>
</Widget>
</Widget>
</Widget>
</Resource>
Assignment:
assignWidget(mItem, "Item");
if (mItem)
mItem->setNeedMouseFocus(false);
assignWidget(mItemShadow, "ItemShadow");
if (mItemShadow)
mItemShadow->setNeedMouseFocus(false);
assignWidget(mFrame, "Frame");
if (mFrame)
mFrame->setNeedMouseFocus(false);
assignWidget(mText, "Text");
if (mText)
mText->setNeedMouseFocus(false);
I then proceed to assign image textures to each in order of frame, item shadow, item.
Solution was to re-order my resource widget layout. I had "Item" coming before "ItemShadow". Thank you for the time, your response made me look where I needed to.
My resource widget contains three imagebox widgets, ordered in such a way as to cope with MyGUI's rendering system and works fine as is, all imageboxes are at the default depth of 0.
I am attempting to render another imagebox widget below it (to highlight the resource).
When I create the imagebox as a sibling widget and set the texture, it renders without breaking rendering order. The moment I set it's depth so it gets rendered below, all of my resource widgets break, rendering the resource's imageboxes in strange orders (shadows above icons in my case).
Is there a work around to this problem?
Relevant Problem Area: