Add IrrlichtDevice::setWindowSize (implemented only on X11, will try Windows next).

A few minor changes to the GUIEditor:
- Displays the window-size
- Update (rarely) when Window now active
- Sleep after drawing to prevent update-delays on resizing
- Driver choice now only for available drivers
- Kick out the "Tools" tab as it's unused so far and just irritating users.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4692 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2014-02-17 12:01:07 +00:00
parent 0fdb7d626b
commit d6f7029221
6 changed files with 48 additions and 13 deletions

View File

@ -227,6 +227,12 @@ namespace irr
\param resize Flag whether the window should be resizable. */
virtual void setResizable(bool resize=false) = 0;
//! Resize the render window.
/** This will only work in windowed mode and is not yet supported on all systems.
It does set the drawing/clientDC size of the window, the window decorations are added to that.
*/
virtual void setWindowSize(const irr::core::dimension2d<u32>& size) = 0;
//! Minimizes the window if possible.
virtual void minimizeWindow() =0;

View File

@ -1341,6 +1341,20 @@ void CIrrDeviceLinux::setResizable(bool resize)
#endif // #ifdef _IRR_COMPILE_WITH_X11_
}
//! Resize the render window.
void CIrrDeviceLinux::setWindowSize(const irr::core::dimension2d<u32>& size)
{
#ifdef _IRR_COMPILE_WITH_X11_
if (CreationParams.DriverType == video::EDT_NULL || CreationParams.Fullscreen )
return;
XWindowChanges values;
values.width = size.Width;
values.height = size.Height;
XConfigureWindow(display, window, CWWidth | CWHeight, &values);
XFlush(display);
#endif // #ifdef _IRR_COMPILE_WITH_X11_
}
//! Return pointer to a list with all video modes supported by the gfx adapter.
video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()

View File

@ -92,6 +92,9 @@ namespace irr
//! Sets if the window should be resizable in windowed mode.
virtual void setResizable(bool resize=false) _IRR_OVERRIDE_;
//! Resize the render window.
virtual void setWindowSize(const irr::core::dimension2d<u32>& size) _IRR_OVERRIDE_;
//! Minimizes the window.
virtual void minimizeWindow() _IRR_OVERRIDE_;

View File

@ -135,6 +135,8 @@ namespace irr
//! Remove all messages pending in the system message loop
virtual void clearSystemMessages() _IRR_OVERRIDE_;
//! Resize the render window.
virtual void setWindowSize(const irr::core::dimension2d<u32>& size) _IRR_OVERRIDE_ {}
protected:

View File

@ -37,16 +37,16 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
if (!skin)
return;
s32 th = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
setRelativePosition(core::rect<s32>(50,50,250,500));
core::rect<s32> dlgRect(50,50,250,500);
setRelativePosition(dlgRect);
setMinSize(core::dimension2du(200,200));
IGUITabControl *TabControl = environment->addTabControl(core::rect<s32>(1,th+5,199,449), this, false, true);
s32 th = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
IGUITabControl *TabControl = environment->addTabControl(core::rect<s32>(1,th+5,dlgRect.getWidth()-1,dlgRect.getHeight()-1), this, false, true);
TabControl->setSubElement(true);
TabControl->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
TabControl->addTab(L"Tools");
//TabControl->addTab(L"Tools");
//L"Texture Cache Browser"
//L"Font Browser"
//L"Font Generator"
@ -83,7 +83,8 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
TreeView->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
IGUITreeViewNode* treenode = TreeView->getRoot();
//treenode->addChildFront(L"Elements");
ResizeButton = environment->addButton(core::rect<s32>(199-th,449-th,199,449), this);
ResizeButton = environment->addButton(core::rect<s32>(dlgRect.getWidth()-(th+1),dlgRect.getHeight()-(th+1),dlgRect.getWidth()-1,dlgRect.getHeight()-1), this);
ResizeButton->setDrawBorder(false);
ResizeButton->setEnabled(false);
ResizeButton->setSpriteBank(skin->getSpriteBank());
@ -92,6 +93,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
ResizeButton->grab();
ResizeButton->setSubElement(true);
ResizeButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
updateTree();
}

View File

@ -14,7 +14,7 @@ using namespace gui;
int main()
{
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
video::E_DRIVER_TYPE driverType=driverChoiceConsole(false);
if (driverType==video::EDT_COUNT)
return 1;
@ -56,21 +56,29 @@ int main()
*/
env->addGUIElement("GUIEditor");
while(device->run())
{
device->sleep(10);
if (device->isWindowActive())
while(device->run())
{
if (!device->isWindowMinimized())
{
const core::dimension2d<u32>& screenSize = driver->getScreenSize();
wchar_t caption[512];
swprintf(caption, 512, L"screen (%4u/%4u)", screenSize.Width, screenSize.Height);
device->setWindowCaption(caption);
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
driver->endScene();
}
// be nice to CPU
device->sleep(10);
if (!device->isWindowActive())
device->sleep(90);
}
device->closeDevice();
device->drop();
return 0;
}