Trying to programmatically create ImageButton

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Jonas
Just popping in
Just popping in
Posts: 1
Joined: Wed Dec 23, 2015 04:16

Trying to programmatically create ImageButton

Postby Jonas » Sat Jan 02, 2016 20:00

As the topic states I'm trying to programmatically create a TaharezLook/ImageButton, for a build menu. So far I've had an easier time creating a normal TaharezLook/Button and using text markup to insert an image, while the ImageButton doesn't show up at all. I have tried a lot of things but right now I'm at a loss as to where to look for info or what to try next.

The code as it stands, first for creating the ImageButton, then the normal Button:

Code: Select all

CEGUI::FrameWindow* ArenaLayer::createBuildMenu() {
   CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
   CEGUI::FrameWindow* window = dynamic_cast<CEGUI::FrameWindow*>(winMgr.createWindow("TaharezLook/FrameWindow", "buildMenu"));

   {
      CEGUI::PushButton* button = dynamic_cast<CEGUI::PushButton*>(winMgr.createWindow("TaharezLook/ImageButton", "button"));
      //button->setProperty("NormalImage", "set:TaharezLook image:CheckboxNormal");
      //button->setProperty("NormalImage", "TaharezLook/CheckboxNormal");

      button->setProperty("Position", "{{0,0},{0,0}}");
      button->setProperty("Size", "{{0,64},{0,20}}");

      button->setProperty("NormalImage", "TaharezLook/CheckboxNormal");
      button->setProperty("HoverImage", "TaharezLook/CheckboxNormal");
      button->setProperty("PushedImage", "TaharezLook/CheckboxNormal");
      button->setProperty("DisabledImage", "TaharezLook/CheckboxNormal");

      window->addChild(button);
      //CEGUI::System::getSingletonPtr()->getDefaultGUIContext().getRootWindow()->addChild(button);
   }

   {
      CEGUI::PushButton* button = dynamic_cast<CEGUI::PushButton*>(winMgr.createWindow("TaharezLook/Button", "button2"));
      button->setText(std::string{ "X[colour='88888888']X[colour='ffffffff']X[image-size='w:32 h:32'][image='" } + TextureController::Instance.getCEGUIImageName(TileType::DEER) + std::string{ "']" });
      window->addChild(button);
   }

   VLOG(2) << "Created buildMenu";

   return window;
}


The resulting window:
http://i.imgur.com/OkpxUTH.png

The button you see in the window is the second Button, the one using text markup. The first button doesn't show up at all.

Any ideas or advice?

bomkallo
Just popping in
Just popping in
Posts: 16
Joined: Fri Dec 11, 2015 15:47

Re: Trying to programmatically create ImageButton

Postby bomkallo » Mon Jan 04, 2016 23:41

I've made quick test for imagebutton in 8.4, and it works and shows vertical scrollbar arrow just for testing purposes and by using standard imageset.

Code: Select all

CEGUI::PushButton *but = static_cast<PushButton*>(WindowManager::getSingleton().createWindow("TaharezLook/ImageButton"));

but->setPosition(UVector2(UDim(0.1, 0), UDim(0.1, 0)));
but->setSize(USize(cegui_reldim(0.2), cegui_reldim(0.2)));

but->setProperty("NormalImage", "TaharezLook/VertScrollDownNormal");
but->setProperty("HoverImage", "TaharezLook/VertScrollDownHover");

CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(but);


User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trying to programmatically create ImageButton

Postby Ident » Tue Jan 05, 2016 07:35

TaharezLook/ImageButton does not exist in CEGUI 0.8.4. I do not know where you got that idea from
CrazyEddie: "I don't like GUIs"

bomkallo
Just popping in
Just popping in
Posts: 16
Joined: Fri Dec 11, 2015 15:47

Re: Trying to programmatically create ImageButton

Postby bomkallo » Tue Jan 05, 2016 14:20

Hmmm, strange. I download cegui from official website and it is cegui-0.8.4. The taharez scheme goes from:
..\CEGUI\cegui-0.8.4\datafiles\schemes which contains:

<FalagardMapping windowType="TaharezLook/ImageButton" targetType="CEGUI/PushButton" renderer="Core/Button" lookNFeel="TaharezLook/ImageButton" />

So what's wrong with my cegui then?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trying to programmatically create ImageButton

Postby Ident » Tue Jan 05, 2016 20:32

Sorry my mistake, a mapping with that name of course exists.
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 14 guests