auto-adjust the Size of Textwindows, colored text

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

Lastmerlin
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Sat Mar 08, 2008 17:25

auto-adjust the Size of Textwindows, colored text

Postby Lastmerlin » Wed Jan 14, 2009 15:21

Hi to all,

I want to make some speech bubbles. The size of these windows should be adjusted to the amount of text they display. Furthermore I'd like to make some words colored to show that some name refers to an important person or item.

What I found so far is:
- Tooltip window allows sizeSelf
- StaticText has TextColours property.

The problem is to put things together.
My questions are:
1. Is it a good idea to use a Tooltip windows for this? I dont think this is the intended use of the Tooltip class ;)
2. Is it possible to color single words ? As far as I have read here, I guess not. If I try to split the text into subwindows, will sizeSelf still work.

Thanks a lot for any advice :)

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Postby Jamarr » Wed Jan 14, 2009 19:09

You would have to write the functionality for both of these yourself afaik.

For the text bubbles, you should probably create a whole new class. For example, either by deriving from Tooltip, copying the desired Tooltip code into a completely separate object, or just creating a completely new object all together; call it TextBubble or something.

As far as color coding words/phrases, you will have to split these up yourself. What I'm thinking is that you could set it up similar to how the editbox works, except instead of characters use window (StaticText) objects. Eg, determine the maximum width you want for the box, then iteratively add each window in sequence to the current row until that width is consumed. When you've reached the max width just move to the next row, and continue to add windows like this until you've run out. Then when in the drawing operation iterate all of the rows drawing the child-windows in sequence and storing the max height per-row, when you change rows use the row height to set the top offset for the next row.

This way you could use it for more than just StaticText windows - you could use it for displaying sets of images, etc. as is; and you could easily extended it to make lists like [#][checkbox][icon][text], etc.

Anyway, that's just a basic idea...it's a shame CEGUI doesn't have widget like this built-in eh :(

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

Postby CrazyEddie » Wed Jan 14, 2009 21:26

Coloured text via markup (though actually it should be a more generalised text formatting system that can use customised parsing of tags in strings) is on the list of things to be done for 0.7.0.

Writing a Window type that sizes itself to a string is trivial. If you're only going to use single-line strings, you could even do that via XML LookNFeel alone (though maybe not if you need to add extensions to support coloured text).

CE.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Thu Jan 15, 2009 20:45

CrazyEddie wrote:Writing a Window type that sizes itself to a string is trivial. If you're only going to use single-line strings, you could even do that via XML LookNFeel alone (though maybe not if you need to add extensions to support coloured text).

pointers plz? This would interest me.

As for the coloured text, there has been a long post in the forums that talk about how you can add this feature yourself into CEGUI (modify the sourcecode). They work pretty good for simple scenarios but they have some problems too (if more then one word is within the colour tag and they get wrapped, if used in editboxes). They are a big hack :)

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

Postby CrazyEddie » Fri Jan 16, 2009 09:18

Pompei2 wrote:pointers plz? This would interest me.

I thought about this just now, and what I said might have been a brain fart :oops: What I considered before, when I made the original statement, would affect just the imagery as opposed to the actual Window size itself.

Apologies for the confusion, and for making these wild claims :) In my defence, I have my mind totally consumed by other things at the moment :D

CE.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Sat Jan 17, 2009 01:10

Hehehe now you know what you can do after that rendertarget stuff :P

Lastmerlin
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Sat Mar 08, 2008 17:25

Postby Lastmerlin » Tue Jan 20, 2009 10:31

Thanks alot.
As I dont have enough time to dig deep into CEGUI atm I will wait for 0.7 for coloured text. For the window size, I am using a simple approximations based on the number of letters and newlines.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 19 guests