Size Property in layout files and Font Size

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

TheWanderer
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Wed Feb 03, 2016 21:58

Size Property in layout files and Font Size

Postby TheWanderer » Sat Nov 09, 2019 23:03

Hi everyone,

So I've created the UI for my project using the Taharez looknfeel files that come with the source and my own layout files. Almost all of elements in those layout files use the proportional field in UDim's when setting their size so that the UI will scale appropriately at different resolutions.

One problem which I've run across is that at certain resolutions, some elements are too short in order to fit the text. I wanted to see if there was a way to state in the layout files some minimum height for a window and whether that minimum height can be set to the height of the font being used in it.

For example, in the code below, the text in the "Seed_EditBox" element is not tall enough to fit the text input into it when at 1920x1200.

Code: Select all

   <Window type="HorizontalLayoutContainer" >
         
      <Property name="Position" value="{{0.01,0.0},{0.15,0}}" />
      <Property name="Size" value="{{0.98,0},{0.05,0}}" />

      <Window name="Seed_Label"  type="TaharezLook/Label" >
         <Property name="Text" value="Seed" />
         <Property name="Size" value="{{0.33,0},{0.05,0}}" />
         <Property name="HorzFormatting" value="LeftAligned" />
      </Window>

      <Window name="Seed_EditBox"  type="TaharezLook/Editbox" >
         <Property name="Size" value="{{0.63,0},{0.05,0}}" />
         <Property name="MaxTextLength" value="11" />
         <Property name="ValidationString" value="^[0-9]*$" />
      </Window>
         
   </Window>



Thank you for any help and let me know if there is any more information which I can provide!

Edit: Almost forgot:

Code: Select all

[14:55:12] Cegui: ---- Version: 0.8.4 (Build: Jan 16 2018 Static Debug Microsoft Windows MSVC++ 11.0 32 bit) ----
[14:55:12] Cegui: ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
[14:55:12] Cegui: ---- XML Parser module is: CEGUI::RapidXMLParser - Official RapidXML based parser module for CEGUI ----
[14:55:12] Cegui: ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
[14:55:12] Cegui: ---- Scripting module is: None ----

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

Re: Size Property in layout files and Font Size

Postby Ident » Sun Nov 24, 2019 12:23

Sorry for the late response. There is no automatically growing widgets except on default branch: see setAdjustWidthToContent setAdjustHeightToContent
CrazyEddie: "I don't like GUIs"

TheWanderer
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Wed Feb 03, 2016 21:58

Re: Size Property in layout files and Font Size

Postby TheWanderer » Mon Dec 02, 2019 22:31

No worries on the delay; simply thanks for the answer :)

If there is no way to self-adjust, do you happen to know how applications usually address the issue of ensuring that UI elements fit their text?

One possibility I'm contemplating is to find some element within my window hierarchy (probably a label), determine what size it should be given the font, and then adjusting the size of the top-most parent window to ensure that everything beneath it resizes appropriately. I'd have to do this for every child of the root window.

Or is this more about finding the appropriate font given the application window size / resolution?

I did look up the "setAdjust*ToContent" functions and they, at least at first glance, look too "general" for what I'm trying to achieve.

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

Re: Size Property in layout files and Font Size

Postby Ident » Fri Dec 06, 2019 13:46

I would calculate the size occupied by text and then set that as widget dimensions, so basically what you said. Some UI systems do this.

Here is the discussion related to this: viewtopic.php?f=5&t=7101&
And afaik this is on default branch only. You can port it to 0.8.X with some programming experience. But it breaks the API/ABI so we won't do this.
CrazyEddie: "I don't like GUIs"

TheWanderer
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Wed Feb 03, 2016 21:58

Re: Size Property in layout files and Font Size

Postby TheWanderer » Wed Dec 11, 2019 19:22

Got it; I'll give my proposed solution a try and see how it does, since I think that's going to be easiest.

I appreciate the answers, Ident :-)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 4 guests