void UCanvasPanelSlot::SynchronizeProperties()
{
	SetOffsets(LayoutData.Offsets);
	SetAnchors(LayoutData.Anchors);
	SetAlignment(LayoutData.Alignment);
	SetAutoSize(bAutoSize);
	SetZOrder(ZOrder);
}
Esempio n. 2
0
void CPipProp::Sizer::Init(RECT& rcBound, RECT& rcVid, RECT& rcTarget)
{
    _ASSERTE((rcVid.left == 0) && (rcVid.top == 0));
    
    CopyRect(&m_BoundingRect, &rcBound);

    float fWidth = (float)(m_BoundingRect.right - m_BoundingRect.left);
    float fHeight = (float)(m_BoundingRect.bottom - m_BoundingRect.top);

    float scaleX = fWidth / rcVid.right,
          scaleY = fHeight / rcVid.bottom;

    // Scale
    int x1 = (int)(scaleX * rcTarget.left), y1 = (int)(scaleY * rcTarget.top),
        x2 = (int)(scaleX * rcTarget.right), y2 = (int)(scaleY * rcTarget.bottom);

    // Normalize to the bounding rectangle
    SetRect(this, x1 + rcBound.left, y1 + rcBound.top, 
            x2 + rcBound.left, y2 + rcBound.top);
    
    SetAnchors();
    SetRegion();
} 
Esempio n. 3
0
BOOL CPipProp::Sizer::TestMouseMove(int x, int y)
{
    // If grabbing right now, resize the Sizer rectangle

    // We keep a minimum 2-pixel distance between opposite rectangle
    // sides. Otherwise it doesn't look like a rectangle any more.)

    if (m_bGrabbed)
    {
        SetRegion();

        switch (m_iGrabbedAnchor)
        {
            case 0:
                top = min(y, bottom - 2);
                left = min(x, right - 2);
                break;
            case 1:
                top = min(y, bottom - 2);
                right = max(x, left + 2);
                break;
            case 2:
                bottom = max(y, top + 2);
                right = max(x, left + 2);
                break;
            case 3:
                bottom = max(y, top + 2);
                left = min(x, right - 2);
                break;
            default:
                _ASSERTE(FALSE);
                break;
        }

        // Trim to the bounding rect
        IntersectRect(this, this, &m_BoundingRect);
        SetAnchors();

        return TRUE;
    }

    // If not grabbing and not selected, nothing to do.
    if (!m_bSelected) {
        return FALSE;
    }

    // If selected, look for hot zone. Is the mouse hovering over an anchor?

    bool bInHotZone = false;
    POINT pt = { x, y };

    for (int i = 0; i < 4; i++)
    {
        if (PtInRect(&m_Anchor[i], pt))
        {
            bInHotZone = true;
            m_iGrabbedAnchor = i;
            break;
        }
    }

    // Change the cursor to a diagonal arrow, to indicate "resizability"
    if (bInHotZone)
    {
        HCURSOR hCursor;
        if (m_iGrabbedAnchor == 0 || m_iGrabbedAnchor == 2)
        {
            hCursor = LoadCursor(0, IDC_SIZENWSE);
        }
        else 
        {
            hCursor = LoadCursor(0, IDC_SIZENESW);
        }
        SetCursor(hCursor);
    }
    else if (m_bInHotZone)
    {
        // We *were* in a hot zone, now we're not, so reset the cursor.
        SetCursor(LoadCursor(0, IDC_ARROW));
    }

    m_bInHotZone = bInHotZone;
    
    return FALSE;
}