Original message below:
_____________________________________
Hello,
I just ported my application from Ogre 1.8 and CEGUI 0.7 to Ogre 1.9 and CEGUI 0.8.4
Code: Select all
02/08/2015 22:49:27 (Std) ---- Version: 0.8.4 (Build: Aug 1 2015 GNU/Linux g++ 4.8.4 64 bit) ----
02/08/2015 22:49:27 (Std) ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
02/08/2015 22:49:27 (Std) ---- XML Parser module is: CEGUI::XercesParser - Official Xerces-C++ based parser module for CEGUI ----
02/08/2015 22:49:27 (Std) ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
02/08/2015 22:49:27 (Std) ---- Scripting module is: None ----
One difference that I have noticed is that all the ItemListbox widgets in my application have stopped rendering their last item entry.
I have written a sample that reproduces this behavior.
Here's the extract regarding the ItemListbox widget:
Code: Select all
CEGUI::ItemListbox * p_list = static_cast<CEGUI::ItemListbox *>(
CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/ItemListbox", "test_listbox"));
p_list->setSize(CEGUI::USize(CEGUI::UDim(1.f,0),CEGUI::UDim(1.f,0)));
CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(p_list);
for(unsigned i = 1; i <= 3; ++i)
{
std::ostringstream oss;
oss << "item #" << i;
std::string text = oss.str();
CEGUI::ItemEntry * p_itm =
static_cast<CEGUI::ItemEntry *>(
CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/ListboxItem", text));
p_itm->setText(text);
p_list->addItem(p_itm);
}
p_list->invalidate();
p_list->show();
// Enabling the next two lines solves the bug
// CEGUI::WindowEventArgs args(box.listbox());
// CEGUI::System::getSingleton().getDefaultGUIContext().onRootWindowChanged(args);
On my machine, this code shows a single listbox with only two items ("item #1" and "item #2") instead of the expected three.
Enabling the last two commented lines solves the problem, but doesn't seem very mmm... clean since onRootWindowChanged is protected.
There must be some piece of code triggered by the call to onRootWindowChanged that forces a full redraw/refresh of the view. What is that piece of code? How can I call it outside of onRootWindowChanged?
Invalidate doesn't either work as I'd expect in this case...
Here's the full sample that reproduces it on my machine (a Gentoo linux box, Ogre and CEGUI compiled by portage) :
Code: Select all
// Hack to access GUIContext::onRootWindowChanged
#define protected public
#include <sstream>
#include <Ogre.h>
#include <CEGUI/CEGUI.h>
#include <CEGUI/RendererModules/Ogre/Renderer.h>
const char * const kMAIN_WINDOW_NAME = "test_window";
int main()
{
Ogre::Root root;
Ogre::ConfigFile cf;
cf.load("resources.cfg");
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
const Ogre::RenderSystemList& r_renderSystemList = root.getAvailableRenderers();
if(0 == r_renderSystemList.size())
{
std::cerr << "No rendersystem was found." << std::endl;
exit(EXIT_FAILURE);
}
root.setRenderSystem(r_renderSystemList[0]);
root.initialise(false);
Ogre::RenderWindow * p_window = root.createRenderWindow(kMAIN_WINDOW_NAME, 800, 600, false);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Ogre::SceneManager * p_sceneManager = root.createSceneManager(Ogre::ST_GENERIC);
Ogre::Camera * p_camera = p_sceneManager->createCamera("test_camera");
p_camera->setPosition(Ogre::Vector3(0,0,80));
p_camera->lookAt(Ogre::Vector3(0,0,0));
p_camera->setNearClipDistance(5);
Ogre::Viewport * p_viewport = p_window->addViewport(p_camera);
p_camera->setAspectRatio(Ogre::Real(p_viewport->getActualWidth()) / Ogre::Real(p_viewport->getActualHeight()));
CEGUI::OgreRenderer::bootstrapSystem(*p_window);
// Ressources
CEGUI::ImageManager::setImagesetDefaultResourceGroup("Imagesets");
CEGUI::Font::setDefaultResourceGroup("Fonts");
CEGUI::Scheme::setDefaultResourceGroup("Schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
CEGUI::WindowManager::setDefaultResourceGroup("Layouts");
CEGUI::ScriptModule::setDefaultResourceGroup("LuaScripts");
CEGUI::SchemeManager::getSingleton().createFromFile( "TaharezLook.scheme" );
CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage( "TaharezLook/MouseArrow" );
CEGUI::FontManager::getSingleton().createFromFile( "DejaVuSans-10.font" );
CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont( "DejaVuSans-10" );
CEGUI::ItemListbox * p_list = static_cast<CEGUI::ItemListbox *>(
CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/ItemListbox", "test_listbox"));
p_list->setSize(CEGUI::USize(CEGUI::UDim(1.f,0),CEGUI::UDim(1.f,0)));
CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(p_list);
for(unsigned i = 1; i <= 3; ++i)
{
std::ostringstream oss;
oss << "item #" << i;
std::string text = oss.str();
CEGUI::ItemEntry * p_itm =
static_cast<CEGUI::ItemEntry *>(
CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/ListboxItem", text));
p_itm->setText(text);
p_list->addItem(p_itm);
}
p_list->invalidate();
p_list->show();
// Enabling the next two lines solves the bug
// CEGUI::WindowEventArgs args(box.listbox());
// CEGUI::System::getSingleton().getDefaultGUIContext().onRootWindowChanged(args);
root.startRendering();
}