void CATextView::delayShowImage() { if (!CAViewAnimation::areBeginAnimationsWithID(m_s__StrID + "showImage")) { CAViewAnimation::beginAnimations(m_s__StrID + "showImage", NULL); CAViewAnimation::setAnimationDuration(0); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CATextView::showImage)); CAViewAnimation::commitAnimations(); } }
CommonUrlImageView::~CommonUrlImageView() { CC_SAFE_RELEASE(dynamic_cast<CAObject*>(m_pDelegate)); m_pDelegate = NULL; CC_SAFE_RETAIN(m_pobImage); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(1.0f); CAViewAnimation::setAnimationDidStopSelector(m_pobImage, CAViewAnimation0_selector(CAImage::release)); CAViewAnimation::commitAnimations(); }
void CAListView::onEnterTransitionDidFinish() { CAScrollView::onEnterTransitionDidFinish(); if (m_pUsedListCells.empty()) { CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CAListView::reloadData)); CAViewAnimation::commitAnimations(); } }
void CANavigationController::replaceViewController(CrossApp::CAViewController *viewController, bool animated) { if (this->getView()->getSuperview() == NULL) { return; } if (m_pNavigationBars.size() == 1) { CANavigationBarItem* item = viewController->getNavigationBarItem(); if (item == NULL) { item = CANavigationBarItem::create(""); } item->setShowGoBackButton(false); viewController->setNavigationBarItem(item); } float x = this->getView()->getBounds().size.width; CAView* lastContainer = m_pContainers.back(); this->createWithContainer(viewController); this->layoutNewContainer(); CAView* newContainer = m_pContainers.back(); CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsFalse(); if (animated) { newContainer->setFrameOrigin(DPoint(x, 0)); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(1/30.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); lastContainer->setFrameOrigin(DPoint(-x/2.0f, 0)); CAViewAnimation::commitAnimations(); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(1/60.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CANavigationController::replaceViewControllerFinish)); newContainer->setFrameOrigin(DPointZero); CAViewAnimation::commitAnimations(); } else { this->replaceViewControllerFinish(); } }
bool CAAutoCollectionView::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent) { if (!m_vTouches.empty()) { m_vTouches.replace(0, pTouch); return true; } bool isInertia = m_tInertia.getLength() < 1.0f; if (!CAScrollView::ccTouchBegan(pTouch, pEvent)) return false; if (m_bAllowsSelection && this->isScrollWindowNotOutSide() == false && isInertia) { DPoint point = m_pContainer->convertTouchToNodeSpace(pTouch); std::map<CAIndexPath3E, CACollectionViewCell*>::iterator itr; for (itr = m_mpUsedCollectionCells.begin(); itr != m_mpUsedCollectionCells.end(); ++itr) { CACollectionViewCell* pCell = itr->second; CC_CONTINUE_IF(pCell == NULL); if (pCell->getFrame().containsPoint(point) && pCell->isVisible()) { CC_BREAK_IF(pCell->getControlState() == CAControlStateDisabled); if (m_pHighlightedCollectionCells != pCell) { if (m_pHighlightedCollectionCells) { m_pHighlightedCollectionCells->setControlStateNormal(); } m_pHighlightedCollectionCells = pCell; } CC_BREAK_IF(pCell->getControlState() == CAControlStateSelected); CAViewAnimation::beginAnimations(m_s__StrID, NULL); CAViewAnimation::setAnimationDuration(0.05f); CAViewAnimation::setAnimationDidStopSelector(pCell, CAViewAnimation0_selector(CACollectionViewCell::setControlStateHighlighted)); CAViewAnimation::commitAnimations(); break; } } } return true; }
CAViewController* CANavigationController::popViewControllerAnimated(bool animated) { if (m_pViewControllers.size() == 1) { return NULL; } float x = this->getView()->getBounds().size.width; size_t index = m_pViewControllers.size() - 2; CAViewController* showViewController = m_pViewControllers.at(index); showViewController->viewDidAppear(); CAViewController* backViewController = m_pViewControllers.back(); CAView* showContainer = m_pContainers.at(m_pContainers.size() - 2); showContainer->setVisible(true); showContainer->setFrameOrigin(CCPoint(-x/2.0f, 0)); CAView* backContainer = m_pContainers.back(); backContainer->setFrameOrigin(CCPointZero); CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsFalse(); if (animated) { CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(1/30.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); showContainer->setFrameOrigin(CCPointZero); CAViewAnimation::commitAnimations(); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(1/60.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CANavigationController::popViewControllerFinish)); backContainer->setFrameOrigin(CCPoint(x, 0)); CAViewAnimation::commitAnimations(); } else { this->popViewControllerFinish(); } return backViewController; }
void CASwitch::updateSwitchState(bool animated, bool callfunced) { float time = 0; if (animated) { time = 0.2f; } m_onImageView->setVisible(m_isOn); m_offImageView->setVisible(!m_isOn); CCPoint point = m_obContentSize/2; m_onImageView->setCenterOrigin(point); m_offImageView->setCenterOrigin(point); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.2f); if (m_isOn) { CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseIn); m_offImageView->setAlpha(0.0f); } else { CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); m_offImageView->setAlpha(1.0f); } CAViewAnimation::commitAnimations(); if (m_thumbTintImageView) { CCPoint point = CCPointZero; point.x = m_isOn ? (m_obContentSize.width - m_thumbTintImageView->getBounds().size.width) : 0; CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.2f); CAViewAnimation::setAnimationDelay(1/60.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseIn); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CASwitch::updateValueChanged)); m_thumbTintImageView->setFrameOrigin(point); CAViewAnimation::commitAnimations(); } }
void CANavigationController::pushViewController(CAViewController* viewController, bool animated) { if (this->getView()->getSuperview() == NULL) { return; } float x = this->getView()->getBounds().size.width; CAView* lastContainer = m_pContainers.back(); this->createWithContainer(viewController); this->layoutNewContainer(); CAView* newContainer = m_pContainers.back(); CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsFalse(); if (animated) { newContainer->setFrameOrigin(CCPoint(x, 0)); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(1/30.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); lastContainer->setFrameOrigin(CCPoint(-x/2.0f, 0)); CAViewAnimation::commitAnimations(); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(1/60.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CANavigationController::pushViewControllerFinish)); newContainer->setFrameOrigin(CCPointZero); CAViewAnimation::commitAnimations(); } else { this->pushViewControllerFinish(); } }
void CAProgress::setProgress(float progress, bool animated) { progress = MIN(1.0f, progress); progress = MAX(0.0f, progress); DPoint point = DPoint(this->getBounds().size.width * progress, 0); if (animated) { this->animatedBegin(); float time = fabsf(progress - m_fProgress) * 0.3f; CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(time); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CAProgress::animatedFinish)); m_pIndicator->setFrameOrigin(point); CAViewAnimation::commitAnimations(); } else { m_pIndicator->setFrameOrigin(point); this->update(0); } }
void CANavigationController::setNavigationBarHidden(bool hidden, bool animated) { CC_RETURN_IF(m_bNavigationBarHidden == hidden); m_bNavigationBarHidden = hidden; CC_RETURN_IF(this->getView()->getSuperview() == NULL); if (animated) { CAAnimation::schedule(CAAnimation_selector(CANavigationController::navigationBarHiddenAnimation), this, 0.25f); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationWillStartSelector(CAApplication::getApplication()->getTouchDispatcher(), CAViewAnimation0_selector(CATouchDispatcher::setDispatchEventsFalse)); CAViewAnimation::setAnimationDidStopSelector(CAApplication::getApplication()->getTouchDispatcher(), CAViewAnimation0_selector(CATouchDispatcher::setDispatchEventsTrue)); CAViewAnimation::commitAnimations(); } else { m_fProgress = 1.0f; DPoint point = this->getNavigationBarNowPoint(m_pViewControllers.back()); m_pNavigationBars.back()->setFrameOrigin(point); if (this->getView()->getSuperview()) { this->update(0); } } }
CAViewController* CANavigationController::popViewControllerAnimated(bool animated) { if (m_pViewControllers.size() == 1) { return NULL; } float x = this->getView()->getBounds().size.width; CAViewController* backViewController = m_pViewControllers.back(); CAView* backContainer = m_pContainers.back(); { backContainer->setFrameOrigin(DPointZero); } size_t index = m_pViewControllers.size() - 2; CAViewController* showViewController = m_pViewControllers.at(index); showViewController->viewDidAppear(); CAView* showContainer = m_pContainers.at(index); showContainer->setVisible(true); { 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) { showContainer->setFrameOrigin(DPoint(-x/2.0f, 0)); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(1/30.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); showContainer->setFrameOrigin(DPointZero); CAViewAnimation::commitAnimations(); CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(1/60.0f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CANavigationController::popViewControllerFinish)); backContainer->setFrameOrigin(DPoint(x, 0)); CAViewAnimation::commitAnimations(); } else { this->popViewControllerFinish(); } return backViewController; }
// [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(CCPointZero); size_t index = 0; CAViewController* showViewController = m_pViewControllers.at(index); showViewController->viewDidAppear(); CAView* showContainer = m_pContainers.at(index); showContainer->setVisible(true); showContainer->setFrameOrigin(CCPoint(-x/2.0f, 0)); { CCRect rect = this->getView()->getBounds(); CCPoint point = this->getNavigationBarNowPoint(showViewController); 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.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(CCPointZero); 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(CCPoint(x, 0)); CAViewAnimation::commitAnimations(); } else { this->popToRootViewControllerFinish(); } }