Example #1
0
StGLMenuItem* StGLMenu::addItem(const StString&                 theLabel,
                                const StHandle<StFloat32Param>& theTrackedValue,
                                const float                     theOnValue) {
    StGLMenuItem* aNewItem = new StGLMenuRadioButton(this, theTrackedValue, theOnValue);
    aNewItem->setText(theLabel);
    return aNewItem;
}
Example #2
0
StGLMenuItem* StGLMenu::addItem(const StString& theLabel,
                                const size_t    theUserData) {
    StGLMenuItem* aNewItem = new StGLMenuItem(this, 0, 0);
    aNewItem->setText(theLabel);
    aNewItem->setUserData(theUserData);
    return aNewItem;
}
Example #3
0
StGLMenuItem* StGLMenu::addItem(const StString&           theLabel,
                                const StHandle<StAction>& theAction,
                                StGLMenu*                 theSubMenu) {
    StGLMenuItem* aNewItem = new StGLMenuActionItem(this, theAction, theSubMenu);
    aNewItem->setText(theLabel);
    return aNewItem;
}
Example #4
0
bool StGLMenu::tryUnClick(const StClickEvent& theEvent,
                          bool&               theIsItemUnclicked) {
    myKeepActive = false;
    bool wasSomeClickedBefore = theIsItemUnclicked;
    bool isSelfClicked = StGLWidget::tryUnClick(theEvent, theIsItemUnclicked);
    bool isSelfItemClicked = !wasSomeClickedBefore && theIsItemUnclicked;
    if(myKeepActive) {
        return isSelfClicked;
    }

    for(StGLWidget* aChild = getChildren()->getStart(); aChild != NULL; aChild = aChild->getNext()) {
        StGLMenuItem* anItem = (StGLMenuItem* )aChild;
        if(anItem->hasSubMenu()
        && anItem->getSubMenu()->myKeepActive) {
            myKeepActive = true;
            return isSelfClicked;
        }
        anItem->setSelected(false);
    }

    if(myIsRootMenu && !isSelfItemClicked) {
        setActive(false); // deactivate root menu
    }

    if(myIsContextual) {
        myRoot->destroyWithDelay(this);
    }

    return isSelfClicked;
}
Example #5
0
int StGLButton::computeWidth(const StString& theText) {
    StGLMenuItem* anItem = getMenuItem();
    if(anItem == NULL) {
        return 0;
    }

    return anItem->computeTextWidth(theText) + myRoot->scale(8) + anItem->getMargins().left + anItem->getMargins().right;
}
Example #6
0
void StGLMenu::stglUpdateSubmenuLayout() {
    stglInit();
    for(StGLWidget* aChild = getChildren()->getStart(); aChild != NULL; aChild = aChild->getNext()) {
        StGLMenuItem* aMenuItem = (StGLMenuItem* )aChild;
        if(aMenuItem->getSubMenu() != NULL) {
            aMenuItem->getSubMenu()->stglUpdateSubmenuLayout();
        }
    }
}
Example #7
0
void StGLMenu::DeleteWithSubMenus(StGLMenu* theMenu) {
    if(theMenu == NULL) {
        return;
    }
    for(StGLWidget* aChild = theMenu->getChildren()->getStart(); aChild != NULL; aChild = aChild->getNext()) {
        StGLMenuItem* anItem = (StGLMenuItem* )aChild;
        if(anItem->getSubMenu() != NULL) {
            DeleteWithSubMenus(anItem->getSubMenu());
        }
    }
    delete theMenu;
}
Example #8
0
StGLButton::StGLButton(StGLWidget*     theParent,
                       const int       theLeft,
                       const int       theTop,
                       const StString& theText)
