[Solved] Nesting static text inside a static image

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

niello
Quite a regular
Quite a regular
Posts: 76
Joined: Tue May 24, 2011 05:54
Contact:

[Solved] Nesting static text inside a static image

Postby niello » Wed Jul 03, 2019 20:21

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?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Nesting static text inside a static image

Postby Ident » Thu Jul 04, 2019 05:56

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.
CrazyEddie: "I don't like GUIs"

niello
Quite a regular
Quite a regular
Posts: 76
Joined: Tue May 24, 2011 05:54
Contact:

Re: Nesting static text inside a static image

Postby niello » Thu Jul 04, 2019 06:52

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
Attachments
UI.zip
(11.6 KiB) Downloaded 707 times

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Nesting static text inside a static image

Postby Ident » Thu Jul 04, 2019 19:34

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.
CrazyEddie: "I don't like GUIs"

niello
Quite a regular
Quite a regular
Posts: 76
Joined: Tue May 24, 2011 05:54
Contact:

Re: Nesting static text inside a static image

Postby niello » Fri Jul 05, 2019 06:22

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?

niello
Quite a regular
Quite a regular
Posts: 76
Joined: Tue May 24, 2011 05:54
Contact:

Re: Nesting static text inside a static image

Postby niello » Fri Jul 05, 2019 06:49

I investigated further and found your commit which adds the problematic code:
https://bitbucket.org/cegui/cegui/commi ... Window.cpp

It 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?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Nesting static text inside a static image

Postby Ident » Fri Jul 05, 2019 16:43

yea, something looks off there, i m looking into it
CrazyEddie: "I don't like GUIs"

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Nesting static text inside a static image

Postby Ident » Fri Jul 05, 2019 17:19

Hopefully fixed with https://bitbucket.org/cegui/cegui/commi ... 19b3d5f45b

Can you confirm?
CrazyEddie: "I don't like GUIs"

niello
Quite a regular
Quite a regular
Posts: 76
Joined: Tue May 24, 2011 05:54
Contact:

Re: Nesting static text inside a static image

Postby niello » Fri Jul 05, 2019 22:05

Yes, now it's fixed. Thanks a lot!

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Nesting static text inside a static image

Postby Ident » Sat Jul 06, 2019 07:52

you are welcome!
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 6 guests