suic::Size HeaderedContentControl::ArrangeOverride(const suic::Size& availableSize)
{
    ClearVisualChildren();
    suic::Rect finalRect(0, 0, availableSize.cx, availableSize.cy);

    if (_header)
    {
        finalRect.bottom = finalRect.top + _header->GetDesiredSize().cy;
        finalRect.left += _indent;
        finalRect.right = finalRect.left + _header->GetDesiredSize().cx;

        AddVisualChild(_header.get());
        _header->Arrange(finalRect);

        finalRect.left = 0;
        finalRect.top = finalRect.bottom;
        finalRect.bottom = availableSize.cy;
        finalRect.right = availableSize.cx;
    }

    if (_content && _content->IsVisible())
    {
        AddVisualChild(_content.get());
        _content->Arrange(finalRect);
    }

    return availableSize;
}
Beispiel #2
0
suic::Size ItemsControl::ArrangeOverride(const suic::Size& availableSize)
{
    suic::Rect finalRect(0, 0, availableSize.cx, availableSize.cy);
    finalRect.Deflate(GetBorderThickness());
    _scrollHost->Arrange(finalRect);
    return availableSize;
}
Beispiel #3
0
suic::Size TabControl::ArrangeOverride(const suic::Size& size)
{
    ClearVisualChildren();

    _headerPanel.ClearLogicalChildren();

    int iItems = GetItems()->GetCount();
    suic::Rect finalRect(0, 0, size.cx, size.cy);

    if (_isAverage && iItems > 0)
    {
        TabItemPtr tabItem;
        int iWid = size.cx / iItems;
        suic::Size itemSize(iWid, _headerHeight);

        for (int i = 0; i < iItems - 1; ++i)
        {
            tabItem = GetItems()->GetItem(i).get();
            tabItem->SetDesiredSize(itemSize);
        }

        tabItem = GetItems()->GetItem(iItems - 1).get();

        itemSize.cx = size.cx - iWid * (iItems - 1);
        tabItem->SetDesiredSize(itemSize);

        for (int i = 0; i < iItems; ++i)
        {
            tabItem = GetItems()->GetItem(i).get();
            _headerPanel.AddLogicalChild(tabItem.get());
        }

        finalRect.bottom = finalRect.top + _headerHeight;

        AddVisualChild(&_headerPanel);
        _headerPanel.Arrange(finalRect);

        finalRect.top = finalRect.bottom;
        finalRect.bottom = size.cy;
    }

    TabItemPtr focusTab(_focusItem);

    if (focusTab)
    {  
        if (focusTab->GetTabContent())
        {
            AddVisualChild(focusTab->GetTabContent());
            focusTab->GetTabContent()->Arrange(finalRect);
        }
    }

    return size;
}
void BasicShapeInset::path(Path& path, const FloatRect& boundingBox)
{
    ASSERT(path.isEmpty());
    float left = floatValueForLength(m_left, boundingBox.width());
    float top = floatValueForLength(m_top, boundingBox.height());
    FloatRect rect(left + boundingBox.x(), top + boundingBox.y(),
        std::max<float>(boundingBox.width() - left - floatValueForLength(m_right, boundingBox.width()), 0),
        std::max<float>(boundingBox.height() - top - floatValueForLength(m_bottom, boundingBox.height()), 0));
    auto radii = FloatRoundedRect::Radii(floatSizeForLengthSize(m_topLeftRadius, boundingBox),
        floatSizeForLengthSize(m_topRightRadius, boundingBox),
        floatSizeForLengthSize(m_bottomLeftRadius, boundingBox),
        floatSizeForLengthSize(m_bottomRightRadius, boundingBox));

    FloatRoundedRect finalRect(rect, radii);
    finalRect.constrainRadii();
    path.addRoundedRect(finalRect);
}
void KisTransparencyMaskTest::testMoveParentLayer()
{
    KisImageSP image;
    KisPaintLayerSP layer;
    KisPaintDeviceSP dev;
    KisTransparencyMaskSP mask;

    initImage(image, layer, dev, mask);
    mask->initSelection(layer);
    mask->selection()->pixelSelection()->invert();
    mask->select(QRect(50, 50, 100, 100));

    KisFullRefreshWalker walker(image->bounds());
    KisAsyncMerger merger;

    walker.collectRects(layer, image->bounds());
    merger.startMerge(walker);

    // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_before.png");

    QRect initialRect(0,0,200,100);
    QCOMPARE(layer->exactBounds(), initialRect);
    QCOMPARE(image->projection()->exactBounds(), QRect(50,50,100,50));


    layer->setX(100);
    layer->setY(100);

    dbgKrita << "Sel. rect before:" << mask->selection()->selectedExactRect();

    mask->setX(100);
    mask->setY(100);

    dbgKrita << "Sel. rect after:" << mask->selection()->selectedExactRect();

    QRect finalRect(100,100,200,100);
    QCOMPARE(layer->exactBounds(), finalRect);

    walker.collectRects(layer, initialRect | finalRect);
    merger.startMerge(walker);

    // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_after.png");
    QCOMPARE(image->projection()->exactBounds(), QRect(150,150,100,50));
}
CSize CXTPMarkupGrid::ArrangeOverride(CSize arrangeSize)
{
	if ((m_pColumnDefinitions->GetCount() == 0 && m_pRowDefinitions->GetCount() == 0) || (m_pCellCachesCollection == NULL))
	{
		int nCount = m_pChildren->GetCount();
		for (int i = 0; i < nCount; i++)
		{
			CXTPMarkupUIElement* pElement = m_pChildren->GetItem(i);
			if (pElement == NULL)
				continue;

			pElement->Arrange(CRect(0, 0, arrangeSize.cx, arrangeSize.cy));
		}
		return arrangeSize;
	}

	SetFinalSize(m_pDefinitionsU, arrangeSize.cx);
	SetFinalSize(m_pDefinitionsV, arrangeSize.cy);
	int nCount = m_pChildren->GetCount();
	for (int i = 0; i < nCount; i++)
	{
		CXTPMarkupUIElement* pElement = m_pChildren->GetItem(i);
		if (pElement == NULL)
			continue;

		CELLCACHE& cellCache =  m_pCellCachesCollection[i];

		int columnIndex = cellCache.nColumnIndex;
		int rowIndex = cellCache.nRowIndex;
		int columnSpan = cellCache.nColumnSpan;
		int rowSpan = cellCache.nRowSpan;

		CRect finalRect(CPoint(m_pDefinitionsU->GetItem(columnIndex)->m_nFinalOffset,
			m_pDefinitionsV->GetItem(rowIndex)->m_nFinalOffset),
			CSize(GetFinalSizeForRange(m_pDefinitionsU, columnIndex, columnSpan),
			GetFinalSizeForRange(m_pDefinitionsV, rowIndex, rowSpan)));

		pElement->Arrange(finalRect);
	}

	return arrangeSize;
}
void STNewAccountAuthorizeView::relayout(){
    if(m_fadeAnimation->finalValue()<.5f){
        m_fadeAnimation->setValueAnimated(1.f, 500);
    }


    QPixmap pix=m_window->pixmap();
    QRect finalRect((m_size.width()-pix.width())/2,
                    (m_size.height()-pix.height())/2,
                    pix.width(),pix.height());
    float per=m_fadeAnimation->value();
    per=STDampedSpringStep(per, 3.f);

    float startPos=m_size.height();//m_size.height()+pix.height()/2;
    float endPos=finalRect.center().y();
    startPos+=(endPos-startPos)*.5f;

    m_window->setPos(finalRect.center().x(),
                     floorf(startPos*(1.f-per)+endPos*per));

}
Beispiel #8
0
void KeyboardApplet::paintInterface(QPainter *p, const QStyleOptionGraphicsItem */*option*/, const QRect &contentsRect)
{
    LayoutUnit layoutUnit = X11Helper::getCurrentLayout();
    if( layoutUnit.isEmpty() )
        return;

    const QIcon icon(getFlag(layoutUnit.layout));
    if( ! icon.isNull() ) {
        p->save();
        p->setRenderHint(QPainter::SmoothPixmapTransform);
        p->setRenderHint(QPainter::Antialiasing);
        QPixmap pixmap = icon.pixmap(contentsRect.size());
        p->drawPixmap(contentsRect, pixmap);
        p->restore();
    }
    if( icon.isNull() || keyboardConfig->isLabelShown() ) {
        QRect finalRect(m_pixmap.rect());
        finalRect.moveCenter(contentsRect.center());
        p->drawPixmap(finalRect, m_pixmap);
    }
}
/*************************************************************************
    Draw the tree item in its current state.
*************************************************************************/
void TreeItem::draw(GeometryBuffer& buffer, const Rect &targetRect,
                    float alpha, const Rect *clipper) const
{
    Rect finalRect(targetRect);

    if (d_iconImage != 0)
    {
        Rect finalPos(finalRect);
        finalPos.setWidth(targetRect.getHeight());
        finalPos.setHeight(targetRect.getHeight());
        d_iconImage->draw(buffer, finalPos, clipper,
                          ColourRect(colour(1,1,1,alpha)));
        finalRect.d_left += targetRect.getHeight();
    }

    if (d_selected && d_selectBrush != 0)
        d_selectBrush->draw(buffer, finalRect, clipper,
                            getModulateAlphaColourRect(d_selectCols, alpha));

    Font* font = getFont();

    if (!font)
        return;

    Vector2 draw_pos(finalRect.getPosition());
    draw_pos.d_y -= (font->getLineSpacing() - font->getBaseline()) * 0.5f;

    if (!d_renderedStringValid)
        parseTextString();

    const ColourRect final_colours(
        getModulateAlphaColourRect(ColourRect(0xFFFFFFFF), alpha));

    for (size_t i = 0; i < d_renderedString.getLineCount(); ++i)
    {
        d_renderedString.draw(i, buffer, draw_pos, &final_colours, clipper, 0.0f);
        draw_pos.d_y += d_renderedString.getPixelSize(i).d_height;
    }
}
Beispiel #10
0
PassOwnPtr<Shape> Shape::createShape(const BasicShape* basicShape, const LayoutSize& logicalBoxSize, WritingMode writingMode, float margin)
{
    ASSERT(basicShape);

    bool horizontalWritingMode = isHorizontalWritingMode(writingMode);
    float boxWidth = horizontalWritingMode ? logicalBoxSize.width().toFloat() : logicalBoxSize.height().toFloat();
    float boxHeight = horizontalWritingMode ? logicalBoxSize.height().toFloat() : logicalBoxSize.width().toFloat();
    OwnPtr<Shape> shape;

    switch (basicShape->type()) {

    case BasicShape::BasicShapeCircleType: {
        const BasicShapeCircle* circle = toBasicShapeCircle(basicShape);
        FloatPoint center = floatPointForCenterCoordinate(circle->centerX(), circle->centerY(), FloatSize(boxWidth, boxHeight));
        float radius = circle->floatValueForRadiusInBox(FloatSize(boxWidth, boxHeight));
        FloatPoint logicalCenter = physicalPointToLogical(center, logicalBoxSize.height().toFloat(), writingMode);

        shape = createCircleShape(logicalCenter, radius);
        break;
    }

    case BasicShape::BasicShapeEllipseType: {
        const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape);
        FloatPoint center = floatPointForCenterCoordinate(ellipse->centerX(), ellipse->centerY(), FloatSize(boxWidth, boxHeight));
        float radiusX = ellipse->floatValueForRadiusInBox(ellipse->radiusX(), center.x(), boxWidth);
        float radiusY = ellipse->floatValueForRadiusInBox(ellipse->radiusY(), center.y(), boxHeight);
        FloatPoint logicalCenter = physicalPointToLogical(center, logicalBoxSize.height().toFloat(), writingMode);

        shape = createEllipseShape(logicalCenter, FloatSize(radiusX, radiusY));
        break;
    }

    case BasicShape::BasicShapePolygonType: {
        const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape);
        const Vector<Length>& values = polygon->values();
        size_t valuesSize = values.size();
        ASSERT(!(valuesSize % 2));
        OwnPtr<Vector<FloatPoint>> vertices = adoptPtr(new Vector<FloatPoint>(valuesSize / 2));
        for (unsigned i = 0; i < valuesSize; i += 2) {
            FloatPoint vertex(
                floatValueForLength(values.at(i), boxWidth),
                floatValueForLength(values.at(i + 1), boxHeight));
            (*vertices)[i / 2] = physicalPointToLogical(vertex, logicalBoxSize.height().toFloat(), writingMode);
        }
        shape = createPolygonShape(vertices.release(), polygon->windRule());
        break;
    }

    case BasicShape::BasicShapeInsetType: {
        const BasicShapeInset& inset = *toBasicShapeInset(basicShape);
        float left = floatValueForLength(inset.left(), boxWidth);
        float top = floatValueForLength(inset.top(), boxHeight);
        float right = floatValueForLength(inset.right(), boxWidth);
        float bottom = floatValueForLength(inset.bottom(), boxHeight);
        FloatRect rect(left, top, std::max<float>(boxWidth - left - right, 0), std::max<float>(boxHeight - top - bottom, 0));
        FloatRect logicalRect = physicalRectToLogical(rect, logicalBoxSize.height().toFloat(), writingMode);

        FloatSize boxSize(boxWidth, boxHeight);
        FloatSize topLeftRadius = physicalSizeToLogical(floatSizeForLengthSize(inset.topLeftRadius(), boxSize), writingMode);
        FloatSize topRightRadius = physicalSizeToLogical(floatSizeForLengthSize(inset.topRightRadius(), boxSize), writingMode);
        FloatSize bottomLeftRadius = physicalSizeToLogical(floatSizeForLengthSize(inset.bottomLeftRadius(), boxSize), writingMode);
        FloatSize bottomRightRadius = physicalSizeToLogical(floatSizeForLengthSize(inset.bottomRightRadius(), boxSize), writingMode);
        FloatRoundedRect::Radii cornerRadii(topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);

        FloatRoundedRect finalRect(logicalRect, cornerRadii);
        finalRect.constrainRadii();

        shape = createInsetShape(finalRect);
        break;
    }

    default:
        ASSERT_NOT_REACHED();
    }

    shape->m_writingMode = writingMode;
    shape->m_margin = margin;

    return shape.release();
}
Beispiel #11
0
suic::Size TreeViewItem::ArrangeOverride(const suic::Size& finalSize)
{
    // 先清除可视节点
    ClearVisualChildren();

    const int ITEMSPACE = 2;

    suic::Rect finalRect(0, 0, finalSize.cx, 0);

    // 布局扩展按钮
    if (_expand->IsVisible())
    {
        finalRect.right = finalRect.left + _expand->GetDesiredSize().cx;
        finalRect.top = (_header->GetDesiredSize().cy - _expand->GetDesiredSize().cy) / 2;
        finalRect.bottom = finalRect.top + _expand->GetDesiredSize().cy;

        AddVisualChild(_expand.get());
        _expand->Arrange(finalRect);

        finalRect.left = finalRect.right + 12;
    }

    // 布局选择按钮
    if (_check.IsVisible())
    {
        finalRect.right = finalRect.left + _check.GetDesiredSize().cx;
        finalRect.top = (_header->GetDesiredSize().cy - _check.GetDesiredSize().cy) / 2;
        finalRect.bottom = finalRect.top + _check.GetDesiredSize().cy;

        AddVisualChild(&_check);
        _check.Arrange(finalRect);

        finalRect.left = finalRect.right;
    }

    if (_icon)
    {
        // 布局图标
        suic::Rect rcIcon(_icon->GetContentBrounds());
    }

    finalRect.right = finalRect.left + _header->GetDesiredSize().cx;
    finalRect.top = 0;
    finalRect.bottom = _header->GetDesiredSize().cy;

    AddVisualChild(_header.get());
    _header->Arrange(finalRect);

    finalRect.top = finalRect.bottom;
    finalRect.left = GetIndent();

    if (!IsCollapsed())
    {
        for (int i = 0; i < GetItems()->GetCount(); ++i)
        {
            TreeViewItemPtr item(GetItems()->GetItem(i));

            finalRect.right = finalRect.left + item->GetDesiredSize().cx;
            finalRect.bottom = finalRect.top + item->GetDesiredSize().cy;

            AddVisualChild(item.get());
            item->Arrange(finalRect);

            finalRect.top = finalRect.bottom;
        }
    }

    return finalSize;
}