本文整理汇总了C++中CAView::getBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ CAView::getBounds方法的具体用法?C++ CAView::getBounds怎么用?C++ CAView::getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAView
的用法示例。
在下文中一共展示了CAView::getBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toast
void UtilManager::toast(string text, CAViewController* object) {
CAApplication::getApplication()->getRootWindow()->removeSubviewByTag(TOAST_VIEW_TAG);
CCSize winSize = CAApplication::getApplication()->getWinSize();
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, 180 * getScale(), 30 * getScale()));
back->setTag(TOAST_VIEW_TAG);
back->setColor(ccc4(31, 31, 31, 200));//40
CALabel *title = CALabel::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),
_dip(back->getBounds().size.height*0.5), 180 * getScale(), 30 * getScale()));
// title->setText(UTF8ToGBK::transferToGbk(text));
title->setText(text);
//title->setText("sssss");
// title->setFontName(getChineseFont());
title->setColor(CAColor_white);
title->setTextAlignment(CATextAlignmentCenter);
title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
title->setFontSize(_px(15));
back->addSubview(title);
//CAApplication::getApplication()->getRootWindow()->getRootViewController()->getView()->addSubview(back);
back->runAction(CCFadeOut::create(1));
//CAApplication::getApplication()->getRootWindow()->addSubview(back);
object->getView()->addSubview(back);
//CCLog("%s", get_date_now().c_str());
scheduleOnce(schedule_selector(UtilManager::removeToast), this, TOAST_TIME);
}
示例2: ccTouchMoved
void CANavigationController::ccTouchMoved(CATouch *pTouch, CAEvent *pEvent)
{
CC_RETURN_IF(m_pViewControllers.size() <= 1);
CC_RETURN_IF(m_bTouchMoved == false);
float offDis = pTouch->getLocation().x - pTouch->getPreviousLocation().x;
CAView* showContainer = m_pContainers.at(m_pContainers.size() - 2);
if (!showContainer->getBounds().size.equals(this->getView()->getBounds().size))
{
showContainer->setFrame(this->getView()->getBounds());
}
showContainer->setVisible(true);
showContainer->setTouchEnabled(false);
CAView* backContainer = m_pContainers.back();
DPoint point1 = backContainer->getFrameOrigin();
point1.x += offDis;
point1.x = MAX(point1.x, 0);
point1.x = MIN(point1.x, this->getView()->getBounds().size.width);
backContainer->setFrameOrigin(point1);
backContainer->setTouchEnabled(false);
DPoint point2 = showContainer->getCenterOrigin();
point2.x = point1.x/2;
showContainer->setCenterOrigin(point2);
m_bPopViewController = ((offDis > 10) || point1.x > this->getView()->getBounds().size.width/4);
}
示例3: passingTouchesViews
void CATouchController::passingTouchesViews(float dt)
{
CAView* view = dynamic_cast<CAView*>(CAApplication::getApplication()->getTouchDispatcher()->getFirstResponder());
bool isContainsFirstPoint = view && view->convertRectToWorldSpace(view->getBounds()).containsPoint(m_tFirstPoint);
if (!isContainsFirstPoint && view)
{
view->ccTouchBegan(m_pTouch, m_pEvent);
}
CC_RETURN_IF(m_vTouchesViews.empty());
CAResponder* responder = m_vTouchesViews.front();
while (responder->nextResponder())
{
m_vTouchesViews.pushBack(responder->nextResponder());
responder = responder->nextResponder();
}
for (int i=0; i<m_vTouchesViews.size();)
{
if (!m_vTouchesViews.at(i)->ccTouchBegan(m_pTouch, m_pEvent))
{
m_vTouchesViews.erase(i);
}
else
{
i++;
}
}
}
示例4: update
void CANavigationController::update(float dt)
{
CCRect rect = this->getView()->getBounds();
CCPoint point = this->getNavigationBarNowPoint();
switch (m_eNavigationBarVerticalAlignment)
{
case CABarVerticalAlignmentTop:
{
rect.origin.y = point.y + m_tNavigationBarSize.height;
rect.size.height = rect.size.height - rect.origin.y;
}
break;
case CABarVerticalAlignmentBottom:
{
rect.size.height = point.y;
}
break;
default:
break;
}
m_pNavigationBars.back()->setFrameOrigin(point);
CAView* secondContainer = m_pSecondContainers.back();
CAViewController* viewController = m_pViewControllers.back();
secondContainer->setFrame(rect);
viewController->getSuperViewRect(secondContainer->getBounds());
}
示例5: popToRootViewControllerAnimated
// [email protected]: 2015-03-08
void CANavigationController::popToRootViewControllerAnimated(bool animated)
{
if (m_pViewControllers.size() == 1)
{
return ;
}
float x = this->getView()->getBounds().size.width;
CAView* backContainer = m_pContainers.back();
backContainer->setFrameOrigin(DPointZero);
size_t index = 0;
CAViewController* showViewController = m_pViewControllers.at(index);
showViewController->viewDidAppear();
CAView* showContainer = m_pContainers.at(index);
showContainer->setVisible(true);
showContainer->setFrameOrigin(DPoint(-x/2.0f, 0));
{
DPoint point = this->getNavigationBarNowPoint(showViewController);
DRect rect = this->getView()->getBounds();
rect.origin.y = point.y + m_tNavigationBarSize.height;
rect.size.height = rect.size.height - rect.origin.y;
m_pNavigationBars.at(index)->setFrameOrigin(point);
CAView* secondContainer = m_pSecondContainers.at(index);
secondContainer->setFrame(rect);
showViewController->getSuperViewRect(secondContainer->getBounds());
}
CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsFalse();
if (animated)
{
CAViewAnimation::beginAnimations("", NULL);
CAViewAnimation::setAnimationDuration(0.25f);
CAViewAnimation::setAnimationDelay(0.02f);
CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut);
showContainer->setFrameOrigin(DPointZero);
CAViewAnimation::commitAnimations();
CAViewAnimation::beginAnimations("", NULL);
CAViewAnimation::setAnimationDuration(0.25f);
CAViewAnimation::setAnimationDelay(0.03f);
CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut);
CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CANavigationController::popToRootViewControllerFinish));
backContainer->setFrameOrigin(DPoint(x, 0));
CAViewAnimation::commitAnimations();
}
else
{
this->popToRootViewControllerFinish();
}
}
示例6: tableCellAtIndex
CATableViewCell* ExchangeViewController::tableCellAtIndex(CATableView* table, const CCSize& cellSize, unsigned int section, unsigned int row)
{
CCLog("row = %d , section = %d", row, section);
CADipSize _size = cellSize;
CATableViewCell* p_Cell = p_TableView->dequeueReusableCellWithIdentifier("2155");
if (p_Cell == NULL )
{
p_Cell = CATableViewCell::create("2155");
p_Cell->setAllowsSelected(false);
CAView* itemImage = CAView::createWithFrame(CADipRect(0, 0, _size.width, _size.height));
itemImage->setColor(ccc4(244, 243, 243, 255));
itemImage->setTag(99);
p_Cell->addSubview(itemImage);
CADipSize itemSize = itemImage->getBounds().size;
CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width/2, itemSize.height/3, itemSize.width,40));
itemText->setTag(100);
itemText->setFontSize(_px(35));
itemText->setTextAlignment(CATextAlignmentCenter);
itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
p_Cell->addSubview(itemText);
CALabel* itemText2 = CALabel::createWithCenter(CADipRect(itemSize.width/2, itemSize.height/5*4, itemSize.width,40));
itemText2->setTag(101);
itemText2->setFontSize(_px(25));
itemText2->setTextAlignment(CATextAlignmentCenter);
itemText2->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
p_Cell->addSubview(itemText2);
CAScale9ImageView* iv = CAScale9ImageView::createWithCenter(CADipRect(itemSize.width-50,itemSize.height/2,50,50));
iv->setImage(CAImage::create("source_material/cell_btn_right.png"));
iv->setTag(101);
p_Cell->addSubview(iv);
CAImageView* icon = CAImageView::createWithCenter(CADipRect(50,itemSize.height/2,64,64));
icon->setTag(101);
icon->setScale(0.6f);
icon->setImage(CAImage::create("source_material/btn_right_blue.png"));
p_Cell->addSubview(icon);
}
CALabel * label = (CALabel*)p_Cell->getSubviewByTag(100);
label->setText( unicode_to_utf8(exChangeMenuTag[row]) );
label->setColor(CAColor_black);
CALabel* label2 = (CALabel*)p_Cell->getSubviewByTag(101);
label2->setText(unicode_to_utf8(exChangeMenuTag2[row]));
label2->setColor(CAColor_gray);
return p_Cell;
}
示例7: getLastResponder
CAResponder* getLastResponder(CATouch* touch, const CAVector<CAView*>& subviews)
{
CAResponder* lastResponder = NULL;
for (CAVector<CAView*>::const_reverse_iterator itr=subviews.rbegin();
itr!=subviews.rend();
itr++)
{
CAView* subview = *itr;
if (subview->isVisible())
{
if (CAViewController* viewController = dynamic_cast<CAViewController*>(subview->getContentContainer()))
{
CC_CONTINUE_IF(!viewController->isTouchEnabled());
DPoint point = subview->convertTouchToNodeSpace(touch);
if (subview->getBounds().containsPoint(point))
{
lastResponder = viewController;
break;
}
}
else
{
CC_CONTINUE_IF(!subview->isTouchEnabled());
DPoint point = subview->convertTouchToNodeSpace(touch);
if (subview->getBounds().containsPoint(point))
{
lastResponder = subview;
break;
}
}
}
}
return lastResponder;
}
示例8: update
void CANavigationController::update(float dt)
{
CAViewController* viewController = m_pViewControllers.back();
DPoint point = this->getNavigationBarNowPoint(viewController);
DRect rect = this->getView()->getBounds();
rect.origin.y = point.y + m_tNavigationBarSize.height;
rect.size.height = rect.size.height - rect.origin.y;
m_pNavigationBars.back()->setFrameOrigin(point);
CAView* secondContainer = m_pSecondContainers.back();
secondContainer->setFrame(rect);
viewController->getSuperViewRect(secondContainer->getBounds());
}
示例9: touchCancelled
void CATouchController::touchCancelled()
{
CAScheduler::unschedule(schedule_selector(CATouchController::passingTouchesViews), this);
CAView* view = dynamic_cast<CAView*>(CAApplication::getApplication()->getTouchDispatcher()->getFirstResponder());
bool isContainsFirstPoint = view && view->convertRectToWorldSpace(view->getBounds()).containsPoint(m_tFirstPoint);
if (!isContainsFirstPoint && view)
{
view->ccTouchCancelled(m_pTouch, m_pEvent);
}
CAVector<CAResponder*>::iterator itr;
for (itr=m_vTouchesViews.begin(); itr!=m_vTouchesViews.end(); itr++)
{
(*itr)->ccTouchCancelled(m_pTouch, m_pEvent);
}
}
示例10: scrollViewWillBeginDragging
void CATabBarController::scrollViewWillBeginDragging(CAScrollView* view)
{
CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsFalse();
for (int i = MAX((int)m_nSelectedIndex - 1, 0);
i < MIN((int)m_nSelectedIndex + 2, m_pViewControllers.size());
i++)
{
if (!m_pViewControllers.at(i)->getView()->getSuperview())
{
CAView* view = m_pContainer->getSubViewAtIndex(i);
m_pViewControllers.at(i)->getView()->setFrame(view->getBounds());
m_pViewControllers.at(i)->addViewFromSuperview(view);
}
m_pViewControllers.at(i)->getView()->setVisible(true);
}
}
示例11: collectionCellAtIndex
CACollectionViewCell* CDUIShowCollectionView::collectionCellAtIndex(CACollectionView *collectionView, const CCSize& cellSize, unsigned int section, unsigned int row, unsigned int item)
{
if (row * 3 + item >= m_vTitle.size())
{
return NULL;
}
CADipSize _size = cellSize;
CACollectionViewCell* p_Cell = collectionView->dequeueReusableCellWithIdentifier("CrossApp");
if (p_Cell == NULL)
{
p_Cell = CACollectionViewCell::create("CrossApp");
p_Cell->setAllowsSelected(false);
CAView* itemImage = CAView::createWithFrame(CADipRect(0, 0, _size.width, _size.height));
itemImage->setTag(99);
p_Cell->addSubview(itemImage);
CADipSize itemSize = itemImage->getBounds().size;
CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width/2, itemSize.height-40, itemSize.width,40));
itemText->setTag(100);
itemText->setFontSize(_px(24));
itemText->setTextAlignment(CATextAlignmentCenter);
itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
p_Cell->addSubview(itemText);
CAImageView* icon = CAImageView::createWithCenter(CADipRect(itemSize.width/2,itemSize.height/3,189,123));
icon->setTag(101);
icon->setScale(0.6f);
p_Cell->addSubview(icon);
}
CAView* itemImageView = p_Cell->getSubviewByTag(99);
itemImageView->setColor(ccc4(244, 243, 243, 255));
int index = row * 3 + item;
CALabel* itemText = (CALabel*)p_Cell->getSubviewByTag(100);
itemText->setText(m_vTitle.at(index));
itemText->setColor(ccc4(34,151,254,255));
CAImageView* icon = (CAImageView*)p_Cell->getSubviewByTag(101);
icon->setImage(CAImage::create(iconTag[index]));
return p_Cell;
}
示例12: renderingSelectedViewController
void CATabBarController::renderingSelectedViewController()
{
if (m_nLastSelectedIndex < m_pViewControllers.size())
{
m_pViewControllers.at(m_nLastSelectedIndex)->getView()->setVisible(false);
m_pViewControllers.at(m_nLastSelectedIndex)->viewDidDisappear();
}
if (!m_pViewControllers.at(m_nSelectedIndex)->getView()->getSuperview())
{
CAView* view = m_pContainer->getSubViewAtIndex(m_nSelectedIndex);
m_pViewControllers.at(m_nSelectedIndex)->getView()->setFrame(view->getBounds());
m_pViewControllers.at(m_nSelectedIndex)->addViewFromSuperview(view);
}
m_pViewControllers.at(m_nSelectedIndex)->getView()->setVisible(true);
m_pViewControllers.at(m_nSelectedIndex)->viewDidAppear();
}
示例13: renderingSelectedViewController
void CATabBarController::renderingSelectedViewController(float dt)
{
std::vector<CAViewController*>::iterator itr;
for (itr=m_pViewControllers.begin(); itr!=m_pViewControllers.end(); itr++)
{
(*itr)->getView()->setVisible(false);
}
m_pViewControllers.at(m_nSelectedIndex)->getView()->setVisible(true);
if (m_pViewControllers.at(m_nSelectedIndex)->getView()->getSuperview() == NULL)
{
CCRect rect = m_pContainer->getFrame();
rect.origin.x = m_nSelectedIndex * rect.size.width;
rect.origin.y = 0;
CAView* view = CAView::createWithFrame(rect);
m_pContainer->addSubview(view);
m_pViewControllers.at(m_nSelectedIndex)->getView()->setFrame(view->getBounds());
m_pViewControllers.at(m_nSelectedIndex)->addViewFromSuperview(view);
}
}
示例14: update
void CATabBarController::update(float dt)
{
CCRect rect = m_pContainer->getFrame();
CCSize size = m_pContainer->getViewSize();
switch (m_eTabBarVerticalAlignment)
{
case CABarVerticalAlignmentTop:
{
rect.origin.y = m_pTabBar->getFrame().origin.y + m_pTabBar->getFrame().size.height;
rect.size.height = this->getView()->getBounds().size.height - rect.origin.y;
}
break;
case CABarVerticalAlignmentBottom:
{
rect.size.height = m_pTabBar->getFrame().origin.y;
}
break;
default:
break;
}
size.height = rect.size.height;
m_pContainer->setFrame(rect);
CCPoint point = m_pContainer->getContentOffset();
m_pContainer->setViewSize(size);
m_pContainer->setContentOffset(point, false);
for (unsigned int i=0; i<m_pViewControllers.size(); i++)
{
CAViewController* viewController = m_pViewControllers.at(i);
CAView* superview = viewController->getView()->getSuperview();
CC_CONTINUE_IF(superview == NULL);
rect.origin.x = superview->getFrameOrigin().x;
rect.origin.y = 0;
superview->setFrame(rect);
viewController->getSuperViewRect(superview->getBounds());
}
}
示例15: touchBegan
void CATouchController::touchBegan()
{
m_tFirstPoint = m_pTouch->getLocation();
std::vector<CAResponder*> vector;
CAView* view = dynamic_cast<CAView*>(CAApplication::getApplication()->getTouchDispatcher()->getFirstResponder());
bool isContainsFirstPoint = view && view->convertRectToWorldSpace(view->getBounds()).containsPoint(m_tFirstPoint);
if (isContainsFirstPoint)
{
vector = this->getEventListener(m_pTouch, view);
}
else
{
vector = this->getEventListener(m_pTouch, CAApplication::getApplication()->getRootWindow());
}
std::vector<CAResponder*>::iterator itr;
for (itr=vector.begin(); itr!=vector.end(); itr++)
{
if ((*itr)->isTouchMovedStopSubviews())
{
m_vTouchMovedsViewCache.pushBack((*itr));
}
}
m_vTouchesViews.pushBack(vector.back());
if (!m_vTouchMovedsViewCache.empty())
{
CAScheduler::schedule(schedule_selector(CATouchController::passingTouchesViews), this, 0, 0, 0.05f);
}
else
{
this->passingTouchesViews();
}
}