MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / doGuideSnap

Method doGuideSnap

Engine/source/gui/editor/guiEditCtrl.cpp:2097–2148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2095//-----------------------------------------------------------------------------
2096
2097void GuiEditCtrl::doGuideSnap( const GuiEvent& event, const RectI& selectionBounds, const RectI& selectionBoundsGlobal, Point2I& delta )
2098{
2099 if( !mSnapToGuides )
2100 return;
2101
2102 Point2I min = getContentControl()->localToGlobalCoord( selectionBounds.point + delta );
2103 Point2I mid = min + selectionBounds.extent / 2;
2104 Point2I max = min + selectionBounds.extent - Point2I( 1, 1 );
2105
2106 for( U32 axis = 0; axis < 2; ++ axis )
2107 {
2108 if( mSnapToEdges )
2109 {
2110 S32 guideMin = -1;
2111 S32 guideMax = -1;
2112
2113 if( mSizingMode == sizingNone ||
2114 ( axis == 0 && mSizingMode & sizingLeft ) ||
2115 ( axis == 1 && mSizingMode & sizingTop ) )
2116 guideMin = findGuide( ( guideAxis ) axis, min, mSnapSensitivity );
2117 if( mSizingMode == sizingNone ||
2118 ( axis == 0 && mSizingMode & sizingRight ) ||
2119 ( axis == 1 && mSizingMode & sizingBottom ) )
2120 guideMax = findGuide( ( guideAxis ) axis, max, mSnapSensitivity );
2121
2122 Point2I pos( 0, 0 );
2123
2124 if( guideMin != -1 )
2125 {
2126 pos[ axis ] = mGuides[ axis ][ guideMin ];
2127 registerSnap( ( snappingAxis ) axis, event.mousePoint, pos, SnapEdgeMin );
2128 }
2129
2130 if( guideMax != -1 )
2131 {
2132 pos[ axis ] = mGuides[ axis ][ guideMax ];
2133 registerSnap( ( snappingAxis ) axis, event.mousePoint, pos, SnapEdgeMax );
2134 }
2135 }
2136
2137 if( mSnapToCenters && mSizingMode == sizingNone )
2138 {
2139 const S32 guideMid = findGuide( ( guideAxis ) axis, mid, mSnapSensitivity );
2140 if( guideMid != -1 )
2141 {
2142 Point2I pos( 0, 0 );
2143 pos[ axis ] = mGuides[ axis ][ guideMid ];
2144 registerSnap( ( snappingAxis ) axis, event.mousePoint, pos, SnapEdgeMid );
2145 }
2146 }
2147 }
2148}
2149
2150//-----------------------------------------------------------------------------
2151

Callers

nothing calls this directly

Calls 3

getContentControlFunction · 0.85
localToGlobalCoordMethod · 0.80
Point2IClass · 0.50

Tested by

no test coverage detected