Page 1 of 1

Trying to programmatically create ImageButton

Posted: Sat Jan 02, 2016 20:00
by Jonas
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?

Re: Trying to programmatically create ImageButton

Posted: Mon Jan 04, 2016 23:41
by bomkallo
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);


Re: Trying to programmatically create ImageButton

Posted: Tue Jan 05, 2016 07:35
by Ident
TaharezLook/ImageButton does not exist in CEGUI 0.8.4. I do not know where you got that idea from

Re: Trying to programmatically create ImageButton

Posted: Tue Jan 05, 2016 14:20
by bomkallo
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?

Re: Trying to programmatically create ImageButton

Posted: Tue Jan 05, 2016 20:32
by Ident
Sorry my mistake, a mapping with that name of course exists.