Minor drawing problem with Context menu

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

Minor drawing problem with Context menu

Post by ceyron »

When setting the skin to BurningSkin the Context Menu is drawn with a extra 3px at top, it's not a big thing but i wanted to report it. I traced the problem in CGUISkin.cpp at line 615

Code: Select all

rect.UpperLeftCorner.Y -= 3;
Not really sure why the burning skin needs the extra pixels, removing this line draws the menu as it should, but might also break how other elements are drawn.

Also i would like to know if you plan to add something like EGDS_SUBMENU_DISTANCE to the EGUI_DEFAULT_SIZE; that would make possible to change the distance between the main menu and it's submenu. Right now the submenu is overlapping the main menu a little.

The obligatory 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::IGUIEnvironment* guienv = NULL;

//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_COMBO_BOX_CHANGED)
            {
                gui::IGUISkin* newSkin = guienv->createSkin((EGUI_SKIN_TYPE) ((gui::IGUIComboBox*)event.GUIEvent.Caller)->getSelected());
                if (newSkin)
                    guienv->setSkin(newSkin);
            }
            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();
    guienv = device->getGUIEnvironment();
 //add a context  menu
    gui::IGUIContextMenu* cm = guienv->addContextMenu(core::rect<s32 > (10, 10, 100, 100), NULL, -1);
    cm->setEnabled(false);
    cm->addItem(L"Menu Item 1");
    cm->addItem(L"Menu Item 2");
    cm->addSeparator();
    cm->addItem(L"Menu Item 3");

    //add combo box
    guienv->addStaticText(L"Select a skin", core::rect<s32 > (120, 20, 220, 30), false, false);
    gui::IGUIComboBox* cb = guienv->addComboBox(core::rect<s32 > (120, 30, 280, 50), NULL, -1);
    cb->addItem(L"EGST_WINDOWS_CLASSIC", EGST_WINDOWS_CLASSIC);
    cb->addItem(L"EGST_WINDOWS_METALLIC", EGST_WINDOWS_METALLIC);
    cb->addItem(L"EGST_BURNING_SKIN", EGST_BURNING_SKIN);
    cb->setSelected(1);

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

        smgr->drawAll();
        guienv->drawAll();
        //draw context menu rect
        driver->draw2DRectangleOutline(cm->getAbsolutePosition(), video::SColor(0xFFFF0000));

        driver->endScene();
    }

    return EXIT_SUCCESS;
}
Image
Post Reply