本文整理汇总了C++中HorizontalLayout::setSpacing方法的典型用法代码示例。如果您正苦于以下问题:C++ HorizontalLayout::setSpacing方法的具体用法?C++ HorizontalLayout::setSpacing怎么用?C++ HorizontalLayout::setSpacing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HorizontalLayout
的用法示例。
在下文中一共展示了HorizontalLayout::setSpacing方法的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;
}
}
示例2:
Dialog::Dialog(std::shared_ptr<DialogData> p) {
using namespace DialogSettings;
sizePolicy = WidgetSizePolicy::PREFER;
layout._setPos(IntPair{borderSz, borderSz});
layout.setMargins(0, 0, 0, 0);
layout.setWidgetAlignment(WidgetAlignmentHoriz::LEFT, WidgetAlignmentVert::TOP);
layout.setSpacing(widgetSpacing);
// process data
assert(p);
data = p;
assert(!data->title.empty());
assert(!data->message.empty());
assert(!data->buttonText.empty());
TextRenderer* tr = GameData::instance().resources->getDefaultTR();
WidgetText* textTitle = new WidgetText;
textTitle->enableBackground(colTitleBg);
textTitle->setRenderer(tr);
textTitle->setTextColor(colText);
textTitle->setText(data->title);
WidgetText* textMessage = new WidgetText;
textMessage->setRenderer(tr);
textMessage->setTextColor(colText);
textMessage->setText(data->message);
// add buttons
HorizontalLayout* hLayout = new HorizontalLayout;
hLayout->setWidgetAlignment(WidgetAlignmentHoriz::LEFT, WidgetAlignmentVert::TOP);
hLayout->setSpacing(btnSpacing);
std::shared_ptr<TextButton::Style> buttonStyle = std::make_shared<TextButton::Style>();
buttonStyle->tr = tr;
buttonStyle->outlineSz = 0;
buttonStyle->colText = colBtnText;
buttonStyle->colBgOut = colBtnBgOut;
buttonStyle->colBgOver = colBtnBgOver;
buttonStyle->colBgDown = colBtnBgDown;
TextButton* button;
for (std::size_t i = 0; i < data->buttonText.size(); ++i) {
button = new TextButton;
button->setStyle(buttonStyle);
button->setText(data->buttonText[i]);
button->setCallback(std::bind(&self_type::buttonCallback, this, i));
hLayout->add(button);
}
// add to layout
layout.add(textTitle);
layout.add(textMessage);
layout.add(hLayout);
// finalize
layout._setParent(this);
_resize(getPrefSize(), WidgetResizeFlag::SELF);
}