Esempio n. 1
0
void Viewport::MouseDown(const Helium::MouseButtonInput& input)
{
	// reset drag mode
	m_DragMode = DragModes::None;

	// are we going to allow entering select drag?
	bool allowSelection = true;

	// if the camera modifier key is down
	if (input.AltIsDown())
	{
		m_Cameras[m_CameraMode].MouseDown( input );

		// camera now owns the drag
		m_DragMode = DragModes::Camera;

		// do NOT allow selection while moving the camera
		allowSelection = false;

		// Save the previous view before it is updated
		UpdateCameraHistory();   
	}
	else if (m_Tool) // else if we have a tool object
	{
		// hit test the tool, and if we intersect or its a tool modifier mouse key
		if (m_Tool->MouseDown( input ) || input.MiddleDown() || input.RightDown())
		{
			// the tool now owns this drag
			m_DragMode = DragModes::Tool;
		}
		else
		{
			// we can still allow selection if it didn't hit he tool
			allowSelection = m_Tool->AllowSelection();
		}
	}

	// if its the left key if we are still looking for a selection
	if ( (input.LeftIsDown() || input.MiddleIsDown()) && m_DragMode == DragModes::None && allowSelection )
	{
		// we are selecting
		m_DragMode = DragModes::Select;

		// reset point trackers
		m_Start = Point (input.GetPosition().x, input.GetPosition().y);
		m_End = Point (input.GetPosition().x, input.GetPosition().y);

		// reset selection frame
		m_SelectionFrame->m_Start = m_Start;
		m_SelectionFrame->m_End = m_End;
		m_SelectionFrame->Update();

		// if we are highlighting
		if ( m_Highlighting )
		{
			// clear the previously highlighted set
			m_ClearHighlight.Raise( ClearHighlightArgs (false) );
		}
	}
}