本文整理汇总了C++中CLayout::setContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CLayout::setContentSize方法的具体用法?C++ CLayout::setContentSize怎么用?C++ CLayout::setContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLayout
的用法示例。
在下文中一共展示了CLayout::setContentSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onClick
void CListViewBasicTest::onClick(Ref* pSender)
{
if( !m_lDatas.empty() )
{
tagItem& tItem = m_lDatas.front();
CLayout* pLayout = CLayout::create();
pLayout->setContentSize(tItem.tSize);
/*
pLayout->setBackgroundColor(Color4B(tItem.tColor.r,
tItem.tColor.g,
tItem.tColor.b,
255));
*/
pLayout->setBackgroundImage("icon.png");
pLayout->ignoreAnchorPointForPosition(false);
pLayout->setAnchorPoint(Vec2(0.5f, 0.5f));
pLayout->setContentSize(Size(tItem.tSize.width - 4, tItem.tSize.height - 2));
pLayout->setPosition(Vec2(tItem.tSize.width/2, tItem.tSize.height/2));
m_pListView->insertNodeAtLast(pLayout);
m_pListView->reloadData();
m_lDatas.pop_front();
}
}
示例2: create
CLayout* CLayout::create(const Size& tContentSize)
{
CLayout* pRet = new CLayout();
if( pRet && pRet->init() )
{
pRet->setContentSize(tContentSize);
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
示例3: onEnter
void CVipCard::onEnter()
{
BaseLayer::onEnter();
//确定
CButton* pConfirm = (CButton*)m_ui->findWidgetById("confirm");
pConfirm->setOnClickListener(this, ccw_click_selector(CVipCard::onConfirm));
CButton* cancel = (CButton*)m_ui->findWidgetById("cancel");
cancel->setOnClickListener(this, ccw_click_selector(CVipCard::onCancel));
CButton* pClose = CButton::create("common/back.png", "common/back.png");
pClose->getSelectedImage()->setScale(1.1f);
pClose->setPosition(VLEFT+50, VTOP-50);
pClose->setOnClickListener(this,ccw_click_selector(CVipCard::onClose));
this->addChild(pClose, 999);
CImageViewScale9* pRect1 = (CImageViewScale9*)m_ui->findWidgetById("rect1");
m_cardText = CursorTextField::textFieldWithPlaceHolder("", FONT_NAME, 29, CCSize(690, 110), ccBLACK);
m_cardText->setPriority(this->getTouchPriority());
m_cardText->setLimitNum(17);
m_cardText->setAnchorPoint(ccp(0, 0.5f));
m_cardText->setPosition( ccp(pRect1->getPositionX()-440, pRect1->getPositionY()));
m_ui->addChild(m_cardText, 999);
//展示区图片
CLayout *pShowInfo = CLayout::create();
CScrollView *pScroll = (CScrollView*)m_ui->findWidgetById("scroll_info");
pScroll->setDirection(eScrollViewDirectionVertical);
pScroll->setBounceable(false);
pScroll->getContainer()->addChild(pShowInfo);
CCSize size = CCSize(957, 471);
pShowInfo->setContentSize(size);
pScroll->setContainerSize(size);
pShowInfo->setPosition(ccp(pScroll->getContainerSize().width*0.5f, pScroll->getContainerSize().height*0.5f));
pScroll->setContentOffsetToTop();
//嫁接内容
CLayout* pLayout = (CLayout*)findWidgetById("layer_info");
pLayout->retain();
pLayout->removeFromParent();
pShowInfo->addChild(pLayout);
pLayout->release();
pLayout->setPosition(ccp(size.width/2, size.height/2+10));
}
示例4: parseControl
//.........这里部分代码省略.........
if (pChild->getTag() > 0)
pChild->setPosition(pChild->getPosition() + Vec2(w / 2, h / 2));
}
pList->insertNodeAtLast(pLayout);
}
pList->reloadData();
}else if (strcmp(item->first_attribute("type")->value(), kTuiControlExpList) == 0){//explist
float w = atof(item->first_attribute("width")->value());
float h = atof(item->first_attribute("height")->value());
float num = atof(item->first_attribute("num")->value());
int r = atoi(item->first_attribute("red")->value());
int g = atoi(item->first_attribute("green")->value());
int b = atoi(item->first_attribute("blue")->value());
int a = atoi(item->first_attribute("alpha")->value());
CExpandableListView* pList = createExpandableListView(tag, Color4B(r, g, b, a), x, y, w, h, rotation);
container->addChild(pList);
for (int i = 0; i < num; i++){//add item
xml_node<char> *iitem = item->first_node(kTuiNodeControl);
w = atof(iitem->first_attribute("width")->value());
h = atof(iitem->first_attribute("height")->value());
int iw, ih = 0;
CExpandableNode *pExpNode = createExpandNode(i, 0, 0, w, h, rotation);
CLayout *pExpNodeItem = nullptr;
for (xml_node<char> *iiitem = iitem->first_node(kTuiNodeControl); iiitem != NULL; iiitem = iiitem->next_sibling()){
if (strcmp(iiitem->first_attribute("type")->value(), kTuiContainerLayout) != 0){
parseControl(pExpNode, iiitem);
}else{
pExpNodeItem = createLayout(0, 0, 0, w, h, rotation);
iw = atof(iiitem->first_attribute("width")->value());
ih = atof(iiitem->first_attribute("height")->value());
pExpNodeItem->setContentSize(Size(iw, ih));
for (xml_node<char> *iiiitem = iiitem->first_node(kTuiNodeControl); iiiitem != NULL; iiiitem = iiiitem->next_sibling()){
parseControl(pExpNodeItem, iiiitem);
}
}
}
for (Node *c : pExpNode->getChildren())
{
if (c->getTag() > 0)
c->setPosition(c->getPosition() + Vec2(w / 2, h / 2));
}
for (Node *c : pExpNodeItem->getChildren())
{
c->setPosition(c->getPosition() + Vec2(iw/2, ih / 2));
}
pExpNode->insertItemNodeAtLast(pExpNodeItem);
pList->insertExpandableNodeAtLast(pExpNode);
}
pList->reloadData();
}else if(strcmp(item->first_attribute("type")->value(),kTuiControlCheckBox) == 0){//checkBox
const char* normal1 = item->first_attribute("normal1")->value();
const char* normal2 = item->first_attribute("normal2")->value();
const char* select1 = item->first_attribute("select1")->value();
const char* select2 = item->first_attribute("select2")->value();
const char* disable1 = item->first_attribute("disable1")->value();
const char* disable2 = item->first_attribute("disable2")->value();
int isUseFrame = atoi(item->first_attribute("spriteFrame")->value());
CCheckBox *pCheckBox = createCheckBox(tag,normal1,normal2,select1,select2,disable1,disable2,x,y,rotation,isUseFrame);
container->addChild(pCheckBox);
}else if(strcmp(item->first_attribute("type")->value(),kTuiControlArmatureBtn) == 0){//ArmatureBtn
const char* png = item->first_attribute("png")->value();