void VEditorScrollControl::onMouseEvent( const char *pEventName, const GuiEvent &pEvent ) { const S32 offsetX = ( mHasVScrollBar ) ? mScrollBarThickness : 0; const S32 offsetY = ( mHasHScrollBar ) ? mScrollBarThickness : 0; const RectI contentRect( 2, 2, getWidth() - offsetX - 4 - 1, getHeight() - offsetY - 4 - ( mHasHScrollBar ) ); if ( !contentRect.pointInRect( pEvent.mousePoint ) ) { // Return! return; } // Argument Buffers. char argBuffer[3][32]; // Format Event-Position Buffer. dSprintf( argBuffer[0], 32, "%d %d", pEvent.mousePoint.x, pEvent.mousePoint.y ); // Format Event-Modifier Buffer. dSprintf( argBuffer[1], 32, "%d", pEvent.modifier ); // Format Mouse-Click Count Buffer. dSprintf( argBuffer[2], 32, "%d", pEvent.mouseClickCount ); // Call Scripts. Con::executef( this, pEventName, argBuffer[0], argBuffer[1], argBuffer[2] ); }
void GuiRiverEditorCtrl::_drawRiverControlNodes( River *river, const ColorI &color ) { if ( !River::smShowSpline ) return; RectI bounds = getBounds(); GFXDrawUtil *drawer = GFX->getDrawUtil(); bool isSelected = ( river == mSelRiver ); bool isHighlighted = ( river == mHoverRiver ); for ( U32 i = 0; i < river->mNodes.size(); i++ ) { if ( false && isSelected && mSelNode == i ) continue; const Point3F &wpos = river->mNodes[i].point; Point3F spos; project( wpos, &spos ); if ( spos.z > 1.0f ) continue; Point2I posi; posi.x = spos.x; posi.y = spos.y; if ( !bounds.pointInRect( posi ) ) continue; ColorI theColor = color; Point2I nodeHalfSize = mNodeHalfSize; if ( isHighlighted && mHoverNode == i ) { //theColor = mHoverNodeColor; nodeHalfSize += Point2I(2,2); } if ( isSelected ) { if ( mSelNode == i ) { theColor.set(0,0,255); } else if ( i == 0 ) { theColor.set(0,255,0); } else if ( i == river->mNodes.size() - 1 ) { theColor.set(255,0,0); } } drawer->drawRectFill( posi - nodeHalfSize, posi + nodeHalfSize, theColor ); } }
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; } }
//-------------------------------------------------------------------------- void GuiColorPickerCtrl::setSelectorPos(const Point2I &pos) { Point2I extent = getExtent(); RectI rect; if (mDisplayMode != pDropperBackground) { extent.x -= 3; extent.y -= 2; rect = RectI(Point2I(1,1), extent); } else { rect = RectI(Point2I(0,0), extent); } if (rect.pointInRect(pos)) { mSelectorPos = pos; mPositionChanged = true; // We now need to update setUpdate(); } else { if ((pos.x > rect.point.x) && (pos.x < (rect.point.x + rect.extent.x))) mSelectorPos.x = pos.x; else if (pos.x <= rect.point.x) mSelectorPos.x = rect.point.x; else if (pos.x >= (rect.point.x + rect.extent.x)) mSelectorPos.x = rect.point.x + rect.extent.x - 1; if ((pos.y > rect.point.y) && (pos.y < (rect.point.y + rect.extent.y))) mSelectorPos.y = pos.y; else if (pos.y <= rect.point.y) mSelectorPos.y = rect.point.y; else if (pos.y >= (rect.point.y + rect.extent.y)) mSelectorPos.y = rect.point.y + rect.extent.y - 1; mPositionChanged = true; setUpdate(); } }