Page 1 of 1

Best way to make a tweaking GUI

Posted: Fri Oct 29, 2010 23:45
by Treb
I am trying to make an anttweakbar esque tweaker with CEGUI. Unfortunately I must be doing it in an suboptimal fashion because it takes about 10 seconds to create the window and it is very slow to render.

The tweaker needs to be hierarchical because it will be used for editing our XML files. I drew an ugly picture in paint to illustrate this. I have a name, edit box, and check box for each value.
Image

Unfortunately the current way I'm approaching this is quite slow. It involves creating about 60 Vanilla/StaticText's and edit boxes and it takes about 10 seconds to create the window and is quite slow to render.

I was wondering how a more experienced user would approach making the type of GUI I explained.


Here is a simplified code sample to illustrate approximately what I'm doing at this point.

Code: Select all

    m_mngr = WindowManager::getSingletonPtr();
    m_rootWin = m_mngr->createWindow("DefaultWindow");
    m_mainWin = m_mngr->createWindow("Vanilla/FrameWindow");
    m_clientWin = m_mngr->createWindow("WindowsLook/ScrollablePane");

    m_rootWin->setMousePassThroughEnabled(true);

    m_rootWin->addChildWindow(m_mainWin);
    m_mainWin->addChildWindow(m_clientWin);

    m_mainWin->setPosition(UVector2(UDim(0,0),UDim(0,0)));
    m_mainWin->setMinSize(UVector2(cegui_absdim(300),cegui_absdim(400)));

    m_clientWin->setPosition(UVector2(UDim(0,0),UDim(0,0)));
    m_clientWin->setSize(UVector2(UDim(1,0),UDim(1,0)));


    float curHeight = 10.f;
    for( uint i = 0; i < 60; ++i )
    {
      Window * win = m_mngr->createWindow("Vanilla/StaticText");

      m_clientWin->addChildWindow(win);

      win->setPosition(UVector2(UDim(0,10.f),UDim(0,curHeight)));
      win->setSize(UVector2(UDim(0,200),UDim(0,30.f)));

      //move next window down, I also do indenting in my full code.
      curHeight += 35.f;
      win->setText(itoa(i,buf,10));
    }

    CEGUI::System::getSingleton().setGUISheet(m_rootWin);

Re: Best way to make a tweaking GUI

Posted: Tue Nov 02, 2010 10:22
by CrazyEddie
I would start by avoiding static text. To be honest, the static text has become bloated and horrible, and is not really suitable for a lightweight label class anymore - which is a shame, since that's what it was supposed to be. I would suggest skinning DefaultWindow using the Falagard/Default window renderer to create a basic label class and replace the static text instances with that, since - unless you want scrollbars and a bunch of other bloat in your labels - this will lighten the load considerably IMO.

CE.

Re: Best way to make a tweaking GUI

Posted: Mon Nov 29, 2010 15:56
by mithryanna
Hmm great stuff. I actually noticed the same problem with a window created in our app; it has a listbox in it that dynamically checks our globe object for map layers, and displays them in a list. Just going through and displaying a checkbox and static text for 3 layers takes a few seconds for the window to load. After reading this I'm going to try switching the labels to default windows instead of static text.

Re: Best way to make a tweaking GUI

Posted: Thu Dec 23, 2010 17:08
by uelkfr
CrazyEddie wrote:I would start by avoiding static text. To be honest, the static text has become bloated and horrible, and is not really suitable for a lightweight label class anymore - which is a shame, since that's what it was supposed to be. I would suggest skinning DefaultWindow using the Falagard/Default window renderer to create a basic label class and replace the static text instances with that, since - unless you want scrollbars and a bunch of other bloat in your labels - this will lighten the load considerably IMO.

CE.

If so, why not to make the text as child (autowindow) of StaticText, or separate <WidgetLook> called "Label" without any bloated stuff. Or split this problem and create <WidgetLook> called "Panel" without text rendering support. There are a lot of approaches for future release :)

Re: Best way to make a tweaking GUI

Posted: Thu Dec 23, 2010 18:38
by Kulik
uelkfr: Yeah, I would start by renaming StaticText to something that would describe that it's powerful but bloated. Perhaps creating Label in the stock skins to replace it in the simple cases. Any ideas what StaticText should be called in 0.8?

Re: Best way to make a tweaking GUI

Posted: Thu Dec 23, 2010 20:50
by Mikademus
Kulik wrote:uelkfr: Yeah, I would start by renaming StaticText to something that would describe that it's powerful but bloated. Perhaps creating Label in the stock skins to replace it in the simple cases. Any ideas what StaticText should be called in 0.8?


BasicText, BasicTextLabel, Label or StaticLabel are good names for a light-weight, bare-bones label component. The current StaticText could be called something like MessagePanel, FullTextWidget or FullTextPanel to signal that it is a feature-rich and high-overhead component.

This discussion should probably be brought over to API breaking consistency fixes intended for CEGUI 0.8.0 though.