Ejemplo n.º 1
0
QMatrix4x4 const & Camera::viewInverted() const
{
    if (m_isViewInvalid){
        recalculateView();
    }
    return *m_viewInverted;
}
Ejemplo n.º 2
0
            inline void updateRecursive(FT mFT)
            {
                // Recalculate depth
                depth = parent == nullptr ? 0 : parent->depth +
                                                    ssvu::toInt(container);

                update(mFT);

                // Recalculate size and position
                recalcSizeSmart(&Widget::scalingX, &Widget::setWidth,
                    &Widget::getLeft, &Widget::getRight, &Vec2f::x,
                    &Vec2<bool>::x);
                recalcSizeSmart(&Widget::scalingY, &Widget::setHeight,
                    &Widget::getTop, &Widget::getBottom, &Vec2f::y,
                    &Vec2<bool>::y);

                for(auto& w : children) w->updateRecursive(mFT);

                recalculateView();
                onPostUpdate();

                updateInput();

                // not needed?
                // recurseChildrenBF<true, true>([this](Widget& mW){
                // mW.updateInput(); });
            }
Ejemplo n.º 3
0
//*******************************************************************************
Camera::Camera( double fovY, int viewportWidth, int viewportHeight, HapticDevice * pHd )
{
	m_LastX = 0.0;
	m_LastY = 0.0;
	m_FovY = fovY;
	m_pHapticDevice = pHd;
	recalculateView(viewportWidth, viewportHeight);
}
Ejemplo n.º 4
0
void Container::setPosition(const sf::Vector2f& newposition)
{
    if(getPosition() != newposition) //If given is different from current
    {
        WidgetBase::setPosition(newposition);
        recalculateView();
        needsWidgetResize = true;
        update();
        scrollBar->recalculateScrollBar(); //Recalculate scrollbar
    }
}
Ejemplo n.º 5
0
void Camera::recalculateViewProjection() const
{
    if (m_isViewInvalid){
        recalculateView();
    }
    if (m_isProjectionInvalid){
        recalculateProjection();
    }
    *m_viewProjection = projection() * view();
    *m_viewProjectionInverted = m_viewProjection->inverted();
    m_isViewProjectionInvalid = false;
}
Ejemplo n.º 6
0
void Container::setSize(const sf::Vector2f& newarea)
{
    if(getSize() != newarea) //If given is different from current
    {
        WidgetBase::setSize(newarea);
        repositionWidgets(); //Reposition things to take up the new space
        recalculateView();
        scrollBar->recalculateScrollBar();
        needsWidgetResize = true;
        update();
    }
}
Ejemplo n.º 7
0
void Container::repositionWidgets()
{
    //Firstly, resize the buttons so they'll fit properly

    //Note - one of these is picked depending on if the button is spaced horizontally or vertically
    const float allocatedHorizontalSpace = (getSize().x/widgets.size())-(spacing.x); //Set maximum height of widget, taking into account spacing
    const float allocatedVerticalSpace = (getSize().y/widgets.size())-(spacing.y); //Set maximum width of widget, taking into account spacing

    //Do the resizing, iterate through each one and set it
    if(allowAutoResizing)
    {
        for(auto iter = widgets.begin(); iter != widgets.end(); iter++)
        {
            if(allocation == Allocation::vertical)
                (*iter)->setSize(sf::Vector2f(getSize().x - ((*iter)->getBezelThickness() * 2), allocatedVerticalSpace));
            else if(allocation == Allocation::horizontal)
                (*iter)->setSize(sf::Vector2f(allocatedHorizontalSpace, getSize().y - ((*iter)->getBezelThickness() * 2)));
        }
    }

    //Secondly, reposition them
    float cPos = 0;
    unsigned int counter = 0;
    drawStopPosition = 0;
    for(auto iter = widgets.begin(); iter != widgets.end(); iter++)
    {
        //We pick one of these depending on if the buttons are being ordered horizontally or vertically.
        if(allocation == Allocation::vertical) //Vertical
        {
            (*iter)->setPosition(sf::Vector2f(getPosition().x + (*iter)->getBezelThickness(), getPosition().y + cPos + (*iter)->getBezelThickness()));
            cPos += (*iter)->getSize().y + spacing.y;

            if(cPos > getSize().y) //If we go over allocated space, cut remaining off.
            {
                drawStopPosition = counter + 1;
            }
        }
        else if(allocation == Allocation::horizontal) //Horizontal
        {
            (*iter)->setPosition(sf::Vector2f(getPosition().x + cPos, getPosition().y + (*iter)->getBezelThickness()));
            cPos += (*iter)->getSize().x + spacing.x;

            if(cPos > getSize().x) //If we go over allocated space, cut remaining off.
            {
                drawStopPosition = counter + 1;
            }
        }
        iter->get()->centerText();
        counter++;
    }
    if(drawStopPosition == 0) //If it hasn't increased then the widgets don't go too far, so draw all of them
        drawStopPosition = widgets.size();
    //Recalculate average widget size
    recalculateAverageWidgetSize();
    //Recalculate scroll menu
    scrollBar->recalculateScrollBar();
    //Recalculate what should/shouldn't be drawn
    recalculateDrawPos();
    //Recalculate view
    recalculateView();
}