void setComponentUnderMouse (Component* const newComponent, const Point<int>& screenPos, const Time& time) { Component* current = getComponentUnderMouse(); if (newComponent != current) { WeakReference<Component> safeNewComp (newComponent); const ModifierKeys originalButtonState (buttonState); if (current != nullptr) { WeakReference<Component> safeOldComp (current); setButtons (screenPos, time, ModifierKeys()); if (safeOldComp != nullptr) { componentUnderMouse = safeNewComp; sendMouseExit (safeOldComp, screenPos, time); } buttonState = originalButtonState; } current = componentUnderMouse = safeNewComp; if (current != nullptr) sendMouseEnter (current, screenPos, time); revealCursor (false); setButtons (screenPos, time, originalButtonState); } }
void setScreenPos (const Point<int>& newScreenPos, const Time& time, const bool forceUpdate) { if (! isDragging()) setComponentUnderMouse (findComponentAt (newScreenPos), newScreenPos, time); if (newScreenPos != lastScreenPos || forceUpdate) { cancelPendingUpdate(); lastScreenPos = newScreenPos; Component* const current = getComponentUnderMouse(); if (current != nullptr) { if (isDragging()) { registerMouseDrag (newScreenPos); sendMouseDrag (current, newScreenPos + unboundedMouseOffset, time); if (isUnboundedMouseModeOn) handleUnboundedDrag (current); } else { sendMouseMove (current, newScreenPos, time); } } revealCursor (false); } }
void GfxCursor32::unhide() { if (_hideCount == 0 || --_hideCount) { return; } _cursor.rect.moveTo(_position.x - _hotSpot.x, _position.y - _hotSpot.y); revealCursor(); }
void GfxCursor32::move() { if (_hideCount) { return; } // Cursor moved onto the screen after being offscreen _cursor.rect.moveTo(_position.x - _hotSpot.x, _position.y - _hotSpot.y); if (_cursorBack.rect.isEmpty()) { revealCursor(); return; } // Cursor moved offscreen if (!_cursor.rect.intersects(_vmapRegion.rect)) { drawToHardware(_cursorBack); return; } if (!_cursor.rect.intersects(_cursorBack.rect)) { // Cursor moved to a completely different part of the screen _drawBuff1.rect = _cursor.rect; _drawBuff1.rect.clip(_vmapRegion.rect); readVideo(_drawBuff1); _drawBuff2.rect = _drawBuff1.rect; copy(_drawBuff2, _drawBuff1); paint(_drawBuff1, _cursor); drawToHardware(_drawBuff1); drawToHardware(_cursorBack); _cursorBack.rect = _cursor.rect; _cursorBack.rect.clip(_vmapRegion.rect); copy(_cursorBack, _drawBuff2); } else { // Cursor moved, but still overlaps the previous cursor location Common::Rect mergedRect(_cursorBack.rect); mergedRect.extend(_cursor.rect); mergedRect.clip(_vmapRegion.rect); _drawBuff2.rect = mergedRect; readVideo(_drawBuff2); copy(_drawBuff2, _cursorBack); _cursorBack.rect = _cursor.rect; _cursorBack.rect.clip(_vmapRegion.rect); copy(_cursorBack, _drawBuff2); paint(_drawBuff2, _cursor); drawToHardware(_drawBuff2); } }
//============================================================================== void enableUnboundedMouseMovement (bool enable, bool keepCursorVisibleUntilOffscreen) { enable = enable && isDragging(); isCursorVisibleUntilOffscreen = keepCursorVisibleUntilOffscreen; if (enable != isUnboundedMouseModeOn) { if ((! enable) && ((! isCursorVisibleUntilOffscreen) || ! unboundedMouseOffset.isOrigin())) { // when released, return the mouse to within the component's bounds if (Component* current = getComponentUnderMouse()) setScreenPosition (current->getScreenBounds().toFloat() .getConstrainedPoint (ScalingHelpers::unscaledScreenPosToScaled (lastScreenPos))); } isUnboundedMouseModeOn = enable; unboundedMouseOffset = Point<float>(); revealCursor (true); } }
//============================================================================== void enableUnboundedMouseMovement (bool enable, bool keepCursorVisibleUntilOffscreen) { enable = enable && isDragging(); isCursorVisibleUntilOffscreen = keepCursorVisibleUntilOffscreen; if (enable != isUnboundedMouseModeOn) { if ((! enable) && ((! isCursorVisibleUntilOffscreen) || ! unboundedMouseOffset.isOrigin())) { // when released, return the mouse to within the component's bounds Component* current = getComponentUnderMouse(); if (current != nullptr) Desktop::setMousePosition (current->getScreenBounds() .getConstrainedPoint (lastScreenPos)); } isUnboundedMouseModeOn = enable; unboundedMouseOffset = Point<int>(); revealCursor (true); } }