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

Method getCursor

Engine/source/gui/editor/guiEditCtrl.cpp:2323–2394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2321//-----------------------------------------------------------------------------
2322
2323void GuiEditCtrl::getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent)
2324{
2325 GuiCanvas *pRoot = getRoot();
2326 if( !pRoot )
2327 return;
2328
2329 showCursor = false;
2330 cursor = NULL;
2331
2332 Point2I ctOffset;
2333 Point2I cext;
2334 GuiControl *ctrl;
2335
2336 Point2I mousePos = globalToLocalCoord(lastGuiEvent.mousePoint);
2337
2338 PlatformWindow *pWindow = static_cast<GuiCanvas*>(getRoot())->getPlatformWindow();
2339 AssertFatal(pWindow != NULL,"GuiControl without owning platform window! This should not be possible.");
2340 PlatformCursorController *pController = pWindow->getCursorController();
2341 AssertFatal(pController != NULL,"PlatformWindow without an owned CursorController!");
2342
2343 S32 desiredCursor = PlatformCursorController::curArrow;
2344
2345 // first see if we hit a sizing knob on the currently selected control...
2346 if (mSelectedControls.size() == 1 )
2347 {
2348 ctrl = mSelectedControls.first();
2349 cext = ctrl->getExtent();
2350 ctOffset = globalToLocalCoord(ctrl->localToGlobalCoord(Point2I(0,0)));
2351 RectI box(ctOffset.x,ctOffset.y,cext.x, cext.y);
2352
2353 GuiEditCtrl::sizingModes sizeMode = (GuiEditCtrl::sizingModes)getSizingHitKnobs(mousePos, box);
2354
2355 if( mMouseDownMode == SizingSelection )
2356 {
2357 if ( ( mSizingMode == ( sizingBottom | sizingRight ) ) || ( mSizingMode == ( sizingTop | sizingLeft ) ) )
2358 desiredCursor = PlatformCursorController::curResizeNWSE;
2359 else if ( ( mSizingMode == ( sizingBottom | sizingLeft ) ) || ( mSizingMode == ( sizingTop | sizingRight ) ) )
2360 desiredCursor = PlatformCursorController::curResizeNESW;
2361 else if ( mSizingMode == sizingLeft || mSizingMode == sizingRight )
2362 desiredCursor = PlatformCursorController::curResizeVert;
2363 else if (mSizingMode == sizingTop || mSizingMode == sizingBottom )
2364 desiredCursor = PlatformCursorController::curResizeHorz;
2365 }
2366 else
2367 {
2368 // Check for current mouse position after checking for actual sizing mode
2369 if ( ( sizeMode == ( sizingBottom | sizingRight ) ) || ( sizeMode == ( sizingTop | sizingLeft ) ) )
2370 desiredCursor = PlatformCursorController::curResizeNWSE;
2371 else if ( ( sizeMode == ( sizingBottom | sizingLeft ) ) || ( sizeMode == ( sizingTop | sizingRight ) ) )
2372 desiredCursor = PlatformCursorController::curResizeNESW;
2373 else if (sizeMode == sizingLeft || sizeMode == sizingRight )
2374 desiredCursor = PlatformCursorController::curResizeVert;
2375 else if (sizeMode == sizingTop || sizeMode == sizingBottom )
2376 desiredCursor = PlatformCursorController::curResizeHorz;
2377 }
2378 }
2379
2380 if( mMouseDownMode == MovingSelection && cursor == NULL )

Callers

nothing calls this directly

Calls 9

getPlatformWindowMethod · 0.80
getCursorControllerMethod · 0.80
getExtentMethod · 0.80
localToGlobalCoordMethod · 0.80
popCursorMethod · 0.80
pushCursorMethod · 0.80
Point2IClass · 0.50
sizeMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected