| @@ -9299,16 +9299,154 @@ private: | |||||
| /*** End of inlined file: juce_ModifierKeys.h ***/ | /*** End of inlined file: juce_ModifierKeys.h ***/ | ||||
| /*** Start of inlined file: juce_Point.h ***/ | |||||
| #ifndef __JUCE_POINT_JUCEHEADER__ | |||||
| #define __JUCE_POINT_JUCEHEADER__ | |||||
| /*** Start of inlined file: juce_AffineTransform.h ***/ | |||||
| #ifndef __JUCE_AFFINETRANSFORM_JUCEHEADER__ | |||||
| #define __JUCE_AFFINETRANSFORM_JUCEHEADER__ | |||||
| class JUCE_API AffineTransform | |||||
| { | |||||
| public: | |||||
| AffineTransform() throw(); | |||||
| AffineTransform (const AffineTransform& other) throw(); | |||||
| AffineTransform (const float mat00, const float mat01, const float mat02, | |||||
| const float mat10, const float mat11, const float mat12) throw(); | |||||
| const AffineTransform& operator= (const AffineTransform& other) throw(); | |||||
| bool operator== (const AffineTransform& other) const throw(); | |||||
| bool operator!= (const AffineTransform& other) const throw(); | |||||
| static const AffineTransform identity; | |||||
| void transformPoint (float& x, | |||||
| float& y) const throw(); | |||||
| void transformPoint (double& x, | |||||
| double& y) const throw(); | |||||
| const AffineTransform translated (const float deltaX, | |||||
| const float deltaY) const throw(); | |||||
| static const AffineTransform translation (const float deltaX, | |||||
| const float deltaY) throw(); | |||||
| const AffineTransform rotated (const float angleInRadians) const throw(); | |||||
| const AffineTransform rotated (const float angleInRadians, | |||||
| const float pivotX, | |||||
| const float pivotY) const throw(); | |||||
| static const AffineTransform rotation (const float angleInRadians) throw(); | |||||
| static const AffineTransform rotation (const float angleInRadians, | |||||
| const float pivotX, | |||||
| const float pivotY) throw(); | |||||
| const AffineTransform scaled (const float factorX, | |||||
| const float factorY) const throw(); | |||||
| static const AffineTransform scale (const float factorX, | |||||
| const float factorY) throw(); | |||||
| const AffineTransform sheared (const float shearX, | |||||
| const float shearY) const throw(); | |||||
| const AffineTransform inverted() const throw(); | |||||
| const AffineTransform followedBy (const AffineTransform& other) const throw(); | |||||
| bool isIdentity() const throw(); | |||||
| bool isSingularity() const throw(); | |||||
| bool isOnlyTranslation() const throw(); | |||||
| float getTranslationX() const throw() { return mat02; } | |||||
| float getTranslationY() const throw() { return mat12; } | |||||
| juce_UseDebuggingNewOperator | |||||
| float mat00, mat01, mat02; | |||||
| float mat10, mat11, mat12; | |||||
| private: | |||||
| const AffineTransform followedBy (const float mat00, const float mat01, const float mat02, | |||||
| const float mat10, const float mat11, const float mat12) const throw(); | |||||
| }; | |||||
| #endif // __JUCE_AFFINETRANSFORM_JUCEHEADER__ | |||||
| /*** End of inlined file: juce_AffineTransform.h ***/ | |||||
| template <typename ValueType> | |||||
| class Point | |||||
| { | |||||
| public: | |||||
| Point() throw() : x (0), y (0) {} | |||||
| Point (const Point& other) throw() : x (other.x), y (other.y) {} | |||||
| Point (const ValueType initialX, const ValueType initialY) throw() : x (initialX), y (initialY) {} | |||||
| ~Point() throw() {} | |||||
| Point& operator= (const Point& other) throw() { x = other.x; y = other.y; return *this; } | |||||
| inline ValueType getX() const throw() { return x; } | |||||
| inline ValueType getY() const throw() { return y; } | |||||
| inline bool operator== (const Point& other) const throw() { return x == other.x && y == other.y; } | |||||
| inline bool operator!= (const Point& other) const throw() { return x != other.x || y != other.y; } | |||||
| bool isOrigin() const throw() { return x == ValueType() && y == ValueType(); } | |||||
| void setXY (const ValueType newX, const ValueType newY) throw() { x = newX; y = newY; } | |||||
| void addXY (const ValueType xToAdd, const ValueType yToAdd) throw() { x += xToAdd; y += yToAdd; } | |||||
| const Point operator+ (const Point& other) const throw() { return Point (x + other.x, y + other.y); } | |||||
| Point& operator+= (const Point& other) throw() { x += other.x; y += other.y; return *this; } | |||||
| const Point operator- (const Point& other) const throw() { return Point (x - other.x, y - other.y); } | |||||
| Point& operator-= (const Point& other) throw() { x -= other.x; y -= other.y; return *this; } | |||||
| ValueType getDistanceFrom (const Point& other) const throw() { return (ValueType) juce_hypot (x - other.x, y - other.y); } | |||||
| void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); } | |||||
| juce_UseDebuggingNewOperator | |||||
| private: | |||||
| ValueType x, y; | |||||
| }; | |||||
| #endif // __JUCE_POINT_JUCEHEADER__ | |||||
| /*** End of inlined file: juce_Point.h ***/ | |||||
| class JUCE_API MouseEvent | class JUCE_API MouseEvent | ||||
| { | { | ||||
| public: | public: | ||||
| MouseEvent (const int x, const int y, | |||||
| MouseEvent (const Point<int>& position, | |||||
| const ModifierKeys& modifiers, | const ModifierKeys& modifiers, | ||||
| Component* const originator, | Component* const originator, | ||||
| const Time& eventTime, | const Time& eventTime, | ||||
| const int mouseDownX, | |||||
| const int mouseDownY, | |||||
| const Point<int> mouseDownPos, | |||||
| const Time& mouseDownTime, | const Time& mouseDownTime, | ||||
| const int numberOfClicks, | const int numberOfClicks, | ||||
| const bool mouseWasDragged) throw(); | const bool mouseWasDragged) throw(); | ||||
| @@ -9331,6 +9469,8 @@ public: | |||||
| int getMouseDownY() const throw(); | int getMouseDownY() const throw(); | ||||
| const Point<int> getMouseDownPosition() const throw(); | |||||
| int getDistanceFromDragStart() const throw(); | int getDistanceFromDragStart() const throw(); | ||||
| int getDistanceFromDragStartX() const throw(); | int getDistanceFromDragStartX() const throw(); | ||||
| @@ -9343,13 +9483,19 @@ public: | |||||
| int getLengthOfMousePress() const throw(); | int getLengthOfMousePress() const throw(); | ||||
| int getScreenX() const throw(); | |||||
| const Point<int> getPosition() const throw(); | |||||
| int getScreenX() const; | |||||
| int getScreenY() const throw(); | |||||
| int getScreenY() const; | |||||
| int getMouseDownScreenX() const throw(); | |||||
| const Point<int> getScreenPosition() const; | |||||
| int getMouseDownScreenY() const throw(); | |||||
| int getMouseDownScreenX() const; | |||||
| int getMouseDownScreenY() const; | |||||
| const Point<int> getMouseDownScreenPosition() const; | |||||
| const MouseEvent getEventRelativeTo (Component* const otherComponent) const throw(); | const MouseEvent getEventRelativeTo (Component* const otherComponent) const throw(); | ||||
| @@ -9360,7 +9506,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| int mouseDownX, mouseDownY; | |||||
| Point<int> mouseDownPos; | |||||
| Time mouseDownTime; | Time mouseDownTime; | ||||
| int numberOfClicks; | int numberOfClicks; | ||||
| bool wasMovedSinceMouseDown; | bool wasMovedSinceMouseDown; | ||||
| @@ -9619,138 +9765,6 @@ public: | |||||
| #define __JUCE_PATH_JUCEHEADER__ | #define __JUCE_PATH_JUCEHEADER__ | ||||
| /*** Start of inlined file: juce_AffineTransform.h ***/ | |||||
| #ifndef __JUCE_AFFINETRANSFORM_JUCEHEADER__ | |||||
| #define __JUCE_AFFINETRANSFORM_JUCEHEADER__ | |||||
| class JUCE_API AffineTransform | |||||
| { | |||||
| public: | |||||
| AffineTransform() throw(); | |||||
| AffineTransform (const AffineTransform& other) throw(); | |||||
| AffineTransform (const float mat00, const float mat01, const float mat02, | |||||
| const float mat10, const float mat11, const float mat12) throw(); | |||||
| const AffineTransform& operator= (const AffineTransform& other) throw(); | |||||
| bool operator== (const AffineTransform& other) const throw(); | |||||
| bool operator!= (const AffineTransform& other) const throw(); | |||||
| static const AffineTransform identity; | |||||
| void transformPoint (float& x, | |||||
| float& y) const throw(); | |||||
| void transformPoint (double& x, | |||||
| double& y) const throw(); | |||||
| const AffineTransform translated (const float deltaX, | |||||
| const float deltaY) const throw(); | |||||
| static const AffineTransform translation (const float deltaX, | |||||
| const float deltaY) throw(); | |||||
| const AffineTransform rotated (const float angleInRadians) const throw(); | |||||
| const AffineTransform rotated (const float angleInRadians, | |||||
| const float pivotX, | |||||
| const float pivotY) const throw(); | |||||
| static const AffineTransform rotation (const float angleInRadians) throw(); | |||||
| static const AffineTransform rotation (const float angleInRadians, | |||||
| const float pivotX, | |||||
| const float pivotY) throw(); | |||||
| const AffineTransform scaled (const float factorX, | |||||
| const float factorY) const throw(); | |||||
| static const AffineTransform scale (const float factorX, | |||||
| const float factorY) throw(); | |||||
| const AffineTransform sheared (const float shearX, | |||||
| const float shearY) const throw(); | |||||
| const AffineTransform inverted() const throw(); | |||||
| const AffineTransform followedBy (const AffineTransform& other) const throw(); | |||||
| bool isIdentity() const throw(); | |||||
| bool isSingularity() const throw(); | |||||
| bool isOnlyTranslation() const throw(); | |||||
| float getTranslationX() const throw() { return mat02; } | |||||
| float getTranslationY() const throw() { return mat12; } | |||||
| juce_UseDebuggingNewOperator | |||||
| float mat00, mat01, mat02; | |||||
| float mat10, mat11, mat12; | |||||
| private: | |||||
| const AffineTransform followedBy (const float mat00, const float mat01, const float mat02, | |||||
| const float mat10, const float mat11, const float mat12) const throw(); | |||||
| }; | |||||
| #endif // __JUCE_AFFINETRANSFORM_JUCEHEADER__ | |||||
| /*** End of inlined file: juce_AffineTransform.h ***/ | |||||
| /*** Start of inlined file: juce_Point.h ***/ | |||||
| #ifndef __JUCE_POINT_JUCEHEADER__ | |||||
| #define __JUCE_POINT_JUCEHEADER__ | |||||
| template <typename ValueType> | |||||
| class Point | |||||
| { | |||||
| public: | |||||
| Point() throw() : x (0), y (0) {} | |||||
| Point (const Point& other) throw() : x (other.x), y (other.y) {} | |||||
| Point (const ValueType initialX, const ValueType initialY) throw() : x (initialX), y (initialY) {} | |||||
| ~Point() throw() {} | |||||
| Point& operator= (const Point& other) throw() { x = other.x; y = other.y; return *this; } | |||||
| inline ValueType getX() const throw() { return x; } | |||||
| inline ValueType getY() const throw() { return y; } | |||||
| void setXY (const ValueType newX, const ValueType newY) throw() { x = newX; y = newY; } | |||||
| void addXY (const ValueType xToAdd, const ValueType yToAdd) throw() { x += xToAdd; y += yToAdd; } | |||||
| const Point operator+ (const Point& other) const throw() { return Point (x + other.x, y + other.y); } | |||||
| Point& operator+= (const Point& other) throw() { x += other.x; y += other.y; return *this; } | |||||
| const Point operator- (const Point& other) const throw() { return Point (x - other.x, y - other.y); } | |||||
| Point& operator-= (const Point& other) throw() { x -= other.x; y -= other.y; return *this; } | |||||
| void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); } | |||||
| juce_UseDebuggingNewOperator | |||||
| private: | |||||
| ValueType x, y; | |||||
| }; | |||||
| #endif // __JUCE_POINT_JUCEHEADER__ | |||||
| /*** End of inlined file: juce_Point.h ***/ | |||||
| /*** Start of inlined file: juce_Rectangle.h ***/ | /*** Start of inlined file: juce_Rectangle.h ***/ | ||||
| #ifndef __JUCE_RECTANGLE_JUCEHEADER__ | #ifndef __JUCE_RECTANGLE_JUCEHEADER__ | ||||
| #define __JUCE_RECTANGLE_JUCEHEADER__ | #define __JUCE_RECTANGLE_JUCEHEADER__ | ||||
| @@ -9810,10 +9824,14 @@ public: | |||||
| inline ValueType getCentreY() const throw() { return y + h / (ValueType) 2; } | inline ValueType getCentreY() const throw() { return y + h / (ValueType) 2; } | ||||
| inline const Point<ValueType> getCentre() const throw() { return Point<ValueType> (x + w / (ValueType) 2, y + h / (ValueType) 2); } | |||||
| bool isEmpty() const throw() { return w <= 0 || h <= 0; } | bool isEmpty() const throw() { return w <= 0 || h <= 0; } | ||||
| const Point<ValueType> getPosition() const throw() { return Point<ValueType> (x, y); } | const Point<ValueType> getPosition() const throw() { return Point<ValueType> (x, y); } | ||||
| void setPosition (const Point<ValueType>& newPos) throw() { x = newPos.getX(); y = newPos.getY(); } | |||||
| void setPosition (const ValueType newX, const ValueType newY) throw() { x = newX; y = newY; } | void setPosition (const ValueType newX, const ValueType newY) throw() { x = newX; y = newY; } | ||||
| void setSize (const ValueType newWidth, const ValueType newHeight) throw() { w = newWidth; h = newHeight; } | void setSize (const ValueType newWidth, const ValueType newHeight) throw() { w = newWidth; h = newHeight; } | ||||
| @@ -9910,12 +9928,23 @@ public: | |||||
| return xCoord >= x && yCoord >= y && xCoord < x + w && yCoord < y + h; | return xCoord >= x && yCoord >= y && xCoord < x + w && yCoord < y + h; | ||||
| } | } | ||||
| bool contains (const Point<ValueType> point) const throw() | |||||
| { | |||||
| return point.getX() >= x && point.getY() >= y && point.getX() < x + w && point.getY() < y + h; | |||||
| } | |||||
| bool contains (const Rectangle& other) const throw() | bool contains (const Rectangle& other) const throw() | ||||
| { | { | ||||
| return x <= other.x && y <= other.y | return x <= other.x && y <= other.y | ||||
| && x + w >= other.x + other.w && y + h >= other.y + other.h; | && x + w >= other.x + other.w && y + h >= other.y + other.h; | ||||
| } | } | ||||
| const Point<ValueType> getConstrainedPoint (const Point<ValueType>& point) const throw() | |||||
| { | |||||
| return Point<ValueType> (jlimit (x, x + w, point.getX()), | |||||
| jlimit (y, y + h, point.getY())); | |||||
| } | |||||
| bool intersects (const Rectangle& other) const throw() | bool intersects (const Rectangle& other) const throw() | ||||
| { | { | ||||
| return x + w > other.x | return x + w > other.x | ||||
| @@ -12243,13 +12272,11 @@ public: | |||||
| virtual void getBounds (int& x, int& y, int& w, int& h) const = 0; | virtual void getBounds (int& x, int& y, int& w, int& h) const = 0; | ||||
| virtual int getScreenX() const = 0; | |||||
| virtual const Point<int> getScreenPosition() const = 0; | |||||
| virtual int getScreenY() const = 0; | |||||
| virtual const Point<int> relativePositionToGlobal (const Point<int>& relativePosition) = 0; | |||||
| virtual void relativePositionToGlobal (int& x, int& y) = 0; | |||||
| virtual void globalPositionToRelative (int& x, int& y) = 0; | |||||
| virtual const Point<int> globalPositionToRelative (const Point<int>& screenPosition) = 0; | |||||
| virtual void setMinimised (bool shouldBeMinimised) = 0; | virtual void setMinimised (bool shouldBeMinimised) = 0; | ||||
| @@ -12291,7 +12318,7 @@ public: | |||||
| virtual void grabFocus() = 0; | virtual void grabFocus() = 0; | ||||
| virtual void textInputRequired (int x, int y) = 0; | |||||
| virtual void textInputRequired (const Point<int>& position) = 0; | |||||
| void handleFocusGain(); | void handleFocusGain(); | ||||
| void handleFocusLoss(); | void handleFocusLoss(); | ||||
| @@ -12448,16 +12475,18 @@ public: | |||||
| void getVisibleArea (RectangleList& result, | void getVisibleArea (RectangleList& result, | ||||
| const bool includeSiblings) const; | const bool includeSiblings) const; | ||||
| int getScreenX() const throw(); | |||||
| int getScreenX() const; | |||||
| int getScreenY() const; | |||||
| int getScreenY() const throw(); | |||||
| const Point<int> getScreenPosition() const; | |||||
| void relativePositionToGlobal (int& x, int& y) const throw(); | |||||
| const Point<int> relativePositionToGlobal (const Point<int>& relativePosition) const; | |||||
| void globalPositionToRelative (int& x, int& y) const throw(); | |||||
| const Point<int> globalPositionToRelative (const Point<int>& screenPosition) const; | |||||
| void relativePositionToOtherComponent (const Component* const targetComponent, | |||||
| int& x, int& y) const throw(); | |||||
| const Point<int> relativePositionToOtherComponent (const Component* const targetComponent, | |||||
| const Point<int>& positionRelativeToThis) const; | |||||
| void setTopLeftPosition (const int x, const int y); | void setTopLeftPosition (const int x, const int y); | ||||
| @@ -12690,7 +12719,7 @@ public: | |||||
| static bool JUCE_CALLTYPE isMouseButtonDownAnywhere() throw(); | static bool JUCE_CALLTYPE isMouseButtonDownAnywhere() throw(); | ||||
| void getMouseXYRelative (int& x, int& y) const throw(); | |||||
| const Point<int> getMouseXYRelative() const; | |||||
| static Component* JUCE_CALLTYPE getComponentUnderMouse() throw(); | static Component* JUCE_CALLTYPE getComponentUnderMouse() throw(); | ||||
| @@ -12834,8 +12863,7 @@ private: | |||||
| void sendEnablementChangeMessage(); | void sendEnablementChangeMessage(); | ||||
| static void* runModalLoopCallback (void*); | static void* runModalLoopCallback (void*); | ||||
| static void bringModalComponentToFront(); | static void bringModalComponentToFront(); | ||||
| void subtractObscuredRegions (RectangleList& result, | |||||
| const int deltaX, const int deltaY, | |||||
| void subtractObscuredRegions (RectangleList& result, const Point<int>& delta, | |||||
| const Rectangle<int>& clipRect, | const Rectangle<int>& clipRect, | ||||
| const Component* const compToAvoid) const throw(); | const Component* const compToAvoid) const throw(); | ||||
| void clipObscuredRegions (Graphics& g, const Rectangle<int>& clipRect, | void clipObscuredRegions (Graphics& g, const Rectangle<int>& clipRect, | ||||
| @@ -13233,13 +13261,13 @@ public: | |||||
| const Rectangle<int> getMainMonitorArea (const bool clippedToWorkArea = true) const throw(); | const Rectangle<int> getMainMonitorArea (const bool clippedToWorkArea = true) const throw(); | ||||
| const Rectangle<int> getMonitorAreaContaining (int x, int y, const bool clippedToWorkArea = true) const throw(); | |||||
| const Rectangle<int> getMonitorAreaContaining (const Point<int>& position, const bool clippedToWorkArea = true) const throw(); | |||||
| static void getMousePosition (int& x, int& y) throw(); | |||||
| static const Point<int> getMousePosition(); | |||||
| static void setMousePosition (int x, int y) throw(); | |||||
| static void setMousePosition (const Point<int>& newPosition); | |||||
| static void getLastMouseDownPosition (int& x, int& y) throw(); | |||||
| static const Point<int> getLastMouseDownPosition() throw(); | |||||
| static int getMouseButtonClickCounter() throw(); | static int getMouseButtonClickCounter() throw(); | ||||
| @@ -13264,8 +13292,7 @@ public: | |||||
| Component* getComponent (const int index) const throw(); | Component* getComponent (const int index) const throw(); | ||||
| Component* findComponentAt (const int screenX, | |||||
| const int screenY) const; | |||||
| Component* findComponentAt (const Point<int>& screenPosition) const; | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| @@ -13289,7 +13316,8 @@ private: | |||||
| Array <Rectangle<int> > monitorCoordsClipped, monitorCoordsUnclipped; | Array <Rectangle<int> > monitorCoordsClipped, monitorCoordsUnclipped; | ||||
| int lastFakeMouseMoveX, lastFakeMouseMoveY, mouseClickCounter; | |||||
| Point<int> lastFakeMouseMove; | |||||
| int mouseClickCounter; | |||||
| bool mouseMovedSignificantlySincePressed; | bool mouseMovedSignificantlySincePressed; | ||||
| struct RecentMouseDown | struct RecentMouseDown | ||||
| @@ -15893,7 +15921,8 @@ public: | |||||
| private: | private: | ||||
| int millisecondsBeforeTipAppears; | int millisecondsBeforeTipAppears; | ||||
| int mouseX, mouseY, mouseClicks; | |||||
| Point<int> lastMousePos; | |||||
| int mouseClicks; | |||||
| unsigned int lastCompChangeTime, lastHideTime; | unsigned int lastCompChangeTime, lastHideTime; | ||||
| Component* lastComponentUnderMouse; | Component* lastComponentUnderMouse; | ||||
| bool changedCompsSinceShown; | bool changedCompsSinceShown; | ||||
| @@ -18663,7 +18692,7 @@ private: | |||||
| Component* headerComponent; | Component* headerComponent; | ||||
| int totalItems, rowHeight, minimumRowWidth; | int totalItems, rowHeight, minimumRowWidth; | ||||
| int outlineThickness; | int outlineThickness; | ||||
| int lastMouseX, lastMouseY, lastRowSelected; | |||||
| int lastRowSelected; | |||||
| bool mouseMoveSelects, multipleSelection, hasDoneInitialUpdate; | bool mouseMoveSelects, multipleSelection, hasDoneInitialUpdate; | ||||
| SparseSet <int> selected; | SparseSet <int> selected; | ||||
| @@ -22864,7 +22893,7 @@ public: | |||||
| private: | private: | ||||
| ComponentBoundsConstrainer* constrainer; | ComponentBoundsConstrainer* constrainer; | ||||
| int originalX, originalY; | |||||
| Point<int> originalPos; | |||||
| }; | }; | ||||
| #endif // __JUCE_COMPONENTDRAGGER_JUCEHEADER__ | #endif // __JUCE_COMPONENTDRAGGER_JUCEHEADER__ | ||||
| @@ -23800,7 +23829,7 @@ private: | |||||
| ComponentPeer* lastPeer; | ComponentPeer* lastPeer; | ||||
| VoidArray registeredParentComps; | VoidArray registeredParentComps; | ||||
| bool reentrant; | bool reentrant; | ||||
| int lastX, lastY, lastWidth, lastHeight; | |||||
| Rectangle<int> lastBounds; | |||||
| #ifdef JUCE_DEBUG | #ifdef JUCE_DEBUG | ||||
| ScopedPointer <ComponentDeletionWatcher> deletionWatcher; | ScopedPointer <ComponentDeletionWatcher> deletionWatcher; | ||||
| #endif | #endif | ||||
| @@ -26595,10 +26624,10 @@ private: | |||||
| int octaveNumForMiddleC; | int octaveNumForMiddleC; | ||||
| void getKeyPos (int midiNoteNumber, int& x, int& w) const; | void getKeyPos (int midiNoteNumber, int& x, int& w) const; | ||||
| int xyToNote (int x, int y, float& mousePositionVelocity); | |||||
| int remappedXYToNote (int x, int y, float& mousePositionVelocity) const; | |||||
| int xyToNote (const Point<int>& pos, float& mousePositionVelocity); | |||||
| int remappedXYToNote (const Point<int>& pos, float& mousePositionVelocity) const; | |||||
| void resetAnyKeysInUse(); | void resetAnyKeysInUse(); | ||||
| void updateNoteUnderMouse (int x, int y); | |||||
| void updateNoteUnderMouse (const Point<int>& pos); | |||||
| void repaintNote (const int midiNoteNumber); | void repaintNote (const int midiNoteNumber); | ||||
| MidiKeyboardComponent (const MidiKeyboardComponent&); | MidiKeyboardComponent (const MidiKeyboardComponent&); | ||||
| @@ -233,20 +233,14 @@ Button::ButtonState Button::updateState (const MouseEvent* const e) | |||||
| if (isEnabled() && isVisible() && ! isCurrentlyBlockedByAnotherModalComponent()) | if (isEnabled() && isVisible() && ! isCurrentlyBlockedByAnotherModalComponent()) | ||||
| { | { | ||||
| int mx, my; | |||||
| Point<int> mousePos; | |||||
| if (e == 0) | if (e == 0) | ||||
| { | |||||
| getMouseXYRelative (mx, my); | |||||
| } | |||||
| mousePos = getMouseXYRelative(); | |||||
| else | else | ||||
| { | |||||
| const MouseEvent e2 (e->getEventRelativeTo (this)); | |||||
| mx = e2.x; | |||||
| my = e2.y; | |||||
| } | |||||
| mousePos = e->getEventRelativeTo (this).getPosition(); | |||||
| const bool over = reallyContains (mx, my, true); | |||||
| const bool over = reallyContains (mousePos.getX(), mousePos.getY(), true); | |||||
| const bool down = isMouseButtonDown(); | const bool down = isMouseButtonDown(); | ||||
| if ((down && (over || (triggerOnMouseDown && buttonState == buttonDown))) || isKeyDown) | if ((down && (over || (triggerOnMouseDown && buttonState == buttonDown))) || isKeyDown) | ||||
| @@ -802,11 +802,7 @@ void ListBox::mouseMove (const MouseEvent& e) | |||||
| if (mouseMoveSelects) | if (mouseMoveSelects) | ||||
| { | { | ||||
| const MouseEvent e2 (e.getEventRelativeTo (this)); | const MouseEvent e2 (e.getEventRelativeTo (this)); | ||||
| selectRow (getRowContainingPosition (e2.x, e2.y), true); | selectRow (getRowContainingPosition (e2.x, e2.y), true); | ||||
| lastMouseX = e2.x; | |||||
| lastMouseY = e2.y; | |||||
| } | } | ||||
| } | } | ||||
| @@ -898,10 +894,8 @@ Image* ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY) | |||||
| if (rowComp != 0 && isRowSelected (firstRow + i)) | if (rowComp != 0 && isRowSelected (firstRow + i)) | ||||
| { | { | ||||
| int x = 0, y = 0; | |||||
| rowComp->relativePositionToOtherComponent (this, x, y); | |||||
| const Rectangle<int> rowRect (x, y, rowComp->getWidth(), rowComp->getHeight()); | |||||
| const Point<int> pos (rowComp->relativePositionToOtherComponent (this, Point<int>())); | |||||
| const Rectangle<int> rowRect (pos.getX(), pos.getY(), rowComp->getWidth(), rowComp->getHeight()); | |||||
| if (imageArea.isEmpty()) | if (imageArea.isEmpty()) | ||||
| imageArea = rowRect; | imageArea = rowRect; | ||||
| @@ -921,11 +915,10 @@ Image* ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY) | |||||
| if (rowComp != 0 && isRowSelected (firstRow + i)) | if (rowComp != 0 && isRowSelected (firstRow + i)) | ||||
| { | { | ||||
| int x = 0, y = 0; | |||||
| rowComp->relativePositionToOtherComponent (this, x, y); | |||||
| const Point<int> pos (rowComp->relativePositionToOtherComponent (this, Point<int>())); | |||||
| Graphics g (*snapshot); | Graphics g (*snapshot); | ||||
| g.setOrigin (x - imageX, y - imageY); | |||||
| g.setOrigin (pos.getX() - imageX, pos.getY() - imageY); | |||||
| if (g.reduceClipRegion (0, 0, rowComp->getWidth(), rowComp->getHeight())) | if (g.reduceClipRegion (0, 0, rowComp->getWidth(), rowComp->getHeight())) | ||||
| rowComp->paintEntireComponent (g); | rowComp->paintEntireComponent (g); | ||||
| } | } | ||||
| @@ -572,7 +572,7 @@ private: | |||||
| Component* headerComponent; | Component* headerComponent; | ||||
| int totalItems, rowHeight, minimumRowWidth; | int totalItems, rowHeight, minimumRowWidth; | ||||
| int outlineThickness; | int outlineThickness; | ||||
| int lastMouseX, lastMouseY, lastRowSelected; | |||||
| int lastRowSelected; | |||||
| bool mouseMoveSelects, multipleSelection, hasDoneInitialUpdate; | bool mouseMoveSelects, multipleSelection, hasDoneInitialUpdate; | ||||
| SparseSet <int> selected; | SparseSet <int> selected; | ||||
| @@ -1150,34 +1150,32 @@ void Slider::restoreMouseIfHidden() | |||||
| if (style == RotaryHorizontalDrag || style == RotaryVerticalDrag) | if (style == RotaryHorizontalDrag || style == RotaryVerticalDrag) | ||||
| { | { | ||||
| int x, y, downX, downY; | |||||
| Desktop::getMousePosition (x, y); | |||||
| Desktop::getLastMouseDownPosition (downX, downY); | |||||
| Point<int> mousePos (Desktop::getMousePosition()); | |||||
| const Point<int> lastMouseDown (Desktop::getLastMouseDownPosition()); | |||||
| if (style == RotaryHorizontalDrag) | if (style == RotaryHorizontalDrag) | ||||
| { | { | ||||
| const double posDiff = valueToProportionOfLength (pos) - valueToProportionOfLength (valueOnMouseDown); | const double posDiff = valueToProportionOfLength (pos) - valueToProportionOfLength (valueOnMouseDown); | ||||
| x = roundToInt (pixelsForFullDragExtent * posDiff + downX); | |||||
| y = downY; | |||||
| mousePos = Point<int> (roundToInt (pixelsForFullDragExtent * posDiff + lastMouseDown.getX()), | |||||
| lastMouseDown.getY()); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const double posDiff = valueToProportionOfLength (valueOnMouseDown) - valueToProportionOfLength (pos); | const double posDiff = valueToProportionOfLength (valueOnMouseDown) - valueToProportionOfLength (pos); | ||||
| x = downX; | |||||
| y = roundToInt (pixelsForFullDragExtent * posDiff + downY); | |||||
| mousePos = Point<int> (lastMouseDown.getX(), | |||||
| roundToInt (pixelsForFullDragExtent * posDiff + lastMouseDown.getY())); | |||||
| } | } | ||||
| Desktop::setMousePosition (x, y); | |||||
| Desktop::setMousePosition (mousePos); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const int pixelPos = (int) getLinearSliderPos (pos); | const int pixelPos = (int) getLinearSliderPos (pos); | ||||
| int x = isHorizontal() ? pixelPos : (getWidth() / 2); | |||||
| int y = isVertical() ? pixelPos : (getHeight() / 2); | |||||
| const Point<int> pos (isHorizontal() ? pixelPos : (getWidth() / 2), | |||||
| isVertical() ? pixelPos : (getHeight() / 2)); | |||||
| relativePositionToGlobal (x, y); | |||||
| Desktop::setMousePosition (x, y); | |||||
| Desktop::setMousePosition (relativePositionToGlobal (pos)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -797,10 +797,7 @@ void TableHeaderComponent::mouseUp (const MouseEvent& e) | |||||
| const MouseCursor TableHeaderComponent::getMouseCursor() | const MouseCursor TableHeaderComponent::getMouseCursor() | ||||
| { | { | ||||
| int x, y; | |||||
| getMouseXYRelative (x, y); | |||||
| if (columnIdBeingResized != 0 || (getResizeDraggerAt (x) != 0 && ! isMouseButtonDown())) | |||||
| if (columnIdBeingResized != 0 || (getResizeDraggerAt (getMouseXYRelative().getX()) != 0 && ! isMouseButtonDown())) | |||||
| return MouseCursor (MouseCursor::LeftRightResizeCursor); | return MouseCursor (MouseCursor::LeftRightResizeCursor); | ||||
| return Component::getMouseCursor(); | return Component::getMouseCursor(); | ||||
| @@ -229,10 +229,7 @@ public: | |||||
| const String getTooltip() | const String getTooltip() | ||||
| { | { | ||||
| int x, y; | |||||
| getMouseXYRelative (x, y); | |||||
| const int columnId = owner.getHeader()->getColumnIdAtX (x); | |||||
| const int columnId = owner.getHeader()->getColumnIdAtX (getMouseXYRelative().getX()); | |||||
| if (columnId != 0 && owner.getModel() != 0) | if (columnId != 0 && owner.getModel() != 0) | ||||
| return owner.getModel()->getCellTooltip (row, columnId); | return owner.getModel()->getCellTooltip (row, columnId); | ||||
| @@ -2126,8 +2126,7 @@ void TextEditor::focusGained (FocusChangeType) | |||||
| ComponentPeer* const peer = getPeer(); | ComponentPeer* const peer = getPeer(); | ||||
| if (peer != 0 && ! isReadOnly()) | if (peer != 0 && ! isReadOnly()) | ||||
| peer->textInputRequired (getScreenX() - peer->getScreenX(), | |||||
| getScreenY() - peer->getScreenY()); | |||||
| peer->textInputRequired (getScreenPosition() - peer->getScreenPosition()); | |||||
| } | } | ||||
| void TextEditor::focusLost (FocusChangeType) | void TextEditor::focusLost (FocusChangeType) | ||||
| @@ -306,11 +306,8 @@ public: | |||||
| const String getTooltip() | const String getTooltip() | ||||
| { | { | ||||
| int x, y; | |||||
| getMouseXYRelative (x, y); | |||||
| Rectangle<int> pos; | Rectangle<int> pos; | ||||
| TreeViewItem* const item = findItemAt (y, pos); | |||||
| TreeViewItem* const item = findItemAt (getMouseXYRelative().getY(), pos); | |||||
| if (item != 0) | if (item != 0) | ||||
| return item->getTooltip(); | return item->getTooltip(); | ||||
| @@ -557,10 +554,8 @@ TreeViewItem* TreeView::getItemOnRow (int index) const | |||||
| TreeViewItem* TreeView::getItemAt (int y) const throw() | TreeViewItem* TreeView::getItemAt (int y) const throw() | ||||
| { | { | ||||
| TreeViewContentComponent* const tc = (TreeViewContentComponent*) viewport->getViewedComponent(); | TreeViewContentComponent* const tc = (TreeViewContentComponent*) viewport->getViewedComponent(); | ||||
| int x; | |||||
| relativePositionToOtherComponent (tc, x, y); | |||||
| Rectangle<int> pos; | Rectangle<int> pos; | ||||
| return tc->findItemAt (y, pos); | |||||
| return tc->findItemAt (relativePositionToOtherComponent (tc, Point<int> (0, y)).getY(), pos); | |||||
| } | } | ||||
| TreeViewItem* TreeView::findItemFromIdentifierString (const String& identifierString) const | TreeViewItem* TreeView::findItemFromIdentifierString (const String& identifierString) const | ||||
| @@ -53,8 +53,7 @@ static const int customCommandMessage = 0x7fff0001; | |||||
| static const int exitModalStateMessage = 0x7fff0002; | static const int exitModalStateMessage = 0x7fff0002; | ||||
| //============================================================================== | //============================================================================== | ||||
| static int unboundedMouseOffsetX = 0; | |||||
| static int unboundedMouseOffsetY = 0; | |||||
| static Point<int> unboundedMouseOffset; | |||||
| static bool isUnboundedMouseModeOn = false; | static bool isUnboundedMouseModeOn = false; | ||||
| static bool isCursorVisibleUntilOffscreen; | static bool isCursorVisibleUntilOffscreen; | ||||
| @@ -412,8 +411,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) | |||||
| jmax (1, getHeight())); | jmax (1, getHeight())); | ||||
| #endif | #endif | ||||
| int x = 0, y = 0; | |||||
| relativePositionToGlobal (x, y); | |||||
| const Point<int> topLeft (relativePositionToGlobal (Point<int> (0, 0))); | |||||
| bool wasFullscreen = false; | bool wasFullscreen = false; | ||||
| bool wasMinimised = false; | bool wasMinimised = false; | ||||
| @@ -429,7 +427,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) | |||||
| removeFromDesktop(); | removeFromDesktop(); | ||||
| setTopLeftPosition (x, y); | |||||
| setTopLeftPosition (topLeft.getX(), topLeft.getY()); | |||||
| } | } | ||||
| if (parentComponent_ != 0) | if (parentComponent_ != 0) | ||||
| @@ -443,8 +441,8 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) | |||||
| Desktop::getInstance().addDesktopComponent (this); | Desktop::getInstance().addDesktopComponent (this); | ||||
| bounds_.setPosition (x, y); | |||||
| peer->setBounds (x, y, getWidth(), getHeight(), false); | |||||
| bounds_.setPosition (topLeft); | |||||
| peer->setBounds (topLeft.getX(), topLeft.getY(), getWidth(), getHeight(), false); | |||||
| peer->setVisible (isVisible()); | peer->setVisible (isVisible()); | ||||
| @@ -741,57 +739,60 @@ int Component::getParentHeight() const throw() | |||||
| : getParentMonitorArea().getHeight(); | : getParentMonitorArea().getHeight(); | ||||
| } | } | ||||
| int Component::getScreenX() const throw() | |||||
| int Component::getScreenX() const | |||||
| { | { | ||||
| return (parentComponent_ != 0) ? parentComponent_->getScreenX() + getX() | |||||
| : (flags.hasHeavyweightPeerFlag ? getPeer()->getScreenX() | |||||
| : getX()); | |||||
| return getScreenPosition().getX(); | |||||
| } | } | ||||
| int Component::getScreenY() const throw() | |||||
| int Component::getScreenY() const | |||||
| { | { | ||||
| return (parentComponent_ != 0) ? parentComponent_->getScreenY() + getY() | |||||
| : (flags.hasHeavyweightPeerFlag ? getPeer()->getScreenY() | |||||
| : getY()); | |||||
| return getScreenPosition().getY(); | |||||
| } | } | ||||
| void Component::relativePositionToGlobal (int& x, int& y) const throw() | |||||
| const Point<int> Component::getScreenPosition() const | |||||
| { | |||||
| return (parentComponent_ != 0) ? parentComponent_->getScreenPosition() + getPosition() | |||||
| : (flags.hasHeavyweightPeerFlag ? getPeer()->getScreenPosition() | |||||
| : getPosition()); | |||||
| } | |||||
| const Point<int> Component::relativePositionToGlobal (const Point<int>& relativePosition) const | |||||
| { | { | ||||
| const Component* c = this; | const Component* c = this; | ||||
| Point<int> p (relativePosition); | |||||
| do | do | ||||
| { | { | ||||
| if (c->flags.hasHeavyweightPeerFlag) | if (c->flags.hasHeavyweightPeerFlag) | ||||
| { | |||||
| c->getPeer()->relativePositionToGlobal (x, y); | |||||
| break; | |||||
| } | |||||
| return c->getPeer()->relativePositionToGlobal (p); | |||||
| x += c->getX(); | |||||
| y += c->getY(); | |||||
| p += c->getPosition(); | |||||
| c = c->parentComponent_; | c = c->parentComponent_; | ||||
| } | } | ||||
| while (c != 0); | while (c != 0); | ||||
| return p; | |||||
| } | } | ||||
| void Component::globalPositionToRelative (int& x, int& y) const throw() | |||||
| const Point<int> Component::globalPositionToRelative (const Point<int>& screenPosition) const | |||||
| { | { | ||||
| if (flags.hasHeavyweightPeerFlag) | if (flags.hasHeavyweightPeerFlag) | ||||
| { | { | ||||
| getPeer()->globalPositionToRelative (x, y); | |||||
| return getPeer()->globalPositionToRelative (screenPosition); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if (parentComponent_ != 0) | if (parentComponent_ != 0) | ||||
| parentComponent_->globalPositionToRelative (x, y); | |||||
| return parentComponent_->globalPositionToRelative (screenPosition) - getPosition(); | |||||
| x -= getX(); | |||||
| y -= getY(); | |||||
| return screenPosition - getPosition(); | |||||
| } | } | ||||
| } | } | ||||
| void Component::relativePositionToOtherComponent (const Component* const targetComponent, int& x, int& y) const throw() | |||||
| const Point<int> Component::relativePositionToOtherComponent (const Component* const targetComponent, const Point<int>& positionRelativeToThis) const | |||||
| { | { | ||||
| Point<int> p (positionRelativeToThis); | |||||
| if (targetComponent != 0) | if (targetComponent != 0) | ||||
| { | { | ||||
| const Component* c = this; | const Component* c = this; | ||||
| @@ -799,22 +800,23 @@ void Component::relativePositionToOtherComponent (const Component* const targetC | |||||
| do | do | ||||
| { | { | ||||
| if (c == targetComponent) | if (c == targetComponent) | ||||
| return; | |||||
| return p; | |||||
| if (c->flags.hasHeavyweightPeerFlag) | if (c->flags.hasHeavyweightPeerFlag) | ||||
| { | { | ||||
| c->getPeer()->relativePositionToGlobal (x, y); | |||||
| p = c->getPeer()->relativePositionToGlobal (p); | |||||
| break; | break; | ||||
| } | } | ||||
| x += c->getX(); | |||||
| y += c->getY(); | |||||
| p += c->getPosition(); | |||||
| c = c->parentComponent_; | c = c->parentComponent_; | ||||
| } | } | ||||
| while (c != 0); | while (c != 0); | ||||
| targetComponent->globalPositionToRelative (x, y); | |||||
| p = targetComponent->globalPositionToRelative (p); | |||||
| } | } | ||||
| return p; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -1546,10 +1548,9 @@ void Component::setMouseCursor (const MouseCursor& cursor) throw() | |||||
| if (flags.visibleFlag) | if (flags.visibleFlag) | ||||
| { | { | ||||
| int mx, my; | |||||
| getMouseXYRelative (mx, my); | |||||
| const Point<int> mousePos (getMouseXYRelative()); | |||||
| if (flags.draggingFlag || reallyContains (mx, my, false)) | |||||
| if (flags.draggingFlag || reallyContains (mousePos.getX(), mousePos.getY(), false)) | |||||
| { | { | ||||
| internalUpdateMouseCursor (false); | internalUpdateMouseCursor (false); | ||||
| } | } | ||||
| @@ -1574,9 +1575,8 @@ void Component::internalUpdateMouseCursor (bool forcedUpdate) throw() | |||||
| { | { | ||||
| MouseCursor mc (getLookAndFeel().getMouseCursorFor (*this)); | MouseCursor mc (getLookAndFeel().getMouseCursorFor (*this)); | ||||
| if (isUnboundedMouseModeOn && (unboundedMouseOffsetX != 0 | |||||
| || unboundedMouseOffsetY != 0 | |||||
| || ! isCursorVisibleUntilOffscreen)) | |||||
| if (isUnboundedMouseModeOn | |||||
| && ((! unboundedMouseOffset.isOrigin()) || ! isCursorVisibleUntilOffscreen)) | |||||
| { | { | ||||
| mc = MouseCursor::NoCursor; | mc = MouseCursor::NoCursor; | ||||
| forcedUpdate = true; | forcedUpdate = true; | ||||
| @@ -1989,22 +1989,18 @@ void Component::getVisibleArea (RectangleList& result, | |||||
| { | { | ||||
| const Component* const c = getTopLevelComponent(); | const Component* const c = getTopLevelComponent(); | ||||
| int x = 0, y = 0; | |||||
| c->relativePositionToOtherComponent (this, x, y); | |||||
| c->subtractObscuredRegions (result, x, y, | |||||
| c->subtractObscuredRegions (result, c->relativePositionToOtherComponent (this, Point<int>()), | |||||
| Rectangle<int> (0, 0, c->getWidth(), c->getHeight()), | Rectangle<int> (0, 0, c->getWidth(), c->getHeight()), | ||||
| this); | this); | ||||
| } | } | ||||
| subtractObscuredRegions (result, 0, 0, unclipped, 0); | |||||
| subtractObscuredRegions (result, Point<int>(), unclipped, 0); | |||||
| result.consolidate(); | result.consolidate(); | ||||
| } | } | ||||
| } | } | ||||
| void Component::subtractObscuredRegions (RectangleList& result, | void Component::subtractObscuredRegions (RectangleList& result, | ||||
| const int deltaX, | |||||
| const int deltaY, | |||||
| const Point<int>& delta, | |||||
| const Rectangle<int>& clipRect, | const Rectangle<int>& clipRect, | ||||
| const Component* const compToAvoid) const throw() | const Component* const compToAvoid) const throw() | ||||
| { | { | ||||
| @@ -2017,7 +2013,7 @@ void Component::subtractObscuredRegions (RectangleList& result, | |||||
| if (c->isOpaque()) | if (c->isOpaque()) | ||||
| { | { | ||||
| Rectangle<int> childBounds (c->bounds_.getIntersection (clipRect)); | Rectangle<int> childBounds (c->bounds_.getIntersection (clipRect)); | ||||
| childBounds.translate (deltaX, deltaY); | |||||
| childBounds.translate (delta.getX(), delta.getY()); | |||||
| result.subtract (childBounds); | result.subtract (childBounds); | ||||
| } | } | ||||
| @@ -2026,11 +2022,8 @@ void Component::subtractObscuredRegions (RectangleList& result, | |||||
| Rectangle<int> newClip (clipRect.getIntersection (c->bounds_)); | Rectangle<int> newClip (clipRect.getIntersection (c->bounds_)); | ||||
| newClip.translate (-c->getX(), -c->getY()); | newClip.translate (-c->getX(), -c->getY()); | ||||
| c->subtractObscuredRegions (result, | |||||
| c->getX() + deltaX, | |||||
| c->getY() + deltaY, | |||||
| newClip, | |||||
| compToAvoid); | |||||
| c->subtractObscuredRegions (result, c->getPosition() + delta, | |||||
| newClip, compToAvoid); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -2253,11 +2246,11 @@ void Component::internalMouseEnter (int x, int y, int64 time) | |||||
| if (flags.repaintOnMouseActivityFlag) | if (flags.repaintOnMouseActivityFlag) | ||||
| repaint(); | repaint(); | ||||
| const MouseEvent me (x, y, | |||||
| const MouseEvent me (Point<int> (x, y), | |||||
| ModifierKeys::getCurrentModifiers(), | ModifierKeys::getCurrentModifiers(), | ||||
| this, | this, | ||||
| Time (time), | Time (time), | ||||
| x, y, | |||||
| Point<int> (x, y), | |||||
| Time (time), | Time (time), | ||||
| 0, false); | 0, false); | ||||
| @@ -2338,11 +2331,11 @@ void Component::internalMouseExit (int x, int y, int64 time) | |||||
| if (flags.repaintOnMouseActivityFlag) | if (flags.repaintOnMouseActivityFlag) | ||||
| repaint(); | repaint(); | ||||
| const MouseEvent me (x, y, | |||||
| const MouseEvent me (Point<int> (x, y), | |||||
| ModifierKeys::getCurrentModifiers(), | ModifierKeys::getCurrentModifiers(), | ||||
| this, | this, | ||||
| Time (time), | Time (time), | ||||
| x, y, | |||||
| Point<int> (x, y), | |||||
| Time (time), | Time (time), | ||||
| 0, false); | 0, false); | ||||
| mouseExit (me); | mouseExit (me); | ||||
| @@ -2409,15 +2402,13 @@ public: | |||||
| if (c != 0 && c->isMouseButtonDown()) | if (c != 0 && c->isMouseButtonDown()) | ||||
| { | { | ||||
| int x, y; | |||||
| c->getMouseXYRelative (x, y); | |||||
| const Point<int> mousePos (c->getMouseXYRelative()); | |||||
| // the offsets have been added on, so must be taken off before calling the | // the offsets have been added on, so must be taken off before calling the | ||||
| // drag.. otherwise they'll be added twice | // drag.. otherwise they'll be added twice | ||||
| x -= unboundedMouseOffsetX; | |||||
| y -= unboundedMouseOffsetY; | |||||
| c->internalMouseDrag (x, y, Time::currentTimeMillis()); | |||||
| c->internalMouseDrag (mousePos.getX() - unboundedMouseOffset.getX(), | |||||
| mousePos.getY() - unboundedMouseOffset.getY(), | |||||
| Time::currentTimeMillis()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2451,9 +2442,7 @@ void Component::internalMouseDown (const int x, const int y, const int64 time) | |||||
| { | { | ||||
| Desktop& desktop = Desktop::getInstance(); | Desktop& desktop = Desktop::getInstance(); | ||||
| int gx = x, gy = y; | |||||
| relativePositionToGlobal (gx, gy); | |||||
| desktop.registerMouseDown (Point<int> (gx, gy), time, this); | |||||
| desktop.registerMouseDown (relativePositionToGlobal (Point<int> (x, y)), time, this); | |||||
| const ComponentDeletionWatcher deletionChecker (this); | const ComponentDeletionWatcher deletionChecker (this); | ||||
| @@ -2469,11 +2458,11 @@ void Component::internalMouseDown (const int x, const int y, const int64 time) | |||||
| if (isCurrentlyBlockedByAnotherModalComponent()) | if (isCurrentlyBlockedByAnotherModalComponent()) | ||||
| { | { | ||||
| // allow blocked mouse-events to go to global listeners.. | // allow blocked mouse-events to go to global listeners.. | ||||
| const MouseEvent me (x, y, | |||||
| const MouseEvent me (Point<int> (x, y), | |||||
| ModifierKeys::getCurrentModifiers(), | ModifierKeys::getCurrentModifiers(), | ||||
| this, | this, | ||||
| Time (time), | Time (time), | ||||
| x, y, | |||||
| Point<int> (x, y), | |||||
| desktop.getLastMouseDownTime(), | desktop.getLastMouseDownTime(), | ||||
| desktop.getNumberOfMultipleClicks(), | desktop.getNumberOfMultipleClicks(), | ||||
| false); | false); | ||||
| @@ -2522,11 +2511,11 @@ void Component::internalMouseDown (const int x, const int y, const int64 time) | |||||
| if (flags.repaintOnMouseActivityFlag) | if (flags.repaintOnMouseActivityFlag) | ||||
| repaint(); | repaint(); | ||||
| const MouseEvent me (x, y, | |||||
| const MouseEvent me (Point<int> (x, y), | |||||
| ModifierKeys::getCurrentModifiers(), | ModifierKeys::getCurrentModifiers(), | ||||
| this, | this, | ||||
| desktop.getLastMouseDownTime(), | desktop.getLastMouseDownTime(), | ||||
| x, y, | |||||
| Point<int> (x, y), | |||||
| desktop.getLastMouseDownTime(), | desktop.getLastMouseDownTime(), | ||||
| desktop.getNumberOfMultipleClicks(), | desktop.getNumberOfMultipleClicks(), | ||||
| false); | false); | ||||
| @@ -2591,29 +2580,24 @@ void Component::internalMouseUp (const int oldModifiers, int x, int y, const int | |||||
| flags.draggingFlag = false; | flags.draggingFlag = false; | ||||
| deleteAndZero (dragRepeater); | deleteAndZero (dragRepeater); | ||||
| x += unboundedMouseOffsetX; | |||||
| y += unboundedMouseOffsetY; | |||||
| x += unboundedMouseOffset.getX(); | |||||
| y += unboundedMouseOffset.getY(); | |||||
| int gx = x, gy = y; | |||||
| relativePositionToGlobal (gx, gy); | |||||
| desktop.registerMouseDrag (Point<int> (gx, gy)); | |||||
| desktop.registerMouseDrag (relativePositionToGlobal (Point<int> (x, y))); | |||||
| const ComponentDeletionWatcher deletionChecker (this); | const ComponentDeletionWatcher deletionChecker (this); | ||||
| if (flags.repaintOnMouseActivityFlag) | if (flags.repaintOnMouseActivityFlag) | ||||
| repaint(); | repaint(); | ||||
| int mdx, mdy; | |||||
| Desktop::getLastMouseDownPosition (mdx, mdy); | |||||
| globalPositionToRelative (mdx, mdy); | |||||
| const Point<int> mouseDownPos (globalPositionToRelative (Desktop::getLastMouseDownPosition())); | |||||
| const Time lastMouseDownTime (desktop.getLastMouseDownTime()); | const Time lastMouseDownTime (desktop.getLastMouseDownTime()); | ||||
| const MouseEvent me (x, y, | |||||
| const MouseEvent me (Point<int> (x, y), | |||||
| oldModifiers, | oldModifiers, | ||||
| this, | this, | ||||
| Time (time), | Time (time), | ||||
| mdx, mdy, | |||||
| mouseDownPos, | |||||
| lastMouseDownTime, | lastMouseDownTime, | ||||
| desktop.getNumberOfMultipleClicks(), | desktop.getNumberOfMultipleClicks(), | ||||
| desktop.mouseMovedSignificantlySincePressed | desktop.mouseMovedSignificantlySincePressed | ||||
| @@ -2733,26 +2717,21 @@ void Component::internalMouseDrag (int x, int y, const int64 time) | |||||
| flags.mouseOverFlag = reallyContains (x, y, false); | flags.mouseOverFlag = reallyContains (x, y, false); | ||||
| x += unboundedMouseOffsetX; | |||||
| y += unboundedMouseOffsetY; | |||||
| x += unboundedMouseOffset.getX(); | |||||
| y += unboundedMouseOffset.getY(); | |||||
| int gx = x, gy = y; | |||||
| relativePositionToGlobal (gx, gy); | |||||
| desktop.registerMouseDrag (Point<int> (gx, gy)); | |||||
| desktop.registerMouseDrag (relativePositionToGlobal (Point<int> (x, y))); | |||||
| const ComponentDeletionWatcher deletionChecker (this); | const ComponentDeletionWatcher deletionChecker (this); | ||||
| int mdx, mdy; | |||||
| Desktop::getLastMouseDownPosition (mdx, mdy); | |||||
| globalPositionToRelative (mdx, mdy); | |||||
| const Point<int> mouseDownPos (globalPositionToRelative (Desktop::getLastMouseDownPosition())); | |||||
| const Time lastMouseDownTime (desktop.getLastMouseDownTime()); | const Time lastMouseDownTime (desktop.getLastMouseDownTime()); | ||||
| const MouseEvent me (x, y, | |||||
| const MouseEvent me (Point<int> (x, y), | |||||
| ModifierKeys::getCurrentModifiers(), | ModifierKeys::getCurrentModifiers(), | ||||
| this, | this, | ||||
| Time (time), | Time (time), | ||||
| mdx, mdy, | |||||
| mouseDownPos, | |||||
| lastMouseDownTime, | lastMouseDownTime, | ||||
| desktop.getNumberOfMultipleClicks(), | desktop.getNumberOfMultipleClicks(), | ||||
| desktop.mouseMovedSignificantlySincePressed | desktop.mouseMovedSignificantlySincePressed | ||||
| @@ -2812,37 +2791,30 @@ void Component::internalMouseDrag (int x, int y, const int64 time) | |||||
| if (isUnboundedMouseModeOn) | if (isUnboundedMouseModeOn) | ||||
| { | { | ||||
| Rectangle<int> screenArea (getParentMonitorArea().expanded (-2, -2)); | Rectangle<int> screenArea (getParentMonitorArea().expanded (-2, -2)); | ||||
| Point<int> mousePos (Desktop::getMousePosition()); | |||||
| int mx, my; | |||||
| Desktop::getMousePosition (mx, my); | |||||
| if (! screenArea.contains (mx, my)) | |||||
| if (! screenArea.contains (mousePos)) | |||||
| { | { | ||||
| int deltaX = 0, deltaY = 0; | int deltaX = 0, deltaY = 0; | ||||
| if (mx <= screenArea.getX() || mx >= screenArea.getRight()) | |||||
| deltaX = getScreenX() + getWidth() / 2 - mx; | |||||
| if (mousePos.getX() <= screenArea.getX() || mousePos.getX() >= screenArea.getRight()) | |||||
| deltaX = getScreenX() + getWidth() / 2 - mousePos.getX(); | |||||
| if (my <= screenArea.getY() || my >= screenArea.getBottom()) | |||||
| deltaY = getScreenY() + getHeight() / 2 - my; | |||||
| if (mousePos.getY() <= screenArea.getY() || mousePos.getY() >= screenArea.getBottom()) | |||||
| deltaY = getScreenY() + getHeight() / 2 - mousePos.getY(); | |||||
| unboundedMouseOffsetX -= deltaX; | |||||
| unboundedMouseOffsetY -= deltaY; | |||||
| unboundedMouseOffset -= Point<int> (deltaX, deltaY); | |||||
| Desktop::setMousePosition (mx + deltaX, | |||||
| my + deltaY); | |||||
| Desktop::setMousePosition (mousePos + Point<int> (deltaX, deltaY)); | |||||
| } | } | ||||
| else if (isCursorVisibleUntilOffscreen | else if (isCursorVisibleUntilOffscreen | ||||
| && (unboundedMouseOffsetX != 0 || unboundedMouseOffsetY != 0) | |||||
| && screenArea.contains (mx + unboundedMouseOffsetX, | |||||
| my + unboundedMouseOffsetY)) | |||||
| && (! unboundedMouseOffset.isOrigin()) | |||||
| && screenArea.contains (mousePos + unboundedMouseOffset)) | |||||
| { | { | ||||
| mx += unboundedMouseOffsetX; | |||||
| my += unboundedMouseOffsetY; | |||||
| unboundedMouseOffsetX = 0; | |||||
| unboundedMouseOffsetY = 0; | |||||
| mousePos += unboundedMouseOffset; | |||||
| unboundedMouseOffset = Point<int>(); | |||||
| Desktop::setMousePosition (mx, my); | |||||
| Desktop::setMousePosition (mousePos); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2859,11 +2831,11 @@ void Component::internalMouseMove (const int x, const int y, const int64 time) | |||||
| { | { | ||||
| Desktop& desktop = Desktop::getInstance(); | Desktop& desktop = Desktop::getInstance(); | ||||
| const MouseEvent me (x, y, | |||||
| const MouseEvent me (Point<int> (x, y), | |||||
| ModifierKeys::getCurrentModifiers(), | ModifierKeys::getCurrentModifiers(), | ||||
| this, | this, | ||||
| Time (time), | Time (time), | ||||
| x, y, | |||||
| Point<int> (x, y), | |||||
| Time (time), | Time (time), | ||||
| 0, false); | 0, false); | ||||
| @@ -2939,14 +2911,13 @@ void Component::internalMouseWheel (const int intAmountX, const int intAmountY, | |||||
| const float wheelIncrementX = intAmountX * (1.0f / 256.0f); | const float wheelIncrementX = intAmountX * (1.0f / 256.0f); | ||||
| const float wheelIncrementY = intAmountY * (1.0f / 256.0f); | const float wheelIncrementY = intAmountY * (1.0f / 256.0f); | ||||
| int mx, my; | |||||
| getMouseXYRelative (mx, my); | |||||
| const Point<int> mousePos (getMouseXYRelative()); | |||||
| const MouseEvent me (mx, my, | |||||
| const MouseEvent me (mousePos, | |||||
| ModifierKeys::getCurrentModifiers(), | ModifierKeys::getCurrentModifiers(), | ||||
| this, | this, | ||||
| Time (time), | Time (time), | ||||
| mx, my, | |||||
| mousePos, | |||||
| Time (time), | Time (time), | ||||
| 0, false); | 0, false); | ||||
| @@ -3403,13 +3374,9 @@ bool JUCE_CALLTYPE Component::isMouseButtonDownAnywhere() throw() | |||||
| return ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown(); | return ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown(); | ||||
| } | } | ||||
| void Component::getMouseXYRelative (int& mx, int& my) const throw() | |||||
| const Point<int> Component::getMouseXYRelative() const | |||||
| { | { | ||||
| Desktop::getMousePosition (mx, my); | |||||
| globalPositionToRelative (mx, my); | |||||
| mx += unboundedMouseOffsetX; | |||||
| my += unboundedMouseOffsetY; | |||||
| return globalPositionToRelative (Desktop::getMousePosition()) + unboundedMouseOffset; | |||||
| } | } | ||||
| void Component::enableUnboundedMouseMovement (bool enable, | void Component::enableUnboundedMouseMovement (bool enable, | ||||
| @@ -3421,25 +3388,15 @@ void Component::enableUnboundedMouseMovement (bool enable, | |||||
| if (enable != isUnboundedMouseModeOn) | if (enable != isUnboundedMouseModeOn) | ||||
| { | { | ||||
| if ((! enable) && ((! isCursorVisibleUntilOffscreen) | if ((! enable) && ((! isCursorVisibleUntilOffscreen) | ||||
| || unboundedMouseOffsetX != 0 | |||||
| || unboundedMouseOffsetY != 0)) | |||||
| || ! unboundedMouseOffset.isOrigin())) | |||||
| { | { | ||||
| // when released, return the mouse to within the component's bounds | // when released, return the mouse to within the component's bounds | ||||
| int mx, my; | |||||
| getMouseXYRelative (mx, my); | |||||
| mx = jlimit (0, getWidth(), mx); | |||||
| my = jlimit (0, getHeight(), my); | |||||
| relativePositionToGlobal (mx, my); | |||||
| Desktop::setMousePosition (mx, my); | |||||
| Desktop::setMousePosition (relativePositionToGlobal (Rectangle<int> (0, 0, getWidth(), getHeight()) | |||||
| .getConstrainedPoint (getMouseXYRelative()))); | |||||
| } | } | ||||
| isUnboundedMouseModeOn = enable; | isUnboundedMouseModeOn = enable; | ||||
| unboundedMouseOffsetX = 0; | |||||
| unboundedMouseOffsetY = 0; | |||||
| unboundedMouseOffset = Point<int>(); | |||||
| internalUpdateMouseCursor (true); | internalUpdateMouseCursor (true); | ||||
| } | } | ||||
| @@ -3453,11 +3410,9 @@ Component* JUCE_CALLTYPE Component::getComponentUnderMouse() throw() | |||||
| //============================================================================== | //============================================================================== | ||||
| const Rectangle<int> Component::getParentMonitorArea() const throw() | const Rectangle<int> Component::getParentMonitorArea() const throw() | ||||
| { | { | ||||
| int centreX = getWidth() / 2; | |||||
| int centreY = getHeight() / 2; | |||||
| relativePositionToGlobal (centreX, centreY); | |||||
| return Desktop::getInstance().getMonitorAreaContaining (centreX, centreY); | |||||
| return Desktop::getInstance() | |||||
| .getMonitorAreaContaining (relativePositionToGlobal (Point<int> (getWidth() / 2, | |||||
| getHeight() / 2))); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -343,33 +343,37 @@ public: | |||||
| @see getX, relativePositionToGlobal | @see getX, relativePositionToGlobal | ||||
| */ | */ | ||||
| int getScreenX() const throw(); | |||||
| int getScreenX() const; | |||||
| /** Returns this component's y co-ordinate relative the the screen's top-left origin. | /** Returns this component's y co-ordinate relative the the screen's top-left origin. | ||||
| @see getY, relativePositionToGlobal | @see getY, relativePositionToGlobal | ||||
| */ | */ | ||||
| int getScreenY() const throw(); | |||||
| int getScreenY() const; | |||||
| /** Returns the position of this component's top-left corner relative to the screen's top-left. | |||||
| */ | |||||
| const Point<int> getScreenPosition() const; | |||||
| /** Converts a position relative to this component's top-left into a screen co-ordinate. | /** Converts a position relative to this component's top-left into a screen co-ordinate. | ||||
| @see globalPositionToRelative, relativePositionToOtherComponent | @see globalPositionToRelative, relativePositionToOtherComponent | ||||
| */ | */ | ||||
| void relativePositionToGlobal (int& x, int& y) const throw(); | |||||
| const Point<int> relativePositionToGlobal (const Point<int>& relativePosition) const; | |||||
| /** Converts a screen co-ordinate into a position relative to this component's top-left. | /** Converts a screen co-ordinate into a position relative to this component's top-left. | ||||
| @see relativePositionToGlobal, relativePositionToOtherComponent | @see relativePositionToGlobal, relativePositionToOtherComponent | ||||
| */ | */ | ||||
| void globalPositionToRelative (int& x, int& y) const throw(); | |||||
| const Point<int> globalPositionToRelative (const Point<int>& screenPosition) const; | |||||
| /** Converts a position relative to this component's top-left into a position | /** Converts a position relative to this component's top-left into a position | ||||
| relative to another component's top-left. | relative to another component's top-left. | ||||
| @see relativePositionToGlobal, globalPositionToRelative | @see relativePositionToGlobal, globalPositionToRelative | ||||
| */ | */ | ||||
| void relativePositionToOtherComponent (const Component* const targetComponent, | |||||
| int& x, int& y) const throw(); | |||||
| const Point<int> relativePositionToOtherComponent (const Component* const targetComponent, | |||||
| const Point<int>& positionRelativeToThis) const; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Moves the component to a new position. | /** Moves the component to a new position. | ||||
| @@ -1578,7 +1582,7 @@ public: | |||||
| The co-ordinates are relative to the component's top-left corner. | The co-ordinates are relative to the component's top-left corner. | ||||
| */ | */ | ||||
| void getMouseXYRelative (int& x, int& y) const throw(); | |||||
| const Point<int> getMouseXYRelative() const; | |||||
| /** Returns the component that's currently underneath the mouse. | /** Returns the component that's currently underneath the mouse. | ||||
| @@ -1979,8 +1983,7 @@ private: | |||||
| void sendEnablementChangeMessage(); | void sendEnablementChangeMessage(); | ||||
| static void* runModalLoopCallback (void*); | static void* runModalLoopCallback (void*); | ||||
| static void bringModalComponentToFront(); | static void bringModalComponentToFront(); | ||||
| void subtractObscuredRegions (RectangleList& result, | |||||
| const int deltaX, const int deltaY, | |||||
| void subtractObscuredRegions (RectangleList& result, const Point<int>& delta, | |||||
| const Rectangle<int>& clipRect, | const Rectangle<int>& clipRect, | ||||
| const Component* const compToAvoid) const throw(); | const Component* const compToAvoid) const throw(); | ||||
| void clipObscuredRegions (Graphics& g, const Rectangle<int>& clipRect, | void clipObscuredRegions (Graphics& g, const Rectangle<int>& clipRect, | ||||
| @@ -34,9 +34,7 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| Desktop::Desktop() throw() | Desktop::Desktop() throw() | ||||
| : lastFakeMouseMoveX (0), | |||||
| lastFakeMouseMoveY (0), | |||||
| mouseClickCounter (0), | |||||
| : mouseClickCounter (0), | |||||
| mouseMovedSignificantlySincePressed (false), | mouseMovedSignificantlySincePressed (false), | ||||
| kioskModeComponent (0) | kioskModeComponent (0) | ||||
| { | { | ||||
| @@ -118,7 +116,7 @@ const Rectangle<int> Desktop::getMainMonitorArea (const bool clippedToWorkArea) | |||||
| return getDisplayMonitorCoordinates (0, clippedToWorkArea); | return getDisplayMonitorCoordinates (0, clippedToWorkArea); | ||||
| } | } | ||||
| const Rectangle<int> Desktop::getMonitorAreaContaining (int cx, int cy, const bool clippedToWorkArea) const throw() | |||||
| const Rectangle<int> Desktop::getMonitorAreaContaining (const Point<int>& position, const bool clippedToWorkArea) const throw() | |||||
| { | { | ||||
| Rectangle<int> best (getMainMonitorArea (clippedToWorkArea)); | Rectangle<int> best (getMainMonitorArea (clippedToWorkArea)); | ||||
| double bestDistance = 1.0e10; | double bestDistance = 1.0e10; | ||||
| @@ -127,11 +125,10 @@ const Rectangle<int> Desktop::getMonitorAreaContaining (int cx, int cy, const bo | |||||
| { | { | ||||
| const Rectangle<int> rect (getDisplayMonitorCoordinates (i, clippedToWorkArea)); | const Rectangle<int> rect (getDisplayMonitorCoordinates (i, clippedToWorkArea)); | ||||
| if (rect.contains (cx, cy)) | |||||
| if (rect.contains (position)) | |||||
| return rect; | return rect; | ||||
| const double distance = juce_hypot ((double) (rect.getCentreX() - cx), | |||||
| (double) (rect.getCentreY() - cy)); | |||||
| const double distance = rect.getCentre().getDistanceFrom (position); | |||||
| if (distance < bestDistance) | if (distance < bestDistance) | ||||
| { | { | ||||
| @@ -154,18 +151,15 @@ Component* Desktop::getComponent (const int index) const throw() | |||||
| return desktopComponents [index]; | return desktopComponents [index]; | ||||
| } | } | ||||
| Component* Desktop::findComponentAt (const int screenX, | |||||
| const int screenY) const | |||||
| Component* Desktop::findComponentAt (const Point<int>& screenPosition) const | |||||
| { | { | ||||
| for (int i = desktopComponents.size(); --i >= 0;) | for (int i = desktopComponents.size(); --i >= 0;) | ||||
| { | { | ||||
| Component* const c = desktopComponents.getUnchecked(i); | Component* const c = desktopComponents.getUnchecked(i); | ||||
| const Point<int> relative (c->globalPositionToRelative (screenPosition)); | |||||
| int x = screenX, y = screenY; | |||||
| c->globalPositionToRelative (x, y); | |||||
| if (c->contains (x, y)) | |||||
| return c->getComponentAt (x, y); | |||||
| if (c->contains (relative.getX(), relative.getY())) | |||||
| return c->getComponentAt (relative.getX(), relative.getY()); | |||||
| } | } | ||||
| return 0; | return 0; | ||||
| @@ -208,11 +202,9 @@ void Desktop::componentBroughtToFront (Component* const c) throw() | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| void Desktop::getLastMouseDownPosition (int& x, int& y) throw() | |||||
| const Point<int> Desktop::getLastMouseDownPosition() throw() | |||||
| { | { | ||||
| const Desktop& d = getInstance(); | |||||
| x = d.mouseDowns[0].position.getX(); | |||||
| y = d.mouseDowns[0].position.getY(); | |||||
| return getInstance().mouseDowns[0].position; | |||||
| } | } | ||||
| int Desktop::getMouseButtonClickCounter() throw() | int Desktop::getMouseButtonClickCounter() throw() | ||||
| @@ -327,10 +319,7 @@ void Desktop::handleAsyncUpdate() | |||||
| //============================================================================== | //============================================================================== | ||||
| void Desktop::timerCallback() | void Desktop::timerCallback() | ||||
| { | { | ||||
| int x, y; | |||||
| getMousePosition (x, y); | |||||
| if (lastFakeMouseMoveX != x || lastFakeMouseMoveY != y) | |||||
| if (lastFakeMouseMove != getMousePosition()) | |||||
| sendMouseMove(); | sendMouseMove(); | ||||
| } | } | ||||
| @@ -340,26 +329,18 @@ void Desktop::sendMouseMove() | |||||
| { | { | ||||
| startTimer (20); | startTimer (20); | ||||
| int x, y; | |||||
| getMousePosition (x, y); | |||||
| lastFakeMouseMoveX = x; | |||||
| lastFakeMouseMoveY = y; | |||||
| lastFakeMouseMove = getMousePosition(); | |||||
| Component* const target = findComponentAt (x, y); | |||||
| Component* const target = findComponentAt (lastFakeMouseMove); | |||||
| if (target != 0) | if (target != 0) | ||||
| { | { | ||||
| target->globalPositionToRelative (x, y); | |||||
| ComponentDeletionWatcher deletionChecker (target); | ComponentDeletionWatcher deletionChecker (target); | ||||
| const Point<int> pos (target->globalPositionToRelative (lastFakeMouseMove)); | |||||
| const Time now (Time::getCurrentTime()); | |||||
| const MouseEvent me (x, y, | |||||
| ModifierKeys::getCurrentModifiers(), | |||||
| target, | |||||
| Time::getCurrentTime(), | |||||
| x, y, | |||||
| Time::getCurrentTime(), | |||||
| 0, false); | |||||
| const MouseEvent me (pos, ModifierKeys::getCurrentModifiers(), | |||||
| target, now, pos, now, 0, false); | |||||
| for (int i = mouseListeners.size(); --i >= 0;) | for (int i = mouseListeners.size(); --i >= 0;) | ||||
| { | { | ||||
| @@ -384,7 +365,7 @@ void Desktop::resetTimer() throw() | |||||
| else | else | ||||
| startTimer (100); | startTimer (100); | ||||
| getMousePosition (lastFakeMouseMoveX, lastFakeMouseMoveY); | |||||
| lastFakeMouseMove = getMousePosition(); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -91,7 +91,7 @@ public: | |||||
| If clippedToWorkArea is true, it will exclude any areas like the taskbar on Windows, | If clippedToWorkArea is true, it will exclude any areas like the taskbar on Windows, | ||||
| or the menu bar on Mac. If clippedToWorkArea is false, the entire monitor area is returned. | or the menu bar on Mac. If clippedToWorkArea is false, the entire monitor area is returned. | ||||
| */ | */ | ||||
| const Rectangle<int> getMonitorAreaContaining (int x, int y, const bool clippedToWorkArea = true) const throw(); | |||||
| const Rectangle<int> getMonitorAreaContaining (const Point<int>& position, const bool clippedToWorkArea = true) const throw(); | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -99,17 +99,17 @@ public: | |||||
| The co-ordinates are relative to the top-left of the main monitor. | The co-ordinates are relative to the top-left of the main monitor. | ||||
| */ | */ | ||||
| static void getMousePosition (int& x, int& y) throw(); | |||||
| static const Point<int> getMousePosition(); | |||||
| /** Makes the mouse pointer jump to a given location. | /** Makes the mouse pointer jump to a given location. | ||||
| The co-ordinates are relative to the top-left of the main monitor. | The co-ordinates are relative to the top-left of the main monitor. | ||||
| */ | */ | ||||
| static void setMousePosition (int x, int y) throw(); | |||||
| static void setMousePosition (const Point<int>& newPosition); | |||||
| /** Returns the last position at which a mouse button was pressed. | /** Returns the last position at which a mouse button was pressed. | ||||
| */ | */ | ||||
| static void getLastMouseDownPosition (int& x, int& y) throw(); | |||||
| static const Point<int> getLastMouseDownPosition() throw(); | |||||
| /** Returns the number of times the mouse button has been clicked since the | /** Returns the number of times the mouse button has been clicked since the | ||||
| app started. | app started. | ||||
| @@ -218,8 +218,7 @@ public: | |||||
| Returns 0 if the co-ordinates are inside a non-Juce window. | Returns 0 if the co-ordinates are inside a non-Juce window. | ||||
| */ | */ | ||||
| Component* findComponentAt (const int screenX, | |||||
| const int screenY) const; | |||||
| Component* findComponentAt (const Point<int>& screenPosition) const; | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -251,7 +250,8 @@ private: | |||||
| Array <Rectangle<int> > monitorCoordsClipped, monitorCoordsUnclipped; | Array <Rectangle<int> > monitorCoordsClipped, monitorCoordsUnclipped; | ||||
| int lastFakeMouseMoveX, lastFakeMouseMoveY, mouseClickCounter; | |||||
| Point<int> lastFakeMouseMove; | |||||
| int mouseClickCounter; | |||||
| bool mouseMovedSignificantlySincePressed; | bool mouseMovedSignificantlySincePressed; | ||||
| struct RecentMouseDown | struct RecentMouseDown | ||||
| @@ -153,8 +153,7 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* const compone | |||||
| if (peer != 0) | if (peer != 0) | ||||
| border = peer->getFrameSize(); | border = peer->getFrameSize(); | ||||
| limits = Desktop::getInstance().getMonitorAreaContaining (bounds.getCentreX(), | |||||
| bounds.getCentreY()); | |||||
| limits = Desktop::getInstance().getMonitorAreaContaining (bounds.getCentre()); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -98,17 +98,14 @@ void ComponentMovementWatcher::componentMovedOrResized (Component&, bool wasMove | |||||
| if (wasMoved) | if (wasMoved) | ||||
| { | { | ||||
| int x = 0, y = 0; | |||||
| component->relativePositionToOtherComponent (component->getTopLevelComponent(), x, y); | |||||
| const Point<int> pos (component->relativePositionToOtherComponent (component->getTopLevelComponent(), Point<int>())); | |||||
| wasMoved = (lastX != x || lastY != y); | |||||
| lastX = x; | |||||
| lastY = y; | |||||
| wasMoved = lastBounds.getPosition() != pos; | |||||
| lastBounds.setPosition (pos); | |||||
| } | } | ||||
| wasResized = (lastWidth != component->getWidth() || lastHeight != component->getHeight()); | |||||
| lastWidth = component->getWidth(); | |||||
| lastHeight = component->getHeight(); | |||||
| wasResized = (lastBounds.getWidth() != component->getWidth() || lastBounds.getHeight() != component->getHeight()); | |||||
| lastBounds.setSize (component->getWidth(), component->getHeight()); | |||||
| if (wasMoved || wasResized) | if (wasMoved || wasResized) | ||||
| componentMovedOrResized (wasMoved, wasResized); | componentMovedOrResized (wasMoved, wasResized); | ||||
| @@ -81,7 +81,7 @@ private: | |||||
| ComponentPeer* lastPeer; | ComponentPeer* lastPeer; | ||||
| VoidArray registeredParentComps; | VoidArray registeredParentComps; | ||||
| bool reentrant; | bool reentrant; | ||||
| int lastX, lastY, lastWidth, lastHeight; | |||||
| Rectangle<int> lastBounds; | |||||
| #ifdef JUCE_DEBUG | #ifdef JUCE_DEBUG | ||||
| ScopedPointer <ComponentDeletionWatcher> deletionWatcher; | ScopedPointer <ComponentDeletionWatcher> deletionWatcher; | ||||
| #endif | #endif | ||||
| @@ -279,9 +279,8 @@ void MenuBarComponent::showMenu (int index) | |||||
| if (prevCompDeletionChecker != 0 && ! prevCompDeletionChecker->hasBeenDeleted()) | if (prevCompDeletionChecker != 0 && ! prevCompDeletionChecker->hasBeenDeleted()) | ||||
| prevFocused->grabKeyboardFocus(); | prevFocused->grabKeyboardFocus(); | ||||
| int mx, my; | |||||
| getMouseXYRelative (mx, my); | |||||
| updateItemUnderMouse (mx, my); | |||||
| const Point<int> mousePos (getMouseXYRelative()); | |||||
| updateItemUnderMouse (mousePos.getX(), mousePos.getY()); | |||||
| repaint(); | repaint(); | ||||
| if (result != 0) | if (result != 0) | ||||
| @@ -320,10 +319,9 @@ void MenuBarComponent::mouseExit (const MouseEvent& e) | |||||
| void MenuBarComponent::mouseDown (const MouseEvent& e) | void MenuBarComponent::mouseDown (const MouseEvent& e) | ||||
| { | { | ||||
| const MouseEvent e2 (e.getEventRelativeTo (this)); | |||||
| if (currentPopupIndex < 0) | if (currentPopupIndex < 0) | ||||
| { | { | ||||
| const MouseEvent e2 (e.getEventRelativeTo (this)); | |||||
| updateItemUnderMouse (e2.x, e2.y); | updateItemUnderMouse (e2.x, e2.y); | ||||
| currentPopupIndex = -2; | currentPopupIndex = -2; | ||||
| @@ -440,9 +438,8 @@ void MenuBarComponent::timerCallback() | |||||
| { | { | ||||
| stopTimer(); | stopTimer(); | ||||
| int mx, my; | |||||
| getMouseXYRelative (mx, my); | |||||
| updateItemUnderMouse (mx, my); | |||||
| const Point<int> mousePos (getMouseXYRelative()); | |||||
| updateItemUnderMouse (mousePos.getX(), mousePos.getY()); | |||||
| } | } | ||||
| @@ -271,8 +271,6 @@ public: | |||||
| menuBarComponent (0), | menuBarComponent (0), | ||||
| managerOfChosenCommand (0), | managerOfChosenCommand (0), | ||||
| componentAttachedTo (0), | componentAttachedTo (0), | ||||
| lastMouseX (0), | |||||
| lastMouseY (0), | |||||
| minimumWidth (0), | minimumWidth (0), | ||||
| maximumNumColumns (7), | maximumNumColumns (7), | ||||
| standardItemHeight (0), | standardItemHeight (0), | ||||
| @@ -492,7 +490,7 @@ public: | |||||
| void mouseWheelMove (const MouseEvent&, float /*amountX*/, float amountY) | void mouseWheelMove (const MouseEvent&, float /*amountX*/, float amountY) | ||||
| { | { | ||||
| alterChildYPos (roundToInt (-10.0f * amountY * PopupMenuSettings::scrollZone)); | alterChildYPos (roundToInt (-10.0f * amountY * PopupMenuSettings::scrollZone)); | ||||
| lastMouseX = -1; | |||||
| lastMouse = Point<int> (-1, -1); | |||||
| } | } | ||||
| bool keyPressed (const KeyPress& key) | bool keyPressed (const KeyPress& key) | ||||
| @@ -572,10 +570,9 @@ public: | |||||
| // as they'll expect the menu to go away, and in fact it'll just | // as they'll expect the menu to go away, and in fact it'll just | ||||
| // come back. So only dismiss synchronously if they're not on the original | // come back. So only dismiss synchronously if they're not on the original | ||||
| // comp that we're attached to. | // comp that we're attached to. | ||||
| int mx, my; | |||||
| componentAttachedTo->getMouseXYRelative (mx, my); | |||||
| const Point<int> mousePos (componentAttachedTo->getMouseXYRelative()); | |||||
| if (componentAttachedTo->reallyContains (mx, my, true)) | |||||
| if (componentAttachedTo->reallyContains (mousePos.getX(), mousePos.getY(), true)) | |||||
| { | { | ||||
| postCommandMessage (PopupMenuSettings::dismissCommandId); // dismiss asynchrounously | postCommandMessage (PopupMenuSettings::dismissCommandId); // dismiss asynchrounously | ||||
| return; | return; | ||||
| @@ -614,16 +611,13 @@ public: | |||||
| startTimer (PopupMenuSettings::timerInterval); // do this in case it was called from a mouse | startTimer (PopupMenuSettings::timerInterval); // do this in case it was called from a mouse | ||||
| // move rather than a real timer callback | // move rather than a real timer callback | ||||
| int mx, my; | |||||
| Desktop::getMousePosition (mx, my); | |||||
| int x = mx, y = my; | |||||
| globalPositionToRelative (x, y); | |||||
| const Point<int> globalMousePos (Desktop::getMousePosition()); | |||||
| const Point<int> localMousePos (globalPositionToRelative (globalMousePos)); | |||||
| const uint32 now = Time::getMillisecondCounter(); | const uint32 now = Time::getMillisecondCounter(); | ||||
| if (now > timeEnteredCurrentChildComp + 100 | if (now > timeEnteredCurrentChildComp + 100 | ||||
| && reallyContains (x, y, true) | |||||
| && reallyContains (localMousePos.getX(), localMousePos.getY(), true) | |||||
| && currentChild->isValidComponent() | && currentChild->isValidComponent() | ||||
| && (! disableMouseMoves) | && (! disableMouseMoves) | ||||
| && ! (activeSubMenu != 0 && activeSubMenu->isVisible())) | && ! (activeSubMenu != 0 && activeSubMenu->isVisible())) | ||||
| @@ -631,17 +625,17 @@ public: | |||||
| showSubMenuFor (currentChild); | showSubMenuFor (currentChild); | ||||
| } | } | ||||
| if (mx != lastMouseX || my != lastMouseY || now > lastMouseMoveTime + 350) | |||||
| if (globalMousePos != lastMouse || now > lastMouseMoveTime + 350) | |||||
| { | { | ||||
| highlightItemUnderMouse (mx, my, x, y); | |||||
| highlightItemUnderMouse (globalMousePos, localMousePos); | |||||
| } | } | ||||
| bool overScrollArea = false; | bool overScrollArea = false; | ||||
| if (isScrolling() | if (isScrolling() | ||||
| && (isOver || (isDown && ((unsigned int) x) < (unsigned int) getWidth())) | |||||
| && ((isScrollZoneActive (false) && y < PopupMenuSettings::scrollZone) | |||||
| || (isScrollZoneActive (true) && y > getHeight() - PopupMenuSettings::scrollZone))) | |||||
| && (isOver || (isDown && ((unsigned int) localMousePos.getX()) < (unsigned int) getWidth())) | |||||
| && ((isScrollZoneActive (false) && localMousePos.getY() < PopupMenuSettings::scrollZone) | |||||
| || (isScrollZoneActive (true) && localMousePos.getY() > getHeight() - PopupMenuSettings::scrollZone))) | |||||
| { | { | ||||
| if (now > lastScroll + 20) | if (now > lastScroll + 20) | ||||
| { | { | ||||
| @@ -651,13 +645,13 @@ public: | |||||
| for (int i = 0; i < getNumChildComponents() && amount == 0; ++i) | for (int i = 0; i < getNumChildComponents() && amount == 0; ++i) | ||||
| amount = ((int) scrollAcceleration) * getChildComponent (i)->getHeight(); | amount = ((int) scrollAcceleration) * getChildComponent (i)->getHeight(); | ||||
| alterChildYPos (y < PopupMenuSettings::scrollZone ? -amount : amount); | |||||
| alterChildYPos (localMousePos.getY() < PopupMenuSettings::scrollZone ? -amount : amount); | |||||
| lastScroll = now; | lastScroll = now; | ||||
| } | } | ||||
| overScrollArea = true; | overScrollArea = true; | ||||
| lastMouseX = -1; // trigger a mouse-move | |||||
| lastMouse = Point<int> (-1, -1); // trigger a mouse-move | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -669,7 +663,7 @@ public: | |||||
| if (hideOnExit && hasBeenOver && (! isOverAny) && activeSubMenu != 0) | if (hideOnExit && hasBeenOver && (! isOverAny) && activeSubMenu != 0) | ||||
| { | { | ||||
| activeSubMenu->updateMouseOverStatus (mx, my); | |||||
| activeSubMenu->updateMouseOverStatus (globalMousePos); | |||||
| isOverAny = isOverAnyMenu(); | isOverAny = isOverAnyMenu(); | ||||
| } | } | ||||
| @@ -715,7 +709,7 @@ public: | |||||
| else if (wasDown && now > menuCreationTime + 250 | else if (wasDown && now > menuCreationTime + 250 | ||||
| && ! (isDown || overScrollArea)) | && ! (isDown || overScrollArea)) | ||||
| { | { | ||||
| isOver = reallyContains (x, y, true); | |||||
| isOver = reallyContains (localMousePos.getX(), localMousePos.getY(), true); | |||||
| if (isOver) | if (isOver) | ||||
| { | { | ||||
| @@ -759,7 +753,7 @@ private: | |||||
| Component* componentAttachedTo; | Component* componentAttachedTo; | ||||
| ScopedPointer <ComponentDeletionWatcher> attachedCompWatcher; | ScopedPointer <ComponentDeletionWatcher> attachedCompWatcher; | ||||
| Rectangle<int> windowPos; | Rectangle<int> windowPos; | ||||
| int lastMouseX, lastMouseY; | |||||
| Point<int> lastMouse; | |||||
| int minimumWidth, maximumNumColumns, standardItemHeight; | int minimumWidth, maximumNumColumns, standardItemHeight; | ||||
| bool isOver, hasBeenOver, isDown, needsToScroll; | bool isOver, hasBeenOver, isDown, needsToScroll; | ||||
| bool dismissOnMouseUp, hideOnExit, disableMouseMoves, hasAnyJuceCompHadFocus; | bool dismissOnMouseUp, hideOnExit, disableMouseMoves, hasAnyJuceCompHadFocus; | ||||
| @@ -789,14 +783,13 @@ private: | |||||
| && (isOver || (activeSubMenu != 0 && activeSubMenu->isOverChildren())); | && (isOver || (activeSubMenu != 0 && activeSubMenu->isOverChildren())); | ||||
| } | } | ||||
| void updateMouseOverStatus (const int mx, const int my) | |||||
| void updateMouseOverStatus (const Point<int>& globalMousePos) | |||||
| { | { | ||||
| int rx = mx, ry = my; | |||||
| globalPositionToRelative (rx, ry); | |||||
| isOver = reallyContains (rx, ry, true); | |||||
| const Point<int> relPos (globalPositionToRelative (globalMousePos)); | |||||
| isOver = reallyContains (relPos.getX(), relPos.getY(), true); | |||||
| if (activeSubMenu != 0) | if (activeSubMenu != 0) | ||||
| activeSubMenu->updateMouseOverStatus (mx, my); | |||||
| activeSubMenu->updateMouseOverStatus (globalMousePos); | |||||
| } | } | ||||
| bool treeContains (const Window* const window) const throw() | bool treeContains (const Window* const window) const throw() | ||||
| @@ -823,8 +816,8 @@ private: | |||||
| const bool alignToRectangle) | const bool alignToRectangle) | ||||
| { | { | ||||
| const Rectangle<int> mon (Desktop::getInstance() | const Rectangle<int> mon (Desktop::getInstance() | ||||
| .getMonitorAreaContaining ((minX + maxX) / 2, | |||||
| (minY + maxY) / 2, | |||||
| .getMonitorAreaContaining (Point<int> ((minX + maxX) / 2, | |||||
| (minY + maxY) / 2), | |||||
| #if JUCE_MAC | #if JUCE_MAC | ||||
| true)); | true)); | ||||
| #else | #else | ||||
| @@ -995,10 +988,7 @@ private: | |||||
| windowPos.getHeight() - (PopupMenuSettings::scrollZone + m->getHeight())), | windowPos.getHeight() - (PopupMenuSettings::scrollZone + m->getHeight())), | ||||
| currentY); | currentY); | ||||
| const Rectangle<int> mon (Desktop::getInstance() | |||||
| .getMonitorAreaContaining (windowPos.getX(), | |||||
| windowPos.getY(), | |||||
| true)); | |||||
| const Rectangle<int> mon (Desktop::getInstance().getMonitorAreaContaining (windowPos.getPosition(), true)); | |||||
| int deltaY = wantedY - currentY; | int deltaY = wantedY - currentY; | ||||
| @@ -1124,15 +1114,13 @@ private: | |||||
| if (childComp->isValidComponent() && childComp->itemInfo.hasActiveSubMenu()) | if (childComp->isValidComponent() && childComp->itemInfo.hasActiveSubMenu()) | ||||
| { | { | ||||
| int left = 0, top = 0; | |||||
| childComp->relativePositionToGlobal (left, top); | |||||
| int right = childComp->getWidth(), bottom = childComp->getHeight(); | |||||
| childComp->relativePositionToGlobal (right, bottom); | |||||
| const Point<int> topLeft (childComp->relativePositionToGlobal (Point<int>())); | |||||
| const Point<int> bottomRight (childComp->relativePositionToGlobal (Point<int> (childComp->getWidth(), childComp->getHeight()))); | |||||
| activeSubMenu = Window::create (*(childComp->itemInfo.subMenu), | activeSubMenu = Window::create (*(childComp->itemInfo.subMenu), | ||||
| dismissOnMouseUp, | dismissOnMouseUp, | ||||
| this, | this, | ||||
| left, right, top, bottom, | |||||
| topLeft.getX(), bottomRight.getX(), topLeft.getY(), bottomRight.getY(), | |||||
| 0, maximumNumColumns, | 0, maximumNumColumns, | ||||
| standardItemHeight, | standardItemHeight, | ||||
| false, 0, menuBarComponent, | false, 0, menuBarComponent, | ||||
| @@ -1151,14 +1139,14 @@ private: | |||||
| return false; | return false; | ||||
| } | } | ||||
| void highlightItemUnderMouse (const int mx, const int my, const int x, const int y) | |||||
| void highlightItemUnderMouse (const Point<int>& globalMousePos, const Point<int>& localMousePos) | |||||
| { | { | ||||
| isOver = reallyContains (x, y, true); | |||||
| isOver = reallyContains (localMousePos.getX(), localMousePos.getY(), true); | |||||
| if (isOver) | if (isOver) | ||||
| hasBeenOver = true; | hasBeenOver = true; | ||||
| if (abs (lastMouseX - mx) > 2 || abs (lastMouseY - my) > 2) | |||||
| if (lastMouse.getDistanceFrom (globalMousePos) > 2) | |||||
| { | { | ||||
| lastMouseMoveTime = Time::getApproximateMillisecondCounter(); | lastMouseMoveTime = Time::getApproximateMillisecondCounter(); | ||||
| @@ -1173,7 +1161,7 @@ private: | |||||
| jassert (activeSubMenu == 0 || activeSubMenu->isValidComponent()) | jassert (activeSubMenu == 0 || activeSubMenu->isValidComponent()) | ||||
| if (isOver && (activeSubMenu != 0) && (mx != lastMouseX || my != lastMouseY)) | |||||
| if (isOver && (activeSubMenu != 0) && globalMousePos != lastMouse) | |||||
| { | { | ||||
| // try to intelligently guess whether the user is moving the mouse towards a currently-open | // try to intelligently guess whether the user is moving the mouse towards a currently-open | ||||
| // submenu. To do this, look at whether the mouse stays inside a triangular region that | // submenu. To do this, look at whether the mouse stays inside a triangular region that | ||||
| @@ -1183,31 +1171,30 @@ private: | |||||
| if (activeSubMenu->getX() > getX()) | if (activeSubMenu->getX() > getX()) | ||||
| { | { | ||||
| lastMouseX -= 2; // to enlarge the triangle a bit, in case the mouse only moves a couple of pixels | |||||
| lastMouse -= Point<int> (2, 0); // to enlarge the triangle a bit, in case the mouse only moves a couple of pixels | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| lastMouseX += 2; | |||||
| lastMouse += Point<int> (2, 0); | |||||
| subX += activeSubMenu->getWidth(); | subX += activeSubMenu->getWidth(); | ||||
| } | } | ||||
| Path areaTowardsSubMenu; | Path areaTowardsSubMenu; | ||||
| areaTowardsSubMenu.addTriangle ((float) lastMouseX, | |||||
| (float) lastMouseY, | |||||
| areaTowardsSubMenu.addTriangle ((float) lastMouse.getX(), | |||||
| (float) lastMouse.getY(), | |||||
| subX, | subX, | ||||
| (float) activeSubMenu->getScreenY(), | (float) activeSubMenu->getScreenY(), | ||||
| subX, | subX, | ||||
| (float) (activeSubMenu->getScreenY() + activeSubMenu->getHeight())); | (float) (activeSubMenu->getScreenY() + activeSubMenu->getHeight())); | ||||
| isMovingTowardsMenu = areaTowardsSubMenu.contains ((float) mx, (float) my); | |||||
| isMovingTowardsMenu = areaTowardsSubMenu.contains ((float) globalMousePos.getX(), (float) globalMousePos.getY()); | |||||
| } | } | ||||
| lastMouseX = mx; | |||||
| lastMouseY = my; | |||||
| lastMouse = globalMousePos; | |||||
| if (! isMovingTowardsMenu) | if (! isMovingTowardsMenu) | ||||
| { | { | ||||
| Component* c = getComponentAt (x, y); | |||||
| Component* c = getComponentAt (localMousePos.getX(), localMousePos.getY()); | |||||
| if (c == this) | if (c == this) | ||||
| c = 0; | c = 0; | ||||
| @@ -1619,10 +1606,9 @@ int PopupMenu::show (const int itemIdThatMustBeVisible, | |||||
| const int maximumNumColumns, | const int maximumNumColumns, | ||||
| const int standardItemHeight) | const int standardItemHeight) | ||||
| { | { | ||||
| int x, y; | |||||
| Desktop::getMousePosition (x, y); | |||||
| const Point<int> mousePos (Desktop::getMousePosition()); | |||||
| return showAt (x, y, | |||||
| return showAt (mousePos.getX(), mousePos.getY(), | |||||
| itemIdThatMustBeVisible, | itemIdThatMustBeVisible, | ||||
| minimumWidth, | minimumWidth, | ||||
| maximumNumColumns, | maximumNumColumns, | ||||
| @@ -33,9 +33,7 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| ComponentDragger::ComponentDragger() | ComponentDragger::ComponentDragger() | ||||
| : constrainer (0), | |||||
| originalX (0), | |||||
| originalY (0) | |||||
| : constrainer (0) | |||||
| { | { | ||||
| } | } | ||||
| @@ -52,9 +50,7 @@ void ComponentDragger::startDraggingComponent (Component* const componentToDrag, | |||||
| if (componentToDrag->isValidComponent()) | if (componentToDrag->isValidComponent()) | ||||
| { | { | ||||
| constrainer = constrainer_; | constrainer = constrainer_; | ||||
| originalX = 0; | |||||
| originalY = 0; | |||||
| componentToDrag->relativePositionToGlobal (originalX, originalY); | |||||
| originalPos = componentToDrag->relativePositionToGlobal (Point<int>()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -65,23 +61,22 @@ void ComponentDragger::dragComponent (Component* const componentToDrag, const Mo | |||||
| if (componentToDrag->isValidComponent()) | if (componentToDrag->isValidComponent()) | ||||
| { | { | ||||
| int x = originalX; | |||||
| int y = originalY; | |||||
| Point<int> pos (originalPos); | |||||
| int w = componentToDrag->getWidth(); | int w = componentToDrag->getWidth(); | ||||
| int h = componentToDrag->getHeight(); | int h = componentToDrag->getHeight(); | ||||
| const Component* const parentComp = componentToDrag->getParentComponent(); | const Component* const parentComp = componentToDrag->getParentComponent(); | ||||
| if (parentComp != 0) | if (parentComp != 0) | ||||
| parentComp->globalPositionToRelative (x, y); | |||||
| pos = parentComp->globalPositionToRelative (pos); | |||||
| x += e.getDistanceFromDragStartX(); | |||||
| y += e.getDistanceFromDragStartY(); | |||||
| pos += Point<int> (e.getDistanceFromDragStartX(), | |||||
| e.getDistanceFromDragStartY()); | |||||
| if (constrainer != 0) | if (constrainer != 0) | ||||
| constrainer->setBoundsForComponent (componentToDrag, Rectangle<int> (x, y, w, h), | |||||
| constrainer->setBoundsForComponent (componentToDrag, Rectangle<int> (pos.getX(), pos.getY(), w, h), | |||||
| false, false, false, false); | false, false, false, false); | ||||
| else | else | ||||
| componentToDrag->setBounds (x, y, w, h); | |||||
| componentToDrag->setBounds (pos.getX(), pos.getY(), w, h); | |||||
| } | } | ||||
| } | } | ||||
| @@ -98,7 +98,7 @@ public: | |||||
| private: | private: | ||||
| ComponentBoundsConstrainer* constrainer; | ComponentBoundsConstrainer* constrainer; | ||||
| int originalX, originalY; | |||||
| Point<int> originalPos; | |||||
| }; | }; | ||||
| #endif // __JUCE_COMPONENTDRAGGER_JUCEHEADER__ | #endif // __JUCE_COMPONENTDRAGGER_JUCEHEADER__ | ||||
| @@ -53,7 +53,7 @@ private: | |||||
| DragAndDropTarget* currentlyOver; | DragAndDropTarget* currentlyOver; | ||||
| String dragDesc; | String dragDesc; | ||||
| const int imageX, imageY; | |||||
| const Point<int> imageOffset; | |||||
| bool hasCheckedForExternalDrag, drawImage; | bool hasCheckedForExternalDrag, drawImage; | ||||
| DragImageComponent (const DragImageComponent&); | DragImageComponent (const DragImageComponent&); | ||||
| @@ -64,14 +64,13 @@ public: | |||||
| const String& desc, | const String& desc, | ||||
| Component* const s, | Component* const s, | ||||
| DragAndDropContainer* const o, | DragAndDropContainer* const o, | ||||
| const int imageX_, const int imageY_) | |||||
| const Point<int>& imageOffset_) | |||||
| : image (im), | : image (im), | ||||
| source (s), | source (s), | ||||
| owner (o), | owner (o), | ||||
| currentlyOver (0), | currentlyOver (0), | ||||
| dragDesc (desc), | dragDesc (desc), | ||||
| imageX (imageX_), | |||||
| imageY (imageY_), | |||||
| imageOffset (imageOffset_), | |||||
| hasCheckedForExternalDrag (false), | hasCheckedForExternalDrag (false), | ||||
| drawImage (true) | drawImage (true) | ||||
| { | { | ||||
| @@ -120,21 +119,19 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| DragAndDropTarget* findTarget (const int screenX, const int screenY, | |||||
| int& relX, int& relY) const | |||||
| DragAndDropTarget* findTarget (const Point<int>& screenPos, | |||||
| Point<int>& relativePos) const | |||||
| { | { | ||||
| Component* hit = getParentComponent(); | Component* hit = getParentComponent(); | ||||
| if (hit == 0) | if (hit == 0) | ||||
| { | { | ||||
| hit = Desktop::getInstance().findComponentAt (screenX, screenY); | |||||
| hit = Desktop::getInstance().findComponentAt (screenPos); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| int rx = screenX, ry = screenY; | |||||
| hit->globalPositionToRelative (rx, ry); | |||||
| hit = hit->getComponentAt (rx, ry); | |||||
| const Point<int> relPos (hit->globalPositionToRelative (screenPos)); | |||||
| hit = hit->getComponentAt (relPos.getX(), relPos.getY()); | |||||
| } | } | ||||
| // (note: use a local copy of the dragDesc member in case the callback runs | // (note: use a local copy of the dragDesc member in case the callback runs | ||||
| @@ -147,9 +144,7 @@ public: | |||||
| if (ddt != 0 && ddt->isInterestedInDragSource (dragDescLocal, source)) | if (ddt != 0 && ddt->isInterestedInDragSource (dragDescLocal, source)) | ||||
| { | { | ||||
| relX = screenX; | |||||
| relY = screenY; | |||||
| hit->globalPositionToRelative (relX, relY); | |||||
| relativePos = hit->globalPositionToRelative (screenPos); | |||||
| return ddt; | return ddt; | ||||
| } | } | ||||
| @@ -168,14 +163,12 @@ public: | |||||
| bool dropAccepted = false; | bool dropAccepted = false; | ||||
| DragAndDropTarget* ddt = 0; | DragAndDropTarget* ddt = 0; | ||||
| int relX = 0, relY = 0; | |||||
| Point<int> relPos; | |||||
| if (isVisible()) | if (isVisible()) | ||||
| { | { | ||||
| setVisible (false); | setVisible (false); | ||||
| ddt = findTarget (e.getScreenX(), | |||||
| e.getScreenY(), | |||||
| relX, relY); | |||||
| ddt = findTarget (e.getScreenPosition(), relPos); | |||||
| // fade this component and remove it - it'll be deleted later by the timer callback | // fade this component and remove it - it'll be deleted later by the timer callback | ||||
| @@ -189,17 +182,15 @@ public: | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| int targetX = source->getWidth() / 2; | |||||
| int targetY = source->getHeight() / 2; | |||||
| source->relativePositionToGlobal (targetX, targetY); | |||||
| const Point<int> target (source->relativePositionToGlobal (Point<int> (source->getWidth() / 2, | |||||
| source->getHeight() / 2))); | |||||
| int ourCentreX = getWidth() / 2; | |||||
| int ourCentreY = getHeight() / 2; | |||||
| relativePositionToGlobal (ourCentreX, ourCentreY); | |||||
| const Point<int> ourCentre (relativePositionToGlobal (Point<int> (getWidth() / 2, | |||||
| getHeight() / 2))); | |||||
| fadeOutComponent (120, | fadeOutComponent (120, | ||||
| targetX - ourCentreX, | |||||
| targetY - ourCentreY); | |||||
| target.getX() - ourCentre.getX(), | |||||
| target.getY() - ourCentre.getY()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -215,31 +206,30 @@ public: | |||||
| currentlyOverWatcher = 0; | currentlyOverWatcher = 0; | ||||
| currentlyOver = 0; | currentlyOver = 0; | ||||
| ddt->itemDropped (dragDescLocal, source, relX, relY); | |||||
| ddt->itemDropped (dragDescLocal, source, relPos.getX(), relPos.getY()); | |||||
| } | } | ||||
| // careful - this object could now be deleted.. | // careful - this object could now be deleted.. | ||||
| } | } | ||||
| } | } | ||||
| void updateLocation (const bool canDoExternalDrag, int x, int y) | |||||
| void updateLocation (const bool canDoExternalDrag, const Point<int>& screenPos) | |||||
| { | { | ||||
| // (note: use a local copy of the dragDesc member in case the callback runs | // (note: use a local copy of the dragDesc member in case the callback runs | ||||
| // a modal loop and deletes this object before it returns) | // a modal loop and deletes this object before it returns) | ||||
| const String dragDescLocal (dragDesc); | const String dragDescLocal (dragDesc); | ||||
| int newX = x + imageX; | |||||
| int newY = y + imageY; | |||||
| Point<int> newPos (screenPos + imageOffset); | |||||
| if (getParentComponent() != 0) | if (getParentComponent() != 0) | ||||
| getParentComponent()->globalPositionToRelative (newX, newY); | |||||
| newPos = getParentComponent()->globalPositionToRelative (newPos); | |||||
| //if (newX != getX() || newY != getY()) | //if (newX != getX() || newY != getY()) | ||||
| { | { | ||||
| setTopLeftPosition (newX, newY); | |||||
| setTopLeftPosition (newPos.getX(), newPos.getY()); | |||||
| int relX = 0, relY = 0; | |||||
| DragAndDropTarget* const ddt = findTarget (x, y, relX, relY); | |||||
| Point<int> relPos; | |||||
| DragAndDropTarget* const ddt = findTarget (screenPos, relPos); | |||||
| drawImage = (ddt == 0) || ddt->shouldDrawDragImageWhenOver(); | drawImage = (ddt == 0) || ddt->shouldDrawDragImageWhenOver(); | ||||
| @@ -266,7 +256,7 @@ public: | |||||
| currentlyOverWatcher = new ComponentDeletionWatcher (dynamic_cast <Component*> (ddt)); | currentlyOverWatcher = new ComponentDeletionWatcher (dynamic_cast <Component*> (ddt)); | ||||
| if (currentlyOver->isInterestedInDragSource (dragDescLocal, source)) | if (currentlyOver->isInterestedInDragSource (dragDescLocal, source)) | ||||
| currentlyOver->itemDragEnter (dragDescLocal, source, relX, relY); | |||||
| currentlyOver->itemDragEnter (dragDescLocal, source, relPos.getX(), relPos.getY()); | |||||
| } | } | ||||
| } | } | ||||
| else if (currentlyOverWatcher != 0 && currentlyOverWatcher->hasBeenDeleted()) | else if (currentlyOverWatcher != 0 && currentlyOverWatcher->hasBeenDeleted()) | ||||
| @@ -277,13 +267,13 @@ public: | |||||
| if (currentlyOver != 0 | if (currentlyOver != 0 | ||||
| && currentlyOver->isInterestedInDragSource (dragDescLocal, source)) | && currentlyOver->isInterestedInDragSource (dragDescLocal, source)) | ||||
| currentlyOver->itemDragMove (dragDescLocal, source, relX, relY); | |||||
| currentlyOver->itemDragMove (dragDescLocal, source, relPos.getX(), relPos.getY()); | |||||
| if (currentlyOver == 0 | if (currentlyOver == 0 | ||||
| && canDoExternalDrag | && canDoExternalDrag | ||||
| && ! hasCheckedForExternalDrag) | && ! hasCheckedForExternalDrag) | ||||
| { | { | ||||
| if (Desktop::getInstance().findComponentAt (x, y) == 0) | |||||
| if (Desktop::getInstance().findComponentAt (screenPos) == 0) | |||||
| { | { | ||||
| hasCheckedForExternalDrag = true; | hasCheckedForExternalDrag = true; | ||||
| StringArray files; | StringArray files; | ||||
| @@ -311,7 +301,7 @@ public: | |||||
| void mouseDrag (const MouseEvent& e) | void mouseDrag (const MouseEvent& e) | ||||
| { | { | ||||
| if (e.originalComponent != this) | if (e.originalComponent != this) | ||||
| updateLocation (true, e.getScreenX(), e.getScreenY()); | |||||
| updateLocation (true, e.getScreenPosition()); | |||||
| } | } | ||||
| void timerCallback() | void timerCallback() | ||||
| @@ -355,9 +345,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||||
| if (thisComp != 0) | if (thisComp != 0) | ||||
| { | { | ||||
| int mx, my; | |||||
| Desktop::getLastMouseDownPosition (mx, my); | |||||
| int imageX = 0, imageY = 0; | |||||
| const Point<int> lastMouseDown (Desktop::getLastMouseDownPosition()); | |||||
| Point<int> imageOffset; | |||||
| if (dragImage == 0) | if (dragImage == 0) | ||||
| { | { | ||||
| @@ -377,18 +366,17 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||||
| const int lo = 150; | const int lo = 150; | ||||
| const int hi = 400; | const int hi = 400; | ||||
| int rx = mx, ry = my; | |||||
| sourceComponent->globalPositionToRelative (rx, ry); | |||||
| const int cx = jlimit (0, dragImage->getWidth(), rx); | |||||
| const int cy = jlimit (0, dragImage->getHeight(), ry); | |||||
| Point<int> relPos (sourceComponent->globalPositionToRelative (lastMouseDown)); | |||||
| Point<int> clipped (Rectangle<int> (0, 0, dragImage->getWidth(), dragImage->getHeight()) | |||||
| .getConstrainedPoint (relPos)); | |||||
| for (int y = dragImage->getHeight(); --y >= 0;) | for (int y = dragImage->getHeight(); --y >= 0;) | ||||
| { | { | ||||
| const double dy = (y - cy) * (y - cy); | |||||
| const double dy = (y - clipped.getY()) * (y - clipped.getY()); | |||||
| for (int x = dragImage->getWidth(); --x >= 0;) | for (int x = dragImage->getWidth(); --x >= 0;) | ||||
| { | { | ||||
| const int dx = x - cx; | |||||
| const int dx = x - clipped.getX(); | |||||
| const int distance = roundToInt (sqrt (dx * dx + dy)); | const int distance = roundToInt (sqrt (dx * dx + dy)); | ||||
| if (distance > lo) | if (distance > lo) | ||||
| @@ -402,25 +390,19 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||||
| } | } | ||||
| } | } | ||||
| imageX = -cx; | |||||
| imageY = -cy; | |||||
| imageOffset = Point<int>() - clipped; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if (imageOffsetFromMouse == 0) | if (imageOffsetFromMouse == 0) | ||||
| { | |||||
| imageX = dragImage->getWidth() / -2; | |||||
| imageY = dragImage->getHeight() / -2; | |||||
| } | |||||
| imageOffset = Point<int> (dragImage->getWidth() / -2, | |||||
| dragImage->getHeight() / -2); | |||||
| else | else | ||||
| { | |||||
| imageX = imageOffsetFromMouse->getX(); | |||||
| imageY = imageOffsetFromMouse->getY(); | |||||
| } | |||||
| imageOffset = *imageOffsetFromMouse; | |||||
| } | } | ||||
| dragImageComponent = new DragImageComponent (dragImage.release(), sourceDescription, sourceComponent, | dragImageComponent = new DragImageComponent (dragImage.release(), sourceDescription, sourceComponent, | ||||
| this, imageX, imageY); | |||||
| this, imageOffset); | |||||
| currentDragDesc = sourceDescription; | currentDragDesc = sourceDescription; | ||||
| @@ -436,7 +418,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||||
| else | else | ||||
| thisComp->addChildComponent (dragImageComponent); | thisComp->addChildComponent (dragImageComponent); | ||||
| ((DragImageComponent*) dragImageComponent)->updateLocation (false, mx, my); | |||||
| ((DragImageComponent*) dragImageComponent)->updateLocation (false, lastMouseDown); | |||||
| dragImageComponent->setVisible (true); | dragImageComponent->setVisible (true); | ||||
| } | } | ||||
| else | else | ||||
| @@ -32,24 +32,21 @@ BEGIN_JUCE_NAMESPACE | |||||
| //============================================================================== | //============================================================================== | ||||
| MouseEvent::MouseEvent (const int x_, | |||||
| const int y_, | |||||
| MouseEvent::MouseEvent (const Point<int>& position, | |||||
| const ModifierKeys& mods_, | const ModifierKeys& mods_, | ||||
| Component* const originator, | Component* const originator, | ||||
| const Time& eventTime_, | const Time& eventTime_, | ||||
| const int mouseDownX_, | |||||
| const int mouseDownY_, | |||||
| const Point<int> mouseDownPos_, | |||||
| const Time& mouseDownTime_, | const Time& mouseDownTime_, | ||||
| const int numberOfClicks_, | const int numberOfClicks_, | ||||
| const bool mouseWasDragged) throw() | const bool mouseWasDragged) throw() | ||||
| : x (x_), | |||||
| y (y_), | |||||
| : x (position.getX()), | |||||
| y (position.getY()), | |||||
| mods (mods_), | mods (mods_), | ||||
| eventComponent (originator), | eventComponent (originator), | ||||
| originalComponent (originator), | originalComponent (originator), | ||||
| eventTime (eventTime_), | eventTime (eventTime_), | ||||
| mouseDownX (mouseDownX_), | |||||
| mouseDownY (mouseDownY_), | |||||
| mouseDownPos (mouseDownPos_), | |||||
| mouseDownTime (mouseDownTime_), | mouseDownTime (mouseDownTime_), | ||||
| numberOfClicks (numberOfClicks_), | numberOfClicks (numberOfClicks_), | ||||
| wasMovedSinceMouseDown (mouseWasDragged) | wasMovedSinceMouseDown (mouseWasDragged) | ||||
| @@ -68,22 +65,27 @@ bool MouseEvent::mouseWasClicked() const throw() | |||||
| int MouseEvent::getMouseDownX() const throw() | int MouseEvent::getMouseDownX() const throw() | ||||
| { | { | ||||
| return mouseDownX; | |||||
| return mouseDownPos.getX(); | |||||
| } | } | ||||
| int MouseEvent::getMouseDownY() const throw() | int MouseEvent::getMouseDownY() const throw() | ||||
| { | { | ||||
| return mouseDownY; | |||||
| return mouseDownPos.getY(); | |||||
| } | |||||
| const Point<int> MouseEvent::getMouseDownPosition() const throw() | |||||
| { | |||||
| return mouseDownPos; | |||||
| } | } | ||||
| int MouseEvent::getDistanceFromDragStartX() const throw() | int MouseEvent::getDistanceFromDragStartX() const throw() | ||||
| { | { | ||||
| return x - mouseDownX; | |||||
| return x - mouseDownPos.getX(); | |||||
| } | } | ||||
| int MouseEvent::getDistanceFromDragStartY() const throw() | int MouseEvent::getDistanceFromDragStartY() const throw() | ||||
| { | { | ||||
| return y - mouseDownY; | |||||
| return y - mouseDownPos.getY(); | |||||
| } | } | ||||
| int MouseEvent::getDistanceFromDragStart() const throw() | int MouseEvent::getDistanceFromDragStart() const throw() | ||||
| @@ -101,32 +103,39 @@ int MouseEvent::getLengthOfMousePress() const throw() | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| int MouseEvent::getScreenX() const throw() | |||||
| const Point<int> MouseEvent::getPosition() const throw() | |||||
| { | |||||
| return Point<int> (x, y); | |||||
| } | |||||
| int MouseEvent::getScreenX() const | |||||
| { | |||||
| return getScreenPosition().getX(); | |||||
| } | |||||
| int MouseEvent::getScreenY() const | |||||
| { | { | ||||
| int sx = x, sy = y; | |||||
| eventComponent->relativePositionToGlobal (sx, sy); | |||||
| return sx; | |||||
| return getScreenPosition().getY(); | |||||
| } | } | ||||
| int MouseEvent::getScreenY() const throw() | |||||
| const Point<int> MouseEvent::getScreenPosition() const | |||||
| { | { | ||||
| int sx = x, sy = y; | |||||
| eventComponent->relativePositionToGlobal (sx, sy); | |||||
| return sy; | |||||
| return eventComponent->relativePositionToGlobal (Point<int> (x, y)); | |||||
| } | } | ||||
| int MouseEvent::getMouseDownScreenX() const throw() | |||||
| int MouseEvent::getMouseDownScreenX() const | |||||
| { | { | ||||
| int sx = mouseDownX, sy = mouseDownY; | |||||
| eventComponent->relativePositionToGlobal (sx, sy); | |||||
| return sx; | |||||
| return getMouseDownScreenPosition().getX(); | |||||
| } | } | ||||
| int MouseEvent::getMouseDownScreenY() const throw() | |||||
| int MouseEvent::getMouseDownScreenY() const | |||||
| { | { | ||||
| int sx = mouseDownX, sy = mouseDownY; | |||||
| eventComponent->relativePositionToGlobal (sx, sy); | |||||
| return sy; | |||||
| return getMouseDownScreenPosition().getY(); | |||||
| } | |||||
| const Point<int> MouseEvent::getMouseDownScreenPosition() const | |||||
| { | |||||
| return eventComponent->relativePositionToGlobal (mouseDownPos); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -138,13 +147,14 @@ const MouseEvent MouseEvent::getEventRelativeTo (Component* const otherComponent | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| MouseEvent me (*this); | |||||
| eventComponent->relativePositionToOtherComponent (otherComponent, me.x, me.y); | |||||
| eventComponent->relativePositionToOtherComponent (otherComponent, me.mouseDownX, me.mouseDownY); | |||||
| me.eventComponent = otherComponent; | |||||
| return me; | |||||
| return MouseEvent (eventComponent->relativePositionToOtherComponent (otherComponent, Point<int> (x, y)), | |||||
| mods, | |||||
| originalComponent, | |||||
| eventTime, | |||||
| eventComponent->relativePositionToOtherComponent (otherComponent, mouseDownPos), | |||||
| mouseDownTime, | |||||
| numberOfClicks, | |||||
| wasMovedSinceMouseDown); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -29,6 +29,7 @@ | |||||
| class Component; | class Component; | ||||
| #include "../keyboard/juce_ModifierKeys.h" | #include "../keyboard/juce_ModifierKeys.h" | ||||
| #include "../../../core/juce_Time.h" | #include "../../../core/juce_Time.h" | ||||
| #include "../../graphics/geometry/juce_Point.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -46,29 +47,24 @@ public: | |||||
| Normally an application will never need to use this. | Normally an application will never need to use this. | ||||
| @param x the x position of the mouse, relative to the component that is passed-in | |||||
| @param y the y position of the mouse, relative to the component that is passed-in | |||||
| @param position the position of the mouse, relative to the component that is passed-in | |||||
| @param modifiers the key modifiers at the time of the event | @param modifiers the key modifiers at the time of the event | ||||
| @param originator the component that the mouse event applies to | @param originator the component that the mouse event applies to | ||||
| @param eventTime the time the event happened | @param eventTime the time the event happened | ||||
| @param mouseDownX the x position of the corresponding mouse-down event (relative to the component that is passed-in). | |||||
| @param mouseDownPos the position of the corresponding mouse-down event (relative to the component that is passed-in). | |||||
| If there isn't a corresponding mouse-down (e.g. for a mouse-move), this will just be | If there isn't a corresponding mouse-down (e.g. for a mouse-move), this will just be | ||||
| the same as the current mouse-x position. | the same as the current mouse-x position. | ||||
| @param mouseDownY the y position of the corresponding mouse-down event (relative to the component that is passed-in) | |||||
| If there isn't a corresponding mouse-down (e.g. for a mouse-move), this will just be | |||||
| the same as the current mouse-y position. | |||||
| @param mouseDownTime the time at which the corresponding mouse-down event happened | @param mouseDownTime the time at which the corresponding mouse-down event happened | ||||
| If there isn't a corresponding mouse-down (e.g. for a mouse-move), this will just be | If there isn't a corresponding mouse-down (e.g. for a mouse-move), this will just be | ||||
| the same as the current mouse-event time. | the same as the current mouse-event time. | ||||
| @param numberOfClicks how many clicks, e.g. a double-click event will be 2, a triple-click will be 3, etc | @param numberOfClicks how many clicks, e.g. a double-click event will be 2, a triple-click will be 3, etc | ||||
| @param mouseWasDragged whether the mouse has been dragged significantly since the previous mouse-down | @param mouseWasDragged whether the mouse has been dragged significantly since the previous mouse-down | ||||
| */ | */ | ||||
| MouseEvent (const int x, const int y, | |||||
| MouseEvent (const Point<int>& position, | |||||
| const ModifierKeys& modifiers, | const ModifierKeys& modifiers, | ||||
| Component* const originator, | Component* const originator, | ||||
| const Time& eventTime, | const Time& eventTime, | ||||
| const int mouseDownX, | |||||
| const int mouseDownY, | |||||
| const Point<int> mouseDownPos, | |||||
| const Time& mouseDownTime, | const Time& mouseDownTime, | ||||
| const int numberOfClicks, | const int numberOfClicks, | ||||
| const bool mouseWasDragged) throw(); | const bool mouseWasDragged) throw(); | ||||
| @@ -146,6 +142,14 @@ public: | |||||
| */ | */ | ||||
| int getMouseDownY() const throw(); | int getMouseDownY() const throw(); | ||||
| /** Returns the co-ordinates of the last place that a mouse was pressed. | |||||
| The co-ordinates are relative to the component specified in MouseEvent::component. | |||||
| @see getDistanceFromDragStart, getDistanceFromDragStartX, mouseWasClicked | |||||
| */ | |||||
| const Point<int> getMouseDownPosition() const throw(); | |||||
| /** Returns the straight-line distance between where the mouse is now and where it | /** Returns the straight-line distance between where the mouse is now and where it | ||||
| was the last time the button was pressed. | was the last time the button was pressed. | ||||
| @@ -203,13 +207,20 @@ public: | |||||
| int getLengthOfMousePress() const throw(); | int getLengthOfMousePress() const throw(); | ||||
| //============================================================================== | //============================================================================== | ||||
| /** The position of the mouse when the event occurred. | |||||
| This position is relative to the top-left of the component to which the | |||||
| event applies (as indicated by the MouseEvent::eventComponent field). | |||||
| */ | |||||
| const Point<int> getPosition() const throw(); | |||||
| /** Returns the mouse x position of this event, in global screen co-ordinates. | /** Returns the mouse x position of this event, in global screen co-ordinates. | ||||
| The co-ordinates are relative to the top-left of the main monitor. | The co-ordinates are relative to the top-left of the main monitor. | ||||
| @see getMouseDownScreenX, Desktop::getMousePosition | @see getMouseDownScreenX, Desktop::getMousePosition | ||||
| */ | */ | ||||
| int getScreenX() const throw(); | |||||
| int getScreenX() const; | |||||
| /** Returns the mouse y position of this event, in global screen co-ordinates. | /** Returns the mouse y position of this event, in global screen co-ordinates. | ||||
| @@ -217,7 +228,15 @@ public: | |||||
| @see getMouseDownScreenY, Desktop::getMousePosition | @see getMouseDownScreenY, Desktop::getMousePosition | ||||
| */ | */ | ||||
| int getScreenY() const throw(); | |||||
| int getScreenY() const; | |||||
| /** Returns the mouse position of this event, in global screen co-ordinates. | |||||
| The co-ordinates are relative to the top-left of the main monitor. | |||||
| @see getMouseDownScreenY, Desktop::getMousePosition | |||||
| */ | |||||
| const Point<int> getScreenPosition() const; | |||||
| /** Returns the x co-ordinate at which the mouse button was last pressed. | /** Returns the x co-ordinate at which the mouse button was last pressed. | ||||
| @@ -225,7 +244,7 @@ public: | |||||
| @see getScreenX, Desktop::getMousePosition | @see getScreenX, Desktop::getMousePosition | ||||
| */ | */ | ||||
| int getMouseDownScreenX() const throw(); | |||||
| int getMouseDownScreenX() const; | |||||
| /** Returns the y co-ordinate at which the mouse button was last pressed. | /** Returns the y co-ordinate at which the mouse button was last pressed. | ||||
| @@ -233,7 +252,15 @@ public: | |||||
| @see getScreenY, Desktop::getMousePosition | @see getScreenY, Desktop::getMousePosition | ||||
| */ | */ | ||||
| int getMouseDownScreenY() const throw(); | |||||
| int getMouseDownScreenY() const; | |||||
| /** Returns the co-ordinates at which the mouse button was last pressed. | |||||
| The co-ordinates are relative to the top-left of the main monitor. | |||||
| @see getScreenY, Desktop::getMousePosition | |||||
| */ | |||||
| const Point<int> getMouseDownScreenPosition() const; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Creates a version of this event that is relative to a different component. | /** Creates a version of this event that is relative to a different component. | ||||
| @@ -267,7 +294,7 @@ public: | |||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| private: | private: | ||||
| int mouseDownX, mouseDownY; | |||||
| Point<int> mouseDownPos; | |||||
| Time mouseDownTime; | Time mouseDownTime; | ||||
| int numberOfClicks; | int numberOfClicks; | ||||
| bool wasMovedSinceMouseDown; | bool wasMovedSinceMouseDown; | ||||
| @@ -78,13 +78,12 @@ void MouseHoverDetector::hoverTimerCallback() | |||||
| if (source != 0) | if (source != 0) | ||||
| { | { | ||||
| int mx, my; | |||||
| source->getMouseXYRelative (mx, my); | |||||
| const Point<int> pos (source->getMouseXYRelative()); | |||||
| if (source->reallyContains (mx, my, false)) | |||||
| if (source->reallyContains (pos.getX(), pos.getY(), false)) | |||||
| { | { | ||||
| hasJustHovered = true; | hasJustHovered = true; | ||||
| mouseHovered (mx, my); | |||||
| mouseHovered (pos.getX(), pos.getY()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -98,15 +98,14 @@ void BubbleComponent::setPosition (Component* componentToPointTo) | |||||
| { | { | ||||
| jassert (componentToPointTo->isValidComponent()); | jassert (componentToPointTo->isValidComponent()); | ||||
| int tx = 0; | |||||
| int ty = 0; | |||||
| Point<int> pos; | |||||
| if (getParentComponent() != 0) | if (getParentComponent() != 0) | ||||
| componentToPointTo->relativePositionToOtherComponent (getParentComponent(), tx, ty); | |||||
| pos = componentToPointTo->relativePositionToOtherComponent (getParentComponent(), pos); | |||||
| else | else | ||||
| componentToPointTo->relativePositionToGlobal (tx, ty); | |||||
| pos = componentToPointTo->relativePositionToGlobal (pos); | |||||
| setPosition (Rectangle<int> (tx, ty, componentToPointTo->getWidth(), componentToPointTo->getHeight())); | |||||
| setPosition (Rectangle<int> (pos.getX(), pos.getY(), componentToPointTo->getWidth(), componentToPointTo->getHeight())); | |||||
| } | } | ||||
| void BubbleComponent::setPosition (const int arrowTipX_, | void BubbleComponent::setPosition (const int arrowTipX_, | ||||
| @@ -76,11 +76,11 @@ public: | |||||
| peer->grabFocus(); | peer->grabFocus(); | ||||
| } | } | ||||
| void textInputRequired (int x, int y) | |||||
| void textInputRequired (const Point<int>& position) | |||||
| { | { | ||||
| ComponentPeer* peer = magnifierComp->getPeer(); | ComponentPeer* peer = magnifierComp->getPeer(); | ||||
| if (peer != 0) | if (peer != 0) | ||||
| peer->textInputRequired (x, y); | |||||
| peer->textInputRequired (position); | |||||
| } | } | ||||
| void getBounds (int& x, int& y, int& w, int& h) const | void getBounds (int& x, int& y, int& w, int& h) const | ||||
| @@ -91,25 +91,25 @@ public: | |||||
| h = component->getHeight(); | h = component->getHeight(); | ||||
| } | } | ||||
| int getScreenX() const { return magnifierComp->getScreenX(); } | |||||
| int getScreenY() const { return magnifierComp->getScreenY(); } | |||||
| const Point<int> getScreenPosition() const | |||||
| { | |||||
| return magnifierComp->getScreenPosition(); | |||||
| } | |||||
| void relativePositionToGlobal (int& x, int& y) | |||||
| const Point<int> relativePositionToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| const double zoom = magnifierComp->getScaleFactor(); | const double zoom = magnifierComp->getScaleFactor(); | ||||
| x = roundToInt (x * zoom); | |||||
| y = roundToInt (y * zoom); | |||||
| magnifierComp->relativePositionToGlobal (x, y); | |||||
| return magnifierComp->relativePositionToGlobal (Point<int> (roundToInt (relativePosition.getX() * zoom), | |||||
| roundToInt (relativePosition.getY() * zoom))); | |||||
| } | } | ||||
| void globalPositionToRelative (int& x, int& y) | |||||
| const Point<int> globalPositionToRelative (const Point<int>& screenPosition) | |||||
| { | { | ||||
| magnifierComp->globalPositionToRelative (x, y); | |||||
| const Point<int> p (magnifierComp->globalPositionToRelative (screenPosition)); | |||||
| const double zoom = magnifierComp->getScaleFactor(); | const double zoom = magnifierComp->getScaleFactor(); | ||||
| x = roundToInt (x / zoom); | |||||
| y = roundToInt (y / zoom); | |||||
| return Point<int> (roundToInt (p.getX() / zoom), | |||||
| roundToInt (p.getY() / zoom)); | |||||
| } | } | ||||
| bool contains (int x, int y, bool) const | bool contains (int x, int y, bool) const | ||||
| @@ -251,27 +251,29 @@ int MidiKeyboardComponent::getKeyStartPosition (const int midiNoteNumber) const | |||||
| static const uint8 whiteNotes[] = { 0, 2, 4, 5, 7, 9, 11 }; | static const uint8 whiteNotes[] = { 0, 2, 4, 5, 7, 9, 11 }; | ||||
| static const uint8 blackNotes[] = { 1, 3, 6, 8, 10 }; | static const uint8 blackNotes[] = { 1, 3, 6, 8, 10 }; | ||||
| int MidiKeyboardComponent::xyToNote (int x, int y, float& mousePositionVelocity) | |||||
| int MidiKeyboardComponent::xyToNote (const Point<int>& pos, float& mousePositionVelocity) | |||||
| { | { | ||||
| if (! reallyContains (x, y, false)) | |||||
| if (! reallyContains (pos.getX(), pos.getY(), false)) | |||||
| return -1; | return -1; | ||||
| Point<int> p (pos); | |||||
| if (orientation != horizontalKeyboard) | if (orientation != horizontalKeyboard) | ||||
| { | { | ||||
| swapVariables (x, y); | |||||
| p = Point<int> (p.getY(), p.getX()); | |||||
| if (orientation == verticalKeyboardFacingLeft) | if (orientation == verticalKeyboardFacingLeft) | ||||
| y = getWidth() - y; | |||||
| p = Point<int> (p.getX(), getWidth() - p.getY()); | |||||
| else | else | ||||
| x = getHeight() - x; | |||||
| p = Point<int> (getHeight() - p.getX(), p.getY()); | |||||
| } | } | ||||
| return remappedXYToNote (x + xOffset, y, mousePositionVelocity); | |||||
| return remappedXYToNote (p + Point<int> (xOffset, 0), mousePositionVelocity); | |||||
| } | } | ||||
| int MidiKeyboardComponent::remappedXYToNote (int x, int y, float& mousePositionVelocity) const | |||||
| int MidiKeyboardComponent::remappedXYToNote (const Point<int>& pos, float& mousePositionVelocity) const | |||||
| { | { | ||||
| if (y < blackNoteLength) | |||||
| if (pos.getY() < blackNoteLength) | |||||
| { | { | ||||
| for (int octaveStart = 12 * (rangeStart / 12); octaveStart <= rangeEnd; octaveStart += 12) | for (int octaveStart = 12 * (rangeStart / 12); octaveStart <= rangeEnd; octaveStart += 12) | ||||
| { | { | ||||
| @@ -285,9 +287,9 @@ int MidiKeyboardComponent::remappedXYToNote (int x, int y, float& mousePositionV | |||||
| getKeyPos (note, kx, kw); | getKeyPos (note, kx, kw); | ||||
| kx += xOffset; | kx += xOffset; | ||||
| if (x >= kx && x < kx + kw) | |||||
| if (pos.getX() >= kx && pos.getX() < kx + kw) | |||||
| { | { | ||||
| mousePositionVelocity = y / (float) blackNoteLength; | |||||
| mousePositionVelocity = pos.getY() / (float) blackNoteLength; | |||||
| return note; | return note; | ||||
| } | } | ||||
| } | } | ||||
| @@ -307,10 +309,10 @@ int MidiKeyboardComponent::remappedXYToNote (int x, int y, float& mousePositionV | |||||
| getKeyPos (note, kx, kw); | getKeyPos (note, kx, kw); | ||||
| kx += xOffset; | kx += xOffset; | ||||
| if (x >= kx && x < kx + kw) | |||||
| if (pos.getX() >= kx && pos.getX() < kx + kw) | |||||
| { | { | ||||
| const int whiteNoteLength = (orientation == horizontalKeyboard) ? getHeight() : getWidth(); | const int whiteNoteLength = (orientation == horizontalKeyboard) ? getHeight() : getWidth(); | ||||
| mousePositionVelocity = y / (float) whiteNoteLength; | |||||
| mousePositionVelocity = pos.getY() / (float) whiteNoteLength; | |||||
| return note; | return note; | ||||
| } | } | ||||
| } | } | ||||
| @@ -643,7 +645,7 @@ void MidiKeyboardComponent::resized() | |||||
| float mousePositionVelocity; | float mousePositionVelocity; | ||||
| const int spaceAvailable = w - scrollButtonW * 2; | const int spaceAvailable = w - scrollButtonW * 2; | ||||
| const int lastStartKey = remappedXYToNote (endOfLastKey - spaceAvailable, 0, mousePositionVelocity) + 1; | |||||
| const int lastStartKey = remappedXYToNote (Point<int> (endOfLastKey - spaceAvailable, 0), mousePositionVelocity) + 1; | |||||
| if (lastStartKey >= 0 && firstKey > lastStartKey) | if (lastStartKey >= 0 && firstKey > lastStartKey) | ||||
| { | { | ||||
| @@ -699,11 +701,11 @@ void MidiKeyboardComponent::resetAnyKeysInUse() | |||||
| } | } | ||||
| } | } | ||||
| void MidiKeyboardComponent::updateNoteUnderMouse (int x, int y) | |||||
| void MidiKeyboardComponent::updateNoteUnderMouse (const Point<int>& pos) | |||||
| { | { | ||||
| float mousePositionVelocity = 0.0f; | float mousePositionVelocity = 0.0f; | ||||
| const int newNote = (mouseDragging || isMouseOver()) | const int newNote = (mouseDragging || isMouseOver()) | ||||
| ? xyToNote (x, y, mousePositionVelocity) : -1; | |||||
| ? xyToNote (pos, mousePositionVelocity) : -1; | |||||
| if (noteUnderMouse != newNote) | if (noteUnderMouse != newNote) | ||||
| { | { | ||||
| @@ -735,19 +737,19 @@ void MidiKeyboardComponent::updateNoteUnderMouse (int x, int y) | |||||
| void MidiKeyboardComponent::mouseMove (const MouseEvent& e) | void MidiKeyboardComponent::mouseMove (const MouseEvent& e) | ||||
| { | { | ||||
| updateNoteUnderMouse (e.x, e.y); | |||||
| updateNoteUnderMouse (e.getPosition()); | |||||
| stopTimer(); | stopTimer(); | ||||
| } | } | ||||
| void MidiKeyboardComponent::mouseDrag (const MouseEvent& e) | void MidiKeyboardComponent::mouseDrag (const MouseEvent& e) | ||||
| { | { | ||||
| float mousePositionVelocity; | float mousePositionVelocity; | ||||
| const int newNote = xyToNote (e.x, e.y, mousePositionVelocity); | |||||
| const int newNote = xyToNote (e.getPosition(), mousePositionVelocity); | |||||
| if (newNote >= 0) | if (newNote >= 0) | ||||
| mouseDraggedToKey (newNote, e); | mouseDraggedToKey (newNote, e); | ||||
| updateNoteUnderMouse (e.x, e.y); | |||||
| updateNoteUnderMouse (e.getPosition()); | |||||
| } | } | ||||
| bool MidiKeyboardComponent::mouseDownOnKey (int /*midiNoteNumber*/, const MouseEvent&) | bool MidiKeyboardComponent::mouseDownOnKey (int /*midiNoteNumber*/, const MouseEvent&) | ||||
| @@ -762,7 +764,7 @@ void MidiKeyboardComponent::mouseDraggedToKey (int /*midiNoteNumber*/, const Mou | |||||
| void MidiKeyboardComponent::mouseDown (const MouseEvent& e) | void MidiKeyboardComponent::mouseDown (const MouseEvent& e) | ||||
| { | { | ||||
| float mousePositionVelocity; | float mousePositionVelocity; | ||||
| const int newNote = xyToNote (e.x, e.y, mousePositionVelocity); | |||||
| const int newNote = xyToNote (e.getPosition(), mousePositionVelocity); | |||||
| mouseDragging = false; | mouseDragging = false; | ||||
| if (newNote >= 0 && mouseDownOnKey (newNote, e)) | if (newNote >= 0 && mouseDownOnKey (newNote, e)) | ||||
| @@ -771,7 +773,7 @@ void MidiKeyboardComponent::mouseDown (const MouseEvent& e) | |||||
| noteUnderMouse = -1; | noteUnderMouse = -1; | ||||
| mouseDragging = true; | mouseDragging = true; | ||||
| updateNoteUnderMouse (e.x, e.y); | |||||
| updateNoteUnderMouse (e.getPosition()); | |||||
| startTimer (500); | startTimer (500); | ||||
| } | } | ||||
| } | } | ||||
| @@ -779,19 +781,19 @@ void MidiKeyboardComponent::mouseDown (const MouseEvent& e) | |||||
| void MidiKeyboardComponent::mouseUp (const MouseEvent& e) | void MidiKeyboardComponent::mouseUp (const MouseEvent& e) | ||||
| { | { | ||||
| mouseDragging = false; | mouseDragging = false; | ||||
| updateNoteUnderMouse (e.x, e.y); | |||||
| updateNoteUnderMouse (e.getPosition()); | |||||
| stopTimer(); | stopTimer(); | ||||
| } | } | ||||
| void MidiKeyboardComponent::mouseEnter (const MouseEvent& e) | void MidiKeyboardComponent::mouseEnter (const MouseEvent& e) | ||||
| { | { | ||||
| updateNoteUnderMouse (e.x, e.y); | |||||
| updateNoteUnderMouse (e.getPosition()); | |||||
| } | } | ||||
| void MidiKeyboardComponent::mouseExit (const MouseEvent& e) | void MidiKeyboardComponent::mouseExit (const MouseEvent& e) | ||||
| { | { | ||||
| updateNoteUnderMouse (e.x, e.y); | |||||
| updateNoteUnderMouse (e.getPosition()); | |||||
| } | } | ||||
| void MidiKeyboardComponent::mouseWheelMove (const MouseEvent&, float ix, float iy) | void MidiKeyboardComponent::mouseWheelMove (const MouseEvent&, float ix, float iy) | ||||
| @@ -801,10 +803,7 @@ void MidiKeyboardComponent::mouseWheelMove (const MouseEvent&, float ix, float i | |||||
| void MidiKeyboardComponent::timerCallback() | void MidiKeyboardComponent::timerCallback() | ||||
| { | { | ||||
| int mx, my; | |||||
| getMouseXYRelative (mx, my); | |||||
| updateNoteUnderMouse (mx, my); | |||||
| updateNoteUnderMouse (getMouseXYRelative()); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -405,10 +405,10 @@ private: | |||||
| int octaveNumForMiddleC; | int octaveNumForMiddleC; | ||||
| void getKeyPos (int midiNoteNumber, int& x, int& w) const; | void getKeyPos (int midiNoteNumber, int& x, int& w) const; | ||||
| int xyToNote (int x, int y, float& mousePositionVelocity); | |||||
| int remappedXYToNote (int x, int y, float& mousePositionVelocity) const; | |||||
| int xyToNote (const Point<int>& pos, float& mousePositionVelocity); | |||||
| int remappedXYToNote (const Point<int>& pos, float& mousePositionVelocity) const; | |||||
| void resetAnyKeysInUse(); | void resetAnyKeysInUse(); | ||||
| void updateNoteUnderMouse (int x, int y); | |||||
| void updateNoteUnderMouse (const Point<int>& pos); | |||||
| void repaintNote (const int midiNoteNumber); | void repaintNote (const int midiNoteNumber); | ||||
| MidiKeyboardComponent (const MidiKeyboardComponent&); | MidiKeyboardComponent (const MidiKeyboardComponent&); | ||||
| @@ -259,9 +259,8 @@ void OpenGLComponent::paint (Graphics&) | |||||
| if (peer != 0) | if (peer != 0) | ||||
| { | { | ||||
| peer->addMaskedRegion (getScreenX() - peer->getScreenX(), | |||||
| getScreenY() - peer->getScreenY(), | |||||
| getWidth(), getHeight()); | |||||
| const Point<int> topLeft (getScreenPosition() - peer->getScreenPosition()); | |||||
| peer->addMaskedRegion (topLeft.getX(), topLeft.getY(), getWidth(), getHeight()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -114,24 +114,22 @@ void ComponentPeer::handleMouseEnter (int x, int y, const int64 time) | |||||
| { | { | ||||
| jassert (Component::componentUnderMouse->isValidComponent()); | jassert (Component::componentUnderMouse->isValidComponent()); | ||||
| const int oldX = x; | |||||
| const int oldY = y; | |||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseExit (x, y, time); | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseExit (relPos.getX(), relPos.getY(), time); | |||||
| Component::componentUnderMouse = 0; | Component::componentUnderMouse = 0; | ||||
| if (deletionChecker.hasBeenDeleted()) | if (deletionChecker.hasBeenDeleted()) | ||||
| return; | return; | ||||
| c = component->getComponentAt (oldX, oldY); | |||||
| c = component->getComponentAt (x, y); | |||||
| } | } | ||||
| Component::componentUnderMouse = c; | Component::componentUnderMouse = c; | ||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseEnter (x, y, time); | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseEnter (relPos.getX(), relPos.getY(), time); | |||||
| } | } | ||||
| } | } | ||||
| @@ -147,16 +145,10 @@ void ComponentPeer::handleMouseMove (int x, int y, const int64 time) | |||||
| if (c != Component::componentUnderMouse) | if (c != Component::componentUnderMouse) | ||||
| { | { | ||||
| const int oldX = x; | |||||
| const int oldY = y; | |||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseExit (x, y, time); | |||||
| x = oldX; | |||||
| y = oldY; | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseExit (relPos.getX(), relPos.getY(), time); | |||||
| Component::componentUnderMouse = 0; | Component::componentUnderMouse = 0; | ||||
| if (deletionChecker.hasBeenDeleted()) | if (deletionChecker.hasBeenDeleted()) | ||||
| @@ -169,10 +161,8 @@ void ComponentPeer::handleMouseMove (int x, int y, const int64 time) | |||||
| if (c != 0) | if (c != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (c, x, y); | |||||
| c->internalMouseEnter (x, y, time); | |||||
| x = oldX; | |||||
| y = oldY; | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (c, Point<int> (x, y))); | |||||
| c->internalMouseEnter (relPos.getX(), relPos.getY(), time); | |||||
| if (deletionChecker.hasBeenDeleted()) | if (deletionChecker.hasBeenDeleted()) | ||||
| return; // if this window has just been deleted.. | return; // if this window has just been deleted.. | ||||
| @@ -181,8 +171,8 @@ void ComponentPeer::handleMouseMove (int x, int y, const int64 time) | |||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseMove (x, y, time); | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseMove (relPos.getX(), relPos.getY(), time); | |||||
| } | } | ||||
| } | } | ||||
| @@ -197,8 +187,8 @@ void ComponentPeer::handleMouseDown (int x, int y, const int64 time) | |||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseDown (x, y, time); | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseDown (relPos.getX(), relPos.getY(), time); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -209,8 +199,8 @@ void ComponentPeer::handleMouseDrag (int x, int y, const int64 time) | |||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseDrag (x, y, time); | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseDrag (relPos.getX(), relPos.getY(), time); | |||||
| } | } | ||||
| } | } | ||||
| @@ -225,39 +215,34 @@ void ComponentPeer::handleMouseUp (const int oldModifiers, int x, int y, const i | |||||
| if (c != Component::componentUnderMouse) | if (c != Component::componentUnderMouse) | ||||
| { | { | ||||
| const int oldX = x; | |||||
| const int oldY = y; | |||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseUp (oldModifiers, x, y, time); | |||||
| x = oldX; | |||||
| y = oldY; | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseUp (oldModifiers, relPos.getX(), relPos.getY(), time); | |||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| Component::componentUnderMouse->internalMouseExit (x, y, time); | |||||
| Component::componentUnderMouse->internalMouseExit (relPos.getX(), relPos.getY(), time); | |||||
| if (deletionChecker.hasBeenDeleted()) | if (deletionChecker.hasBeenDeleted()) | ||||
| return; | return; | ||||
| c = component->getComponentAt (oldX, oldY); | |||||
| c = component->getComponentAt (x, y); | |||||
| } | } | ||||
| Component::componentUnderMouse = c; | Component::componentUnderMouse = c; | ||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseEnter (x, y, time); | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseEnter (relPos.getX(), relPos.getY(), time); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseUp (oldModifiers, x, y, time); | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseUp (oldModifiers, relPos.getX(), relPos.getY(), time); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -270,9 +255,8 @@ void ComponentPeer::handleMouseExit (int x, int y, const int64 time) | |||||
| if (Component::componentUnderMouse != 0) | if (Component::componentUnderMouse != 0) | ||||
| { | { | ||||
| component->relativePositionToOtherComponent (Component::componentUnderMouse, x, y); | |||||
| Component::componentUnderMouse->internalMouseExit (x, y, time); | |||||
| const Point<int> relPos (component->relativePositionToOtherComponent (Component::componentUnderMouse, Point<int> (x, y))); | |||||
| Component::componentUnderMouse->internalMouseExit (relPos.getX(), relPos.getY(), time); | |||||
| Component::componentUnderMouse = 0; | Component::componentUnderMouse = 0; | ||||
| } | } | ||||
| } | } | ||||
| @@ -299,14 +283,13 @@ void ComponentPeer::sendFakeMouseMove() throw() | |||||
| component->bounds_.setBounds (realX, realY, realW, realH); | component->bounds_.setBounds (realX, realY, realW, realH); | ||||
| } | } | ||||
| int x, y; | |||||
| component->getMouseXYRelative (x, y); | |||||
| const Point<int> pos (component->getMouseXYRelative()); | |||||
| if (((unsigned int) x) < (unsigned int) component->getWidth() | |||||
| && ((unsigned int) y) < (unsigned int) component->getHeight() | |||||
| && contains (x, y, false)) | |||||
| if (((unsigned int) pos.getX()) < (unsigned int) component->getWidth() | |||||
| && ((unsigned int) pos.getY()) < (unsigned int) component->getHeight() | |||||
| && contains (pos.getX(), pos.getY(), false)) | |||||
| { | { | ||||
| postMessage (new Message (fakeMouseMoveMessage, x, y, 0)); | |||||
| postMessage (new Message (fakeMouseMoveMessage, pos.getX(), pos.getY(), 0)); | |||||
| } | } | ||||
| fakeMouseMessageSent = true; | fakeMouseMessageSent = true; | ||||
| @@ -638,11 +621,10 @@ void ComponentPeer::handleFileDragMove (const StringArray& files, int x, int y) | |||||
| if (newTarget != 0) | if (newTarget != 0) | ||||
| { | { | ||||
| Component* const targetComp = dynamic_cast <Component*> (newTarget); | Component* const targetComp = dynamic_cast <Component*> (newTarget); | ||||
| int mx = x, my = y; | |||||
| component->relativePositionToOtherComponent (targetComp, mx, my); | |||||
| const Point<int> pos (component->relativePositionToOtherComponent (targetComp, Point<int> (x, y))); | |||||
| dragAndDropTargetComponent = new ComponentDeletionWatcher (dynamic_cast <Component*> (newTarget)); | dragAndDropTargetComponent = new ComponentDeletionWatcher (dynamic_cast <Component*> (newTarget)); | ||||
| newTarget->fileDragEnter (files, mx, my); | |||||
| newTarget->fileDragEnter (files, pos.getX(), pos.getY()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -654,9 +636,9 @@ void ComponentPeer::handleFileDragMove (const StringArray& files, int x, int y) | |||||
| if (newTarget != 0) | if (newTarget != 0) | ||||
| { | { | ||||
| Component* const targetComp = dynamic_cast <Component*> (newTarget); | Component* const targetComp = dynamic_cast <Component*> (newTarget); | ||||
| component->relativePositionToOtherComponent (targetComp, x, y); | |||||
| const Point<int> pos (component->relativePositionToOtherComponent (targetComp, Point<int> (x, y))); | |||||
| newTarget->fileDragMove (files, x, y); | |||||
| newTarget->fileDragMove (files, pos.getX(), pos.getY()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -691,8 +673,8 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, int x, int y) | |||||
| return; | return; | ||||
| } | } | ||||
| component->relativePositionToOtherComponent (targetComp, x, y); | |||||
| target->filesDropped (files, x, y); | |||||
| const Point<int> pos (component->relativePositionToOtherComponent (targetComp, Point<int> (x, y))); | |||||
| target->filesDropped (files, pos.getX(), pos.getY()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -150,16 +150,13 @@ public: | |||||
| virtual void getBounds (int& x, int& y, int& w, int& h) const = 0; | virtual void getBounds (int& x, int& y, int& w, int& h) const = 0; | ||||
| /** Returns the x-position of this window, relative to the screen's origin. */ | /** Returns the x-position of this window, relative to the screen's origin. */ | ||||
| virtual int getScreenX() const = 0; | |||||
| /** Returns the y-position of this window, relative to the screen's origin. */ | |||||
| virtual int getScreenY() const = 0; | |||||
| virtual const Point<int> getScreenPosition() const = 0; | |||||
| /** Converts a position relative to the top-left of this component to screen co-ordinates. */ | /** Converts a position relative to the top-left of this component to screen co-ordinates. */ | ||||
| virtual void relativePositionToGlobal (int& x, int& y) = 0; | |||||
| virtual const Point<int> relativePositionToGlobal (const Point<int>& relativePosition) = 0; | |||||
| /** Converts a screen co-ordinate to a position relative to the top-left of this component. */ | /** Converts a screen co-ordinate to a position relative to the top-left of this component. */ | ||||
| virtual void globalPositionToRelative (int& x, int& y) = 0; | |||||
| virtual const Point<int> globalPositionToRelative (const Point<int>& screenPosition) = 0; | |||||
| /** Minimises the window. */ | /** Minimises the window. */ | ||||
| virtual void setMinimised (bool shouldBeMinimised) = 0; | virtual void setMinimised (bool shouldBeMinimised) = 0; | ||||
| @@ -255,7 +252,7 @@ public: | |||||
| This may cause things like a virtual on-screen keyboard to appear, depending | This may cause things like a virtual on-screen keyboard to appear, depending | ||||
| on the OS. | on the OS. | ||||
| */ | */ | ||||
| virtual void textInputRequired (int x, int y) = 0; | |||||
| virtual void textInputRequired (const Point<int>& position) = 0; | |||||
| /** Called when the window gains keyboard focus. */ | /** Called when the window gains keyboard focus. */ | ||||
| void handleFocusGain(); | void handleFocusGain(); | ||||
| @@ -475,8 +475,7 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s) | |||||
| if (newPos.isEmpty()) | if (newPos.isEmpty()) | ||||
| return false; | return false; | ||||
| const Rectangle<int> screen (Desktop::getInstance().getMonitorAreaContaining (newPos.getCentreX(), | |||||
| newPos.getCentreY())); | |||||
| const Rectangle<int> screen (Desktop::getInstance().getMonitorAreaContaining (newPos.getCentre())); | |||||
| ComponentPeer* const peer = isOnDesktop() ? getPeer() : 0; | ComponentPeer* const peer = isOnDesktop() ? getPeer() : 0; | ||||
| if (peer != 0) | if (peer != 0) | ||||
| @@ -40,8 +40,6 @@ TooltipWindow::TooltipWindow (Component* const parentComponent, | |||||
| const int millisecondsBeforeTipAppears_) | const int millisecondsBeforeTipAppears_) | ||||
| : Component ("tooltip"), | : Component ("tooltip"), | ||||
| millisecondsBeforeTipAppears (millisecondsBeforeTipAppears_), | millisecondsBeforeTipAppears (millisecondsBeforeTipAppears_), | ||||
| mouseX (0), | |||||
| mouseY (0), | |||||
| lastHideTime (0), | lastHideTime (0), | ||||
| lastComponentUnderMouse (0), | lastComponentUnderMouse (0), | ||||
| changedCompsSinceShown (true) | changedCompsSinceShown (true) | ||||
| @@ -80,24 +78,23 @@ void TooltipWindow::showFor (const String& tip) | |||||
| jassert (tip.isNotEmpty()); | jassert (tip.isNotEmpty()); | ||||
| tipShowing = tip; | tipShowing = tip; | ||||
| int mx, my; | |||||
| Desktop::getMousePosition (mx, my); | |||||
| Point<int> mousePos (Desktop::getMousePosition()); | |||||
| if (getParentComponent() != 0) | if (getParentComponent() != 0) | ||||
| getParentComponent()->globalPositionToRelative (mx, my); | |||||
| mousePos = getParentComponent()->globalPositionToRelative (mousePos); | |||||
| int x, y, w, h; | int x, y, w, h; | ||||
| getLookAndFeel().getTooltipSize (tip, w, h); | getLookAndFeel().getTooltipSize (tip, w, h); | ||||
| if (mx > getParentWidth() / 2) | |||||
| x = mx - (w + 12); | |||||
| if (mousePos.getX() > getParentWidth() / 2) | |||||
| x = mousePos.getX() - (w + 12); | |||||
| else | else | ||||
| x = mx + 24; | |||||
| x = mousePos.getX() + 24; | |||||
| if (my > getParentHeight() / 2) | |||||
| y = my - (h + 6); | |||||
| if (mousePos.getY() > getParentHeight() / 2) | |||||
| y = mousePos.getY() - (h + 6); | |||||
| else | else | ||||
| y = my + 6; | |||||
| y = mousePos.getY() + 6; | |||||
| setBounds (x, y, w, h); | setBounds (x, y, w, h); | ||||
| setVisible (true); | setVisible (true); | ||||
| @@ -148,11 +145,9 @@ void TooltipWindow::timerCallback() | |||||
| const bool mouseWasClicked = clickCount > mouseClicks; | const bool mouseWasClicked = clickCount > mouseClicks; | ||||
| mouseClicks = clickCount; | mouseClicks = clickCount; | ||||
| int mx, my; | |||||
| Desktop::getMousePosition (mx, my); | |||||
| const bool mouseMovedQuickly = (abs (mx - mouseX) + abs (my - mouseY) > 12); | |||||
| mouseX = mx; | |||||
| mouseY = my; | |||||
| const Point<int> mousePos (Desktop::getMousePosition()); | |||||
| const bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12; | |||||
| lastMousePos = mousePos; | |||||
| if (tipChanged || mouseWasClicked || mouseMovedQuickly) | if (tipChanged || mouseWasClicked || mouseMovedQuickly) | ||||
| lastCompChangeTime = now; | lastCompChangeTime = now; | ||||
| @@ -100,7 +100,8 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| int millisecondsBeforeTipAppears; | int millisecondsBeforeTipAppears; | ||||
| int mouseX, mouseY, mouseClicks; | |||||
| Point<int> lastMousePos; | |||||
| int mouseClicks; | |||||
| unsigned int lastCompChangeTime, lastHideTime; | unsigned int lastCompChangeTime, lastHideTime; | ||||
| Component* lastComponentUnderMouse; | Component* lastComponentUnderMouse; | ||||
| bool changedCompsSinceShown; | bool changedCompsSinceShown; | ||||
| @@ -291,22 +291,21 @@ void TopLevelWindow::centreAroundComponent (Component* c, const int width, const | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| int x = (c->getWidth() - width) / 2; | |||||
| int y = (c->getHeight() - height) / 2; | |||||
| c->relativePositionToGlobal (x, y); | |||||
| Point<int> p (c->relativePositionToGlobal (Point<int> ((c->getWidth() - width) / 2, | |||||
| (c->getHeight() - height) / 2))); | |||||
| Rectangle<int> parentArea (c->getParentMonitorArea()); | Rectangle<int> parentArea (c->getParentMonitorArea()); | ||||
| if (getParentComponent() != 0) | if (getParentComponent() != 0) | ||||
| { | { | ||||
| getParentComponent()->globalPositionToRelative (x, y); | |||||
| p = getParentComponent()->globalPositionToRelative (p); | |||||
| parentArea.setBounds (0, 0, getParentWidth(), getParentHeight()); | parentArea.setBounds (0, 0, getParentWidth(), getParentHeight()); | ||||
| } | } | ||||
| parentArea.reduce (12, 12); | parentArea.reduce (12, 12); | ||||
| setBounds (jlimit (parentArea.getX(), jmax (parentArea.getX(), parentArea.getRight() - width), x), | |||||
| jlimit (parentArea.getY(), jmax (parentArea.getY(), parentArea.getBottom() - height), y), | |||||
| setBounds (jlimit (parentArea.getX(), jmax (parentArea.getX(), parentArea.getRight() - width), p.getX()), | |||||
| jlimit (parentArea.getY(), jmax (parentArea.getY(), parentArea.getBottom() - height), p.getY()), | |||||
| width, height); | width, height); | ||||
| } | } | ||||
| } | } | ||||
| @@ -65,6 +65,12 @@ public: | |||||
| /** Returns the point's y co-ordinate. */ | /** Returns the point's y co-ordinate. */ | ||||
| inline ValueType getY() const throw() { return y; } | inline ValueType getY() const throw() { return y; } | ||||
| inline bool operator== (const Point& other) const throw() { return x == other.x && y == other.y; } | |||||
| inline bool operator!= (const Point& other) const throw() { return x != other.x || y != other.y; } | |||||
| /** Returns true if the point is (0, 0). */ | |||||
| bool isOrigin() const throw() { return x == ValueType() && y == ValueType(); } | |||||
| /** Changes the point's x and y co-ordinates. */ | /** Changes the point's x and y co-ordinates. */ | ||||
| void setXY (const ValueType newX, const ValueType newY) throw() { x = newX; y = newY; } | void setXY (const ValueType newX, const ValueType newY) throw() { x = newX; y = newY; } | ||||
| @@ -83,13 +89,15 @@ public: | |||||
| /** Subtracts another point's co-ordinates to this one. */ | /** Subtracts another point's co-ordinates to this one. */ | ||||
| Point& operator-= (const Point& other) throw() { x -= other.x; y -= other.y; return *this; } | Point& operator-= (const Point& other) throw() { x -= other.x; y -= other.y; return *this; } | ||||
| /** Returns the straight-line distance between this point and another one. */ | |||||
| ValueType getDistanceFrom (const Point& other) const throw() { return (ValueType) juce_hypot (x - other.x, y - other.y); } | |||||
| /** Uses a transform to change the point's co-ordinates. | /** Uses a transform to change the point's co-ordinates. | ||||
| This will only compile if ValueType = float! | This will only compile if ValueType = float! | ||||
| @see AffineTransform::transformPoint | @see AffineTransform::transformPoint | ||||
| */ | */ | ||||
| void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); } | void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); } | ||||
| //============================================================================== | //============================================================================== | ||||
| juce_UseDebuggingNewOperator | juce_UseDebuggingNewOperator | ||||
| @@ -107,6 +107,8 @@ public: | |||||
| /** Returns the y co-ordinate of the rectangle's centre. */ | /** Returns the y co-ordinate of the rectangle's centre. */ | ||||
| inline ValueType getCentreY() const throw() { return y + h / (ValueType) 2; } | inline ValueType getCentreY() const throw() { return y + h / (ValueType) 2; } | ||||
| inline const Point<ValueType> getCentre() const throw() { return Point<ValueType> (x + w / (ValueType) 2, y + h / (ValueType) 2); } | |||||
| /** Returns true if the rectangle's width and height are both zero or less */ | /** Returns true if the rectangle's width and height are both zero or less */ | ||||
| bool isEmpty() const throw() { return w <= 0 || h <= 0; } | bool isEmpty() const throw() { return w <= 0 || h <= 0; } | ||||
| @@ -114,6 +116,9 @@ public: | |||||
| /** Returns the rectangle's top-left position as a Point. */ | /** Returns the rectangle's top-left position as a Point. */ | ||||
| const Point<ValueType> getPosition() const throw() { return Point<ValueType> (x, y); } | const Point<ValueType> getPosition() const throw() { return Point<ValueType> (x, y); } | ||||
| /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ | |||||
| void setPosition (const Point<ValueType>& newPos) throw() { x = newPos.getX(); y = newPos.getY(); } | |||||
| /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ | /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ | ||||
| void setPosition (const ValueType newX, const ValueType newY) throw() { x = newX; y = newY; } | void setPosition (const ValueType newX, const ValueType newY) throw() { x = newX; y = newY; } | ||||
| @@ -256,6 +261,12 @@ public: | |||||
| return xCoord >= x && yCoord >= y && xCoord < x + w && yCoord < y + h; | return xCoord >= x && yCoord >= y && xCoord < x + w && yCoord < y + h; | ||||
| } | } | ||||
| /** Returns true if this co-ordinate is inside the rectangle. */ | |||||
| bool contains (const Point<ValueType> point) const throw() | |||||
| { | |||||
| return point.getX() >= x && point.getY() >= y && point.getX() < x + w && point.getY() < y + h; | |||||
| } | |||||
| /** Returns true if this other rectangle is completely inside this one. */ | /** Returns true if this other rectangle is completely inside this one. */ | ||||
| bool contains (const Rectangle& other) const throw() | bool contains (const Rectangle& other) const throw() | ||||
| { | { | ||||
| @@ -263,6 +274,13 @@ public: | |||||
| && x + w >= other.x + other.w && y + h >= other.y + other.h; | && x + w >= other.x + other.w && y + h >= other.y + other.h; | ||||
| } | } | ||||
| /** Returns the nearest point to the specified point that lies within this rectangle. */ | |||||
| const Point<ValueType> getConstrainedPoint (const Point<ValueType>& point) const throw() | |||||
| { | |||||
| return Point<ValueType> (jlimit (x, x + w, point.getX()), | |||||
| jlimit (y, y + h, point.getY())); | |||||
| } | |||||
| /** Returns true if any part of another rectangle overlaps this one. */ | /** Returns true if any part of another rectangle overlaps this one. */ | ||||
| bool intersects (const Rectangle& other) const throw() | bool intersects (const Rectangle& other) const throw() | ||||
| { | { | ||||
| @@ -111,7 +111,7 @@ static const int eventMask = NoEventMask | KeyPressMask | KeyReleaseMask | Butto | |||||
| //============================================================================== | //============================================================================== | ||||
| static int pointerMap[5]; | static int pointerMap[5]; | ||||
| static int lastMousePosX = 0, lastMousePosY = 0; | |||||
| static Point<int> lastMousePos; | |||||
| enum MouseButtons | enum MouseButtons | ||||
| { | { | ||||
| @@ -789,26 +789,19 @@ public: | |||||
| h = wh; | h = wh; | ||||
| } | } | ||||
| int getScreenX() const | |||||
| const Point<int> getScreenPosition() const | |||||
| { | { | ||||
| return wx; | |||||
| return Point<int> (wx, wy); | |||||
| } | } | ||||
| int getScreenY() const | |||||
| const Point<int> relativePositionToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| return wy; | |||||
| return relativePosition + getScreenPosition(); | |||||
| } | } | ||||
| void relativePositionToGlobal (int& x, int& y) | |||||
| const Point<int> globalPositionToRelative (const Point<int>& screenPosition) | |||||
| { | { | ||||
| x += wx; | |||||
| y += wy; | |||||
| } | |||||
| void globalPositionToRelative (int& x, int& y) | |||||
| { | |||||
| x -= wx; | |||||
| y -= wy; | |||||
| return screenPosition - getScreenPosition(); | |||||
| } | } | ||||
| void setMinimised (bool shouldBeMinimised) | void setMinimised (bool shouldBeMinimised) | ||||
| @@ -1091,7 +1084,7 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| void textInputRequired (int /*x*/, int /*y*/) | |||||
| void textInputRequired (const Point<int>&) | |||||
| { | { | ||||
| } | } | ||||
| @@ -1352,7 +1345,7 @@ public: | |||||
| getEventTime (buttonPressEvent->time)); | getEventTime (buttonPressEvent->time)); | ||||
| } | } | ||||
| lastMousePosX = lastMousePosY = 0x100000; | |||||
| lastMousePos = Point<int> (0x100000, 0x100000); | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -1376,7 +1369,7 @@ public: | |||||
| buttonRelEvent->x, buttonRelEvent->y, | buttonRelEvent->x, buttonRelEvent->y, | ||||
| getEventTime (buttonRelEvent->time)); | getEventTime (buttonRelEvent->time)); | ||||
| lastMousePosX = lastMousePosY = 0x100000; | |||||
| lastMousePos = Point<int> (0x100000, 0x100000); | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -1386,13 +1379,11 @@ public: | |||||
| updateKeyModifiers (movedEvent->state); | updateKeyModifiers (movedEvent->state); | ||||
| int x, y, mouseMods; | |||||
| getMousePos (x, y, mouseMods); | |||||
| Point<int> mousePos (Desktop::getMousePosition()); | |||||
| if (lastMousePosX != x || lastMousePosY != y) | |||||
| if (lastMousePos != mousePos) | |||||
| { | { | ||||
| lastMousePosX = x; | |||||
| lastMousePosY = y; | |||||
| lastMousePos = mousePos; | |||||
| if (parentWindow != 0 && (styleFlags & windowHasTitleBar) == 0) | if (parentWindow != 0 && (styleFlags & windowHasTitleBar) == 0) | ||||
| { | { | ||||
| @@ -1411,26 +1402,23 @@ public: | |||||
| { | { | ||||
| parentWindow = wParent; | parentWindow = wParent; | ||||
| updateBounds(); | updateBounds(); | ||||
| x -= getScreenX(); | |||||
| y -= getScreenY(); | |||||
| mousePos -= getScreenPosition(); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| parentWindow = 0; | parentWindow = 0; | ||||
| x -= getScreenX(); | |||||
| y -= getScreenY(); | |||||
| mousePos -= getScreenPosition(); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| x -= getScreenX(); | |||||
| y -= getScreenY(); | |||||
| mousePos -= getScreenPosition(); | |||||
| } | } | ||||
| if ((currentModifiers & ModifierKeys::allMouseButtonModifiers) == 0) | if ((currentModifiers & ModifierKeys::allMouseButtonModifiers) == 0) | ||||
| handleMouseMove (x, y, getEventTime (movedEvent->time)); | |||||
| handleMouseMove (mousePos.getX(), mousePos.getY(), getEventTime (movedEvent->time)); | |||||
| else | else | ||||
| handleMouseDrag (x, y, getEventTime (movedEvent->time)); | |||||
| handleMouseDrag (mousePos.getX(), mousePos.getY(), getEventTime (movedEvent->time)); | |||||
| } | } | ||||
| break; | break; | ||||
| @@ -1438,7 +1426,7 @@ public: | |||||
| case EnterNotify: | case EnterNotify: | ||||
| { | { | ||||
| lastMousePosX = lastMousePosY = 0x100000; | |||||
| lastMousePos = Point<int> (0x100000, 0x100000); | |||||
| const XEnterWindowEvent* const enterEvent = (const XEnterWindowEvent*) &event->xcrossing; | const XEnterWindowEvent* const enterEvent = (const XEnterWindowEvent*) &event->xcrossing; | ||||
| if ((currentModifiers & ModifierKeys::allMouseButtonModifiers) == 0 | if ((currentModifiers & ModifierKeys::allMouseButtonModifiers) == 0 | ||||
| @@ -2336,7 +2324,7 @@ private: | |||||
| void resetDragAndDrop() | void resetDragAndDrop() | ||||
| { | { | ||||
| dragAndDropFiles.clear(); | dragAndDropFiles.clear(); | ||||
| lastDropX = lastDropY = -1; | |||||
| lastDropPos = Point<int> (-1, -1); | |||||
| dragAndDropCurrentMimeType = 0; | dragAndDropCurrentMimeType = 0; | ||||
| dragAndDropSourceWindow = 0; | dragAndDropSourceWindow = 0; | ||||
| srcMimeTypeAtomList.clear(); | srcMimeTypeAtomList.clear(); | ||||
| @@ -2401,14 +2389,13 @@ private: | |||||
| dragAndDropSourceWindow = clientMsg->data.l[0]; | dragAndDropSourceWindow = clientMsg->data.l[0]; | ||||
| const int dropX = ((int) clientMsg->data.l[2] >> 16) - getScreenX(); | |||||
| const int dropY = ((int) clientMsg->data.l[2] & 0xffff) - getScreenY(); | |||||
| Point<int> dropPos ((int) clientMsg->data.l[2] >> 16, | |||||
| (int) clientMsg->data.l[2] & 0xffff); | |||||
| dropPos -= getScreenPosition(); | |||||
| if (lastDropX != dropX || lastDropY != dropY) | |||||
| if (lastDropPos != dropPos) | |||||
| { | { | ||||
| lastDropX = dropX; | |||||
| lastDropY = dropY; | |||||
| lastDropPos = dropPos; | |||||
| dragAndDropTimestamp = clientMsg->data.l[3]; | dragAndDropTimestamp = clientMsg->data.l[3]; | ||||
| Atom targetAction = XA_XdndActionCopy; | Atom targetAction = XA_XdndActionCopy; | ||||
| @@ -2428,7 +2415,7 @@ private: | |||||
| updateDraggedFileList (clientMsg); | updateDraggedFileList (clientMsg); | ||||
| if (dragAndDropFiles.size() > 0) | if (dragAndDropFiles.size() > 0) | ||||
| handleFileDragMove (dragAndDropFiles, dropX, dropY); | |||||
| handleFileDragMove (dragAndDropFiles, dropPos.getX(), dropPos.getY()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2438,13 +2425,13 @@ private: | |||||
| updateDraggedFileList (clientMsg); | updateDraggedFileList (clientMsg); | ||||
| const StringArray files (dragAndDropFiles); | const StringArray files (dragAndDropFiles); | ||||
| const int lastX = lastDropX, lastY = lastDropY; | |||||
| const Point<int> lastPos (lastDropPos); | |||||
| sendDragAndDropFinish(); | sendDragAndDropFinish(); | ||||
| resetDragAndDrop(); | resetDragAndDrop(); | ||||
| if (files.size() > 0) | if (files.size() > 0) | ||||
| handleFileDragDrop (files, lastX, lastY); | |||||
| handleFileDragDrop (files, lastPos.getX(), lastPos.getY()); | |||||
| } | } | ||||
| void handleDragAndDropEnter (const XClientMessageEvent* const clientMsg) | void handleDragAndDropEnter (const XClientMessageEvent* const clientMsg) | ||||
| @@ -2578,7 +2565,8 @@ private: | |||||
| } | } | ||||
| StringArray dragAndDropFiles; | StringArray dragAndDropFiles; | ||||
| int dragAndDropTimestamp, lastDropX, lastDropY; | |||||
| int dragAndDropTimestamp; | |||||
| Point<int> lastDropPos; | |||||
| Atom XA_OtherMime, dragAndDropCurrentMimeType; | Atom XA_OtherMime, dragAndDropCurrentMimeType; | ||||
| Window dragAndDropSourceWindow; | Window dragAndDropSourceWindow; | ||||
| @@ -2737,17 +2725,18 @@ bool Desktop::canUseSemiTransparentWindows() throw() | |||||
| return false; | return false; | ||||
| } | } | ||||
| void Desktop::getMousePosition (int& x, int& y) throw() | |||||
| const Point<int> Desktop::getMousePosition() | |||||
| { | { | ||||
| int mouseMods; | |||||
| int x, y, mouseMods; | |||||
| getMousePos (x, y, mouseMods); | getMousePos (x, y, mouseMods); | ||||
| return Point<int> (x, y); | |||||
| } | } | ||||
| void Desktop::setMousePosition (int x, int y) throw() | |||||
| void Desktop::setMousePosition (const Point<int>& newPosition) | |||||
| { | { | ||||
| ScopedXLock xlock; | ScopedXLock xlock; | ||||
| Window root = RootWindow (display, DefaultScreen (display)); | Window root = RootWindow (display, DefaultScreen (display)); | ||||
| XWarpPointer (display, None, root, 0, 0, 0, 0, x, y); | |||||
| XWarpPointer (display, None, root, 0, 0, 0, 0, newPosition.getX(), newPosition.getY()); | |||||
| } | } | ||||
| @@ -93,10 +93,9 @@ public: | |||||
| void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); | void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); | ||||
| void getBounds (int& x, int& y, int& w, int& h, const bool global) const; | void getBounds (int& x, int& y, int& w, int& h, const bool global) const; | ||||
| void getBounds (int& x, int& y, int& w, int& h) const; | void getBounds (int& x, int& y, int& w, int& h) const; | ||||
| int getScreenX() const; | |||||
| int getScreenY() const; | |||||
| void relativePositionToGlobal (int& x, int& y); | |||||
| void globalPositionToRelative (int& x, int& y); | |||||
| const Point<int> getScreenPosition() const; | |||||
| const Point<int> relativePositionToGlobal (const Point<int>& relativePosition); | |||||
| const Point<int> globalPositionToRelative (const Point<int>& screenPosition); | |||||
| void setMinimised (bool shouldBeMinimised); | void setMinimised (bool shouldBeMinimised); | ||||
| bool isMinimised() const; | bool isMinimised() const; | ||||
| void setFullScreen (bool shouldBeFullScreen); | void setFullScreen (bool shouldBeFullScreen); | ||||
| @@ -121,7 +120,7 @@ public: | |||||
| virtual void viewFocusLoss(); | virtual void viewFocusLoss(); | ||||
| bool isFocused() const; | bool isFocused() const; | ||||
| void grabFocus(); | void grabFocus(); | ||||
| void textInputRequired (int x, int y); | |||||
| void textInputRequired (const Point<int>& position); | |||||
| //============================================================================== | //============================================================================== | ||||
| void repaint (int x, int y, int w, int h); | void repaint (int x, int y, int w, int h); | ||||
| @@ -717,7 +716,7 @@ void UIViewComponentPeer::grabFocus() | |||||
| } | } | ||||
| } | } | ||||
| void UIViewComponentPeer::textInputRequired (int /*x*/, int /*y*/) | |||||
| void UIViewComponentPeer::textInputRequired (const Point<int>&) | |||||
| { | { | ||||
| } | } | ||||
| @@ -817,13 +816,12 @@ bool Desktop::canUseSemiTransparentWindows() throw() | |||||
| return true; | return true; | ||||
| } | } | ||||
| void Desktop::getMousePosition (int& x, int& y) throw() | |||||
| const Point<int> Desktop::getMousePosition() | |||||
| { | { | ||||
| x = juce_lastMouseX; | |||||
| y = juce_lastMouseY; | |||||
| return Point<int> (juce_lastMouseX, juce_lastMouseY); | |||||
| } | } | ||||
| void Desktop::setMousePosition (int x, int y) throw() | |||||
| void Desktop::setMousePosition (const Point<int>&) | |||||
| { | { | ||||
| } | } | ||||
| @@ -145,20 +145,19 @@ bool Desktop::canUseSemiTransparentWindows() throw() | |||||
| return true; | return true; | ||||
| } | } | ||||
| void Desktop::getMousePosition (int& x, int& y) throw() | |||||
| const Point<int> Desktop::getMousePosition() | |||||
| { | { | ||||
| const ScopedAutoReleasePool pool; | const ScopedAutoReleasePool pool; | ||||
| const NSPoint p ([NSEvent mouseLocation]); | const NSPoint p ([NSEvent mouseLocation]); | ||||
| x = roundToInt (p.x); | |||||
| y = roundToInt ([[[NSScreen screens] objectAtIndex: 0] frame].size.height - p.y); | |||||
| return Point<int> (roundToInt (p.x), roundToInt ([[[NSScreen screens] objectAtIndex: 0] frame].size.height - p.y)); | |||||
| } | } | ||||
| void Desktop::setMousePosition (int x, int y) throw() | |||||
| void Desktop::setMousePosition (const Point<int>& newPosition) | |||||
| { | { | ||||
| // this rubbish needs to be done around the warp call, to avoid causing a | // this rubbish needs to be done around the warp call, to avoid causing a | ||||
| // bizarre glitch.. | // bizarre glitch.. | ||||
| CGAssociateMouseAndMouseCursorPosition (false); | CGAssociateMouseAndMouseCursorPosition (false); | ||||
| CGWarpMouseCursorPosition (CGPointMake (x, y)); | |||||
| CGWarpMouseCursorPosition (CGPointMake (newPosition.getX(), newPosition.getY())); | |||||
| CGAssociateMouseAndMouseCursorPosition (true); | CGAssociateMouseAndMouseCursorPosition (true); | ||||
| } | } | ||||
| @@ -76,12 +76,11 @@ public: | |||||
| if (topComp->getPeer() != 0) | if (topComp->getPeer() != 0) | ||||
| { | { | ||||
| int x = 0, y = 0; | |||||
| owner->relativePositionToOtherComponent (topComp, x, y); | |||||
| const Point<int> pos (owner->relativePositionToOtherComponent (topComp, Point<int>())); | |||||
| NSRect r; | NSRect r; | ||||
| r.origin.x = (float) x; | |||||
| r.origin.y = (float) y; | |||||
| r.origin.x = (float) pos.getX(); | |||||
| r.origin.y = (float) pos.getY(); | |||||
| r.size.width = (float) owner->getWidth(); | r.size.width = (float) owner->getWidth(); | ||||
| r.size.height = (float) owner->getHeight(); | r.size.height = (float) owner->getHeight(); | ||||
| r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height); | r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height); | ||||
| @@ -135,10 +135,9 @@ public: | |||||
| void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); | void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); | ||||
| void getBounds (int& x, int& y, int& w, int& h, const bool global) const; | void getBounds (int& x, int& y, int& w, int& h, const bool global) const; | ||||
| void getBounds (int& x, int& y, int& w, int& h) const; | void getBounds (int& x, int& y, int& w, int& h) const; | ||||
| int getScreenX() const; | |||||
| int getScreenY() const; | |||||
| void relativePositionToGlobal (int& x, int& y); | |||||
| void globalPositionToRelative (int& x, int& y); | |||||
| const Point<int> getScreenPosition() const; | |||||
| const Point<int> relativePositionToGlobal (const Point<int>& relativePosition); | |||||
| const Point<int> globalPositionToRelative (const Point<int>& screenPosition); | |||||
| void setMinimised (bool shouldBeMinimised); | void setMinimised (bool shouldBeMinimised); | ||||
| bool isMinimised() const; | bool isMinimised() const; | ||||
| void setFullScreen (bool shouldBeFullScreen); | void setFullScreen (bool shouldBeFullScreen); | ||||
| @@ -199,7 +198,7 @@ public: | |||||
| virtual void viewFocusLoss(); | virtual void viewFocusLoss(); | ||||
| bool isFocused() const; | bool isFocused() const; | ||||
| void grabFocus(); | void grabFocus(); | ||||
| void textInputRequired (int x, int y); | |||||
| void textInputRequired (const Point<int>& position); | |||||
| //============================================================================== | //============================================================================== | ||||
| void repaint (int x, int y, int w, int h); | void repaint (int x, int y, int w, int h); | ||||
| @@ -858,34 +857,21 @@ void NSViewComponentPeer::getBounds (int& x, int& y, int& w, int& h) const | |||||
| getBounds (x, y, w, h, ! isSharedWindow); | getBounds (x, y, w, h, ! isSharedWindow); | ||||
| } | } | ||||
| int NSViewComponentPeer::getScreenX() const | |||||
| const Point<int> NSViewComponentPeer::getScreenPosition() const | |||||
| { | { | ||||
| int x, y, w, h; | int x, y, w, h; | ||||
| getBounds (x, y, w, h, true); | getBounds (x, y, w, h, true); | ||||
| return x; | |||||
| return Point<int> (x, y); | |||||
| } | } | ||||
| int NSViewComponentPeer::getScreenY() const | |||||
| const Point<int> NSViewComponentPeer::relativePositionToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| int x, y, w, h; | |||||
| getBounds (x, y, w, h, true); | |||||
| return y; | |||||
| } | |||||
| void NSViewComponentPeer::relativePositionToGlobal (int& x, int& y) | |||||
| { | |||||
| int wx, wy, ww, wh; | |||||
| getBounds (wx, wy, ww, wh, true); | |||||
| x += wx; | |||||
| y += wy; | |||||
| return relativePosition + getScreenPosition(); | |||||
| } | } | ||||
| void NSViewComponentPeer::globalPositionToRelative (int& x, int& y) | |||||
| const Point<int> NSViewComponentPeer::globalPositionToRelative (const Point<int>& screenPosition) | |||||
| { | { | ||||
| int wx, wy, ww, wh; | |||||
| getBounds (wx, wy, ww, wh, true); | |||||
| x -= wx; | |||||
| y -= wy; | |||||
| return screenPosition - getScreenPosition(); | |||||
| } | } | ||||
| NSRect NSViewComponentPeer::constrainRect (NSRect r) | NSRect NSViewComponentPeer::constrainRect (NSRect r) | ||||
| @@ -1125,7 +1111,7 @@ void NSViewComponentPeer::grabFocus() | |||||
| } | } | ||||
| } | } | ||||
| void NSViewComponentPeer::textInputRequired (int /*x*/, int /*y*/) | |||||
| void NSViewComponentPeer::textInputRequired (const Point<int>&) | |||||
| { | { | ||||
| } | } | ||||
| @@ -1288,13 +1274,10 @@ void NSViewComponentPeer::redirectMouseWheel (NSEvent* ev) | |||||
| void NSViewComponentPeer::showArrowCursorIfNeeded() | void NSViewComponentPeer::showArrowCursorIfNeeded() | ||||
| { | { | ||||
| if (Component::getComponentUnderMouse() == 0) | |||||
| if (Component::getComponentUnderMouse() == 0 | |||||
| && Desktop::getInstance().findComponentAt (Desktop::getInstance().getMousePosition()) == 0) | |||||
| { | { | ||||
| int mx, my; | |||||
| Desktop::getInstance().getMousePosition (mx, my); | |||||
| if (Desktop::getInstance().findComponentAt (mx, my) == 0) | |||||
| [[NSCursor arrowCursor] set]; | |||||
| [[NSCursor arrowCursor] set]; | |||||
| } | } | ||||
| } | } | ||||
| @@ -286,10 +286,9 @@ public: | |||||
| if (topComp->getPeer() != 0) | if (topComp->getPeer() != 0) | ||||
| { | { | ||||
| int x = 0, y = 0; | |||||
| owner->relativePositionToOtherComponent (topComp, x, y); | |||||
| const Point<int> pos (owner->relativePositionToOtherComponent (topComp, Point<int>())); | |||||
| owner->setControlBounds (Rectangle<int> (x, y, owner->getWidth(), owner->getHeight())); | |||||
| owner->setControlBounds (Rectangle<int> (pos.getX(), pos.getY(), owner->getWidth(), owner->getHeight())); | |||||
| } | } | ||||
| } | } | ||||
| @@ -452,9 +451,7 @@ bool ActiveXControlComponent::createControl (const void* controlIID) | |||||
| if (dynamic_cast <Win32ComponentPeer*> (peer) != 0) | if (dynamic_cast <Win32ComponentPeer*> (peer) != 0) | ||||
| { | { | ||||
| int x = 0, y = 0; | |||||
| relativePositionToOtherComponent (getTopLevelComponent(), x, y); | |||||
| const Point<int> pos (relativePositionToOtherComponent (getTopLevelComponent(), Point<int>())); | |||||
| HWND hwnd = (HWND) peer->getNativeHandle(); | HWND hwnd = (HWND) peer->getNativeHandle(); | ||||
| ScopedPointer <ActiveXControlData> info (new ActiveXControlData (hwnd, this)); | ScopedPointer <ActiveXControlData> info (new ActiveXControlData (hwnd, this)); | ||||
| @@ -469,15 +466,15 @@ bool ActiveXControlComponent::createControl (const void* controlIID) | |||||
| if (OleSetContainedObject (info->control, TRUE) == S_OK) | if (OleSetContainedObject (info->control, TRUE) == S_OK) | ||||
| { | { | ||||
| RECT rect; | RECT rect; | ||||
| rect.left = x; | |||||
| rect.top = y; | |||||
| rect.right = x + getWidth(); | |||||
| rect.bottom = y + getHeight(); | |||||
| rect.left = pos.getX(); | |||||
| rect.top = pos.getY(); | |||||
| rect.right = pos.getX() + getWidth(); | |||||
| rect.bottom = pos.getY() + getHeight(); | |||||
| if (info->control->DoVerb (OLEIVERB_SHOW, 0, info->clientSite, 0, hwnd, &rect) == S_OK) | if (info->control->DoVerb (OLEIVERB_SHOW, 0, info->clientSite, 0, hwnd, &rect) == S_OK) | ||||
| { | { | ||||
| control = info.release(); | control = info.release(); | ||||
| setControlBounds (Rectangle<int> (x, y, getWidth(), getHeight())); | |||||
| setControlBounds (Rectangle<int> (pos.getX(), pos.getY(), getWidth(), getHeight())); | |||||
| ((ActiveXControlData*) control)->controlHWND = getHWND (this); | ((ActiveXControlData*) control)->controlHWND = getHWND (this); | ||||
| @@ -590,36 +590,22 @@ public: | |||||
| h -= windowBorder.getTopAndBottom(); | h -= windowBorder.getTopAndBottom(); | ||||
| } | } | ||||
| int getScreenX() const | |||||
| const Point<int> getScreenPosition() const | |||||
| { | { | ||||
| RECT r; | RECT r; | ||||
| GetWindowRect (hwnd, &r); | GetWindowRect (hwnd, &r); | ||||
| return r.left + windowBorder.getLeft(); | |||||
| return Point<int> (r.left + windowBorder.getLeft(), | |||||
| r.top + windowBorder.getTop()); | |||||
| } | } | ||||
| int getScreenY() const | |||||
| const Point<int> relativePositionToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| RECT r; | |||||
| GetWindowRect (hwnd, &r); | |||||
| return r.top + windowBorder.getTop(); | |||||
| return relativePosition + getScreenPosition(); | |||||
| } | } | ||||
| void relativePositionToGlobal (int& x, int& y) | |||||
| const Point<int> globalPositionToRelative (const Point<int>& screenPosition) | |||||
| { | { | ||||
| RECT r; | |||||
| GetWindowRect (hwnd, &r); | |||||
| x += r.left + windowBorder.getLeft(); | |||||
| y += r.top + windowBorder.getTop(); | |||||
| } | |||||
| void globalPositionToRelative (int& x, int& y) | |||||
| { | |||||
| RECT r; | |||||
| GetWindowRect (hwnd, &r); | |||||
| x -= r.left + windowBorder.getLeft(); | |||||
| y -= r.top + windowBorder.getTop(); | |||||
| return screenPosition - getScreenPosition(); | |||||
| } | } | ||||
| void setMinimised (bool shouldBeMinimised) | void setMinimised (bool shouldBeMinimised) | ||||
| @@ -779,7 +765,7 @@ public: | |||||
| shouldDeactivateTitleBar = oldDeactivate; | shouldDeactivateTitleBar = oldDeactivate; | ||||
| } | } | ||||
| void textInputRequired (int /*x*/, int /*y*/) | |||||
| void textInputRequired (const Point<int>&) | |||||
| { | { | ||||
| if (! hasCreatedCaret) | if (! hasCreatedCaret) | ||||
| { | { | ||||
| @@ -1691,9 +1677,8 @@ private: | |||||
| HRESULT __stdcall DragEnter (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) | HRESULT __stdcall DragEnter (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) | ||||
| { | { | ||||
| updateFileList (pDataObject); | updateFileList (pDataObject); | ||||
| int x = mousePos.x, y = mousePos.y; | |||||
| owner->globalPositionToRelative (x, y); | |||||
| owner->handleFileDragMove (files, x, y); | |||||
| const Point<int> pos (owner->globalPositionToRelative (Point<int> (mousePos.x, mousePos.y))); | |||||
| owner->handleFileDragMove (files, pos.getX(), pos.getY()); | |||||
| *pdwEffect = DROPEFFECT_COPY; | *pdwEffect = DROPEFFECT_COPY; | ||||
| return S_OK; | return S_OK; | ||||
| } | } | ||||
| @@ -1706,9 +1691,8 @@ private: | |||||
| HRESULT __stdcall DragOver (DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) | HRESULT __stdcall DragOver (DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) | ||||
| { | { | ||||
| int x = mousePos.x, y = mousePos.y; | |||||
| owner->globalPositionToRelative (x, y); | |||||
| owner->handleFileDragMove (files, x, y); | |||||
| const Point<int> pos (owner->globalPositionToRelative (Point<int> (mousePos.x, mousePos.y))); | |||||
| owner->handleFileDragMove (files, pos.getX(), pos.getY()); | |||||
| *pdwEffect = DROPEFFECT_COPY; | *pdwEffect = DROPEFFECT_COPY; | ||||
| return S_OK; | return S_OK; | ||||
| } | } | ||||
| @@ -1716,9 +1700,8 @@ private: | |||||
| HRESULT __stdcall Drop (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) | HRESULT __stdcall Drop (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) | ||||
| { | { | ||||
| updateFileList (pDataObject); | updateFileList (pDataObject); | ||||
| int x = mousePos.x, y = mousePos.y; | |||||
| owner->globalPositionToRelative (x, y); | |||||
| owner->handleFileDragDrop (files, x, y); | |||||
| const Point<int> pos (owner->globalPositionToRelative (Point<int> (mousePos.x, mousePos.y))); | |||||
| owner->handleFileDragDrop (files, pos.getX(), pos.getY()); | |||||
| *pdwEffect = DROPEFFECT_COPY; | *pdwEffect = DROPEFFECT_COPY; | ||||
| return S_OK; | return S_OK; | ||||
| } | } | ||||
| @@ -2001,9 +1984,8 @@ private: | |||||
| if (LOWORD (wParam) == WA_CLICKACTIVE | if (LOWORD (wParam) == WA_CLICKACTIVE | ||||
| && component->isCurrentlyBlockedByAnotherModalComponent()) | && component->isCurrentlyBlockedByAnotherModalComponent()) | ||||
| { | { | ||||
| int mx, my; | |||||
| component->getMouseXYRelative (mx, my); | |||||
| Component* const underMouse = component->getComponentAt (mx, my); | |||||
| const Point<int> mousePos (component->getMouseXYRelative()); | |||||
| Component* const underMouse = component->getComponentAt (mousePos.getX(), mousePos.getY()); | |||||
| if (underMouse != 0 && underMouse->isCurrentlyBlockedByAnotherModalComponent()) | if (underMouse != 0 && underMouse->isCurrentlyBlockedByAnotherModalComponent()) | ||||
| Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); | Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); | ||||
| @@ -2072,8 +2054,8 @@ private: | |||||
| { | { | ||||
| const int oldModifiers = currentModifiers; | const int oldModifiers = currentModifiers; | ||||
| MouseEvent e (0, 0, ModifierKeys::getCurrentModifiersRealtime(), component, | |||||
| getMouseEventTime(), 0, 0, getMouseEventTime(), 1, false); | |||||
| MouseEvent e (Point<int>(), ModifierKeys::getCurrentModifiersRealtime(), component, | |||||
| getMouseEventTime(), Point<int>(), getMouseEventTime(), 1, false); | |||||
| if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) | if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) | ||||
| e.mods = ModifierKeys (e.mods.getRawFlags() | ModifierKeys::leftButtonModifier); | e.mods = ModifierKeys (e.mods.getRawFlags() | ModifierKeys::leftButtonModifier); | ||||
| @@ -2321,17 +2303,16 @@ bool AlertWindow::showNativeDialogBox (const String& title, | |||||
| //============================================================================== | //============================================================================== | ||||
| void Desktop::getMousePosition (int& x, int& y) throw() | |||||
| const Point<int> Desktop::getMousePosition() | |||||
| { | { | ||||
| POINT mousePos; | POINT mousePos; | ||||
| GetCursorPos (&mousePos); | GetCursorPos (&mousePos); | ||||
| x = mousePos.x; | |||||
| y = mousePos.y; | |||||
| return Point<int> (mousePos.x, mousePos.y); | |||||
| } | } | ||||
| void Desktop::setMousePosition (int x, int y) throw() | |||||
| void Desktop::setMousePosition (const Point<int>& newPosition) | |||||
| { | { | ||||
| SetCursorPos (x, y); | |||||
| SetCursorPos (newPosition.getX(), newPosition.getY()); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||