first congratulations to the new RC2. Works without problems so far. And the mouse cursor Z-Value is finally fixed


So, now to the problem. I'm using the code from this thread: http://www.cegui.org.uk/phpBB2/viewtopic.php?t=1040. I've modified the code, so that it works with the 0.5.0 RC2.
The DragItem disappears, when moving to another "drop target". And when I move the DragItem within the start "drop target", it doesn't reset its position. Can anyone help me?
Here is the whole example, it a modified Sample_FirstWindow. I removed the whole comments.
Code: Select all
#include "Sample_FirstWindow.h"
#include "CEGUI.h"
int main(int argc, char *argv[])
{
FirstWindowSample app;
return app.run();
}
bool handleDragEnter(const CEGUI::EventArgs& args)
{
using namespace CEGUI;
const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(args);
ddea.window->setProperty("FrameColours", "tl:FF00FF00 tr:FF00FF00 bl:FF00FF00 br:FF00FF00");
return true;
}
bool handleDragLeave(const CEGUI::EventArgs& args)
{
using namespace CEGUI;
const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(args);
ddea.window->setProperty("FrameColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF");
return true;
}
bool handleDragDropped(const CEGUI::EventArgs& args)
{
using namespace CEGUI;
const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(args);
ddea.window->setProperty("FrameColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF");
ddea.window->addChildWindow(ddea.dragDropItem);
return true;
}
CEGUI::Window* createDragDropSlot(CEGUI::Window* parent, const CEGUI::UVector2& position)
{
using namespace CEGUI;
Window* slot = WindowManager::getSingleton().createWindow("TaharezLook/StaticImage");
parent->addChildWindow(slot);
slot->setPosition(position);
slot->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim(0.2f)));
slot->subscribeEvent(Window::EventDragDropItemEnters, &handleDragEnter);
slot->subscribeEvent(Window::EventDragDropItemLeaves, &handleDragLeave);
slot->subscribeEvent(Window::EventDragDropItemDropped, &handleDragDropped);
return slot;
}
bool FirstWindowSample::initialiseSample()
{
using namespace CEGUI;
Imageset* taharezImages = ImagesetManager::getSingleton().createImageset("TaharezLook.imageset");
System::getSingleton().setDefaultMouseCursor(&taharezImages->getImage("MouseArrow"));
FontManager::getSingleton().createFont("Commonwealth-10.font");
WidgetLookManager::getSingleton().parseLookNFeelSpecification("TaharezLook.looknfeel");
SchemeManager::getSingleton().loadScheme("TaharezLookWidgets.scheme");
WindowManager& winMgr = WindowManager::getSingleton();
DefaultWindow* root = (DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");
System::getSingleton().setGUISheet(root);
Window* rs = winMgr.createWindow("TaharezLook/FrameWindow");
root->addChildWindow(rs);
rs->setPosition(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.25f)));
rs->setSize(UVector2(cegui_reldim(0.33f), cegui_reldim( 0.33f)));
rs->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
rs->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
rs->setText("Rucksack");
// create main equipped items window.
Window* eq = winMgr.createWindow("TaharezLook/FrameWindow");
root->addChildWindow(eq);
eq->setPosition(UVector2(cegui_reldim(0.57f), cegui_reldim( 0.25f)));
eq->setSize(UVector2(cegui_reldim(0.33f), cegui_reldim( 0.33f)));
eq->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
eq->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
eq->setText("Equipped Items");
// add slots to rucksack
Window* startSlot =
createDragDropSlot(rs, UVector2(cegui_reldim(0.05f), cegui_reldim(0.2f)));
createDragDropSlot(rs, UVector2(cegui_reldim(0.3f), cegui_reldim(0.2f)));
createDragDropSlot(rs, UVector2(cegui_reldim(0.55f), cegui_reldim(0.2f)));
createDragDropSlot(rs, UVector2(cegui_reldim(0.05f), cegui_reldim(0.5f)));
createDragDropSlot(rs, UVector2(cegui_reldim(0.3f), cegui_reldim(0.5f)));
createDragDropSlot(rs, UVector2(cegui_reldim(0.55f), cegui_reldim(0.5f)));
// add slots to equipment window
createDragDropSlot(eq, UVector2(cegui_reldim(0.05f), cegui_reldim(0.2f)));
createDragDropSlot(eq, UVector2(cegui_reldim(0.3f), cegui_reldim(0.2f)));
createDragDropSlot(eq, UVector2(cegui_reldim(0.55f), cegui_reldim(0.2f)));
createDragDropSlot(eq, UVector2(cegui_reldim(0.05f), cegui_reldim(0.5f)));
createDragDropSlot(eq, UVector2(cegui_reldim(0.3f), cegui_reldim(0.5f)));
createDragDropSlot(eq, UVector2(cegui_reldim(0.55f), cegui_reldim(0.5f)));
// create a drag/drop item
DragContainer* item = static_cast<DragContainer*>(
winMgr.createWindow("DragContainer", "theItem"));
item->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim(0.05f)));
item->setSize(UVector2(cegui_reldim(0.9f), cegui_reldim(0.9f)));
// set a static image as drag container's contents
Window* itemIcon = winMgr.createWindow("TaharezLook/StaticImage");
item->addChildWindow(itemIcon);
itemIcon->setPosition(UVector2(cegui_reldim(0), cegui_reldim(0)));
itemIcon->setSize(UVector2(cegui_reldim(1), cegui_reldim(1)));
itemIcon->setProperty("Image", "set:TaharezLook image:CloseButtonNormal");
// disable to allow inputs to pass through.
itemIcon->disable();
// set starting slot for the item.
startSlot ->addChildWindow(item); // return true so that the samples framework knows that initialisation was a
// success, and that it should now run the sample.
return true;
}
void FirstWindowSample::cleanupSample()
{
}