コード例 #1
0
ファイル: UIEvent.cpp プロジェクト: Joincheng/lithtech
BOOL CUIKeyEvent::IsInverse(const CUIEvent &cOther) const
{
	return (ClassName() == ((const CUIKeyEvent *)&cOther)->ClassName()) &&
		(GetCode() == ((const CUIKeyEvent *)&cOther)->GetCode()) && 
		(((GetType() == UIEVENT_KEYDOWN) && (cOther.GetType() == UIEVENT_KEYUP)) ||
		 ((GetType() == UIEVENT_KEYUP) && (cOther.GetType() == UIEVENT_KEYDOWN)));
}
コード例 #2
0
ファイル: UIEvent.cpp プロジェクト: Joincheng/lithtech
BOOL CUIMouseEvent::IsInverse(const CUIEvent &cOther) const
{
	return	(ClassName() == ((const CUIMouseEvent *)&cOther)->ClassName()) &&
			(GetButton() == ((const CUIMouseEvent *)&cOther)->GetButton()) && 
			(((GetType() == UIEVENT_MOUSEDOWN) && (cOther.GetType() == UIEVENT_MOUSEUP)) ||
			 ((GetType() == UIEVENT_MOUSEUP) && (cOther.GetType() == UIEVENT_MOUSEDOWN)));
}
コード例 #3
0
void CRegionViewCommand::SetToggle(DWORD dwIndex, const CUIEvent &cEvent)
{
    if (GetToggleCount() <= dwIndex)
        SetToggleCount(dwIndex + 1);
    delete m_cToggleList[dwIndex];
    m_cToggleList[dwIndex] = cEvent.Clone();
}
コード例 #4
0
ファイル: hotkey.cpp プロジェクト: Joincheng/lithtech
//adds a key to the list of keys needed to trigger the event
//returns true if it successful, or false if there is
//no more room to store the key
bool CHotKey::AddEvent(const CUIEvent& Event)
{
	//clone it and add it to the starting list
	CUIEvent* pClone = Event.Clone();

	//ensure it worked properly
	if(pClone == LTNULL)
	{
		return false;
	}

	//add it to the starting list
	m_StartEventList.Add(pClone);

	//find the inverse
	int nInverse = UIEVENT_NONE;

	switch(pClone->GetType())
	{
	case UIEVENT_KEYDOWN:	nInverse = UIEVENT_KEYUP;		break;
	case UIEVENT_KEYUP:		nInverse = UIEVENT_KEYDOWN;		break;
	case UIEVENT_MOUSEDOWN:	nInverse = UIEVENT_MOUSEUP;		break;
	case UIEVENT_MOUSEUP:	nInverse = UIEVENT_MOUSEDOWN;	break;
	default:				nInverse = UIEVENT_NONE;		break;
	}

	//if it was a valid inverse, lets add it to the end list
	if(nInverse != UIEVENT_NONE)
	{
		//add another clone
		pClone = Event.Clone();

		if(pClone)
		{
			//but switch this one to the inverse
			pClone->SetType(nInverse);

			m_EndEventList.Add(pClone);
		}
	}

	return true;
}
コード例 #5
0
void CRegionViewCommand::WatchEvent(const CUIEvent &cEvent)
{
    for (DWORD dwLoop = 0; dwLoop < m_cToggleList.GetSize(); dwLoop++)
    {
        if (cEvent == *m_cToggleList[dwLoop])
            m_cToggleStateList[dwLoop] = TRUE;
        else if (cEvent.IsInverse(*m_cToggleList[dwLoop]))
            m_cToggleStateList[dwLoop] = FALSE;
    }

    CRegionViewTracker::WatchEvent(cEvent);
}
コード例 #6
0
BOOL CRVTrackerPolyScale::OnUpdate(const CUIEvent &cEvent)
{
	// Only update on idle events
	if (cEvent.GetType() != UIEVENT_NONE)
		return TRUE;

	// Don't update if it hasn't moved
	if (m_cCurPt == m_cLastPt)
		return TRUE;

	CVector			newVert;
	DWORD			i;

	// Do the autoscroll of the window
	DoAutoScroll();

	CVector vNormal(0.0f,0.0f,0.0f);
	vNormal = m_vPerpNormal;

	if (m_bPerp)
	{
		for( i=0; i < m_cMovingVerts; i++ )
		{
			m_cMovingVerts[i]() -= vNormal * (CReal)(m_cCurPt.y - m_cLastPt.y);
		}
	}
	else 
	{
		CReal scaleFactor = ((CReal)(m_cLastPt.y - m_cCurPt.y)) / 100.0f;

		for( i=0; i < m_cMovingVerts; i++ )
		{
			CEditVert	&vert = m_cMovingVerts[i]();
			CVector vDiff = vert - m_vScaleRefPt;

			vDiff -= vNormal * vNormal.Dot(vDiff);

			vert += vDiff * scaleFactor;
		}
	}

	if( GetApp()->m_bFullUpdate )
	{
		m_pView->GetDocument()->UpdateAllViews(m_pView);
		m_pView->DrawRect();
	}

	m_cLastPt = m_cCurPt;

	return TRUE;
}
コード例 #7
0
BOOL CRVTrackerCurveEdit::OnUpdate(const CUIEvent &cEvent)
{
	CEditRegion *pRegion;
	CVectorProp *pProp;
	CBaseEditObj *pObj;
	CEditGrid *pGrid;
	DVector newPos, curCtrlPos;
	DWORD i;

	// Only move during idle
	if (m_bIdleOnly && (cEvent.GetType() != UIEVENT_NONE))
		return TRUE;

	// Jump out if the position hasn't moved
	if (m_cCurPt == m_cLastPt)
		return TRUE;

	pRegion = m_pView->GetRegion();
	if(m_iCurObject >= pRegion->m_Objects.GetSize())
		return FALSE;
	
	pObj = pRegion->m_Objects[m_iCurObject];
	if(m_iCurProp >= pObj->m_PropList.m_Props.GetSize())
		return FALSE;

	pProp = (CVectorProp*)pObj->m_PropList.m_Props[m_iCurProp];
	if(pProp->m_Type != LT_PT_VECTOR)
		return FALSE;

	if(!m_pView->EditGrid().IntersectRay(4, m_pView->ViewDef()->MakeRayFromScreenPoint(m_cCurPt), newPos))
		return FALSE;

	curCtrlPos = pObj->GetPos() + pProp->m_Vector;

	// Use the forward vector of the grid to determine what to set.
	pGrid = &m_pView->EditGrid();
	for(i=0; i < 3; i++)
	{
		if(fabs(pGrid->m_Forward[i]) < 0.0001f)
			curCtrlPos[i] = newPos[i];
	}

	pProp->m_Vector = curCtrlPos - pObj->GetPos();
	
	m_pView->GetDocument()->UpdateAllViews(m_pView);

	m_pView->Invalidate(TRUE);

	return TRUE;
}
コード例 #8
0
BOOL CRVTrackerMenuItem::OnUpdate( const CUIEvent& cEvent )
{
	if( cEvent.GetType() == UIEVENT_NONE )
	{
		if( m_bStart )
		{
			if( m_pView && m_pOnCommand )
			{
				// execute the command:
				(m_pView->*m_pOnCommand)();
			}
			m_bStart = FALSE;
		}
		return TRUE;
	}
	return TRUE;
}
コード例 #9
0
ファイル: hotkey.cpp プロジェクト: Joincheng/lithtech
//given a specific event, it will get the appropriate value associated
//with the type of the event
uint32 CHotKey::GetEventValue(const CUIEvent& Event)
{
	uint32 nValue = 0;
	switch(Event.GetType())
	{
	case UIEVENT_KEYDOWN:
	case UIEVENT_KEYUP:
		nValue = ((CUIKeyEvent&)Event).GetCode();
		break;
	case UIEVENT_MOUSEDOWN:
	case UIEVENT_MOUSEUP:
		nValue = ((CUIMouseEvent&)Event).GetButton();
		break;
	default:
		break;
	}

	return nValue;
}
コード例 #10
0
BOOL CRVTrackerNodeMove::OnUpdate(const CUIEvent &cEvent)
{
	// Only update on idle
	if (cEvent.GetType() != UIEVENT_NONE)
		return TRUE;

	// Don't update if it hasn't moved
	if (m_cCurPt == m_cLastPt)
		return TRUE;

	LTVector newVert, moveOffset, translateAmount;
	DWORD i, j;
	CWorldNode *pNode;
	CEditBrush *pBrush;
	CEditPoly *pPoly;

	// If the mouse is outside of the view, then autoscroll the view
	DoAutoScroll();

	// Use the current mouse position and use the delta from the last to update the 
	// position of the node in 3d views...
	if( m_pView->GetVertexFromPoint(m_cCurPt, newVert))
	{
		moveOffset = newVert - m_vStartVec;

		// Snap the movement to the current move axis (may be all axis)
		moveOffset.x *= m_vMoveSnapAxis.x;
		moveOffset.y *= m_vMoveSnapAxis.y;
		moveOffset.z *= m_vMoveSnapAxis.z;

		// If the shift key is pressed, then snap the object to horizontal or vertical movement if
		// that hasn't been done already.		
		if (m_bLockAxis)
		{
			// Make sure that there isn't currently a move axis defined
			if (m_vMoveSnapAxis == CVector(1.0f, 1.0f, 1.0f))
			{
				// Create an absolute vector so that the magnitudes can be compared
				CVector vAbsolute(fabs(m_vTotalMoveOffset.x), fabs(m_vTotalMoveOffset.y), fabs(m_vTotalMoveOffset.z));

				// Check to see if we should snap to the x axis
				if (vAbsolute.x > vAbsolute.y && vAbsolute.x > vAbsolute.z)
				{
					// Cancel the movement along the y and z axis
					moveOffset.y=(-1)*m_vTotalMoveOffset.y;
					moveOffset.z=(-1)*m_vTotalMoveOffset.z;

					m_vMoveSnapAxis=CVector(1.0f, 0.0f, 0.0f);
				}

				// Check to see if we should snap to the y axis
				if (vAbsolute.y > vAbsolute.x && vAbsolute.y > vAbsolute.z)
				{
					// Cancel the movement along the y and z axis
					moveOffset.x=(-1)*m_vTotalMoveOffset.x;
					moveOffset.z=(-1)*m_vTotalMoveOffset.z;

					m_vMoveSnapAxis=CVector(0.0f, 1.0f, 0.0f);
				}

				// Check to see if we should snap to the z axis
				if (vAbsolute.z > vAbsolute.x && vAbsolute.z > vAbsolute.y)
				{
					// Cancel the movement along the y and z axis
					moveOffset.x=(-1)*m_vTotalMoveOffset.x;
					moveOffset.y=(-1)*m_vTotalMoveOffset.y;

					m_vMoveSnapAxis=CVector(0.0f, 0.0f, 1.0f);
				}
			}
		}
		else
		{
			m_vMoveSnapAxis=CVector(1.0f, 1.0f, 1.0f);
		}

		// Update the total move offset.  This is used to snap the nodes when the shift key is pressed.
		m_vTotalMoveOffset+=moveOffset;

		// Go through all the selected nodes and move them...
		for( i=0; i < m_pView->GetRegion()->m_Selections; i++ )
		{
			pNode = m_pView->GetRegion()->m_Selections[i];

			// Handle movement for Brush nodes...
			if(pNode->GetType() == Node_Brush)
			{
				// Get the brush pointer...
				pBrush = pNode->AsBrush();

				// Check for perpendicular movement...
				if(m_bPerp)
				{
					translateAmount = -(m_pView->EditGrid().Forward() * (CReal)(m_cCurPt.y - m_cLastPt.y));
				}
				// planar movement...
				else
				{
					translateAmount = moveOffset;
				}

				for( j=0; j < pBrush->m_Points; j++ )
					pBrush->m_Points[j] += translateAmount;

				// Update the texture space on the polies that are stuck.
				for(j=0; j < pBrush->m_Polies; j++)
				{
					pPoly = pBrush->m_Polies[j];
				
					for(uint32 nCurrTex = 0; nCurrTex < CEditPoly::NUM_TEXTURES; nCurrTex++)
					{
						CTexturedPlane& Texture = pPoly->GetTexture(nCurrTex);

						pPoly->SetTextureSpace(nCurrTex, Texture.GetO() + translateAmount, Texture.GetP(), Texture.GetQ());
					}
				}

				m_pView->GetRegion()->UpdateBrush(pBrush);
			}
			// Handle movement for object nodes...
			else if((pNode->GetType() == Node_Object) || 
					(pNode->GetType() == Node_PrefabRef))
			{
				// Check if perpendicular movement...
				if(m_bPerp)
				{
					LTVector vCurPos = pNode->GetPos();
					vCurPos -= m_pView->EditGrid().Forward() * (CReal)(m_cCurPt.y - m_cLastPt.y);
					pNode->SetPos(vCurPos);
				}
				// planar movement...
				else
				{
					pNode->SetPos(pNode->GetPos() + moveOffset);
				}
			}
		}

		// Update starting vertex for next pass...
		m_vStartVec = newVert;
	}

	// If user wants all the views updated, then do it...
	if( GetApp()->m_bFullUpdate )
	{
		m_pView->GetDocument()->UpdateAllViews(m_pView);
		m_pView->DrawRect();
	}

	m_cLastPt = m_cCurPt;

	return TRUE;
}
コード例 #11
0
BOOL CRVTrackerDrawPoly::OnUpdate(const CUIEvent &cEvent)
{

	//see if they want to finish drawing the polygon
	if(m_bFinishDrawingPoly)
	{
		// Make sure we don't cancel when the focus goes away
		m_bAllowCancel = FALSE;
		// Create the brush
		m_pView->FinishDrawingPoly();
		m_bAllowCancel = TRUE;

		//we are no longer drawing a poly, so we can start another one
		m_bFinishDrawingPoly = FALSE;

		return FALSE;
	}

	BOOL bCancel = FALSE;

	// Handle any events that happen
	if (m_pUndoTracker)
	{
		BOOL bOldActive = m_pUndoTracker->GetActive();
		m_pUndoTracker->ProcessEvent(cEvent);
		if((bOldActive == FALSE) && m_pUndoTracker->GetActive())
			bCancel = OnUndo();
	}
	if (m_pNewVertexTracker)
	{
		BOOL bOldActive = m_pNewVertexTracker->GetActive();
		m_pNewVertexTracker->ProcessEvent(cEvent);
		if((bOldActive == FALSE) && m_pNewVertexTracker->GetActive())
			bCancel = OnNewVertex();
	}
	if (m_pSplitTracker)
	{
		BOOL bOldActive = m_pSplitTracker->GetActive();
		m_pSplitTracker->ProcessEvent(cEvent);
		if((bOldActive == FALSE) && m_pSplitTracker->GetActive())
			bCancel = OnSplit();
	}
	if (m_pRotateTracker)
	{
		BOOL bOldActive = m_pRotateTracker->GetActive();
		m_pRotateTracker->ProcessEvent(cEvent);
		if((bOldActive == FALSE) && m_pRotateTracker->GetActive())
			bCancel = OnRotate();
	}
	if (m_pInsertEdgeTracker)
	{
		BOOL bOldActive = m_pInsertEdgeTracker->GetActive();
		m_pInsertEdgeTracker->ProcessEvent(cEvent);
		if((bOldActive == FALSE) && m_pInsertEdgeTracker->GetActive())
			bCancel = OnNewEdge();
	}
	if(m_pVertSnapTracker)
	{
		m_pVertSnapTracker->ProcessEvent(cEvent);
		m_bVertSnap = m_pVertSnapTracker->GetActive();
	}
	if(m_pCloseTracker)
	{
		BOOL bOldActive = m_pCloseTracker->GetActive();
		m_pCloseTracker->ProcessEvent(cEvent);
		if((bOldActive == FALSE) && m_pCloseTracker->GetActive())
			bCancel = ClosePoly();
	}

		

	if (bCancel)
		// End the tracker 
		return FALSE;

	// Only update everything else on idle events
	if (cEvent.GetType() != UIEVENT_NONE)
		return TRUE;

	// Don't update if it hasn't moved
	if (m_cCurPt == m_cLastPt)
		return TRUE;

	// Do the autoscroll of the window
	DoAutoScroll();

	switch( m_pView->m_EditState )
	{
		case EDIT_DRAWINGPOLY:
		{
			UpdateDrawPolyVertex(m_cCurPt);
			break;
		}
	}


	// Update the views...
	m_pView->GetDocument()->UpdateAllViews(m_pView);
	m_pView->DrawRect();

	m_cLastPt = m_cCurPt;

	return TRUE;
}
コード例 #12
0
BOOL CRVTrackerExtrudePoly::OnUpdate(const CUIEvent &cEvent)
{
	// Only update on idle events
	if (cEvent.GetType() != UIEVENT_NONE)
		return TRUE;

	// Don't update if it hasn't moved
	if (m_cCurPt == m_cLastPt)
		return TRUE;

	//find the delta we moved
	float fDelta = (float)(m_cCurPt.y - m_cLastPt.y);

	//keep track of our old moved amount
	float fOldMove = m_fTotalMoved;	
	
	//update our total moved amount
	m_fTotalMoved += fDelta;

	//the amount we will want to offset
	float fOffset;

	if(m_bSnap)
	{
		//get our grid size
		float fGridSize = (float)m_pView->GetGridSpacing();

		//find our snap position of the original pos
		float fOldSnapPos = fOldMove - (float)fmod(fOldMove, fGridSize);

		//get our new snap position
		float fNewSnapPos = m_fTotalMoved - (float)fmod(m_fTotalMoved, fGridSize);

		//now find the total offset
		fOffset = fNewSnapPos - fOldSnapPos;
	}
	else
	{
		fOffset = fDelta;
	}

	if(fabs(fOffset) > 0.01f)
	{
		for(uint32 i=0; i < m_cMovingVerts; i++ )
		{
			m_cMovingVerts[i]() -= m_vPerpNormal * fOffset;
			m_cMovingVerts[i].m_pBrush->UpdateBoundingInfo();
		}

		if( GetApp()->m_bFullUpdate )
		{
			m_pView->GetDocument()->UpdateAllViews(m_pView);
			m_pView->DrawRect();
		}
	}

	CenterCursor();

	//m_cLastPt = m_cCurPt;

	return TRUE;
}
コード例 #13
0
ファイル: RVTrackerZoom.cpp プロジェクト: Joincheng/lithtech
BOOL CRVTrackerZoom::OnUpdate(const CUIEvent &cEvent)
{
	// Only move during idle
	if (m_bIdleOnly && (cEvent.GetType() != UIEVENT_NONE))
		return TRUE;

	int32 zDelta = GetWheelDelta();

	if( zDelta == 0 )
		return FALSE;

	BOOL bZoomToCursor = GetApp()->GetOptions().GetControlsOptions()->IsZoomToCursor();

	//clear out the wheel delta
	SetWheelDelta( 0 );

	CNavigator *pNav = &m_pView->Nav();

	// Set the initial speed value
	float fSpeed = (m_bFast) ? 3.0f : 0.5f;

	//see if we are in a parallel viewport
	if( m_pView->IsParallelViewType() )
	{
		

		//see if we want to zoom to the cursor
		if(bZoomToCursor)
		{
			// Convert cursor position to world coordinates:
			CVector vCursor;
			CRect rect;
			m_pView->GetWindowRect( &rect );
			CPoint cursorPt = m_cCurPt;
			m_pView->GetVertexFromPoint( cursorPt, vCursor, FALSE );

			// Zoom:
			m_pView->ViewDef()->m_Magnify += ((CReal)zDelta * m_pView->ViewDef()->m_Magnify) / 300.0f;
			if( m_pView->ViewDef()->m_Magnify < 0.0001f )
				m_pView->ViewDef()->m_Magnify = 0.0001f;

			CVector vCursor2;
			m_pView->GetVertexFromPoint( cursorPt, vCursor2, FALSE );
			// This effectively makes the cursor position the focal point for the zoom.
			pNav->Pos() += vCursor - vCursor2;  
		}
		else
		{
			//we just want to zoom in
			m_pView->ViewDef()->m_Magnify += ((CReal)zDelta * m_pView->ViewDef()->m_Magnify) / 300.0f;
			if( m_pView->ViewDef()->m_Magnify < 0.0001f )
				m_pView->ViewDef()->m_Magnify = 0.0001f;
		}
		
	}
	//Walk-through, meaning that we take a ray through the screen
	else 
	{
		//we are in a perspective viewport.

		if(!bZoomToCursor)
		{
			pNav->Pos() += pNav->Forward() * (float)zDelta * fSpeed;
		}
		else
		{
			CEditRay ray = m_pView->ViewDef()->MakeRayFromScreenPoint( m_cCurPt );
			CVector forward = ray.m_Dir;
			forward.Norm();
			pNav->Pos() += forward * ((CReal)zDelta * fSpeed);
		}
	}

	m_pView->Invalidate();

	return TRUE;
}