Setting a buttons images
Moderators: CEGUI MVP, CEGUI Team
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
Setting a buttons images
Hi Eddie,
Simple question for you I think. After creating a PushButton, Im trying to change the images it uses, with my own versions from an imageset I created. It seems the methods I need (setNormalImage etc.) are held in TLButton.
I nearly managed to get it working, by including "WidgetSets\TaharezLook\include\TLButton.h" and getting a referance to the button window in question, then creating a new RenderableImage etc... but I keep falling down with unresolved external symbols etc.
I know Im going about this wrong way. If youve got a pushbutton whats the quickest and easiest way to change its images?
Simple question for you I think. After creating a PushButton, Im trying to change the images it uses, with my own versions from an imageset I created. It seems the methods I need (setNormalImage etc.) are held in TLButton.
I nearly managed to get it working, by including "WidgetSets\TaharezLook\include\TLButton.h" and getting a referance to the button window in question, then creating a new RenderableImage etc... but I keep falling down with unresolved external symbols etc.
I know Im going about this wrong way. If youve got a pushbutton whats the quickest and easiest way to change its images?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Setting a buttons images
Hmmm. Your approach is basically correct, though you'll need to add the TaharezLook.lib to your application project settings (since you are now using it directly - hence the unresolved externals).
As an aside, I have been considering promoting that functionality from TLButton into the base PushButton class - since it's quite logical that all buttons would need this ability. I guess this proves the need, so I'll add this to the TODO list.
HTH
CE.
As an aside, I have been considering promoting that functionality from TLButton into the base PushButton class - since it's quite logical that all buttons would need this ability. I guess this proves the need, so I'll add this to the TODO list.
HTH
CE.
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
Setting a buttons images
Sounds good, thanks again.
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
Setting a buttons images
Ok, I managed to do it.
Theres something strange though, the button wont show up on my window frame unless I click somewhere (anywhere) on the frame itself, only then does it pop into view.
Can you see if Im missing something please?
Here be my code. Note I tried a few methods at the end to force the button into view, but didnt work.

Can you see if Im missing something please?
Here be my code. Note I tried a few methods at the end to force the button into view, but didnt work.
Code: Select all
PushButton* btnArrowR = (PushButton*)winMgr.createWindow((utf8*)"Taharez Button", (utf8*)"ArrowRight");
CameraPanel->addChildWindow(btnArrowR);
btnArrowR->setPosition(Point(0.48f, 0.48f));
btnArrowR->setSize(Size(0.2f, 0.2f));
btnArrowR->setMaximumSize(Size(1.0f, 1.0f));
TLButton* btnRight = (TLButton*)winMgr.getWindow((utf8*)"ArrowRight");
btnRight->setStandardImageryEnabled(false);
btnRight->setCustomImageryAutoSized(true);
RenderableImage img;
img.setHorzFormatting(RenderableImage::HorzStretched);
img.setVertFormatting(RenderableImage::VertStretched);
img.setImage(&giset->getImage((utf8*)"ArrowRightNormal"));
btnRight->setNormalImage(&img);
btnRight->setDisabledImage(&img);
img.setImage(&giset->getImage((utf8*)"ArrowRightHighlight"));
btnRight->setHoverImage(&img);
img.setImage(&giset->getImage((utf8*)"ArrowRightDown"));
btnRight->setPushedImage(&img);
btnRight->setVisible(true);
btnRight->setEnabled(true);
btnRight->show();
btnArrowR->setVisible(true);
btnArrowR->setEnabled(true);
btnArrowR->show();
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Setting a buttons images
This is another case of a bug that came up the other day - where I have forgotten to trigger the redraw
What you need to do in the mean time is to force the redraw by doing this:
That should fix the problem until I can get it done properly in CVS.
HTH
CE.

What you need to do in the mean time is to force the redraw by doing this:
Code: Select all
btnArrowR->requestRedraw();
That should fix the problem until I can get it done properly in CVS.
HTH
CE.
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
Setting a buttons images
Hehe, no sweat.
Unfortunately, requestRedraw doesnt seem to solve my problem. I tried it on the PushButton, also on the the TLButton, the parent panel and the frame window.
Unfortunately, requestRedraw doesnt seem to solve my problem. I tried it on the PushButton, also on the the TLButton, the parent panel and the frame window.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Setting a buttons images
Oh, okay. I'll have to have a play around and get back to you 

- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Setting a buttons images
Okay, I'm about to commit the fixes for this to CVS. The problem is caused by the fact that, internally, the initial areas for the images are not being set.
Since there is a 5 hour delay for anonymous CVS access to sync, a work-around for the problem is not to add the button to its parent until after you have set the images.
HTH
CE.
Since there is a 5 hour delay for anonymous CVS access to sync, a work-around for the problem is not to add the button to its parent until after you have set the images.
HTH
CE.
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
Setting a buttons images
Excellant, that does indeed do the trick
Cheers man

