示例#1
0
void CANavigationController::pushViewControllerFinish()
{
    CAViewController* viewController = m_pViewControllers.back();
    
    if (viewController->getNavigationBarItem() == NULL && viewController->getTitle().compare("") != 0)
    {
        viewController->setNavigationBarItem(CANavigationBarItem::create(viewController->getTitle()));
    }
    m_pNavigationBar->pushItem(viewController->getNavigationBarItem());
    viewController->getView()->setFrameOrigin(CCPointZero);
    
    CAViewController* lastViewController = m_pViewControllers.at(m_pViewControllers.size() - 2);
    lastViewController->getView()->setFrameOrigin(CCPointZero);
    lastViewController->getView()->setVisible(false);
    lastViewController->viewDidDisappear();
}
void CANavigationController::update(float dt)
{
    CCRect rect = m_pContainer->getFrame();

    switch (m_eNavigationBarVerticalAlignment)
    {
    case CABarVerticalAlignmentTop:
    {
        rect.origin.y = m_pNavigationBar->getFrame().origin.y + m_pNavigationBar->getFrame().size.height;
        rect.size.height = this->getView()->getBounds().size.height - rect.origin.y;
    }
    break;
    case CABarVerticalAlignmentBottom:
    {
        rect.size.height = m_pNavigationBar->getFrame().origin.y;
    }
    break;
    default:
        break;
    }

    m_pContainer->setFrame(rect);

    for (unsigned int i=0; i<m_pViewControllers.size(); i++)
    {
        CAViewController* viewController = m_pViewControllers.at(i);
        rect.origin.x = viewController->getView()->getFrameOrigin().x;
        rect.origin.y = 0;
        viewController->getSuperViewRect(rect);
    }
}
示例#3
0
void CANavigationController::pushViewControllerFinish()
{
    m_pContainer->setFrame(CCRect(0, m_pContainer->getFrame().origin.y, 0, 0));
    
    CAViewController* lastViewController = m_pViewControllers.at(m_pViewControllers.size() - 2);
    lastViewController->getView()->removeFromSuperview();
}
示例#4
0
void CANavigationController::replaceViewController(CrossApp::CAViewController *viewController, bool animated)
{
    if (this->getView()->getSuperview() == NULL)
    {
        return;
    }
    
    if (m_pContainer->getActionByTag(0))
    {
        return;
    }
    
    float x = m_pContainer->getFrame().size.width;
    
    CAViewController* lastViewController = m_pViewControllers.back();
    viewController->m_pNavigationController = this;
    m_pViewControllers.insert(m_pViewControllers.size()-1, viewController);
    viewController->addViewFromSuperview(m_pContainer);
    viewController->viewDidDisappear();
    viewController->getView()->setFrameOrigin(CCPoint(x, 0));
    
    if (animated)
    {
        CCSequence* actionsLast =
        CCSequence::create(
                           CCDelayTime::create(0.03f),
                           
                           CCEaseSineOut::create(CCFrameOrginTo::create(0.25f, CCPoint(-x/2.0f, 0))),
                           
                           NULL);
        
        lastViewController->getView()->runAction(actionsLast);
        
        
        CCSequence* actions =
        CCSequence::create(
                           CCCallFunc::create(CAApplication::getApplication()->getTouchDispatcher(), callfunc_selector(CATouchDispatcher::setDispatchEventsFalse)),
                           
                           CCDelayTime::create(0.02f),
                           
                           CCEaseSineOut::create(CCFrameOrginTo::create(0.25f, CCPointZero)),
                           
                           CCCallFunc::create(this, callfunc_selector(CANavigationController::replaceViewControllerFinish)),
                           
                           CCCallFunc::create(CAApplication::getApplication()->getTouchDispatcher(),callfunc_selector(CATouchDispatcher::setDispatchEventsTrue)),
                           
                           NULL);
        
        viewController->getView()->runAction(actions);
    }
    else
    {
        this->replaceViewControllerFinish();
    }
    
}
CAViewController* CANavigationController::popViewControllerAnimated(bool animated)
{
    if (m_pViewControllers.size() == 1)
    {
        return NULL;
    }

    if (m_pContainer->getActionByTag(0))
    {
        return NULL;
    }

    unsigned int index = m_pViewControllers.size() - 2;
    CAViewController* showViewController = m_pViewControllers.at(index);
    showViewController->getView()->setFrame(CCRectZero);
    m_pContainer->addSubview(showViewController->getView());

    CAViewController* backViewController = m_pViewControllers.back();

    float x = m_pContainer->getFrame().size.width;
    backViewController->getView()->setFrame(CCRect(x, 0, 0, 0));

    if (animated)
    {
        m_pContainer->stopAllActions();
        m_pContainer->setFrameOrigin(CCPoint(-x, m_pContainer->getFrameOrigin().y));

        CCDelayTime* delayTime = CCDelayTime::create(0.2f);
        CCFrameOrginTo* moveTo = CCFrameOrginTo::create(0.4f, CCPoint(0, m_pContainer->getFrameOrigin().y));
        CCEaseSineOut* easeBack = CCEaseSineOut::create(moveTo);
        CCCallFunc* finish = CCCallFunc::create(this, callfunc_selector(CANavigationController::popViewControllerFinish));
        CCSequence* actions = CCSequence::create(delayTime, easeBack, finish, NULL);
        m_pContainer->runAction(actions);
        actions->setTag(0);
    }
    else
    {
        this->popViewControllerFinish();
    }
    return backViewController;
}
示例#6
0
void CANavigationController::popViewControllerFinish()
{
    CAViewController* lastViewController = m_pViewControllers.back();
    lastViewController->viewDidDisappear();
    lastViewController->m_pNavigationController = NULL;
    lastViewController->removeViewFromSuperview();
    lastViewController->retain()->autorelease();
    m_pViewControllers.popBack();
    m_pNavigationBar->popItem();
    CAViewController* showViewController = m_pViewControllers.back();
    showViewController->getView()->setFrameOrigin(CCPointZero);
}
void CANavigationController::pushViewControllerFinish()
{
    m_pContainer->setFrame(CCRect(0, m_pContainer->getFrame().origin.y, 0, 0));

    CAViewController* viewController = m_pViewControllers.back();

    if (viewController->getNavigationBarItem() == NULL && viewController->getTitle().compare("") != 0)
    {
        viewController->setNavigationBarItem(CANavigationBarItem::create(viewController->getTitle()));
    }
    m_pNavigationBar->pushItem(viewController->getNavigationBarItem());

    CAViewController* lastViewController = m_pViewControllers.at(m_pViewControllers.size() - 2);
    lastViewController->getView()->removeFromSuperview();
}
示例#8
0
void CANavigationController::replaceViewControllerFinish()
{
    CAViewController* lastViewController = m_pViewControllers.back();
    lastViewController->retain()->autorelease();
    m_pViewControllers.popBack();
    m_pNavigationBar->popItem();
    lastViewController->viewDidDisappear();
    lastViewController->removeViewFromSuperview();
    
    CAViewController* viewController = m_pViewControllers.back();
    viewController->getView()->setFrameOrigin(CCPointZero);
    if (viewController->getNavigationBarItem() == NULL && viewController->getTitle().compare("") != 0)
    {
        viewController->setNavigationBarItem(CANavigationBarItem::create(viewController->getTitle()));
    }
    m_pNavigationBar->pushItem(viewController->getNavigationBarItem());
}
示例#9
0
void CANavigationController::pushViewController(CAViewController* viewController, bool animated)
{
    if (this->getView()->getSuperview() == NULL)
    {
        return;
    }

    if (m_pContainer->getActionByTag(0))
    {
        return;
    }

    float x = m_pContainer->getFrame().size.width;
    
    CAViewController* lastViewController = m_pViewControllers.back();
    lastViewController->getView()->setFrame(CCRect(-x, 0, 0, 0));
    viewController->retain();
    viewController->m_pNavigationController = this;
    m_pViewControllers.push_back(viewController);
    if (viewController->getNavigationBarItem() == NULL && viewController->getTitle().compare("") != 0)
    {
        viewController->setNavigationBarItem(CANavigationBarItem::create(viewController->getTitle()));
    }
    m_pNavigationBar->pushItem(viewController->getNavigationBarItem());
    viewController->addViewFromSuperview(m_pContainer);
    
    if (animated)
    {
        m_pContainer->stopAllActions();
        m_pContainer->setFrame(CCRect(x, m_pContainer->getFrame().origin.y, 0, 0));
        
        CCDelayTime* delayTime = CCDelayTime::create(0.1f);
        CCMoveBy* moveBy = CCMoveBy::create(0.3f, CCPoint(-x, 0));
        CCEaseSineOut* easeBack = CCEaseSineOut::create(moveBy);
        CCCallFunc* finish = CCCallFunc::create(this, callfunc_selector(CANavigationController::pushViewControllerFinish));
        CCSequence* actions = CCSequence::create(delayTime, easeBack, finish, NULL);
        m_pContainer->runAction(actions);
        actions->setTag(0);
    }
    else
    {
        this->pushViewControllerFinish();
    }
}
示例#10
0
void CANavigationController::replaceViewController(CrossApp::CAViewController *viewController, bool animated)
{
    if (this->getView()->getSuperview() == NULL)
    {
        return;
    }

    if (m_pContainer->getActionByTag(0))
    {
        return;
    }

    float x = m_pContainer->getFrame().size.width;

    CAViewController* lastViewController = m_pViewControllers.back();
    lastViewController->getView()->setFrame(CCRect(-x, 0, 0, 0));
    viewController->retain();
    viewController->m_pNavigationController = this;
    m_pViewControllers.insert(m_pViewControllers.end()-1, viewController);
    viewController->addViewFromSuperview(m_pContainer);

    if (animated)
    {
        m_pContainer->stopAllActions();
        m_pContainer->setFrameOrigin(CCPoint(x, m_pContainer->getFrameOrigin().y));

        CCDelayTime* delayTime = CCDelayTime::create(0.5f);
        CCFrameOrginTo* moveTo = CCFrameOrginTo::create(0.4f, CCPoint(0, m_pContainer->getFrameOrigin().y));
        CCEaseSineOut* easeBack = CCEaseSineOut::create(moveTo);
        CCCallFunc* finish = CCCallFunc::create(this, callfunc_selector(CANavigationController::replaceViewControllerFinish));
        CCSequence* actions = CCSequence::create(delayTime, easeBack, finish, NULL);
        m_pContainer->runAction(actions);
        actions->setTag(0);
    }
    else
    {
        this->replaceViewControllerFinish();
    }

}
示例#11
0
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());
    }
}
示例#12
0
CAViewController* CANavigationController::popViewControllerAnimated(bool animated)
{
    if (m_pViewControllers.size() == 1)
    {
        return NULL;
    }
    
    if (m_pContainer->getActionByTag(0))
    {
        return NULL;
    }
    
    float x = m_pContainer->getFrame().size.width;
    
    unsigned int index = m_pViewControllers.size() - 2;
    CAViewController* showViewController = m_pViewControllers.at(index);
    if (!showViewController->getView()->getBounds().size.equals(m_pContainer->getBounds().size))
    {
        showViewController->getSuperViewRect(m_pContainer->getBounds());
    }
    showViewController->getView()->setFrameOrigin(CCPoint(-x/2.0f, 0));
    showViewController->getView()->setVisible(true);
    showViewController->viewDidAppear();
    
    CAViewController* backViewController = m_pViewControllers.back();
    
    if (animated)
    {
        CCSequence* actionsLast =
        CCSequence::create(
                           CCDelayTime::create(0.02f),
                           
                           CCEaseSineOut::create(CCFrameOrginTo::create(0.25f, CCPointZero)),
                           
                           NULL);
        
        showViewController->getView()->runAction(actionsLast);
        
        
        CCSequence* actions =
        CCSequence::create(
                           CCCallFunc::create(CAApplication::getApplication()->getTouchDispatcher(), callfunc_selector(CATouchDispatcher::setDispatchEventsFalse)),
                           
                           CCDelayTime::create(0.03f),
                           
                           CCEaseSineOut::create(CCFrameOrginTo::create(0.25f, CCPoint(x, 0))),
                           
                           CCCallFunc::create(this, callfunc_selector(CANavigationController::popViewControllerFinish)),
                           
                           CCCallFunc::create(CAApplication::getApplication()->getTouchDispatcher(),callfunc_selector(CATouchDispatcher::setDispatchEventsTrue)),
                           
                           NULL);
        
        backViewController->getView()->runAction(actions);
    }
    else
    {
        this->popViewControllerFinish();
    }
    return backViewController;
}