Hello Guest

Author Topic: [solved] tk2dTextMesh and tk2dUILayoutContainerSizer  (Read 4148 times)

Trogl

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
[solved] tk2dTextMesh and tk2dUILayoutContainerSizer
« on: October 19, 2013, 10:55:21 pm »
hello! First of all I want to say I really impressed by your UI system, it is pretty cool  :o .

Now some questions. Here is the context: I'm trying to create a scrollable list of the different-height text blocks.
something like that:


So obviously I need to make the tk2dUILayoutContainerSizer to change its size depend of bounds of tk2dTextMesh in realtime.
For now I can't figure out how doing it. Looks like tk2dUILayoutContainerSizer have not any fields like "width", "height".
So for now I have this:



The height of tk2dUILayoutContainerSizer   doesn't match  the text height.

What should I do to fix it?
« Last Edit: October 20, 2013, 09:42:02 pm by Trogl »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dTextMesh and tk2dUILayoutContainerSizer
« Reply #1 on: October 19, 2013, 11:33:23 pm »
The text mesh doesn't feed back to the size at the moment. If you would like to implement this yourself, I suggest
1. Create a layout object and attach to the textmesh. Whenever the text changes, change the layout size to match.
2. When you add this layout to the parent layout, use AddLayout( item, tk2dUILayoutItem.FixedSizeLayoutItem() )
3. If added in the correct order, everything should be sized correctly in your main layout.

The remaining issue is handling resizing text. To cope with that, change the text size, change the text meshes layout size (SetBounds). Call DoChildLayout on the parent layouts moving up the hierarchy for everything to work properly. All of this was planned but we haven't had the time to implement it properly. It is likely to be in a future version.

Trogl

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: tk2dTextMesh and tk2dUILayoutContainerSizer
« Reply #2 on: October 20, 2013, 09:41:37 pm »
Thanks, now it works as I need.