On resizing a TextComponent dynamically

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

tamakazura
Just popping in
Just popping in
Posts: 6
Joined: Wed Aug 04, 2010 21:57

On resizing a TextComponent dynamically

Postby tamakazura » Wed Aug 04, 2010 22:21

Dear CEGUI Forum Denizens:

I have a custom widget. It has an imagery section called label, which I would like to resize horizontally dynamically.
I don't want to resize the whole widget, just the label.
I've noticed that when you get a named imagerysection in code, you can't get any information on the components it contains. You can add them, but not retreive or replace them.

<ImagerySection name="label">
<TextComponent>
<Area>
<Dim type="TopEdge">
<AbsoluteDim value="0" />
</Dim>
<Dim type="LeftEdge">
<AbsoluteDim value="31" />
</Dim>
<Dim type="RightEdge">
<UnifiedDim scale="1" offset="-3" type="RightEdge" />
</Dim>
<Dim type="BottomEdge">
<UnifiedDim scale="1" type="BottomEdge" />
</Dim>
</Area>
</TextComponent>
</ImagerySection>

In code, this translates to an imagerysection object with a textcomponent area. I want to change the right edge to a different unified dim. I'm also having trouble with this because I'd like to get the current width of this component so that I could compare it to the horiz. extent of some text, but I can't get that value from the imagerlysection as far as I can tell. Could someone please explain how to access this data?

Also, let's say that I wanted to make the textcomponent above refer to a named area for its dimensions. That way, I could just edit the named area. How would I do that?

Thanks a lot for your help!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: On resizing a TextComponent dynamically

Postby CrazyEddie » Thu Aug 05, 2010 09:16

Ok. First my excuses! This area of the system was written in a YAGNI style. And I was right, I didn't need it - it's just that some of you guys did! :lol:

More seriously, if you need to modify dimensions of some area defined for skin component you should define a property and use PropertyDim to refer to that property in the Area definition (it also allows you to read the current value, of course). The property based approach means the changes and values are per-window, which in most cases is what people want / need - I'm not sure if this is true in your case, if not there are issues regarding fetching a defined UDim, because it's final dimension is tied to some base dimension (i.e. the window width or height of the window the skin is associated with).

Also, let's say that I wanted to make the textcomponent above refer to a named area for its dimensions. That way, I could just edit the named area. How would I do that?

That's a TODO item, and one I'm surprised does not get asked about more often.

CE.

tamakazura
Just popping in
Just popping in
Posts: 6
Joined: Wed Aug 04, 2010 21:57

Re: On resizing a TextComponent dynamically

Postby tamakazura » Mon Aug 09, 2010 21:02

Thanks a bunch. Got it working. Part of the trouble was that I'm running an old version (0.6.1) where the factory registry process is still defined in macros instead of templates, and I was having a hard time reading them or finding docs. Figured it out, though.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 13 guests