[fixed]IGUITabControl added tab drawing bug

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
ceyron
Posts: 63
Joined: Tue Mar 03, 2009 5:10 pm
Location: Bucuresti, România

[fixed]IGUITabControl added tab drawing bug

Post by ceyron »

Tabs of a tab control aligned to bottom with setTabVerticalAlignment() won't draw as expected when setDrawBackground() is set to true.
I'm afraid my english is bad so you might not understand therefore i set up a little testcase.

Code: Select all

#include <cstdlib>
#include <irrlicht.h>

using namespace std;
using namespace irr;
using namespace gui; 
using namespace scene;
using namespace video;

gui::IGUITabControl* tc = NULL;//pointer to our  tab control

//quick event receiver class
class MyEventReceiver : public IEventReceiver
{
    virtual bool OnEvent(const SEvent& event)
    {
        if(event.EventType == EET_GUI_EVENT)
        {
            if(event.GUIEvent.EventType == EGET_CHECKBOX_CHANGED)
               tc->getTab(0)->setDrawBackground(((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked());
            else if(event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
                tc->setTabVerticalAlignment(((gui::IGUIButton*)event.GUIEvent.Caller)->isPressed()?EGUIA_LOWERRIGHT:EGUIA_UPPERLEFT);
            else
                return false;

            return true;
        }
        return false;
    }
} ;

/*
 *
 */
int main(int argc, char** argv)
{
    MyEventReceiver receiver;
    IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<u32> (800, 600), 32, false, false, false, &receiver);

    if (!device)
        return EXIT_FAILURE;

    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
    gui::IGUIEnvironment* guienv = device->getGUIEnvironment();

    //set the tab control and add a tab to it
    tc = guienv->addTabControl(core::rect<s32>(30,10,230,190),NULL,true,true);
    tc->addTab(L"Test Tab")->setBackgroundColor(video::SColor(0xA0FF00FF));

    //add checkbox that toggles the background drawing of the tab
    guienv->addCheckBox(false,core::rect<s32>(240,140,380,160),NULL, -1, L"Toggle Tab  Draw Background");

    //add button that will call setTabVerticalAlignment() and align the tab to bottom
    guienv->addButton(core::rect<s32>(240,170,380,190),NULL,-1,L"setTabVerticalAlignment()")->setIsPushButton(true);

 while (device->run())
    {
        driver->beginScene(true, true, video::SColor(0xFFA0A0A0));

        smgr->drawAll();
        guienv->drawAll();

        driver->endScene();
    }

    return EXIT_SUCCESS;
}

Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Thanks for reporting and the testcase!

It turned out that the tabs didn't get repositioned at all when setTabVerticalAlignment was changed - so elements on them also were positioned wrong afterwards.

It's now fixed in the svn 1.7 release branch (r3513) along with a few minor correction for the tab-clipping.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply