| 820 | //----------------------------------------------------------------------------- |
| 821 | |
| 822 | void GuiWindowCtrl::onMouseDragged(const GuiEvent &event) |
| 823 | { |
| 824 | GuiControl *parent = getParent(); |
| 825 | GuiCanvas *root = getRoot(); |
| 826 | if ( !root ) |
| 827 | return; |
| 828 | |
| 829 | mMousePosition = globalToLocalCoord(event.mousePoint); |
| 830 | Point2I deltaMousePosition = event.mousePoint - mMouseDownPosition; |
| 831 | |
| 832 | Point2I newPosition = getPosition(); |
| 833 | Point2I newExtent = getExtent(); |
| 834 | bool resizeX = false; |
| 835 | bool resizeY = false; |
| 836 | mResizeWindow = false; |
| 837 | mRepositionWindow = false; |
| 838 | |
| 839 | if (mMouseMovingWin && parent) |
| 840 | { |
| 841 | if( parent != root ) |
| 842 | { |
| 843 | newPosition.x = mOrigBounds.point.x + deltaMousePosition.x; |
| 844 | newPosition.y = getMax(0, mOrigBounds.point.y + deltaMousePosition.y ); |
| 845 | mRepositionWindow = true; |
| 846 | } |
| 847 | else |
| 848 | { |
| 849 | newPosition.x = getMax(0, getMin(parent->getWidth() - getWidth(), mOrigBounds.point.x + deltaMousePosition.x)); |
| 850 | newPosition.y = getMax(0, getMin(parent->getHeight() - getHeight(), mOrigBounds.point.y + deltaMousePosition.y)); |
| 851 | } |
| 852 | |
| 853 | // Check snapping to other windows |
| 854 | if( mEdgeSnap ) |
| 855 | { |
| 856 | RectI bounds = getGlobalBounds(); |
| 857 | bounds.point = mOrigBounds.point + deltaMousePosition; |
| 858 | EdgeRectI edges = EdgeRectI( bounds, mResizeMargin ); |
| 859 | |
| 860 | // Create a global-space rectangle that covers the snapping |
| 861 | // zone of this window. Double the space in which snapping occurs |
| 862 | // for top and bottom. |
| 863 | RectI snapZone = bounds; |
| 864 | snapZone.point.x -= SnapDistance; |
| 865 | snapZone.point.y -= SnapDistance; |
| 866 | snapZone.extent.x += SnapDistance + SnapDistance; |
| 867 | snapZone.extent.y += SnapDistance + SnapDistance; |
| 868 | |
| 869 | //check if we need to offset because of the menubar |
| 870 | U32 menuBarHeight = 0; |
| 871 | GuiCanvas* guiCanvas = getRoot(); |
| 872 | if (guiCanvas) |
| 873 | { |
| 874 | #ifdef TORQUE_TOOLS |
| 875 | GuiMenuBar* menuBar = dynamic_cast<GuiMenuBar*>(guiCanvas->getMenuBar()); |
| 876 | if (menuBar) |
| 877 | { |
| 878 | menuBarHeight = menuBar->getHeight(); |
| 879 | } |
nothing calls this directly
no test coverage detected