diff --git a/changes.txt b/changes.txt index 6be4ccc..e09ee12 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- Add ICursorControl::getReferenceRect - Fix: Listbox no longer sending EGET_LISTBOX_SELECTED_AGAIN instead of EGET_LISTBOX_CHANGED when pressed mouse was moved over item before releasing the mouse button - Listbox items can now change individual background colors - Fix some bitfield sizes in SMaterial which were chosen too small for enums (PolygonOffsetDirection, ZWriteEnable, BlendOperation) diff --git a/include/ICursorControl.h b/include/ICursorControl.h index 4a9c617..87f4566 100644 --- a/include/ICursorControl.h +++ b/include/ICursorControl.h @@ -160,6 +160,12 @@ namespace gui \param rect: A pointer to an reference rectangle or 0 to disable the reference rectangle.*/ virtual void setReferenceRect(core::rect* rect=0) = 0; + //! Returns the current absolute reference rect used for the cursor position + /** \param rect Will receive the reference rectangle when the function returns true + When the result is false drivers can still write some platform specific values in there. + Generally at least the width/height of the returned rect will correspond to the current window size. + \return Return true when a reference rectangle has been set and is used by this driver */ + virtual bool getReferenceRect(core::rect& rect) { return false; } //! Sets the active cursor icon /** Setting cursor icons is so far only supported on Win32 and Linux */ diff --git a/source/Irrlicht/CIrrDeviceConsole.h b/source/Irrlicht/CIrrDeviceConsole.h index fb4a1e6..a88c5ad 100644 --- a/source/Irrlicht/CIrrDeviceConsole.h +++ b/source/Irrlicht/CIrrDeviceConsole.h @@ -197,6 +197,20 @@ namespace irr UseReferenceRect = false; } + virtual bool getReferenceRect(core::rect& rect) IRR_OVERRIDE + { + if ( UseReferenceRect ) + { + rect = ReferenceRect; + } + else + { + rect.UpperLeftCorner = core::vector2di(0,0); + rect.LowerRightCorner.X = (irr::s32)WindowSize.Width; + rect.LowerRightCorner.Y = (irr::s32)WindowSize.Height; + } + return UseReferenceRect; + } //! Updates the internal cursor position void setInternalCursorPosition(const core::position2di &pos) diff --git a/source/Irrlicht/CIrrDeviceFB.h b/source/Irrlicht/CIrrDeviceFB.h index e782c58..e0562f2 100644 --- a/source/Irrlicht/CIrrDeviceFB.h +++ b/source/Irrlicht/CIrrDeviceFB.h @@ -160,6 +160,14 @@ namespace irr { } + virtual bool getReferenceRect(core::rect& rect) IRR_OVERRIDE + { + rect.UpperLeftCorner = core::vector2di(0,0); + rect.LowerRightCorner.X = (irr::s32)Device->CreationParams.WindowSize.Width; + rect.LowerRightCorner.Y = (irr::s32)Device->CreationParams.WindowSize.Height; + return false; + } + private: void updateCursorPos() diff --git a/source/Irrlicht/CIrrDeviceLinux.h b/source/Irrlicht/CIrrDeviceLinux.h index 9ecf758..1e84db7 100644 --- a/source/Irrlicht/CIrrDeviceLinux.h +++ b/source/Irrlicht/CIrrDeviceLinux.h @@ -327,6 +327,21 @@ namespace irr UseReferenceRect = false; } + virtual bool getReferenceRect(core::rect& rect) IRR_OVERRIDE + { + if ( UseReferenceRect ) + { + rect = ReferenceRect; + } + else + { + rect.UpperLeftCorner = core::vector2di(0,0); + rect.LowerRightCorner.X = (irr::s32)Device->Width; + rect.LowerRightCorner.Y = (irr::s32)Device->Height; + } + return UseReferenceRect; + } + //! Sets the active cursor icon virtual void setActiveIcon(gui::ECURSOR_ICON iconId) IRR_OVERRIDE; diff --git a/source/Irrlicht/CIrrDeviceSDL.h b/source/Irrlicht/CIrrDeviceSDL.h index 06f11f9..3fa12c7 100644 --- a/source/Irrlicht/CIrrDeviceSDL.h +++ b/source/Irrlicht/CIrrDeviceSDL.h @@ -168,6 +168,14 @@ namespace irr { } + virtual bool getReferenceRect(core::rect& rect) IRR_OVERRIDE + { + rect.UpperLeftCorner = core::vector2di(0,0); + rect.LowerRightCorner.X = (irr::s32)Device->Width; + rect.LowerRightCorner.Y = (irr::s32)Device->Height; + return false; + } + private: void updateCursorPos() diff --git a/source/Irrlicht/CIrrDeviceWin32.h b/source/Irrlicht/CIrrDeviceWin32.h index 0acea07..f2641e4 100644 --- a/source/Irrlicht/CIrrDeviceWin32.h +++ b/source/Irrlicht/CIrrDeviceWin32.h @@ -275,6 +275,30 @@ namespace irr UseReferenceRect = false; } + virtual bool getReferenceRect(core::rect& rect) IRR_OVERRIDE + { + if ( UseReferenceRect ) + { + rect = ReferenceRect; + } + else + { + RECT wndRect; + if (GetWindowRect(HWnd, &wndRect)) + { + rect.UpperLeftCorner.X = wndRect.left+BorderX; + rect.UpperLeftCorner.Y = wndRect.top+BorderY; + } + else // error case - not sure if it matters what we set here as coordinates returned will be -1, -1 + { + rect.UpperLeftCorner = core::vector2di(0,0); + } + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + (irr::s32)WindowSize.Width; + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + (irr::s32)WindowSize.Height; + } + return UseReferenceRect; + } + /** Used to notify the cursor that the window was resized. */ void OnResize(const core::dimension2d& size) {