void RenderSVGRoot::layout()
{
    ASSERT(needsLayout());

    // Arbitrary affine transforms are incompatible with LayoutState.
    view()->disableLayoutState();

    LayoutRepainter repainter(*this, checkForRepaintDuringLayout() && selfNeedsLayout());

    int oldWidth = width();
    calcWidth();

    int oldHeight = height();
    calcHeight();

    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    setWidth(static_cast<int>(width() * svg->currentScale()));
    setHeight(static_cast<int>(height() * svg->currentScale()));
    calcViewport();

    // RenderSVGRoot needs to take special care to propagate window size changes to the children,
    // if the outermost <svg> is using relative x/y/width/height values. Hence the additonal parameters.
    layoutChildren(this, selfNeedsLayout() || (svg->hasRelativeValues() && (width() != oldWidth || height() != oldHeight)));
    repainter.repaintAfterLayout();

    view()->enableLayoutState();
    setNeedsLayout(false);
}
示例#2
0
void AbstractContent::addButtonItem(ButtonItem * button)
{
    m_controlItems.append(button);
    button->setVisible(m_controlsVisible);
    button->setZValue(3.0);
    layoutChildren();
}
示例#3
0
void QAbstractScrollAreaPrivate::init()
{
    Q_Q(QAbstractScrollArea);
    viewport = new QWidget(q);
    viewport->setObjectName(QLatin1String("qt_scrollarea_viewport"));
    viewport->setBackgroundRole(QPalette::Base);
    viewport->setAutoFillBackground(true);
    scrollBarContainers[Qt::Horizontal] = new QAbstractScrollAreaScrollBarContainer(Qt::Horizontal, q);
    scrollBarContainers[Qt::Horizontal]->setObjectName(QLatin1String("qt_scrollarea_hcontainer"));
    hbar = scrollBarContainers[Qt::Horizontal]->scrollBar;
    hbar->setRange(0,0);
    scrollBarContainers[Qt::Horizontal]->setVisible(false);
    QObject::connect(hbar, SIGNAL(valueChanged(int)), q, SLOT(_q_hslide(int)));
    QObject::connect(hbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
    scrollBarContainers[Qt::Vertical] = new QAbstractScrollAreaScrollBarContainer(Qt::Vertical, q);
    scrollBarContainers[Qt::Vertical]->setObjectName(QLatin1String("qt_scrollarea_vcontainer"));
    vbar = scrollBarContainers[Qt::Vertical]->scrollBar;
    vbar->setRange(0,0);
    scrollBarContainers[Qt::Vertical]->setVisible(false);
    QObject::connect(vbar, SIGNAL(valueChanged(int)), q, SLOT(_q_vslide(int)));
    QObject::connect(vbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
    viewportFilter.reset(new QAbstractScrollAreaFilter(this));
    viewport->installEventFilter(viewportFilter.data());
    viewport->setFocusProxy(q);
    q->setFocusPolicy(Qt::WheelFocus);
    q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
    q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    layoutChildren();
#ifndef Q_WS_MAC
#ifndef QT_NO_GESTURES
    viewport->grabGesture(Qt::PanGesture);
#endif
#endif
}
示例#4
0
void AbstractContent::resizeContents(const QRect & rect, bool keepRatio)
{
    if (!rect.isValid())
        return;

    prepareGeometryChange();

    m_contentsRect = rect;
    if (keepRatio) {
        int hfw = contentHeightForWidth(rect.width());
        if (hfw > 1) {
            m_contentsRect.setTop(-hfw / 2);
            m_contentsRect.setHeight(hfw);
        }
    }

    if (m_frame)
        m_frameRect = m_frame->frameRect(m_contentsRect);
    else
        m_frameRect = m_contentsRect;

    layoutChildren();
    update();
    GFX_CHANGED();
}
示例#5
0
void BBGroup::setShape( int x,int y,int w,int h ){
	BBGadget::setShape( x,y,w,h );

	int pw=_cw,ph=_ch;
	clientShape( &_cx,&_cy,&_cw,&_ch );
	if( pw==_cw && ph==_ch ) return;

	layoutChildren();
}
SDeclarativeIndicatorContainer::SDeclarativeIndicatorContainer(QDeclarativeItem *parent)
    : SDeclarativeImplicitSizeItem(parent), d_ptr(new SDeclarativeIndicatorContainerPrivate)
{
#if defined(Q_OS_SYMBIAN) && defined(HAVE_SYMBIAN_INTERNAL)
    QT_TRAP_THROWING(d_ptr->dataHandler = CSDeclarativeIndicatorDataHandler::NewL(this));
#endif // Q_OS_SYMBIAN && HAVE_SYMBIAN_INTERNAL

    connect(this, SIGNAL(indicatorSizeChanged()), this, SLOT(layoutChildren()));
    connect(this, SIGNAL(indicatorPaddingChanged(int)), this, SLOT(layoutChildren()));
    connect(this, SIGNAL(maxIndicatorCountChanged(int)), this, SLOT(layoutChildren()));
}
示例#7
0
void AbstractContent::setFrame(Frame * frame)
{
    delete m_frame;
    m_frame = frame;
    if (m_frame)
        FrameFactory::setDefaultPictureClass(m_frame->frameClass());
    resizeContents(m_contentsRect);
    layoutChildren();
    update();
    GFX_CHANGED();
}
	void CCControlBase::layoutChildren(ELayoutMode layoutMode, bool resize)	{
		// now check for all sub layers and call needsLayout to
		CCArray* children(getChildren());
		CCObject* child;

		const float verticalOffset(static_cast<float>(m_marginV));


		if(resize == true)	{

			const CCSize& currentContentSize(getContentSize());
			float contentHeight(verticalOffset);
			// determine the new content height
			CCARRAY_FOREACH(children, child)
			{
				CCControlBase* ctrlBase(dynamic_cast<CCControlBase*>(child));
				if(ctrlBase != nullptr)	{
					CCSize preferredSize(CCSizeMake(currentContentSize.width - (m_marginH * 2),0));
					CCSize ctrlPreferredSize(ctrlBase->getPreferredSize());
					ctrlPreferredSize.width = preferredSize.width;
					ctrlBase->setPreferredSize(ctrlPreferredSize);
					ctrlBase->needsLayout();

					contentHeight += ctrlBase->getContentSize().height;
					contentHeight += verticalOffset;
				}
				else	{
					CCScale9Sprite* sprite(dynamic_cast<CCScale9Sprite*>(child));
					if(sprite == _backGroundSprite)	{

					}
					else	{
						CCControlButton* btn(dynamic_cast<CCControlButton*>(child));
						if(btn != nullptr)	{
							contentHeight += (btn->getContentSize().height + verticalOffset * 2);
							contentHeight += verticalOffset * 2;
						}
						else	{
							CCNode* node(dynamic_cast<CCNode*>(child));
							if(node != nullptr)	{
								contentHeight += node->getContentSize().height;
								contentHeight += verticalOffset;
							}
						}
					}
				}
			}

			CCSize newContentSize(getContentSize());
			newContentSize.height = contentHeight;
			setPreferredSize(newContentSize);
			needsLayout();
			layoutChildren(ELayoutMode_topLeftDown);
		}
示例#9
0
void AbstractContent::setFrame(Frame * frame)
{
    delete m_frame;
    m_frame = frame;
    FrameFactory::setDefaultPictureClass(frameClass());
    if (!m_frame && m_frameTextItem)
        m_frameTextItem->hide();
    resizeContents(m_contentRect);
    layoutChildren();
    update();
    GFX_CHANGED();
}
void RenderSVGContainer::layout()
{
    ASSERT(needsLayout());
    ASSERT(!view()->layoutStateEnabled()); // RenderSVGRoot disables layoutState for the SVG rendering tree.

    calcViewport(); // Allow RenderSVGViewportContainer to update its viewport

    LayoutRepainter repainter(*this, checkForRepaintDuringLayout() || selfWillPaint());
    calculateLocalTransform(); // Allow RenderSVGTransformableContainer to update its transform

    layoutChildren(this, selfNeedsLayout());
    repainter.repaintAfterLayout();

    setNeedsLayout(false);
}
示例#11
0
void AbstractContent::setFrameTextEnabled(bool enabled)
{
    // create the Text Item, if enabled...
    if (enabled && !m_frameTextItem) {
        m_frameTextItem = new FrameTextItem(this);
        m_frameTextItem->setTextInteractionFlags(Qt::TextEditorInteraction);
        QFont f("Sans Serif");
        //f.setPointSizeF(7.5);
        m_frameTextItem->setFont(f);
        m_frameTextItem->setZValue(1.0);
        layoutChildren();
    }

    // ...or destroy it if disabled
    else if (!enabled && m_frameTextItem) {
        delete m_frameTextItem;
        m_frameTextItem = 0;
    }
}
void LayoutableShadowNode::layout(LayoutContext layoutContext) {
  layoutChildren(layoutContext);

  for (auto child : getLayoutableChildNodes()) {
    if (!child->getHasNewLayout()) {
      continue;
    }

    child->ensureUnsealed();
    child->setHasNewLayout(false);

    const LayoutMetrics childLayoutMetrics = child->getLayoutMetrics();
    if (childLayoutMetrics.displayType == DisplayType::None) {
      continue;
    }

    LayoutContext childLayoutContext = LayoutContext(layoutContext);
    childLayoutContext.absolutePosition += childLayoutMetrics.frame.origin;

    child->layout(layoutContext);
  }
}
示例#13
0
void BBSplitter::setDivShape( int x,int y,int w,int h ){
	_divx=x;_divy=y;_divw=w;_divh=h;
	layoutChildren();
}
void RenderSVGHiddenContainer::layout()
{
    ASSERT(needsLayout());
    layoutChildren(this, selfNeedsLayout()); 
    setNeedsLayout(false);    
}
示例#15
0
AbstractContent::AbstractContent(QGraphicsScene *scene, bool fadeIn, bool noRescale, QGraphicsItem * parent)
    : AbstractDisposeable(fadeIn, parent)
    , m_contentRect(-100, -75, 200, 150)
    , m_frame(0)
    , m_frameTextItem(0)
    , m_controlsVisible(false)
    , m_dirtyTransforming(false)
    , m_transformRefreshTimer(0)
    , m_gfxChangeTimer(0)
    , m_mirrorItem(0)
#if QT_VERSION < 0x040600
    , m_rotationAngle(0)
#endif
    , m_fxIndex(0)
{
    // the buffered graphics changes timer
    m_gfxChangeTimer = new QTimer(this);
    m_gfxChangeTimer->setInterval(0);
    m_gfxChangeTimer->setSingleShot(true);

    // customize item's behavior
    setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsSelectable);
#if QT_VERSION >= 0x040600
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
#endif
    // allow some items (eg. the shape controls for text) to be shown
    setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
    setAcceptHoverEvents(true);

    // create child controls
    createCorner(Qt::TopLeftCorner, noRescale);
    createCorner(Qt::TopRightCorner, noRescale);
    createCorner(Qt::BottomLeftCorner, noRescale);
    createCorner(Qt::BottomRightCorner, noRescale);

    //ButtonItem * bFront = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-order-front.png"), this);
    //bFront->setToolTip(tr("Raise"));
    //connect(bFront, SIGNAL(clicked()), this, SLOT(slotStackRaise()));
    //addButtonItem(bFront);

    ButtonItem * bConf = new ButtonItem(ButtonItem::Control, Qt::green, QIcon(":/data/action-configure.png"), this);
    bConf->setToolTip(tr("Change properties..."));
    connect(bConf, SIGNAL(clicked()), this, SLOT(slotConfigure()));
    addButtonItem(bConf);

    ButtonItem * bPersp = new ButtonItem(ButtonItem::Control, Qt::red, QIcon(":/data/action-perspective.png"), this);
    bPersp->setToolTip(tr("Drag around to change the perspective.\nHold SHIFT to move faster.\nUse CTRL to cancel the transformations."));
    connect(bPersp, SIGNAL(dragging(const QPointF&,Qt::KeyboardModifiers)), this, SLOT(slotSetPerspective(const QPointF&,Qt::KeyboardModifiers)));
    connect(bPersp, SIGNAL(doubleClicked()), this, SLOT(slotClearPerspective()));
    addButtonItem(bPersp);

    ButtonItem * bDelete = new ButtonItem(ButtonItem::Control, Qt::red, QIcon(":/data/action-delete.png"), this);
    bDelete->setSelectsParent(false);
    bDelete->setToolTip(tr("Remove"));
    connect(bDelete, SIGNAL(clicked()), this, SIGNAL(requestRemoval()));
    addButtonItem(bDelete);

    // create default frame
    Frame * frame = FrameFactory::defaultPictureFrame();
    setFrame(frame);

    // hide and layoutChildren buttons
    layoutChildren();

    // add to the scene
    scene->addItem(this);

    // display mirror
#if QT_VERSION >= 0x040600
    // WORKAROUND with Qt 4.6-tp1 there are crashes activating a mirror before setting the scene
    // need to rethink this anyway
    setMirrored(false);
#else
    setMirrored(RenderOpts::LastMirrored);
#endif
}