| 1863 | //----------------------------------------------------------------------------- |
| 1864 | |
| 1865 | void GuiEditCtrl::registerSnap( snappingAxis axis, const Point2I& mousePoint, const Point2I& point, snappingEdges edge, GuiControl* ctrl ) |
| 1866 | { |
| 1867 | bool takeNewSnap = false; |
| 1868 | const Point2I globalPoint = getContentControl()->localToGlobalCoord( point ); |
| 1869 | |
| 1870 | // If we have no snap yet, just take this one. |
| 1871 | |
| 1872 | if( !mSnapped[ axis ] ) |
| 1873 | takeNewSnap = true; |
| 1874 | |
| 1875 | // Otherwise see if this snap is the better one. |
| 1876 | |
| 1877 | else |
| 1878 | { |
| 1879 | // Compare deltas to pointer. |
| 1880 | |
| 1881 | S32 deltaCurrent = mAbs( mSnapOffset[ axis ] - mousePoint[ axis ] ); |
| 1882 | S32 deltaNew = mAbs( globalPoint[ axis ] - mousePoint[ axis ] ); |
| 1883 | |
| 1884 | if( deltaCurrent > deltaNew ) |
| 1885 | takeNewSnap = true; |
| 1886 | } |
| 1887 | |
| 1888 | if( takeNewSnap ) |
| 1889 | { |
| 1890 | mSnapped[ axis ] = true; |
| 1891 | mSnapOffset[ axis ] = globalPoint[ axis ]; |
| 1892 | mSnapEdge[ axis ] = edge; |
| 1893 | mSnapTargets[ axis ] = ctrl; |
| 1894 | } |
| 1895 | } |
| 1896 | |
| 1897 | //----------------------------------------------------------------------------- |
| 1898 |
nothing calls this directly
no test coverage detected