ComboBox drop down size with alternate fonts

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
rubixcuber
Posts: 7
Joined: Fri Feb 19, 2010 6:01 pm

ComboBox drop down size with alternate fonts

Post by rubixcuber »

Normally the drop down portion of the combo box is sized to fit the choices, but when changing the font it seems to still use the size for the base font as shown below.

Image

Is there any way to make this work without changing the engine? Or is there something I'm missing?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ComboBox drop down size with alternate fonts

Post by CuteAlien »

I'll have to check, but that sounds like a bug. I try to find some time next week to look into it. Thanks for the report.

edit: Did you try to call setMaxSelectionRows after changing the font? That could be a workaround.
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
rubixcuber
Posts: 7
Joined: Fri Feb 19, 2010 6:01 pm

Re: ComboBox drop down size with alternate fonts

Post by rubixcuber »

Looks like calling setMaxSelectionRows will change the size, but still based on the the base font and will not make it any larger than the number of entries so it still ends up cut off with a larger font.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ComboBox drop down size with alternate fonts

Post by CuteAlien »

OK, took me a while until I got this. This only happened when the font changed while that list was open. It's fixed in svn trunk r5009.

Test-code:

Code: Select all

 
#include <irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
 
int main()
{
    video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
    IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(640, 480));
    if (device == 0)
        return 1; // could not create selected driver.
 
    video::IVideoDriver* driver = device->getVideoDriver();
    IGUIEnvironment* env = device->getGUIEnvironment();
    
    IGUIComboBox * combo = env->addComboBox(core::rect<s32>(10,100, 200, 130));
    for ( int i=0; i<50; ++i )
    {
        irr::core::stringw foo(i);
        foo += L". item";
        combo->addItem(foo.c_str());
    }
 
    gui::IGUISkin* skin = env->getSkin();
    gui::IGUIFont* oldFont = skin->getFont();
    oldFont->grab();
    gui::IGUIFont* fontBig = env->getFont("../../media/bigfont.png");
    fontBig->grab();
    
    u32 oldTime = device->getTimer ()->getTime();
 
    while(device->run() && driver)
    {
        if (device->isWindowActive())
        {
            u32 currentTime = device->getTimer ()->getTime();
            if ( currentTime-oldTime > 5000 )
            {
                oldTime = currentTime;
                if ( skin->getFont() == oldFont )
                    skin->setFont(fontBig);             
                else
                    skin->setFont(oldFont);             
                    
            }
            
            driver->beginScene(true, true, SColor(0,200,200,200));
            env->drawAll();
            driver->endScene();
        }
        
    }
 
    device->drop();
 
    return 0;
}
 
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