Setting a buttons images

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Setting a buttons images

Postby spannerman » Mon Jul 19, 2004 12:09

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?

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

Setting a buttons images

Postby CrazyEddie » Mon Jul 19, 2004 12:17

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.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Setting a buttons images

Postby spannerman » Mon Jul 19, 2004 12:25

Sounds good, thanks again.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Setting a buttons images

Postby spannerman » Mon Jul 19, 2004 13:37

Ok, I managed to do it. 8) 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.

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();


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

Setting a buttons images

Postby CrazyEddie » Mon Jul 19, 2004 13:53

This is another case of a bug that came up the other day - where I have forgotten to trigger the redraw :oops:

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.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Setting a buttons images

Postby spannerman » Mon Jul 19, 2004 14:09

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.

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

Setting a buttons images

Postby CrazyEddie » Mon Jul 19, 2004 17:18

Oh, okay. I'll have to have a play around and get back to you :D

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

Setting a buttons images

Postby CrazyEddie » Mon Jul 19, 2004 19:59

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.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Setting a buttons images

Postby spannerman » Mon Jul 19, 2004 20:27

Excellant, that does indeed do the trick :D

Cheers man

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Setting a buttons images

Postby spannerman » Wed Jul 21, 2004 10:39

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.

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

Setting a buttons images

Postby CrazyEddie » Wed Jul 21, 2004 11:25

I could give you some excuses, but I won't. The method is missing in the base class and so is basically never called :oops: I'll fix this immediately and post back with a patch once it's in CVS.

Sorry.

CE.

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

Setting a buttons images

Postby CrazyEddie » Wed Jul 21, 2004 11:46

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);

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Setting a buttons images

Postby spannerman » Wed Jul 21, 2004 13:03

Thanks dude :D

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.

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

Setting a buttons images

Postby CrazyEddie » Wed Jul 21, 2004 13:30

Hehe :D I can't help it, especially when I make mistakes like that one :lol:

Anyway, keep up the testing ;)

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Setting a buttons images

Postby spannerman » Thu Jul 22, 2004 11:51

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?


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 11 guests