: StGLMenu(theParent, theLeft, theTop, StGLMenu::MENU_ZERO) {
    setShowBounds(true);
    StGLMenuItem* aBtn = addItem(theText);
    aBtn->signals.onItemClick.connect(this, &StGLButton::doItemClick);
    aBtn->setupAlignment(StGLTextFormatter::ST_ALIGN_X_CENTER,
                         StGLTextFormatter::ST_ALIGN_Y_CENTER);

    myWidth = aBtn->computeTextWidth() + myRoot->scale(16);
}
Example #9
0
void StCADViewerGUI::doShowMobileExMenu(const size_t ) {
    const int aTop = scale(56);

    StGLMenu*     aMenu  = new StGLMenu(this, 0, aTop, StGLMenu::MENU_VERTICAL_COMPACT, true);
    StGLMenuItem* anItem = NULL;
    aMenu->setCorner(StGLCorner(ST_VCORNER_TOP, ST_HCORNER_RIGHT));
    aMenu->setContextual(true);

    anItem = aMenu->addItem(tr(MENU_HELP_ABOUT));
    anItem->setIcon(stCMenuIcon("actionHelp"));
    anItem->signals.onItemClick += stSlot(this, &StCADViewerGUI::doAboutProgram);
    //anItem = aMenu->addItem(myPlugin->StApplication::params.ActiveDevice->getActiveValue());
    anItem = aMenu->addItem(tr(MENU_HELP_SETTINGS));
    anItem->setIcon(stCMenuIcon("actionSettings"));
    anItem->signals.onItemClick += stSlot(this, &StCADViewerGUI::doMobileSettings);
    aMenu->stglInit();
    setFocus(aMenu);
}
Example #10
0
bool StGLButton::stglInit() {
    const int aWidth = myWidth;
    if(!StGLMenu::stglInit()) {
        return false;
    }

    myWidth = aWidth;
    StGLMenuItem* anItem = getMenuItem();
    if(anItem == NULL) {
        return true;
    }

    anItem->changeRectPx().left()   = 0;
    anItem->changeRectPx().right()  = myWidth;
    anItem->changeRectPx().bottom() = anItem->changeRectPx().top() + myItemHeight;
    anItem->setTextWidth(myWidth - anItem->getMargins().left - anItem->getMargins().right);
    changeRectPx().right()  = getRectPx().left() + myWidth;
    changeRectPx().bottom() = getRectPx().top()  + myItemHeight;
    return true;
}
Example #11
0
void StGLButton::setLabel(const StString& theLabel) {
    StGLMenuItem* anItem = getMenuItem();
    if(anItem != NULL) {
        anItem->setText(theLabel);
    }
}
Example #12
0
void StGLButton::setFocus(const bool theValue) {
    StGLMenuItem* anItem = getMenuItem();
    if(anItem != NULL) {
        anItem->setFocus(theValue);
    }
}
Example #13
0
StGLMenuItem* StGLMenu::addItem(const StHandle<StBoolParamNamed>& theTrackedValue) {
    StGLMenuItem* aNewItem = new StGLMenuCheckbox(this, theTrackedValue);
    aNewItem->setText(theTrackedValue->getName());
    return aNewItem;
}
Example #14
0
StGLMenuItem* StGLMenu::addItem(const StHandle<StEnumParam>& theTrackedValue,
                                const int32_t                theOnValue) {
    StGLMenuItem* aNewItem = new StGLMenuRadioButton(this, theTrackedValue, theOnValue);
    aNewItem->setText(theTrackedValue->getOptionLabel(theOnValue));
    return aNewItem;
}
Example #15
0
StGLMenuItem* StGLMenu::addItem(const StString&              theLabel,
                                const StHandle<StBoolParam>& theTrackedValue) {
    StGLMenuItem* aNewItem = new StGLMenuCheckbox(this, theTrackedValue);
    aNewItem->setText(theLabel);
    return aNewItem;
}
Example #16
0
StGLMenuItem* StGLMenu::addItem(const StString& theLabel,
                                StGLMenu*       theSubMenu) {
    StGLMenuItem* aNewItem = new StGLMenuItem(this, 0, 0, theSubMenu);
    aNewItem->setText(theLabel);
    return aNewItem;
}
Example #17
0
void StGLButton::setFocus(const bool theValue) {
    StGLMenuItem* anItem = (StGLMenuItem* )getChildren()->getStart();
    if(anItem != NULL) {
        anItem->setFocus(theValue);
    }
}
Example #18
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;
}
Example #19
0
StGLMenuItem* StGLButton::addItem(const StString& theLabel) {
    StGLMenuItem* aNewItem = new StGLPassiveMenuItem(this);
    aNewItem->setText(theLabel);
    return aNewItem;
}