| 1876 | //----------------------------------------------------------------------------- |
| 1877 | |
| 1878 | void GuiEditCtrl::registerSnap( snappingAxis axis, const Point2I& mousePoint, const Point2I& point, snappingEdges edge, GuiControl* ctrl ) |
| 1879 | { |
| 1880 | bool takeNewSnap = false; |
| 1881 | const Point2I globalPoint = getContentControl()->localToGlobalCoord( point ); |
| 1882 | |
| 1883 | // If we have no snap yet, just take this one. |
| 1884 | |
| 1885 | if( !mSnapped[ axis ] ) |
| 1886 | takeNewSnap = true; |
| 1887 | |
| 1888 | // Otherwise see if this snap is the better one. |
| 1889 | |
| 1890 | else |
| 1891 | { |
| 1892 | // Compare deltas to pointer. |
| 1893 | |
| 1894 | S32 deltaCurrent = mAbs( mSnapOffset[ axis ] - mousePoint[ axis ] ); |
| 1895 | S32 deltaNew = mAbs( globalPoint[ axis ] - mousePoint[ axis ] ); |
| 1896 | |
| 1897 | if( deltaCurrent > deltaNew ) |
| 1898 | takeNewSnap = true; |
| 1899 | } |
| 1900 | |
| 1901 | if( takeNewSnap ) |
| 1902 | { |
| 1903 | mSnapped[ axis ] = true; |
| 1904 | mSnapOffset[ axis ] = globalPoint[ axis ]; |
| 1905 | mSnapEdge[ axis ] = edge; |
| 1906 | mSnapTargets[ axis ] = ctrl; |
| 1907 | } |
| 1908 | } |
| 1909 | |
| 1910 | //----------------------------------------------------------------------------- |
| 1911 |
nothing calls this directly
no test coverage detected