当前位置: 首页>>代码示例>>C++>>正文


C++ HorizontalLayout::addWidget方法代码示例

本文整理汇总了C++中HorizontalLayout::addWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ HorizontalLayout::addWidget方法的具体用法?C++ HorizontalLayout::addWidget怎么用?C++ HorizontalLayout::addWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HorizontalLayout的用法示例。


在下文中一共展示了HorizontalLayout::addWidget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: finish

void HallMainWidget::finish()
{
    float hrate = getHorAdaptResourceScale();
    CCSprite *bottomBg = CCSprite::createWithSpriteFrameName("hallbottom.png");
    CCSize bgSize = bottomBg->getContentSize();
    BasNodeDelegateWidget *bottomBar = new BasNodeDelegateWidget(bottomBg,CCSizeMake(bgSize.width * hrate,bgSize.height * hrate));
    this->addChild(bottomBar);
    bottomBar->setLeft("parent",uilib::Left);
    bottomBar->setRight("parent",uilib::Right);
    bottomBar->setBottom("parent",uilib::Bottom);
    bottomBar->setHeight(bgSize.height * hrate);

    BasWidget *pageWidget = new BasWidget;
    this->addChild(pageWidget);
    pageWidget->setLeft("parent",uilib::Left);
    pageWidget->setRight("parent",uilib::Right);
    pageWidget->setTop("parent",uilib::Top);
    pageWidget->setBottom(bottomBar->getName(),uilib::Top);

    BasWidget *buttonContainer =  bottomBar;

    if(m_pages.size() != 0){
        HorizontalLayout *barlay = new HorizontalLayout;
        barlay->setSpacing(5);
        barlay->setAlignChildsSize(true);
        barlay->setAveraged(true);
        barlay->setSizeLimitedToParent();
        BasButton *button;
        if(m_buttonTheme.empty())
            m_buttonTheme = "default";

        BasNodeAction *pageMoveIn = UiNodeActionFactory::getInstance()->getMoveActionByName("movein");
        pageMoveIn->setEaseType(uilib::EaseNone);
        pageMoveIn->setMoveInType(uilib::HorizontalRightIn);

        BasNodeAction *pageMoveOut = UiNodeActionFactory::getInstance()->getMoveActionByName("moveout");
        pageMoveOut->setEaseType(uilib::EaseNone);
        pageMoveOut->setMoveOutType(uilib::HorizontalRightOut);

        for(unsigned int i = 0;i < m_pages.size();i++){
            HallPageDef *page = m_pages[i];
            button = new BasButton;
            button->setTouchPriority(uilib::HighestPriority);
            button->setButtonIndex(i);
            button->setClickCB(this,callfuncND_selector(HallMainWidget::onPageButtonClicked));
            button->setButtonInfo("",m_buttonTheme,
                                  page->m_img,
                                  CCSizeMake(0,0),
                                  page->m_pressedImg
                                  );
            button->setWidthHeightRate(0.735);
            barlay->addWidget(button);
            page->m_page->setContainer(pageWidget);
            page->m_page->setMoveinAction(pageMoveIn);
            page->m_page->setMoveoutAction(pageMoveOut);
        }
        buttonContainer->setLayout(barlay);
        m_currPage = 0;
    }
}
开发者ID:firedragonpzy,项目名称:DirectFire-android,代码行数:60,代码来源:hallmainwidget.cpp

示例2: finished

