New GUI class addons for Irrlicht.

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.

New GUI class addons for Irrlicht.

Postby christianclavet » Sat Aug 06, 2016 8:52 pm

Hi!

I almost lost theses ones when I put development on a pause on IRB.

I created 2 new GUI controls that I intended to use with IRB but that can be used by any project. With some refactoring it could even be integrated with Irrlicht to give even more niceties to the current GUI.

The new controls that have done are mostly related to better windows AND content.
- New GUI Window class that can be stretched and can be used as "panels". I used most of the code in these for the IRB windows.
- New GUI Window content class. This is SUB-GUI that normally goes inside a window, that you can define it size, and if the container is bigger that the size of it's parent windows will give you scrollbars. I was planning to use this GUI in IRB for ingame inventory. With some more code, we could add DRAG&DROP functionnalities to this class.. (transfering items in a backpack for example)

Here is the complete source done with CodeBlock on Linux. If you need it for Windows, just take the classes files and check the source.
http://www.clavet.org/irrlicht/WindowClass.zip

Here is the main.cpp of the example to see how to use it:
cpp Code: Select all
#include <irrlicht.h>
#include "GUI/CGUIExtWindow.h"
#include "GUI/CGUIConWindow.h"
 
 
using namespace irr;
 
 
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
 
int main()
{
 
    IrrlichtDevice *device =
        createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
            false, false, false, 0);
 
    if (!device)
        return 1;
 
 
    device->setWindowCaption(L"New windows types - Irrlicht Engine Demo");
 
 
    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();
 
    smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
    //Custom window that can scale (scalable windows / panes)
    CGUIExtWindow* win = new CGUIExtWindow(L"Windows that can scale, first",
        guienv,guienv->getRootGUIElement(),-1,rect<s32>(10,10,400,300));
 
    win->setDevice(device); //Need to set the device first.
    win->setStretchable(true); //Enable the window to be stretched (all directions)
    win->setCloseHide(true); //Will hide the window instead of removing it.
    win->setMinSize(core::dimension2du(320,200)); //Limit of the size
 
 
    guienv->addStaticText(L"This is the Irrlicht OPENGL renderer!",
        rect<s32>(10,30,260,52),true,-1,win);
 
 
    // Creating a content window
    CGUIConWindow* content = new CGUIConWindow(guienv, win,-1,rect<s32>(10,60,250,200));
 
    content->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
    content->setDrawBackground(true);
    content->useParentScale(true); //Will use the parent as a reference for the max scale of this window.
 
    IGUIStaticText* Texte=guienv->addStaticText(L"Test in progress - Test in progress - Test in progress - Test in progress - Test in progress - Test in progress - Test in progress ",
        core::rect<s32>(10,10,240,240),true,true,content);
 
 
    IGUIStaticText* Texte1=guienv->addStaticText(L"Test in progress - Test in progress - Test in progress - Test in progress - Test in progress - Test in progress - Test in progress ",
        core::rect<s32>(260,10,490,240),true,true,content);
    Texte1->setBackgroundColor(video::SColor(255,255,255,255));
 
    IGUIStaticText* Texte2=guienv->addStaticText(L"Test in progress - Test in progress - Test in progress - Test in progress - Test in progress - Test in progress - Test in progress ",
        core::rect<s32>(10,260,490,490),true,true,content);
    Texte2->setBackgroundColor(video::SColor(255,240,0,0));
 
    IGUIStaticText* Texte3=guienv->addStaticText(L"Test in progress - Test in progress - Test in progress - Test in progress - Test in progress - Test in progress - Test in progress ",
        core::rect<s32>(510,260,990,490),true,true,content);
    Texte3->setBackgroundColor(video::SColor(255,255,255,0));
 
 
    while(device->run())
    {
 
        driver->beginScene(true, true, SColor(255,100,101,140));
 
        smgr->drawAll();
        guienv->drawAll();
 
        driver->endScene();
    }
 
 
    device->drop();
 
    return 0;
}
 
 
 
User avatar
christianclavet
 
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest