コード例 #1
0
ファイル: StGLScrollArea.cpp プロジェクト: angelstudio/sview
void StGLScrollArea::stglResize() {
    StGLWidget* aContent = myChildren.getStart();
    StGLContext& aCtx = getContext();
    if(!isScrollable()
    && aContent != NULL
    && aContent->getRectPx().top() < 0
    && aContent->getCorner().v == ST_VCORNER_TOP) {
        const int aDelta = -aContent->getRectPx().top();
        aContent->changeRectPx().top()    += aDelta;
        aContent->changeRectPx().bottom() += aDelta;
    }

    if(isScrollable()
    && aContent != NULL) {
        const int    aSizeY       = stMax(getRectPx().height(), 1);
        const int    aContSizeY   = aContent->getRectPx().height();
        const double aScaleY      = double(aSizeY) / double(aContSizeY);
        const int    aScrollSizeY = stMax(int(aScaleY * (double )aSizeY), myRoot->scale(4));
        const double aPosY        = double(-aContent->getRectPx().top()) / double(aContSizeY - aSizeY);

        StArray<StGLVec2> aVertices(4);
        StRectI_t aRectPx = getRectPxAbsolute();
        aRectPx.left()   =  aRectPx.right() - myRoot->scale(2);
        aRectPx.top()    += int(aPosY * double(aSizeY - aScrollSizeY));
        aRectPx.bottom() =  aRectPx.top() + aScrollSizeY;

        myRoot->getRectGl(aRectPx, aVertices);
        myBarVertBuf.init(aCtx, aVertices);
    } else {
        myBarVertBuf.release(aCtx);
    }

    StGLWidget::stglResize();
}
コード例 #2
0
ファイル: StGLMenu.cpp プロジェクト: angelstudio/sview
void StGLMenu::stglResize() {
    // Since all children should be StGLMenuItem implementing delayed resize,
    // just postpone resize until items will be actually rendered.
    //StGLWidget::stglResize();
    for(StGLWidget* aChild = getChildren()->getStart(); aChild != NULL; aChild = aChild->getNext()) {
        ((StGLMenuItem* )aChild)->changeRectPx();
    }

    StGLContext& aCtx = getContext();

    StArray<StGLVec2> aVertices(4);
    getRectGl(aVertices);
    myVertexBuf.init(aCtx, aVertices);

    if(myToDrawBounds) {
        StRectI_t aRectBnd = getRectPxAbsolute();
        aRectBnd.left()   -= 1;
        aRectBnd.right()  += 1;
        aRectBnd.top()    -= 1;
        aRectBnd.bottom() += 1;
        myRoot->getRectGl(aRectBnd, aVertices);
        myVertexBndBuf.init(aCtx, aVertices);
    }
    myIsResized = false;
}
コード例 #3
0
ファイル: StGLWidget.cpp プロジェクト: KindDragon/sview
void StGLWidget::stglScissorRect(StGLBoxPx& theScissorRect) const {
    myRoot->stglScissorRect(getRectPxAbsolute(), theScissorRect);
}
コード例 #4
0
ファイル: StGLWidget.cpp プロジェクト: KindDragon/sview
void StGLWidget::getRectGl(StArray<StGLVec2>& theVertices) const {
    myRoot->getRectGl(getRectPxAbsolute(), theVertices);
}
コード例 #5
0
ファイル: StGLWidget.cpp プロジェクト: KindDragon/sview
StRectD_t StGLWidget::getRectGl() const {
    return myRoot->getRectGl(getRectPxAbsolute());
}
コード例 #6
0
ファイル: StGLMenu.cpp プロジェクト: angelstudio/sview
bool StGLMenu::stglInit() {
    myWidth = 0;
    myIsInitialized = StGLWidget::stglInit();
    if(!myIsInitialized) {
        return false;
    }
    int aMarginLeft = 0;
    for(StGLWidget* aChild = getChildren()->getStart(); aChild != NULL; aChild = aChild->getNext()) {
        StGLMenuItem* anItem = (StGLMenuItem* )aChild;
        aMarginLeft = stMax(aMarginLeft, anItem->getMargins().left);
        int anItemW = anItem->getMargins().left + anItem->computeTextWidth() + anItem->getMargins().right;
        if(myOrient == MENU_HORIZONTAL) {
            anItem->changeRectPx().moveLeftTo(myWidth);
            anItem->changeRectPx().right() = anItem->getRectPx().left() + anItemW;
            anItem->setTextWidth(anItemW - anItem->getMargins().left);
            myWidth += anItemW;
        } else {
            myWidth = stMax(myWidth, anItemW);
        }
        if(anItem->getSubMenu() != NULL) {
            if(myOrient == MENU_HORIZONTAL) {
                anItem->getSubMenu()->changeRectPx().moveTopLeftTo(anItem->getRectPxAbsolute().left(), anItem->getRectPxAbsolute().bottom());
            } else if(myOrient == MENU_VERTICAL
                   || myOrient == MENU_VERTICAL_COMPACT) {
                anItem->getSubMenu()->changeRectPx().moveTopLeftTo(anItem->getRectPxAbsolute().right() - myRoot->scale(10),
                                                                   anItem->getRectPxAbsolute().top());
            }
        }
    }
    StGLWidget* aChildLast = getChildren()->getLast();
    if(aChildLast != NULL) {
        changeRectPx().right()  = getRectPx().left() + aChildLast->getRectPx().right();
        changeRectPx().bottom() = getRectPx().top()  + aChildLast->getRectPx().bottom();
    }
    int aWidth = stMax(myWidthMin, myWidth);
    if(myOrient == MENU_VERTICAL
    || myOrient == MENU_VERTICAL_COMPACT) {
        changeRectPx().right() = getRectPx().left() + aWidth;
        int anItemCount = 0;
        for(StGLWidget* aChild = getChildren()->getStart(); aChild != NULL; aChild = aChild->getNext(), ++anItemCount) {
            StGLMenuItem* anItem = (StGLMenuItem* )aChild;
            anItem->changeRectPx().moveTopTo(anItemCount * myItemHeight);
            anItem->changeRectPx().right() = anItem->getRectPx().left() + aWidth;
            anItem->setTextWidth(aWidth);
            if(anItem->getSubMenu() != NULL) {
                anItem->getSubMenu()->changeRectPx().moveTopLeftTo(getRectPxAbsolute().right() - myRoot->scale(10),
                                                                   anItem->getRectPxAbsolute().top());
            }
        }
        changeRectPx().bottom() = getRectPx().top() + anItemCount * myItemHeight;
    }

    // already initialized?
    if(myVertexBuf.isValid()) {
        // synchronize menu items visibility
        setOpacity(myOpacity, true);
        return true;
    }

    stglResize();
    return myIsInitialized;
}