Exemplo n.º 1
0
int ViewportConfiguration::layoutWidth() const
{
    ASSERT(!constraintsAreAllRelative(m_configuration));

    const FloatSize& minimumLayoutSize = m_minimumLayoutSize;
    if (m_configuration.widthIsSet) {
        // If we scale to fit, then accept the viewport width with sanity checking.
        if (!m_configuration.initialScaleIsSet) {
            double maximumScale = this->maximumScale();
            double maximumContentWidthInViewportCoordinate = maximumScale * m_configuration.width;
            if (maximumContentWidthInViewportCoordinate < minimumLayoutSize.width()) {
                // The content zoomed to maxScale does not fit the the view. Return the minimum width
                // satisfying the constraint maximumScale.
                return std::round(minimumLayoutSize.width() / maximumScale);
            }
            return std::round(m_configuration.width);
        }

        // If not, make sure the viewport width and initial scale can co-exist.
        double initialContentWidthInViewportCoordinate = m_configuration.width * m_configuration.initialScale;
        if (initialContentWidthInViewportCoordinate < minimumLayoutSize.width()) {
            // The specified width does not fit in viewport. Return the minimum width that satisfy the initialScale constraint.
            return std::round(minimumLayoutSize.width() / m_configuration.initialScale);
        }
        return std::round(m_configuration.width);
    }

    // If the page has a real scale, then just return the minimum size over the initial scale.
    if (m_configuration.initialScaleIsSet && !m_configuration.heightIsSet)
        return std::round(minimumLayoutSize.width() / m_configuration.initialScale);

    if (minimumLayoutSize.height() > 0)
        return std::round(minimumLayoutSize.width() * layoutHeight() / minimumLayoutSize.height());
    return minimumLayoutSize.width();
}
//----------------------------------------------------------------------------//
void HorizontalLayoutContainer::layout()
{
    // used to compare UDims
    const float absHeight = getChildContentArea().get().getHeight();

    // this is where we store the left offset
    // we continually increase this number as we go through the windows
    UDim leftOffset(0, 0);
    UDim layoutHeight(0, 0);

    for (ChildList::iterator it = d_children.begin(); it != d_children.end(); ++it)
    {
        Window* window = static_cast<Window*>(*it);

        const UVector2 offset = getOffsetForWindow(window);
        const UVector2 boundingSize = getBoundingSizeForWindow(window);

        // full child window width, including margins
        const UDim& childHeight = boundingSize.d_y;

        if (CoordConverter::asAbsolute(layoutHeight, absHeight) <
            CoordConverter::asAbsolute(childHeight, absHeight))
        {
            layoutHeight = childHeight;
        }

        window->setPosition(offset + UVector2(leftOffset, UDim(0, 0)));
        leftOffset += boundingSize.d_x;
    }

    setSize(USize(leftOffset, layoutHeight));
}
Exemplo n.º 3
0
bool ViewportConfiguration::shouldIgnoreVerticalScalingConstraints() const
{
    if (!m_canIgnoreScalingConstraints)
        return false;

    if (!m_configuration.allowsShrinkToFit)
        return false;

    bool laidOutTallerThanViewport = m_contentSize.height() > layoutHeight();
    if (m_viewportArguments.height == ViewportArguments::ValueDeviceHeight && m_viewportArguments.width == ViewportArguments::ValueAuto)
        return laidOutTallerThanViewport;

    return false;
}
Exemplo n.º 4
0
IntSize ViewportConfiguration::layoutSize() const
{
    return IntSize(layoutWidth(), layoutHeight());
}
Exemplo n.º 5
0
double ViewportConfiguration::initialScaleIgnoringContentSize() const
{
    return initialScaleFromSize(layoutWidth(), layoutHeight(), false);
}
Exemplo n.º 6
0
double ViewportConfiguration::initialScale() const
{
    return initialScaleFromSize(m_contentSize.width() > 0 ? m_contentSize.width() : layoutWidth(), m_contentSize.height() > 0 ? m_contentSize.height() : layoutHeight(), shouldIgnoreScalingConstraints());
}