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

Method doGuideSnap

Engine/source/gui/editor/guiEditCtrl.cpp:2110–2161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

getContentControlFunction · 0.85
localToGlobalCoordMethod · 0.80
Point2IClass · 0.50

Tested by

no test coverage detected