void LoginRegDialog::finished()
{
    //init bg
    CCSize dialogSize = CCSizeMake(m_anchorWidth,m_anchorHeight);
    UiThemeDef *uiDef = UiThemeMgrProxy::getInstance()->getThemeByName(m_theme);
    BasSkin *skin = BorderImageSkin::create(dialogSize,uiDef,m_bg);
    if(skin) setSkin(skin);

    LangDef *lang = UiThemeMgrProxy::getInstance()->getThemeMgr()->getLangDef();
    if(1){ // title
        m_loginTitleWidget = new BasButton;
        m_loginTitleWidget->setCanTouch(false);
        m_loginTitleWidget->setButtonInfo("","fonts/uifont35.fnt",m_theme,m_titleBg);
        m_loginTitleWidget->setHorizontal("parent",0.5);
        m_loginTitleWidget->setTop("parent",uilib::Top);
        m_loginTitleWidget->setMaxHeightRefSize("parent",0.15);
        m_loginTitleWidget->setTopMargin(m_edgeSize);

        m_regTitleWidget = new BasButton;
        m_regTitleWidget->setCanTouch(false);
        m_regTitleWidget->setButtonInfo("","fonts/uifont35.fnt",m_theme,m_titleBg);
        m_regTitleWidget->setHorizontal("parent",0.5);
        m_regTitleWidget->setTop("parent",uilib::Top);
        m_regTitleWidget->setMaxHeightRefSize("parent",0.15);
        m_regTitleWidget->setTopMargin(m_edgeSize);
    }
    if(1){//buttons
        m_loginWidget = new BasWidget;
        HorizontalLayout *hlay;
        hlay = new HorizontalLayout;
        m_loginButton = new BasButton;
        m_loginButton->setCanTouch(true);
        m_loginButton->setButtonInfo(lang->getStringById(StringEnum::Login).data(),"fonts/uifont35.fnt",m_theme,m_loginImg,CCSizeMake(0,0),ccWHITE);
        m_loginButton->setButtonIndex(LoginButton);
        m_loginButton->setClickCB(this,callfuncND_selector(LoginRegDialog::onButtonClicked));

        m_loginCancelButton = new BasButton;
        m_loginCancelButton->setCanTouch(true);
        m_loginCancelButton->setButtonInfo(lang->getStringById(StringEnum::Cancel).data(),"fonts/uifont35.fnt",m_theme,m_cancelImg,CCSizeMake(0,0),ccWHITE);
        m_loginCancelButton->setButtonIndex(LoginCancelButton);
        m_loginCancelButton->setClickCB(this,callfuncND_selector(LoginRegDialog::onButtonClicked));

        m_loginRegButton = new BasButton;
        m_loginRegButton->setCanTouch(true);
        m_loginRegButton->setButtonInfo(lang->getStringById(StringEnum::Register).data(),"fonts/uifont35.fnt",m_theme,m_loginRegImg,CCSizeMake(0,0),ccWHITE);
        m_loginRegButton->setButtonIndex(LoginRegButton);
        m_loginRegButton->setClickCB(this,callfuncND_selector(LoginRegDialog::onButtonClicked));

        hlay->addWidget(m_loginButton);
        hlay->addWidget(m_loginCancelButton);
        hlay->addWidget(m_loginRegButton);
        hlay->setAlignChildsSize(true);
        hlay->setAveraged(true);

        m_loginWidget->setLayout(hlay);
        m_loginWidget->setLeft("parent",uilib::Left);
        m_loginWidget->setRight("parent",uilib::Right);
        m_loginWidget->setBottom("parent",uilib::Bottom);
        m_loginWidget->setMaxHeightRefSize("parent",0.2);
        m_loginWidget->setBottomMargin(m_edgeSize);
        m_loginWidget->setLeftMargin(m_edgeSize);
        m_loginWidget->setRightMargin(m_edgeSize);

        m_regWidget = new BasWidget;
        hlay = new HorizontalLayout;
        m_regButton = new BasButton;
        m_regButton->setCanTouch(true);
        m_regButton->setButtonInfo(lang->getStringById(StringEnum::Register).data(),"fonts/uifont35.fnt",m_theme,m_regImg,CCSizeMake(0,0),ccWHITE);
        m_regButton->setButtonIndex(RegButton);
        m_regButton->setClickCB(this,callfuncND_selector(LoginRegDialog::onButtonClicked));

        m_regBackButton = new BasButton;
        m_regBackButton->setCanTouch(true);
        m_regBackButton->setButtonInfo(lang->getStringById(StringEnum::Back).data(),"fonts/uifont35.fnt",m_theme,m_regBackImg,CCSizeMake(0,0),ccWHITE);
        m_regBackButton->setButtonIndex(RegBackButton);
        m_regBackButton->setClickCB(this,callfuncND_selector(LoginRegDialog::onButtonClicked));

        hlay->addWidget(m_regButton);
        hlay->addWidget(m_regBackButton);
        hlay->setAlignChildsSize(true);
        hlay->setAveraged(true);

        m_regWidget->setLayout(hlay);
        m_regWidget->setLeft("parent",uilib::Left);
        m_regWidget->setRight("parent",uilib::Right);
        m_regWidget->setBottom("parent",uilib::Bottom);
        m_regWidget->setMaxHeightRefSize("parent",0.2);
        m_regWidget->setBottomMargin(m_edgeSize);
        m_regWidget->setLeftMargin(m_edgeSize);
        m_regWidget->setRightMargin(m_edgeSize);

        //actions
        BasNodeAction *moveIn = UiNodeActionFactory::getInstance()->getMoveActionByName("movein");
        BasNodeAction *moveOut = UiNodeActionFactory::getInstance()->getMoveActionByName("moveout");
        moveIn->setEaseType(uilib::EaseSineInOut);
        moveIn->setMoveInType(uilib::ScaleYIn);
        moveOut->setEaseType(uilib::EaseSineInOut);
        moveOut->setMoveOutType(uilib::ScaleYOut);
        moveOut->setActionTime(0.2);
        moveIn->setStartTime(0.2);
//.........这里部分代码省略.........
开发者ID:firedragonpzy,项目名称:DirectFire-android,代码行数:101,代码来源:loginregdialog.cpp


注:本文中的HorizontalLayout::addWidget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。