Add ClipCursor (Windows only)
This commit is contained in:
@@ -104,6 +104,7 @@ WindowBase::WindowBase(const CreateWindowSettings& settings)
|
||||
, _trackingMouseOffset(Vector2::Zero)
|
||||
, _isUsingMouseOffset(false)
|
||||
, _isTrackingMouse(false)
|
||||
, _isClippingCursor(false)
|
||||
, RenderTask(nullptr)
|
||||
{
|
||||
// Update window location based on start location
|
||||
|
||||
@@ -288,6 +288,7 @@ protected:
|
||||
bool _isUsingMouseOffset;
|
||||
Rectangle _mouseOffsetScreenSize;
|
||||
bool _isTrackingMouse;
|
||||
bool _isClippingCursor;
|
||||
|
||||
explicit WindowBase(const CreateWindowSettings& settings);
|
||||
virtual ~WindowBase();
|
||||
@@ -694,6 +695,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the cursor clipping.
|
||||
/// </summary>
|
||||
/// <param name="bounds">The bounds that the cursor will be confined to.</param>
|
||||
API_FUNCTION() virtual void StartClippingCursor(const Rectangle& bounds)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value indicating whenever the cursor is being clipped.
|
||||
/// </summary>
|
||||
API_PROPERTY bool IsCursorClipping() const
|
||||
{
|
||||
return _isClippingCursor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends the cursor clipping.
|
||||
/// </summary>
|
||||
API_FUNCTION() virtual void EndClippingCursor()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mouse cursor.
|
||||
/// </summary>
|
||||
|
||||
@@ -564,6 +564,34 @@ void WindowsWindow::EndTrackingMouse()
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsWindow::StartClippingCursor(const Rectangle& bounds)
|
||||
{
|
||||
ASSERT(HasHWND());
|
||||
|
||||
if (!_isClippingCursor)
|
||||
{
|
||||
_isClippingCursor = true;
|
||||
}
|
||||
|
||||
const RECT lpRect = {
|
||||
bounds.GetUpperLeft().X,
|
||||
bounds.GetUpperLeft().Y,
|
||||
bounds.GetBottomRight().X,
|
||||
bounds.GetBottomRight().Y
|
||||
};
|
||||
ClipCursor(&lpRect);
|
||||
}
|
||||
|
||||
void WindowsWindow::EndClippingMouse()
|
||||
{
|
||||
if (_isClippingCursor)
|
||||
{
|
||||
_isClippingCursor = false;
|
||||
|
||||
ClipCursor(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsWindow::SetCursor(CursorType type)
|
||||
{
|
||||
// Base
|
||||
|
||||
@@ -120,6 +120,8 @@ public:
|
||||
DragDropEffect DoDragDrop(const StringView& data) override;
|
||||
void StartTrackingMouse(bool useMouseScreenOffset) override;
|
||||
void EndTrackingMouse() override;
|
||||
void StartClippingCursor(const Rectangle& bounds) override;
|
||||
void EndClippingCursor() override;
|
||||
void SetCursor(CursorType type) override;
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
Reference in New Issue
Block a user