Commit d6f70292 authored by cutealien's avatar cutealien

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
parent 0fdb7d62
...@@ -227,6 +227,12 @@ namespace irr ...@@ -227,6 +227,12 @@ namespace irr
\param resize Flag whether the window should be resizable. */ \param resize Flag whether the window should be resizable. */
virtual void setResizable(bool resize=false) = 0; 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. //! Minimizes the window if possible.
virtual void minimizeWindow() =0; virtual void minimizeWindow() =0;
......
...@@ -1341,6 +1341,20 @@ void CIrrDeviceLinux::setResizable(bool resize) ...@@ -1341,6 +1341,20 @@ void CIrrDeviceLinux::setResizable(bool resize)
#endif // #ifdef _IRR_COMPILE_WITH_X11_ #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. //! Return pointer to a list with all video modes supported by the gfx adapter.
video::IVideoModeList* CIrrDeviceLinux::getVideoModeList() video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
......
...@@ -92,6 +92,9 @@ namespace irr ...@@ -92,6 +92,9 @@ namespace irr
//! Sets if the window should be resizable in windowed mode. //! Sets if the window should be resizable in windowed mode.
virtual void setResizable(bool resize=false) _IRR_OVERRIDE_; 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. //! Minimizes the window.
virtual void minimizeWindow() _IRR_OVERRIDE_; virtual void minimizeWindow() _IRR_OVERRIDE_;
......
...@@ -135,6 +135,8 @@ namespace irr ...@@ -135,6 +135,8 @@ namespace irr
//! Remove all messages pending in the system message loop //! Remove all messages pending in the system message loop
virtual void clearSystemMessages() _IRR_OVERRIDE_; virtual void clearSystemMessages() _IRR_OVERRIDE_;
//! Resize the render window.
virtual void setWindowSize(const irr::core::dimension2d<u32>& size) _IRR_OVERRIDE_ {}
protected: protected:
......
...@@ -37,16 +37,16 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec ...@@ -37,16 +37,16 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
if (!skin) if (!skin)
return; return;
s32 th = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); core::rect<s32> dlgRect(50,50,250,500);
setRelativePosition(dlgRect);
setRelativePosition(core::rect<s32>(50,50,250,500));
setMinSize(core::dimension2du(200,200)); 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->setSubElement(true);
TabControl->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); TabControl->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
TabControl->addTab(L"Tools"); //TabControl->addTab(L"Tools");
//L"Texture Cache Browser" //L"Texture Cache Browser"
//L"Font Browser" //L"Font Browser"
//L"Font Generator" //L"Font Generator"
...@@ -83,7 +83,8 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec ...@@ -83,7 +83,8 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
TreeView->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); TreeView->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
IGUITreeViewNode* treenode = TreeView->getRoot(); IGUITreeViewNode* treenode = TreeView->getRoot();
//treenode->addChildFront(L"Elements"); //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->setDrawBorder(false);
ResizeButton->setEnabled(false); ResizeButton->setEnabled(false);
ResizeButton->setSpriteBank(skin->getSpriteBank()); ResizeButton->setSpriteBank(skin->getSpriteBank());
...@@ -92,6 +93,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec ...@@ -92,6 +93,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
ResizeButton->grab(); ResizeButton->grab();
ResizeButton->setSubElement(true); ResizeButton->setSubElement(true);
ResizeButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); ResizeButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
updateTree(); updateTree();
} }
......
...@@ -14,7 +14,7 @@ using namespace gui; ...@@ -14,7 +14,7 @@ using namespace gui;
int main() int main()
{ {
// ask user for driver // ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole(); video::E_DRIVER_TYPE driverType=driverChoiceConsole(false);
if (driverType==video::EDT_COUNT) if (driverType==video::EDT_COUNT)
return 1; return 1;
...@@ -56,21 +56,29 @@ int main() ...@@ -56,21 +56,29 @@ int main()
*/ */
env->addGUIElement("GUIEditor"); 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)); driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll(); smgr->drawAll();
env->drawAll(); env->drawAll();
driver->endScene(); driver->endScene();
} }
// be nice to CPU
device->sleep(10);
if (!device->isWindowActive())
device->sleep(90);
} }
device->closeDevice();
device->drop(); device->drop();
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment