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
auto-adjust the Size of Textwindows, colored text
Moderators: CEGUI MVP, CEGUI Team
-
- Not too shy to talk
- Posts: 33
- Joined: Sat Mar 08, 2008 17:25
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
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
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
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.
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.
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
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Pompei2 wrote:pointers plz? This would interest me.
I thought about this just now, and what I said might have been a brain fart 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
CE.
-
- Not too shy to talk
- Posts: 33
- Joined: Sat Mar 08, 2008 17:25
Who is online
Users browsing this forum: No registered users and 12 guests