bool EditTSCtrl::onInputEvent(const InputEventInfo & event) { if(mRightMousePassThru && event.deviceType == MouseDeviceType && event.objInst == KEY_BUTTON1 && event.action == SI_BREAK) { // if the right mouse pass thru is enabled, // we want to reactivate mouse on a right mouse button up GuiCanvas *pCanvas = getRoot(); if( !pCanvas ) return false; PlatformWindow *pWindow = static_cast<GuiCanvas*>(getRoot())->getPlatformWindow(); if( !pWindow ) return false; PlatformCursorController *pController = pWindow->getCursorController(); if( !pController ) return false; pWindow->setMouseLocked(false); pCanvas->setCursorON( true ); if(mDisplayType != DisplayTypePerspective) { mouseUnlock(); pCanvas->setForceMouseToGUI(false); pCanvas->setClampTorqueCursor(mLastMouseClamping); } } if(mMiddleMousePassThru && event.deviceType == MouseDeviceType && event.objInst == KEY_BUTTON2 && event.action == SI_BREAK) { // if the middle mouse pass thru is enabled, // we want to reactivate mouse on a middle mouse button up GuiCanvas *pCanvas = getRoot(); if( !pCanvas ) return false; PlatformWindow *pWindow = static_cast<GuiCanvas*>(getRoot())->getPlatformWindow(); if( !pWindow ) return false; PlatformCursorController *pController = pWindow->getCursorController(); if( !pController ) return false; pWindow->setMouseLocked(false); pCanvas->setCursorON( true ); } // we return false so that the canvas can properly process the right mouse button up... return false; }
void GuiDecalEditorCtrl::get3DCursor( GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_ ) { cursor = NULL; visible = false; GuiCanvas *root = getRoot(); if ( !root ) return; S32 currCursor = PlatformCursorController::curArrow; if ( root->mCursorChanged == currCursor ) return; PlatformWindow *window = root->getPlatformWindow(); PlatformCursorController *controller = window->getCursorController(); // We've already changed the cursor, // so set it back before we change it again. if( root->mCursorChanged != -1) controller->popCursor(); // Now change the cursor shape controller->pushCursor(currCursor); root->mCursorChanged = currCursor; }
void EditTSCtrl::onMiddleMouseDown(const GuiEvent & event) { mMiddleMouseDown = true; mMiddleMouseTriggered = false; mLastBorderMoveTime = 0; if(!mLeftMouseDown && !mRightMouseDown && mMiddleMousePassThru && mProfile->mCanKeyFocus) { GuiCanvas *pCanvas = getRoot(); if( !pCanvas ) return; PlatformWindow *pWindow = static_cast<GuiCanvas*>(getRoot())->getPlatformWindow(); if( !pWindow ) return; PlatformCursorController *pController = pWindow->getCursorController(); if( !pController ) return; // ok, gotta disable the mouse // script functions are lockMouse(true); Canvas.cursorOff(); pWindow->setMouseLocked(true); pCanvas->setCursorON( false ); // Trigger 2 is used by the camera MoveManager::mTriggerCount[2]++; mMiddleMouseTriggered = true; setFirstResponder(); } }
void ForestEditorCtrl::onSleep() { // Pop our default cursor off. GuiCanvas *root = getRoot(); if ( root ) { PlatformWindow *window = root->getPlatformWindow(); PlatformCursorController *controller = window->getCursorController(); controller->popCursor(); } Parent::onSleep(); }
void GuiSplitContainer::getCursor( GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent ) { GuiCanvas *rootCtrl = getRoot(); if ( !rootCtrl ) return; S32 desiredCursor = 0; RectI splitRect = getSplitRect(); // Figure out which cursor we want if we need one if ( mOrientation == Horizontal ) desiredCursor = PlatformCursorController::curResizeHorz; else if ( mOrientation == Vertical ) desiredCursor = PlatformCursorController::curResizeVert; PlatformWindow *platformWindow = static_cast<GuiCanvas*>(getRoot())->getPlatformWindow(); AssertFatal( platformWindow != NULL,"GuiControl without owning platform window! This should not be possible." ); PlatformCursorController *cusrorController = platformWindow->getCursorController(); AssertFatal( cusrorController != NULL,"PlatformWindow without an owned CursorController!" ); // Check to see if we need one or just the default... Point2I localPoint = Point2I( globalToLocalCoord( lastGuiEvent.mousePoint ) ); if ( splitRect.pointInRect( localPoint ) || mDragging ) { // Do we need to change it or is it already set? if ( rootCtrl->mCursorChanged != desiredCursor ) { // We've already changed the cursor, so set it back if ( rootCtrl->mCursorChanged != -1 ) cusrorController->popCursor(); // Now change the cursor shape cusrorController->pushCursor( desiredCursor ); rootCtrl->mCursorChanged = desiredCursor; } } else if ( rootCtrl->mCursorChanged != -1 ) { // Just the default cusrorController->popCursor(); rootCtrl->mCursorChanged = -1; } }
bool ForestEditorCtrl::onWake() { if ( !Parent::onWake() ) return false; // Push our default cursor on here once. GuiCanvas *root = getRoot(); if ( root ) { S32 currCursor = PlatformCursorController::curArrow; PlatformWindow *window = root->getPlatformWindow(); PlatformCursorController *controller = window->getCursorController(); controller->pushCursor( currCursor ); } return true; }
void EditTSCtrl::onRightMouseDown(const GuiEvent & event) { // always process the right mouse event first... mRightMouseDown = true; mLastBorderMoveTime = 0; make3DMouseEvent(mLastEvent, event); on3DRightMouseDown(mLastEvent); if(!mLeftMouseDown && mRightMousePassThru && mProfile->mCanKeyFocus) { GuiCanvas *pCanvas = getRoot(); if( !pCanvas ) return; PlatformWindow *pWindow = static_cast<GuiCanvas*>(getRoot())->getPlatformWindow(); if( !pWindow ) return; PlatformCursorController *pController = pWindow->getCursorController(); if( !pController ) return; // ok, gotta disable the mouse // script functions are lockMouse(true); Canvas.cursorOff(); pWindow->setMouseLocked(true); pCanvas->setCursorON( false ); if(mDisplayType != DisplayTypePerspective) { mouseLock(); mLastMousePos = event.mousePoint; pCanvas->setForceMouseToGUI(true); mLastMouseClamping = pCanvas->getClampTorqueCursor(); pCanvas->setClampTorqueCursor(false); } if(mDisplayType == DisplayTypeIsometric) { // Store the screen center point on the terrain for a possible rotation TerrainBlock* activeTerrain = getActiveTerrain(); if( activeTerrain ) { F32 extx, exty; if(event.modifier & SI_SHIFT) { extx = F32(event.mousePoint.x); exty = F32(event.mousePoint.y); } else { extx = getExtent().x * 0.5; exty = getExtent().y * 0.5; } Point3F sp(extx, exty, 0.0f); // Near plane projection Point3F start; unproject(sp, &start); Point3F end = start + mLastEvent.vec * 4000.0f; Point3F tStartPnt, tEndPnt; activeTerrain->getTransform().mulP(start, &tStartPnt); activeTerrain->getTransform().mulP(end, &tEndPnt); RayInfo info; bool result = activeTerrain->castRay(tStartPnt, tEndPnt, &info); if(result) { info.point.interpolate(start, end, info.t); mIsoCamRotCenter = info.point; } else { mIsoCamRotCenter = start; } } else { F32 extx = getExtent().x * 0.5; F32 exty = getExtent().y * 0.5; Point3F sp(extx, exty, 0.0f); // Near plane projection unproject(sp, &mIsoCamRotCenter); } } setFirstResponder(); } }