Page 1 of 1
[Solved] Nesting static text inside a static image
Posted: Wed Jul 03, 2019 20:21
by niello
Hi. There is a strange behaviour if I try to save TaharezLook/StaticText as a child of TaharezLook/StaticImage. For some reason Window::isPropertyAtDefault() checks lookfeel of our parent and not our own. StaticImage has a property definition:
Code: Select all
<PropertyDefinition name="HorzFormatting" initialValue="Stretched" redrawOnWrite="true" type="HorizontalFormatting"/>
and Window::isPropertyAtDefault() detects it at
Code: Select all
// If this property is a target of a PropertyLink, we always report it as being at default.
WidgetLookFeel::StringSet propDefNames = wlf.getPropertyDefinitionNames(true);
if(propDefNames.find(property->getName()) != propDefNames.end())
return true;
and says that HorzFormatting is at its default value, no matter what value is. HorzFormatting doesn't get saved and changes are lost.
Does anyoune know why it works this way and can it be fixed?
Re: Nesting static text inside a static image
Posted: Thu Jul 04, 2019 05:56
by Ident
There is a strange behaviour if I try to save TaharezLook/StaticText as a child of TaharezLook/StaticImage.
That would be in the layout, not LNF, correct? If it is in the layout then it should be a property, not a propertydefinition. If it is a LNF file then please post the widget definition.
Re: Nesting static text inside a static image
Posted: Thu Jul 04, 2019 06:52
by niello
Yes, nesting happens in a layout. But the property definition is in LNF and it causes property in the layout not be saved as 'being default' despite it is not in a default value. Look at attachment.
LoadingScreen.layout - no nesting. Property is saved: <Property name="HorzFormatting" value="CentreAligned" />. But if you click on StaticImage ('BG'), it goes to front and hides StaticText ('Text'). So I want nesting.
LoadingScreen2.layout - nesting. Property is not saved because Window::isPropertyAtDefault() always reports it as default based on _parent_ LNF. So when you load this layout, 'Text' will be left-aligned no matter what you set in editor.
TaharezLook.looknfeel - LNF, where you can see PropertyDefinition of HorzFormatting in StaticImage, which blocks saving of HorzFormatting property of nested StaticText
Re: Nesting static text inside a static image
Posted: Thu Jul 04, 2019 19:34
by Ident
I think I get it now. The LNF is unchanged, right? You need to set the RiseOnClick property to false if you do not want the sibling windows to overlap each other upon interaction.
Please tell me if this solved the issue.
Re: Nesting static text inside a static image
Posted: Fri Jul 05, 2019 06:22
by niello
LNF is unchanged.
Yes, setting RiseOnClickEnabled to false helped, thanks.
But the overall situation looks very counter-intuitive. Isn't it a bug? Why parent window blocks completely unrelated properties of the child window?
In GameMenuSample.layout you can see "Generic/Label" as a child of "Generic/Image", so this is considered a normal practice. Probably we sholud fix this (or add clear explaination why this behaviour is the only appropriate).
PS: is there a best-practices guide of how to create UI screen from scratch? Like 'always add a root DefaultWindow', 'if you want to group elements, place them into the container X', 'never make widget A child of widget B' etc?
Re: Nesting static text inside a static image
Posted: Fri Jul 05, 2019 06:49
by niello
I investigated further and found your commit which adds the problematic code:
https://bitbucket.org/cegui/cegui/commi ... Window.cppIt seems that mistake was introduced here. We intend to check property _link_ definition, but check property definition. Both still exist in a WidgetLookFeel and are separate entities. Could you fix this please?
Re: Nesting static text inside a static image
Posted: Fri Jul 05, 2019 16:43
by Ident
yea, something looks off there, i m looking into it
Re: Nesting static text inside a static image
Posted: Fri Jul 05, 2019 17:19
by Ident
Re: Nesting static text inside a static image
Posted: Fri Jul 05, 2019 22:05
by niello
Yes, now it's fixed. Thanks a lot!
Re: Nesting static text inside a static image
Posted: Sat Jul 06, 2019 07:52
by Ident
you are welcome!