I am going to need a widget similar to StaticText, but that will be able to have some limited functionality similar to HTML. I am planning on developing this, but I figured I would throw it out there in case someone else has already implemented something similar or would like to provide some insight/feedback.
Here are the basic requirements I'm trying to fulfill:
1. Be able to set colors and limited font formatting inline (italics, bold, underline, etc)
2. Be able to set certain parts of the text as "links" that would be clickable and have their own callback event handler
3. Text would be marked up in a fashion very similar to HTML using <tag></tag> syntax.
I don't need anything more than that at the moment for my project, and I can probably even do without the the font formatting if that proves to be too much of an issue. I would image that it would require the font used to have the underline/bold/italic versions of each character, and I think that links in the text being an alternate color would be enough without needing them to be underlined like standard HTML.
I saw another thread about implementing something similar to this, and it was suggested that they were planning on modify the actual Font code so that the ability to set colors inline would be universal for all controls. I do like this idea, but I think that since I'm going to be needing the callbacks for link handling I'll just make it specific to this extended StaticText control for now.
I have been using CEGUI for a while, but this will be my first attempt at customizing or adding on to it (I haven't had the need since it is already so full-featured). Any comments/advice/suggestions are welcome!
Extending StaticText with Simple HTML
Moderators: CEGUI MVP, CEGUI Team
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
This would be an awesome addition to CEGUI, and as you've seen it's be discussed a few times.
The biggest proplem will definitely be the font formatting. The current font system is'nt in anyway geared for it, and yes it would require a new font for each different formatting.
Colours are "easy" though, but you'll be doing some customized splitting of the text into section with the different colours.
One thing I would suggest was that you worked against CVS head.
It's much more friendly to customization...
[edit] And porting it from 0.4 to 0.5 will likely be VERY troublesome...[/edit]
HTH, and _please_ ask if there's anything. I'd love to see this in action
-Tomas
The biggest proplem will definitely be the font formatting. The current font system is'nt in anyway geared for it, and yes it would require a new font for each different formatting.
Colours are "easy" though, but you'll be doing some customized splitting of the text into section with the different colours.
One thing I would suggest was that you worked against CVS head.
It's much more friendly to customization...
[edit] And porting it from 0.4 to 0.5 will likely be VERY troublesome...[/edit]
HTH, and _please_ ask if there's anything. I'd love to see this in action
-Tomas
Thanks for the encouragement and advice... unfortunately, all the work I've done so far has been against the 0.4.1 source, but I'm learning a lot about how the internal text rendering stuff works so I assume that will be useful with the current source as well. For my first pass, I'm simply adding in the color feature which is similar to the method you mentioned above (with splitting the text into multiple parts). The way i'm currently doing it is by parsing the string to be rendered and looking for embedded tags like {color:.5,0,0}dark red text{/col} and then storing a list of character position offsets and color values that will then be used at the time of rendering to change the color appropriately during rendering. I'm almost finished with this part, and once it's done I'll take another pass at it using the CVS HEAD source and try to implement it more efficiently and with more features using what I've learned so far.
By the way, is this the right forum or should I start a thread in a more technical developer forum once I start getting to the nitty gritty details and need to dicuss it?
By the way, is this the right forum or should I start a thread in a more technical developer forum once I start getting to the nitty gritty details and need to dicuss it?
first screenshot
http://www.indpoint.com/screenshots/scr ... acked2.png
Here is a link to the first screenshot using the control I'm building...
It is extending the Window class, and you add elements to it using either an addText(String str,Font *font) method, or addWindow(Window *wnd). It then arranges all of the added elements "inline" and wraps using the Width of the container window, or wraps at any \n line breaks in the text. It still needs a bit of work, but its starting to come together.
One thing I'm still trying to decide on... if you want a certain section of text to be clickable, like a link, then I am thinking I may just overlay a transparent Window on top of the text to handle all of the event processing... but I'm open to any suggestions if anyone has any.
Here is a link to the first screenshot using the control I'm building...
It is extending the Window class, and you add elements to it using either an addText(String str,Font *font) method, or addWindow(Window *wnd). It then arranges all of the added elements "inline" and wraps using the Width of the container window, or wraps at any \n line breaks in the text. It still needs a bit of work, but its starting to come together.
One thing I'm still trying to decide on... if you want a certain section of text to be clickable, like a link, then I am thinking I may just overlay a transparent Window on top of the text to handle all of the event processing... but I'm open to any suggestions if anyone has any.
Update
I have the links working (I used a method based on what Dalfy mentioned above). The links fire an EventLinkClicked event, and I created an implementation of the EventArgs class to pass along a user-defined link value based on which link was clicked. There are still plenty of optimizations to be done, and I'm not even entirely sure I implemented it in the best way possible... but in any case it's working and I'm in the process of testing it a bit more thoroughly... I'll post a link to the source if it looks like it's working okay for me.
Well, I haven't had a chance to put the finishing touches on the project yet... I am currently in the progress of porting all my code to C#, so that has been taking up most of my free time. I have been reluctant to post the source that I have currently, since I think it might be better to wait until it is completely working so that nobody is trying to use hacked together code that I introduce into the community... I will hopefully be able to get back to it this week if all goes well. I'll keep you posted though, and will try to have some source up this week.
Return to “CEGUI Library Development Discussion”
Who is online
Users browsing this forum: No registered users and 3 guests