Exemplo n.º 1
0
void StGLRootWidget::stglResize(const StGLBoxPx& theRectPx) {
    const bool isChanged = getRectPx().right()  != theRectPx.width()
                        || getRectPx().bottom() != theRectPx.height();

    myProjCamera.resize(*myGlCtx, theRectPx.width(), theRectPx.height());

    changeRectPx().right()  = theRectPx.width();  // (left, top) forced to zero point (0, 0)
    changeRectPx().bottom() = theRectPx.height();

    myProjCamera.getZParams(myRectGl);
    myScaleGlX = (myRectGl.right() - myRectGl.left()) / GLdouble(getRectPx().width());
    myScaleGlY = (myRectGl.top() - myRectGl.bottom()) / GLdouble(getRectPx().height());

    myScrProjMat = myProjCamera.getProjMatrix();
    myScrProjMat.translate(StGLVec3(0.0f, 0.0f, -myProjCamera.getZScreen()));

    if(myMenuProgram->isValid()) {
        myMenuProgram->use(*myGlCtx);
        myMenuProgram->setProjMat(*myGlCtx, getScreenProjection());
        myMenuProgram->unuse(*myGlCtx);
    }

    // update all child widgets
    if(isChanged) {
        StGLWidget::stglResize();
    }
}
Exemplo n.º 2
0
bool StGLSwitchTextured::stglInit() {
    bool isOK = StGLWidget::stglInit();
    StGLWidget* aChild = getChildren()->getStart();
    if(aChild != NULL) {
        // just upsacle to fit children
        changeRectPx().right()  = getRectPx().left() + aChild->getRectPx().width();
        changeRectPx().bottom() = getRectPx().top()  + aChild->getRectPx().height();
    }
    return isOK;
}
Exemplo n.º 3
0
bool StGLButton::stglInit() {
    const int aWidth = myWidth;
    if(!StGLMenu::stglInit()) {
        return false;
    }

    myWidth = aWidth;
    StGLMenuItem* anItem = (StGLMenuItem* )getChildren()->getStart();
    if(anItem == NULL) {
        return true;
    }

    anItem->changeRectPx().left()   = 0;
    anItem->changeRectPx().right()  = myWidth;
    anItem->changeRectPx().bottom() = anItem->changeRectPx().top() + myItemHeight;
    anItem->setTextWidth(myWidth);
    changeRectPx().right()  = getRectPx().left() + myWidth;
    changeRectPx().bottom() = getRectPx().top()  + myItemHeight;
    return true;
}
Exemplo n.º 4
0
bool StGLRangeFieldFloat32::stglInit() {
    if(myValueText != NULL) {
        return true;
    }

    myValueText = new StGLTextArea(this, 0, 0, StGLCorner(ST_VCORNER_CENTER, ST_HCORNER_LEFT), -myRoot->scale(1), myRoot->scale(10));
    onValueChange(0.0f);
    myValueText->setTextColor(StGLVec3(1.0f, 1.0f, 1.0f));
    myValueText->setVisibility(true, true);
    if(!myValueText->stglInitAutoHeightWidth()) {
        delete myValueText; myValueText = NULL;
        return false;
    }

    myValueText->changeRectPx().right() += myRoot->scale(10);
    myValueText->setTextWidth(myValueText->getRectPx().width());
    myValueText->setupAlignment(StGLTextFormatter::ST_ALIGN_X_RIGHT, StGLTextFormatter::ST_ALIGN_Y_TOP);
    onValueChange(myTrackValue->getValue());
    const GLint aHeight = myValueText->getRectPx().height();

    StGLButton* aButDec = new StGLButton(this, 0, 0, "-");
    aButDec->setCorner(StGLCorner(ST_VCORNER_CENTER, ST_HCORNER_LEFT));
    aButDec->setHeight(aHeight);
    aButDec->setWidth(myRoot->scale(15));
    aButDec->setVisibility(true, true);
    aButDec->signals.onBtnClick += stSlot(this, &StGLRangeFieldFloat32::doDecrement);

    myValueText->changeRectPx().moveLeftTo(aButDec->getRectPx().right() - myRoot->scale(5));

    StGLButton* aButInc = new StGLButton(this, myValueText->getRectPx().right() + myRoot->scale(5), 0, "+");
    aButInc->setCorner(StGLCorner(ST_VCORNER_CENTER, ST_HCORNER_LEFT));
    aButInc->setHeight(aHeight);
    aButInc->setWidth(myRoot->scale(15));
    aButInc->setVisibility(true, true);
    aButInc->signals.onBtnClick += stSlot(this, &StGLRangeFieldFloat32::doIncrement);

    changeRectPx().right()  = getRectPx().left() + aButInc->getRectPx().right();
    changeRectPx().bottom() = getRectPx().top()  + aHeight;

    return StGLWidget::stglInit();
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
void StGLMsgStack::stglResize() {
    changeRectPx().bottom() = myRoot->getRectPx().height();
    changeRectPx().right()  = myRoot->getRectPx().width();
    StGLWidget::stglResize();
}
Exemplo n.º 7
0
void StGLButton::setWidth(const int theWidth) {
    myWidth = theWidth;
    changeRectPx().right() = changeRectPx().left() + theWidth;
}