Esempio n. 1
0
extern BOOL EndSelect( pixels x, pixels y )
/******************************************

    We are done a select (the user let the mouse button go).
*/
{
    if( MouseMode != MENU_SELECT ) return( FALSE );
    SnapToGrid( &x, &y );
    ReleaseCapture();
    RegionIsSelected = TRUE;
    return( TRUE );
}
Esempio n. 2
0
extern BOOL MoveSelect( unsigned state, pixels x, pixels y )
/***********************************************************

    The mouse moved. Update the select rectangle.
*/
{
    SnapToGrid( &x, &y );
    NotSameAsStart( &x, &y );
    if( MouseMode != MENU_SELECT ) return( FALSE );
    if( state & MK_LBUTTON ) {
        if( SelectEndX != x || SelectEndY != y ) {
            XORSelectedRegion();
            SelectEndX = x;
            SelectEndY = y;
            XORSelectedRegion();
        }
    }
    return( TRUE );
}
Esempio n. 3
0
extern BOOL StartSelect( pixels x, pixels y )
/********************************************

    Record the spot at which selection started
*/
{
    if( MouseMode != MENU_SELECT ) return( FALSE );
    if( RegionIsSelected ) XORSelectedRegion();
    SetCapture( WinHandle );
    x -= BitInfo.bmWidth / 2;
    y -= BitInfo.bmWidth / 2;
    SnapToGrid( &x, &y );
    SelectStartX = x;
    SelectStartY = y;
    NotSameAsStart( &x, &y );
    SelectEndX = x;
    SelectEndY = y;
    XORSelectedRegion();
    return( TRUE );
}
//================================================================================================================
void MenuEditorSystem::OnMouseMove(WPARAM btnState, int x, int y)
{
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		m_SelectedMousePos.x = x;
		m_SelectedMousePos.y = y;
		
		m_leftButtonDown = true;
		
		// If applicable, Add a button
		if (BetterString(m_SelectedButtonImageName) != "")
		{
			AddButton();
		}
		
		// If applicable, Add a text
		AddText();
	}
	else
	{
		m_leftButtonDown = false;
	}
	
	m_MouseMovePos = SnapToGrid(x, y);

	// Move a button or text display cover
	if (editType == ET_Button && (action == A_Place || action == A_Move))
	{
		if (m_displaySpriteCover == NULL)
		{
			if (BetterString(m_SelectedButtonImageName) != "")
			{
				m_displaySpriteCover = new Sprite(m_D3DSystem);
				m_displaySpriteCover->Initialize(m_mainGameDirectory->m_menu_sprites_path, m_SelectedButtonImageName, XMFLOAT3(m_MouseMovePos.x, m_MouseMovePos.y, 0), 80, 30, PhysicsType::STATIC);
			}
		}
	}
}
Esempio n. 5
0
void CMapzoneEdit::VectorSnapToGrid(Vector *dest, float gridsize)
{
    dest->x = SnapToGrid(dest->x, gridsize);
    dest->y = SnapToGrid(dest->y, gridsize);
    dest->z = SnapToGrid(dest->z, gridsize);
}
Esempio n. 6
0
void CMapzoneEdit::Update()
{
    if (mom_zone_edit.GetBool())
    {
        if (!m_bEditing)
        {
            m_nBuildStage = BUILDSTAGE_NONE;
            m_bEditing = true;
        }
    }
    else
    {
        if (m_bEditing)
        {
            m_nBuildStage = BUILDSTAGE_NONE;
            m_bEditing = false;
        }

        return;
    }

    CBasePlayer *pPlayer = UTIL_GetLocalPlayer();

    if (!pPlayer) return;


    trace_t tr;
    Vector vecFwd;

    AngleVectors(pPlayer->EyeAngles(), &vecFwd);

    UTIL_TraceLine(pPlayer->EyePosition(), pPlayer->EyePosition() + vecFwd * m_flReticleDist, MASK_PLAYERSOLID, pPlayer, COLLISION_GROUP_NONE, &tr);

    Vector vecAim = tr.endpos;

    if (mom_zone_grid.GetInt() > 0)
        VectorSnapToGrid(&vecAim, (float) mom_zone_grid.GetInt());


    if (m_nBuildStage >= BUILDSTAGE_START)
    {
        Vector vecP2, vecP3, vecP4;

        if (m_nBuildStage >= BUILDSTAGE_END)
        {
            vecP3 = m_vecBuildEnd;
        }
        else
        {
            vecP3 = vecAim;
        }

        vecP3[2] = m_vecBuildStart[2];

        // Bottom
        vecP2[0] = m_vecBuildStart[0];
        vecP2[1] = vecP3[1];
        vecP2[2] = m_vecBuildStart[2];

        vecP4[0] = vecP3[0];
        vecP4[1] = m_vecBuildStart[1];
        vecP4[2] = m_vecBuildStart[2];

        DebugDrawLine(m_vecBuildStart, vecP2, 255, 255, 255, true, -1.0f);
        DebugDrawLine(vecP2, vecP3, 255, 255, 255, true, -1.0f);
        DebugDrawLine(vecP3, vecP4, 255, 255, 255, true, -1.0f);
        DebugDrawLine(vecP4, m_vecBuildStart, 255, 255, 255, true, -1.0f);

        if (m_nBuildStage >= BUILDSTAGE_END)
        {
            Vector vecP5, vecP6, vecP8;

            m_vecBuildEnd[2] = SnapToGrid(m_vecBuildStart[2] + GetZoneHeightToPlayer(pPlayer), (float) mom_zone_grid.GetInt());

            // Top
            vecP5 = m_vecBuildStart;
            vecP5.z = m_vecBuildEnd[2];

            vecP6 = vecP2;
            vecP6.z = m_vecBuildEnd[2];

            vecP8 = vecP4;
            vecP8.z = m_vecBuildEnd[2];

            DebugDrawLine(vecP5, vecP6, 255, 255, 255, true, -1.0f);
            DebugDrawLine(vecP6, m_vecBuildEnd, 255, 255, 255, true, -1.0f);
            DebugDrawLine(m_vecBuildEnd, vecP8, 255, 255, 255, true, -1.0f);
            DebugDrawLine(vecP8, vecP5, 255, 255, 255, true, -1.0f);

            // Bottom to top
            DebugDrawLine(m_vecBuildStart, vecP5, 255, 255, 255, true, -1.0f);
            DebugDrawLine(vecP2, vecP6, 255, 255, 255, true, -1.0f);
            DebugDrawLine(vecP3, m_vecBuildEnd, 255, 255, 255, true, -1.0f);
            DebugDrawLine(vecP4, vecP8, 255, 255, 255, true, -1.0f);
        }
    }

    // Draw surface normal. Makes it a bit easier to see where reticle is hitting.
    if (tr.DidHit())
    {
        DebugDrawLine(vecAim, vecAim + tr.plane.normal * 24.0f, 0, 0, 255, true, -1.0f);
    }

    DrawReticle(&vecAim, (mom_zone_grid.GetInt() > 0) ? ((float) mom_zone_grid.GetInt() / 2.0f) : 8.0f);
}
//================================================================================================================
void MenuEditorSystem::CalculateSelectedMousePosition(int x, int y)
{
	m_SelectedMousePos = SnapToGrid(x, y);
}
//================================================================================================================
void MenuEditorSystem::OnMouseMove(WPARAM btnState, int x, int y)
{
	int dX, dY, tdX, tdY;
	
	// Calculate movement delta from previous frame
	if (dragPrevX != -1)
	{
		dX = x - dragPrevX;
		dY = y - dragPrevY;
		tdX = x - dragStartX;
		tdY = y - dragStartY;
	}
	
	if (gridMode == GM_Snap)
	{
		XMFLOAT2 selToolPoint = SnapToGrid(x, y);
		
		m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		
		// Move a button display cover if in button mode
		UpdateDisplaySprite(selToolPoint.x, selToolPoint.y);
		
		// If a button or text is being moved then continue to move it
		MoveButton(selToolPoint.x, selToolPoint.y);
		MoveText(selToolPoint.x, selToolPoint.y);
		
		HighlightButton(selToolPoint.x, selToolPoint.y);
		HighlightText(selToolPoint.x, selToolPoint.y);
	}
	else
	{
		// Move a button display cover if in button mode
		UpdateDisplaySprite(x, y);
		
		// If a button or text is being moved then continue to move it
		MoveButton(x, y);
		MoveText(x, y);
		
		HighlightButton(x, y);
		HighlightText(x, y);
	}
	
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		CalculateSelectedMousePosition(x, y);
		
		stampPressed = true;
		
		// If applicable, Add a button
		AddButton();
		
		// If applicable, Add a text
		AddText();
		
		// Selects a button on the map and deletes it if in button delete mode
		DeleteButton();
		
		// Selects a text on the map and deletes it if in text delete mode
		DeleteText();
	}
	
	// Remember current mouse co-ordinates for next frame
	if (dragPrevX != -1)
	{
		dragPrevX = x;
		dragPrevY = y;
	}
}
Esempio n. 9
0
//================================================================================================================
void HUDEditorSystem::OnMouseMove(WPARAM btnState, int x, int y)
{
	if (gridMode == GM_Snap)
	{
		XMFLOAT2 selToolPoint = SnapToGrid(x, y);
		
		m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		
		// Move a image display cover if in image mode
		UpdateDisplaySprite(selToolPoint.x, selToolPoint.y);
		
		// If a image or text is being moved then continue to move it
		MoveImage(selToolPoint.x, selToolPoint.y);
		MoveText(selToolPoint.x, selToolPoint.y);
		
		HighlightImage(selToolPoint.x, selToolPoint.y);
		HighlightText(selToolPoint.x, selToolPoint.y);
	}
	else
	{
		// Move a image display cover if in image mode
		UpdateDisplaySprite(x, y);
		
		// If a image or text is being moved then continue to move it
		MoveImage(x, y);
		MoveText(x, y);
		
		HighlightImage(x, y);
		HighlightText(x, y);
	}
	
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		CalculateSelectedMousePosition(x, y);
		
		stampPressed = true;
		
		// If applicable, Add a image
		AddImage();
		
		// If applicable, Add a text
		AddText();
		
		// Selects a image on the map and deletes it if in image delete mode
		DeleteImage();
		
		// Selects a text on the map and deletes it if in text delete mode
		DeleteText();
	}
	
	// Move a button or text display cover
	/*if (editMode == ET_Button && (action == A_Place || action == A_Move))
	{
		XMFLOAT2 selToolPoint = SnapToGrid(x, y);
		
		m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
	}*/
}
NS_IMETHODIMP
nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
{
  NS_NAMED_LITERAL_STRING(leftStr, "left");
  NS_NAMED_LITERAL_STRING(topStr, "top");

  if (mIsResizing) {
    // we are resizing and the mouse pointer's position has changed
    // we have to resdisplay the shadow
    nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
    PRInt32 clientX, clientY;
    mouseEvent->GetClientX(&clientX);
    mouseEvent->GetClientY(&clientY);

    PRInt32 newX = GetNewResizingX(clientX, clientY);
    PRInt32 newY = GetNewResizingY(clientX, clientY);
    PRInt32 newWidth  = GetNewResizingWidth(clientX, clientY);
    PRInt32 newHeight = GetNewResizingHeight(clientX, clientY);

    mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
                                        leftStr,
                                        newX);
    mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
                                        topStr,
                                        newY);
    mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
                                        NS_LITERAL_STRING("width"),
                                        newWidth);
    mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
                                        NS_LITERAL_STRING("height"),
                                        newHeight);

    return SetResizingInfoPosition(newX, newY, newWidth, newHeight);
  }

  if (mGrabberClicked) {
    nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
    PRInt32 clientX, clientY;
    mouseEvent->GetClientX(&clientX);
    mouseEvent->GetClientY(&clientY);

    nsCOMPtr<nsILookAndFeel> look = do_GetService(kLookAndFeelCID);
    NS_ASSERTION(look, "Look and feel service must be implemented for this toolkit");

    PRInt32 xThreshold=1, yThreshold=1;
    look->GetMetric(nsILookAndFeel::eMetric_DragThresholdX, xThreshold);
    look->GetMetric(nsILookAndFeel::eMetric_DragThresholdY, yThreshold);

    if (PR_ABS(clientX - mOriginalX ) * 2 >= xThreshold ||
        PR_ABS(clientY - mOriginalY ) * 2 >= yThreshold) {
      mGrabberClicked = PR_FALSE;
      StartMoving(nsnull);
    }
  }
  if (mIsMoving) {
    nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
    PRInt32 clientX, clientY;
    mouseEvent->GetClientX(&clientX);
    mouseEvent->GetClientY(&clientY);

    PRInt32 newX = mPositionedObjectX + clientX - mOriginalX;
    PRInt32 newY = mPositionedObjectY + clientY - mOriginalY;

    SnapToGrid(newX, newY);

    mHTMLCSSUtils->SetCSSPropertyPixels(mPositioningShadow, leftStr, newX);
    mHTMLCSSUtils->SetCSSPropertyPixels(mPositioningShadow, topStr, newY);
  }
  return NS_OK;
}
Esempio n. 11
0
nsresult
HTMLEditor::MouseMove(nsIDOMMouseEvent* aMouseEvent)
{
  MOZ_ASSERT(aMouseEvent);

  NS_NAMED_LITERAL_STRING(leftStr, "left");
  NS_NAMED_LITERAL_STRING(topStr, "top");

  if (mIsResizing) {
    // we are resizing and the mouse pointer's position has changed
    // we have to resdisplay the shadow
    int32_t clientX, clientY;
    aMouseEvent->GetClientX(&clientX);
    aMouseEvent->GetClientY(&clientY);

    int32_t newX = GetNewResizingX(clientX, clientY);
    int32_t newY = GetNewResizingY(clientX, clientY);
    int32_t newWidth  = GetNewResizingWidth(clientX, clientY);
    int32_t newHeight = GetNewResizingHeight(clientX, clientY);

    mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::left,
                                        newX);
    mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::top,
                                        newY);
    mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::width,
                                        newWidth);
    mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::height,
                                        newHeight);

    return SetResizingInfoPosition(newX, newY, newWidth, newHeight);
  }

  if (mGrabberClicked) {
    int32_t clientX, clientY;
    aMouseEvent->GetClientX(&clientX);
    aMouseEvent->GetClientY(&clientY);

    int32_t xThreshold =
      LookAndFeel::GetInt(LookAndFeel::eIntID_DragThresholdX, 1);
    int32_t yThreshold =
      LookAndFeel::GetInt(LookAndFeel::eIntID_DragThresholdY, 1);

    if (DeprecatedAbs(clientX - mOriginalX) * 2 >= xThreshold ||
        DeprecatedAbs(clientY - mOriginalY) * 2 >= yThreshold) {
      mGrabberClicked = false;
      StartMoving(nullptr);
    }
  }
  if (mIsMoving) {
    int32_t clientX, clientY;
    aMouseEvent->GetClientX(&clientX);
    aMouseEvent->GetClientY(&clientY);

    int32_t newX = mPositionedObjectX + clientX - mOriginalX;
    int32_t newY = mPositionedObjectY + clientY - mOriginalY;

    SnapToGrid(newX, newY);

    mCSSEditUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::left,
                                        newX);
    mCSSEditUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::top,
                                        newY);
  }
  return NS_OK;
}