Hi there,
I am trying to create a tutorial for my program. Is there any option in CEGUI that allow me to highlight a window that has been desactivated? In other words, I would like to make the window more visible to the user during the tutorial but still have it desactived so then the user cannot click any button, etc.
I also have an editbox (listbox) and I am able to add, delete all items and save them. Now I need to only delete the last added item. The items on the list are added according to what each user clicks so it may vary every time. Does any one know a way of doing this?
I tried to display some text on the screen by using mWindow->setDebugText
but nothing was displayed. Is there any other method?
My last question Smile
I have a static image like the one that exists on the GUI demo. Is it possible to only have a skydome on the static image and not on the background (root window)?
Thanks in advance.
Several CEGUI questions
Moderators: CEGUI MVP, CEGUI Team
Within the Tab Order wiki entry I played with the alpha of the widget, making it brighter when it has the focus and darker when it loses it:
But that's not what you asked. The real solution is more difficult.
I would create a DefaultWindow slightly bigger than the widget and have it display a border of a certain color:
What won't work is the "BackgroundColours" property and the way I offset pos; I don't have access to my editor to fully work it out. Hopefully you can get it to work and will post some code here and in the wiki.
Hope this helps.
Code: Select all
#define HACKED_FOCUS_GAIN(window) CEGUI::WindowManager::getSingleton().getWindow(window)->setAlpha(1.0f)
#define HACKED_FOCUS_LOSS(window) CEGUI::WindowManager::getSingleton().getWindow(window)->setAlpha(0.8f)
But that's not what you asked. The real solution is more difficult.
I would create a DefaultWindow slightly bigger than the widget and have it display a border of a certain color:
Code: Select all
using namespace CEGUI;
WindowManager& winMgr = WindowManager::getSingleton();
Window* highlight = winMgr.createWindow("DefaultWindow", "highlight_wnd");
highlight->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0)));
highlight->setSize(UVector2(cegui_reldim(1), cegui_reldim( 1)));
highlight->setProperty("BackgroundEnabled", "true");
highlight->setProperty("BackgroundColours", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000");
// aarrggbb in Hexadecimal (alpha, red, green, blue)
// tl: top left, tr: top right, bl: bottom left, br: bottom right
void setHighlight(Window* pWindow, bool pHighlight)
{
if(pHighlight)
{
UVector2 pos = pWindow->getPosition();
pos.x_left -= 10;
pos.x_right += 10;
pos.y_top -= 10;
pos.y_bottom += 10;
highlight->setPosition(pos);
highlight->setVisible(true);
}
else
{
highlight->setVisible(false);
}
}
What won't work is the "BackgroundColours" property and the way I offset pos; I don't have access to my editor to fully work it out. Hopefully you can get it to work and will post some code here and in the wiki.
Hope this helps.
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
I also have an editbox (listbox) and I am able to add, delete all items and save them. Now I need to only delete the last added item. The items on the list are added according to what each user clicks so it may vary every time. Does any one know a way of doing this?
ListboxItems have an ID which you can set. For example when inserting a new item, you could upate a counter, and set the new items' ID to match that new value. Now to delete the last item, you need to query the listbox for the item with that ID. You can use 'getItemCount' and 'getListboxItemFromIndex'. to loop the items and query their IDs. Using this technique also works when the list is sorted.
I tried to display some text on the screen by using mWindow->setDebugText
but nothing was displayed. Is there any other method?
That's not a CEGUI call. I cannot see how it's implemented, probably Ogre? In that case you need to enable the HUD by pressing 'F' i think. To show some text you can use a StaticText widget. Refer to the WidgetGalore wiki page for a how-to.
I have a static image like the one that exists on the GUI demo. Is it possible to only have a skydome on the static image and not on the background (root window)?
Well the skydome is not on the root window; it's just that the root window has no background, so you can look through it. What you are looking for is a render to texture, which is currently not possible. If you are using Ogre, you might search their forum because IIRC there has been some work done on 3D GUI's and such
HTH
- kungfoomasta
- Not too shy to talk
- Posts: 34
- Joined: Wed Apr 06, 2005 08:25
Actually I'm fairly certain the OGRE GUI Demo uses Render To Texture for the image windows.
I was looking through the code a few days ago, so I may be a bit off, but you can create an Image using a name and Texture. So all you need to do is create the render to texture and pass the texture to make the image, and apply the image to the window. In either case, I would look at the source to see how it's done, it doesn't look that complex at all. (Assuming you understand rtt's a little)
KungFooMasta
I was looking through the code a few days ago, so I may be a bit off, but you can create an Image using a name and Texture. So all you need to do is create the render to texture and pass the texture to make the image, and apply the image to the window. In either case, I would look at the source to see how it's done, it doesn't look that complex at all. (Assuming you understand rtt's a little)
KungFooMasta
Hi, thank you very much for your replies.
I managed to delete the last elements of my listbox as suggested.
I can now display text (that users write on an edit box) on the screen using staticText. I have now two further questions regarding this.
When a user clicks to add some text, he/she writes on an edit box and then click on a button to add the text to a listbox.
The second time the user clicks to add more text:
1- the editbox still contains the previous text
2- the text displayed on the listbox is displayed twice (or three times depending on the number of times the user clicks to add some text)
Do you know how I could fix this?
Also, do you know how I could set a maximum number of characters that an edit box can have? I thought I could use something like mEditBox->setMaximumSize();
I still didnt attempt to highlight windows or to change the rtt background.
Thanks in advance.
I managed to delete the last elements of my listbox as suggested.
I can now display text (that users write on an edit box) on the screen using staticText. I have now two further questions regarding this.
When a user clicks to add some text, he/she writes on an edit box and then click on a button to add the text to a listbox.
The second time the user clicks to add more text:
1- the editbox still contains the previous text
2- the text displayed on the listbox is displayed twice (or three times depending on the number of times the user clicks to add some text)
Do you know how I could fix this?
Also, do you know how I could set a maximum number of characters that an edit box can have? I thought I could use something like mEditBox->setMaximumSize();
I still didnt attempt to highlight windows or to change the rtt background.
Thanks in advance.
1- the editbox still contains the previous text
You could clear it with a call to editbox->SetText( "" );
2- the text displayed on the listbox is displayed twice (or three times depending on the number of times the user clicks to add some text)
It's your job to dothis, e.g. when handling tha add button you could search the listbox for an item with the text, e.g. with the function "findItemWithText (const String &text, const ListboxItem *start_item)".
Also, do you know how I could set a maximum number of characters that an edit box can have? I thought I could use something like mEditBox->setMaximumSize();
Ther is a function like this, called "setMaxTextLength".
Here comes my question: do you know the CEGUI's API reference ? It is very util, all my answers come from there:
Return to “Offtopic Discussion”
Who is online
Users browsing this forum: No registered users and 2 guests