Cheers man
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
Setting a buttons images
Hey,
I cant get the setDisabledImage method for the PushButton to work. I have a seperate image to show the button as disabled, but when I disable the button with setEnabled(false); it's 'NormalImage' is still being used. The button does seem to be disabled though i.e. its images dont change with hover etc. and it cant be clicked.
I had a look, but the only difference I can see in the code was the block from line 428 in TLButton.cpp (in the drawDisabled method), where it seems to be less lines of code than the other methods. I dont think this is the problem area though, just thought I'd mention it in case.
I cant get the setDisabledImage method for the PushButton to work. I have a seperate image to show the button as disabled, but when I disable the button with setEnabled(false); it's 'NormalImage' is still being used. The button does seem to be disabled though i.e. its images dont change with hover etc. and it cant be clicked.
I had a look, but the only difference I can see in the code was the block from line 428 in TLButton.cpp (in the drawDisabled method), where it seems to be less lines of code than the other methods. I dont think this is the problem area though, just thought I'd mention it in case.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Setting a buttons images
I could give you some excuses, but I won't. The method is missing in the base class and so is basically never called
I'll fix this immediately and post back with a patch once it's in CVS.
Sorry.
CE.

Sorry.
CE.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Setting a buttons images
This is now in CVS, as ever due to the sync time, here's the patch...
Code: Select all
Index: include/elements/CEGUIButtonBase.h
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/include/elements/CEGUIButtonBase.h,v
retrieving revision 1.9
diff -u -r1.9 CEGUIButtonBase.h
--- include/elements/CEGUIButtonBase.h 21 Jul 2004 09:50:15 -0000 1.9
+++ include/elements/CEGUIButtonBase.h 21 Jul 2004 11:42:06 -0000
@@ -275,6 +275,19 @@
virtual void drawPushed(float z) {drawNormal(z);}
+ /*!
+ \brief
+ Render the button-type widget in it's 'disabled' state
+
+ \param z
+ float value specifying the base Z co-ordinate that should be used when rendering
+
+ \return
+ Nothing
+ */
+ virtual void drawDisabled(float z) {drawNormal(z);}
+
+
/*************************************************************************
Implementation Data
*************************************************************************/
Index: src/elements/CEGUIButtonBase.cpp
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/src/elements/CEGUIButtonBase.cpp,v
retrieving revision 1.7
diff -u -r1.7 CEGUIButtonBase.cpp
--- src/elements/CEGUIButtonBase.cpp 9 Jul 2004 13:46:07 -0000 1.7
+++ src/elements/CEGUIButtonBase.cpp 21 Jul 2004 11:42:06 -0000
@@ -187,6 +187,10 @@
{
drawPushed(z);
}
+ else if (isDisabled())
+ {
+ drawDisabled(z);
+ }
else
{
drawNormal(z);
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
Setting a buttons images
Thanks dude
By the way, you dont need to apologise for anything man, come on! 8O Im using your free GUI system, which is still in production. As I use it, Im happy to be helping to test it and to report issues. You dont owe me anything, this GUI is a life saver to me.

By the way, you dont need to apologise for anything man, come on! 8O Im using your free GUI system, which is still in production. As I use it, Im happy to be helping to test it and to report issues. You dont owe me anything, this GUI is a life saver to me.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Setting a buttons images
Hehe
I can't help it, especially when I make mistakes like that one
Anyway, keep up the testing


Anyway, keep up the testing

- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
Setting a buttons images
Hehe, will do
On a subject related to button images, Im trying to fashion a basic tab header out of a custom ListHeader. I have two questions on this:
1) Is there a way to tell which list header column is currently selected, if any, out of all the columns? Would I be able to track this using the sort functionality (even though Im not interested in actually sorting anything)?
2) ListHeader Images - how do I set my own custom ones? I.e. Hover and normal. I tried going down the same route as what I did for the pushbutton, but couldnt get it to work. Is the ListHeader made up of TLButton's under the hood?

On a subject related to button images, Im trying to fashion a basic tab header out of a custom ListHeader. I have two questions on this:
1) Is there a way to tell which list header column is currently selected, if any, out of all the columns? Would I be able to track this using the sort functionality (even though Im not interested in actually sorting anything)?
2) ListHeader Images - how do I set my own custom ones? I.e. Hover and normal. I tried going down the same route as what I did for the pushbutton, but couldnt get it to work. Is the ListHeader made up of TLButton's under the hood?
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 20 guests