Ejemplo n.º 1
0
void ViewCanvas::OnMouseMove(wxMouseEvent& e)
{
    // Grab focus on mouse move if our top level window is active
    if ( !m_Focused )
    {
        wxWindow* parent = GetParent();
        while ( !parent->IsTopLevel() )
            parent = parent->GetParent();

        wxTopLevelWindow* topLevel = reinterpret_cast< wxTopLevelWindow* >( parent );
        if ( topLevel->IsActive() )
        {
            SetFocus();
        }
    }

    if (m_Focused)
    {
        Helium::MouseMoveInput input;
        Helium::ConvertEvent( e, input );
        m_Viewport.MouseMove( input );
        e.Skip( input.GetSkipped() );

        Refresh();
        Update();
    }
}
Ejemplo n.º 2
0
///////////////////////////////////////////////////////////////////////////////
// Move the camera.
// 
void RenderWindow::OnMouseMove( wxMouseEvent& args )
{
    args.Skip();

    if ( HasCapture() )
    {
        Helium::MouseMoveInput input;
        Helium::ConvertEvent( args, input );
        m_Camera.MouseMove( input );
        args.Skip( input.GetSkipped() );

        Refresh();
    }
}
Ejemplo n.º 3
0
void Viewport::MouseMove( const Helium::MouseMoveInput& input )
{
	// this sucks, be we don't get a keyup for alt
	if (m_DragMode == DragModes::Camera && !input.AltIsDown())
	{
		m_DragMode = DragModes::None;
	}

	int highlightStartX = -1, highlightStartY = -1, highlightEndX = -1, highlightEndY = -1;

	switch (m_DragMode)
	{
	case DragModes::None:
		{
			// setup highlight
			if ( m_Highlighting && (!m_Tool || m_Tool->AllowSelection()) )
			{
				highlightStartX = highlightEndX = input.GetPosition().x;
				highlightStartY = highlightEndY = input.GetPosition().y;
			}

			if ( m_Tool )
			{
				m_Tool->MouseMove( input );
			}

			break;
		}

	case DragModes::Select:
		{
			m_End = Point (input.GetPosition().x, input.GetPosition().y);
			m_SelectionFrame->m_End = m_End;
			m_SelectionFrame->Update();

			if ( !m_Tool || m_Tool->AllowSelection() )
			{
				// setup highlight
				highlightStartX = m_SelectionFrame->m_Start.x;
				highlightStartY = m_SelectionFrame->m_Start.y;
				highlightEndX = input.GetPosition().x;
				highlightEndY = input.GetPosition().y;
			}

			break;
		}

	case DragModes::Camera:
		{
			if (input.AltIsDown())
			{
				m_Cameras[m_CameraMode].MouseMove( input );
			}

			break;
		}

	case DragModes::Tool:
		{
			if (m_Tool)
			{
				if ( m_Tool->AllowSelection() )
				{ 
					// setup highlight
					highlightStartX = highlightEndX = input.GetPosition().x;
					highlightStartY = highlightEndY = input.GetPosition().y;
				}

				m_Tool->MouseMove( input );
			}
			else
			{
				HELIUM_BREAK();
			}

			break;
		}
	}

	if (highlightStartX != -1 && highlightStartY != -1 && highlightEndX != -1 && highlightEndY != -1)
	{
		PickVisitor* pick = NULL;
		SelectionTargetMode targetMode = SelectionTargetModes::Single;

		if (highlightStartX == highlightEndX && highlightStartY == highlightEndY)
		{         
			pick = new FrustumLinePickVisitor (&m_Cameras[m_CameraMode], highlightStartX, highlightStartY);
			targetMode = SelectionTargetModes::Single;
		}
		else 
		{
			Frustum worldSpaceFrustum;

			if ( m_Cameras[m_CameraMode].ViewportToFrustum( (float32_t)highlightStartX, (float32_t)highlightStartY, (float32_t)highlightEndX, (float32_t)highlightEndY, worldSpaceFrustum) )
			{
				Point center ( Point (highlightStartX, highlightStartY) + Point (highlightEndX, highlightEndY) / 2 );

				Line line;
				m_Cameras[m_CameraMode].ViewportToLine( (float32_t)center.x, (float32_t)center.y, line);

				pick = new FrustumLinePickVisitor( &m_Cameras[m_CameraMode], line, worldSpaceFrustum );
				targetMode = SelectionTargetModes::Multiple;
			}
		}

		if (pick)
		{
			SetHighlightArgs args (pick, targetMode);
			m_SetHighlight.Raise( args );
			delete pick;
			pick = NULL;
		}
	}
}