Esempio n. 1
0
bool CATabBarController::initWithViewControllers(const std::vector<CAViewController*>& viewControllers)
{
    CAViewController::init();
    
    do
    {
        CC_BREAK_IF(viewControllers.size() == 0);
        m_pViewControllers.insert(m_pViewControllers.begin(), viewControllers.begin(), viewControllers.end());
        
        std::vector<CATabBarItem*> items;
        
        for (unsigned int i=0; i<m_pViewControllers.size(); i++)
        {
            CAViewController* view = m_pViewControllers.at(i);
            view->retain();
            view->m_pTabBarController = this;
            if (view->getTabBarItem() == NULL)
            {
                const char* title = CCString::createWithFormat("item%d",i)->getCString();
                CATabBarItem* item = CATabBarItem::create(title, NULL, i);
                view->setTabBarItem(item);
            }
            items.push_back(view->getTabBarItem());
        }
        
        m_pTabBar = CATabBar::create(items);
        m_pTabBar->retain();
        m_pTabBar->setDelegate(this);
    }
    while (0);
    
    return true;
    
}
Esempio n. 2
0
bool CATabBarController::showSelectedViewControllerAtIndex(unsigned int index, bool animated)
{
    do
    {
        CC_BREAK_IF(index >= m_pViewControllers.size());
        CAViewController* viewController = m_pViewControllers.at(index);
        CC_BREAK_IF(viewController->isEqual(m_pSelectedViewController));
        
        if (m_pSelectedViewController)
        {
            m_pSelectedViewController->getView()->removeFromSuperview();
            m_pSelectedViewController = NULL;
        }
        
        m_pSelectedViewController = viewController;
        m_pContainer->addSubview(m_pSelectedViewController->getView());
        
        if (animated)
        {
            
        }
        else
        {
        
        }
        
        return true;
    }
    while (0);
    
    return false;
}
Esempio n. 3
0
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);
    }
}
Esempio n. 4
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();
}
Esempio n. 5
0
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());
}
Esempio n. 6
0
CAViewController* CANavigationController::popViewControllerAtIndex(int index)
{
    if (index >= m_pViewControllers.size() || index < 0)
    {
        return NULL;
    }
    
    if (index == m_pViewControllers.size() - 1)
    {
        return this->popViewControllerAnimated(false);
    }
    
    CAViewController* viewController = m_pViewControllers.at(index);
    viewController->viewDidDisappear();
    viewController->m_pNavigationController = NULL;
    viewController->removeViewFromSuperview();
    viewController->retain()->autorelease();
    m_pViewControllers.erase(index);
    
    m_pContainers.at(index)->removeFromSuperview();
    m_pContainers.erase(index);
    
    m_pSecondContainers.erase(index);
    
    m_pNavigationBars.erase(index);
    
    return viewController;
}
Esempio n. 7
0
void CANavigationController::layoutNewContainer()
{
    CCRect navigation_bar_rect = CCRectZero;
    navigation_bar_rect.size = m_tNavigationBarSize;
    
    CCRect container_rect = this->getView()->getBounds();
    
    if (m_bNavigationBarHidden)
    {
        navigation_bar_rect.origin = this->getNavigationBarTakeBackPoint();
    }
    else
    {
        container_rect.size.height -= m_tNavigationBarSize.height;
        navigation_bar_rect.origin = this->getNavigationBarOpenPoint();
        
        if (m_eNavigationBarVerticalAlignment == CABarVerticalAlignmentTop)
        {
            container_rect.origin.y = m_tNavigationBarSize.height;
        }
    }
    
    CAView* container = m_pContainers.back();
    container->setFrame(this->getView()->getBounds());
    
    CANavigationBar* navigationBar = m_pNavigationBars.back();
    navigationBar->setFrame(navigation_bar_rect);

    CAView* secondContainer = m_pSecondContainers.back();
    secondContainer->setFrame(container_rect);
    
    CAViewController* viewController = m_pViewControllers.back();
    viewController->addViewFromSuperview(secondContainer);
    viewController->viewDidAppear();
}
Esempio n. 8
0
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);
    
    CAViewController* viewController = m_pViewControllers.back();
    rect.origin = CCPointZero;
    viewController->getSuperViewRect(rect);
}
Esempio n. 9
0
void CATabBarController::update(float dt)
{
    DRect rect = this->getView()->getFrame();
    
    DPoint point = this->getTabBarNowPoint();
    
    switch (m_eTabBarVerticalAlignment)
    {
        case CABarVerticalAlignmentTop:
        {
            rect.origin.y = point.y + m_pTabBar->getFrame().size.height;
            rect.size.height = rect.size.height - rect.origin.y;
        }
            break;
        case CABarVerticalAlignmentBottom:
        {
            rect.size.height = point.y;
        }
            break;
        default:
            break;
    }
    
    m_pTabBar->setFrameOrigin(point);
    m_pContainer->setFrame(rect);
    
    for (size_t i=0; i<m_pViewControllers.size(); i++)
    {
        DRect r = m_pContainer->getSubViewAtIndex((int)i)->getFrame();
        r.size = rect.size;
        m_pContainer->getSubViewAtIndex((int)i)->setFrame(r);
        CAViewController* viewController = m_pViewControllers.at(i);
        viewController->getSuperViewRect(m_pContainer->getBounds());
    }
}
Esempio n. 10
0
// [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();
    }
}
Esempio n. 11
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();
    }
    
}
Esempio n. 12
0
void CANavigationController::viewDidLoad()
{
    CCRect navigation_bar_rect = CCRectZero;
    
    CCRect container_rect = this->getView()->getBounds();
    
    if (m_bNavigationBarHidden)
    {
        switch (m_eNavigationBarVerticalAlignment)
        {
            case CABarVerticalAlignmentTop:
            {
                navigation_bar_rect.origin.y = -m_pNavigationBar->getFrame().size.height;
            }
                break;
            case CABarVerticalAlignmentBottom:
            {
                navigation_bar_rect.origin.y = container_rect.size.height;
            }
                break;
            default:
                break;
        }
    }
    else
    {
        container_rect.size.height -= m_pNavigationBar->getFrame().size.height;
        switch (m_eNavigationBarVerticalAlignment)
        {
            case CABarVerticalAlignmentTop:
            {
                container_rect.origin.y = m_pNavigationBar->getFrame().size.height;
            }
                break;
            case CABarVerticalAlignmentBottom:
            {
                navigation_bar_rect.origin.y = container_rect.size.height;
            }
                break;
            default:
                break;
        }
    }
    
    m_pContainer = new CAView();
    m_pContainer->setFrame(container_rect);
    this->getView()->addSubview(m_pContainer);
    m_pContainer->release();
    
    CAViewController* viewController = m_pViewControllers.front();
    viewController->addViewFromSuperview(m_pContainer);
    
    m_pNavigationBar->setFrame(navigation_bar_rect);
    this->getView()->addSubview(m_pNavigationBar);
    m_pNavigationBar->setDelegate(this);
}
Esempio n. 13
0
void CANavigationController::homingViewControllerFinish()
{
    size_t index = m_pViewControllers.size() - 2;
    CAViewController* lastViewController = m_pViewControllers.at(index);
    lastViewController->viewDidDisappear();
    
    CAView* lastContainer = m_pContainers.at(index);
    lastContainer->setVisible(false);
    CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsTrue();
}
Esempio n. 14
0
void CANavigationController::popViewControllerFinish()
{
    CAViewController* lastViewController = m_pViewControllers.back();
    lastViewController->m_pNavigationController = NULL;
    lastViewController->removeViewFromSuperview();
    lastViewController->autorelease();
    m_pViewControllers.pop_back();
    m_pNavigationBar->popItem();
    m_pContainer->setFrame(CCRect(0, m_pContainer->getFrame().origin.y, 0, 0));
}
Esempio n. 15
0
void CANavigationController::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent)
{
    CC_RETURN_IF(CAViewAnimation::areBeginAnimationsWithID("navigation_animation"));
    CC_RETURN_IF(m_pViewControllers.size() <= 1);
    
    float x = this->getView()->getBounds().size.width;
    size_t index = m_pViewControllers.size() - 2;
    CAViewController* lastViewController = m_pViewControllers.at(index);
    
    CAView* lastContainer = m_pContainers.at(index);
    lastContainer->setVisible(true);
    lastContainer->setTouchEnabled(true);
    
    CAView* backContainer = m_pContainers.back();
    backContainer->setTouchEnabled(true);
    
    CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsFalse();
    
    if (m_bPopViewController)
    {
        lastViewController->viewDidAppear();
        
        CAViewAnimation::beginAnimations("navigation_animation", NULL);
        CAViewAnimation::setAnimationDuration(0.25f);
        CAViewAnimation::setAnimationDelay(0.02f);
        CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut);
        lastContainer->setFrameOrigin(DPointZero);
        CAViewAnimation::commitAnimations();
        
        CAViewAnimation::beginAnimations("navigation_animation2", NULL);
        CAViewAnimation::setAnimationDuration(0.25f);
        CAViewAnimation::setAnimationDelay(0.03f);
        CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut);
        CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CANavigationController::popViewControllerFinish));
        backContainer->setFrameOrigin(DPoint(x, 0));
        CAViewAnimation::commitAnimations();
    }
    else
    {
        CAViewAnimation::beginAnimations("navigation_animation", NULL);
        CAViewAnimation::setAnimationDuration(0.25f);
        CAViewAnimation::setAnimationDelay(0.03f);
        CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut);
        lastContainer->setFrameOrigin(DPoint(-x/2.0f, 0));
        CAViewAnimation::commitAnimations();
        
        CAViewAnimation::beginAnimations("navigation_animation2", NULL);
        CAViewAnimation::setAnimationDuration(0.25f);
        CAViewAnimation::setAnimationDelay(0.02f);
        CAViewAnimation::setAnimationCurve(CAViewAnimationCurveEaseOut);
        CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CANavigationController::homingViewControllerFinish));
        backContainer->setFrameOrigin(DPointZero);
        CAViewAnimation::commitAnimations();
    }
}
Esempio n. 16
0
void CANavigationController::viewDidLoad()
{
    CAViewController* viewController = m_pViewControllers.front();
    viewController->retain()->autorelease();
    m_pViewControllers.popFront();
    this->createWithContainer(viewController);
    
    m_tNavigationBarSize = m_pNavigationBars.front()->getFrame().size;
    
    this->layoutNewContainer();
}
Esempio n. 17
0
void CANavigationController::pushViewControllerFinish()
{
    CAView* lastContainer = m_pContainers.at(m_pContainers.size() - 2);
    lastContainer->setVisible(false);
    
    CAView* newContainer = m_pContainers.back();
    newContainer->setFrameOrigin(DPointZero);
    
    CAViewController* lastViewController = m_pViewControllers.at(m_pViewControllers.size() - 2);
    lastViewController->viewDidDisappear();
    
    CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsTrue();
}
Esempio n. 18
0
void CANavigationController::viewDidLoad()
{
    CCRect rect = this->getView()->getBounds();
    rect.size.height -= m_pNavigationBar->getFrame().size.height;
    rect.origin.y = m_pNavigationBar->getFrame().size.height;
    
    m_pContainer = CAView::createWithFrame(rect);
    this->getView()->addSubview(m_pContainer);
    
    CAViewController* viewController = m_pViewControllers.front();
    viewController->addViewFromSuperview(m_pContainer);
    
    m_pNavigationBar->setFrame(CCRectZero);
    this->getView()->addSubview(m_pNavigationBar);
    m_pNavigationBar->setDelegate(this);
}
Esempio n. 19
0
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());
}
Esempio n. 20
0
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;
}
Esempio n. 21
0
void CANavigationController::pushViewControllerFinish()
{
    float x = this->getView()->getBounds().size.width;
    
    CAView* lastContainer = m_pContainers.at(m_pContainers.size() - 2);
    lastContainer->setVisible(false);
    lastContainer->setFrameOrigin(CCPoint(-x/2.0f, 0));
    
    CAView* newContainer = m_pContainers.back();
    newContainer->setFrameOrigin(CCPointZero);
    
    CAViewController* lastViewController = m_pViewControllers.at(m_pViewControllers.size() - 2);
    lastViewController->viewDidDisappear();
    
    m_bSlidingMinX = m_pViewControllers.size() <= 1;
    CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsTrue();
}
Esempio n. 22
0
bool CATabBarController::initWithViewControllers(const std::vector<CAViewController*>& viewControllers, CABarVerticalAlignment var)
{
    CAViewController::init();

    do
    {
        CC_BREAK_IF(viewControllers.size() == 0);
        m_pViewControllers.insert(m_pViewControllers.begin(), viewControllers.begin(), viewControllers.end());

        std::vector<CATabBarItem*> items;

        for (unsigned int i=0; i<m_pViewControllers.size(); i++)
        {
            CAViewController* view = m_pViewControllers.at(i);
            view->retain();
            view->m_pTabBarController = this;
            if (view->getTabBarItem() == NULL)
            {
                const char* title = CCString::createWithFormat("item%d",i)->getCString();
                CATabBarItem* item = CATabBarItem::create(title, NULL);
                item->setTag(i);
                view->setTabBarItem(item);
            }
            items.push_back(view->getTabBarItem());
        }

        m_pTabBar = CATabBar::create(items);
        m_pTabBar->retain();
        m_pTabBar->setAnchorPoint(CCPointZero);
        m_pTabBar->setDelegate(this);

        m_pContainer = new CAScrollView();
        m_pContainer->initWithFrame(CCRectZero);
        m_pContainer->setScrollEnabled(false);
        m_pContainer->setBounces(false);
        m_pContainer->setShowsHorizontalScrollIndicator(false);
        m_pContainer->setShowsVerticalScrollIndicator(false);

    }
    while (0);

    m_eTabBarVerticalAlignment = var;

    return true;

}
Esempio n. 23
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();
    }
}
Esempio n. 24
0
void CANavigationController::replaceViewControllerFinish()
{
    CAView* newContainer = m_pContainers.back();
    newContainer->setFrameOrigin(DPointZero);
    
    size_t index = m_pViewControllers.size() - 2;
    CAViewController* lastViewController = m_pViewControllers.at(index);
    lastViewController->viewDidDisappear();
    lastViewController->m_pNavigationController = NULL;
    lastViewController->removeViewFromSuperview();
    m_pViewControllers.erase(index);
    
    CAView* backContainer = m_pContainers.at(index);
    backContainer->removeFromSuperview();
    m_pContainers.erase(index);
    m_pSecondContainers.erase(index);
    m_pNavigationBars.erase(index);
    CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsTrue();
}
Esempio n. 25
0
void CANavigationController::popViewControllerFinish()
{
    CAViewController* backViewController = m_pViewControllers.back();
    backViewController->viewDidDisappear();
    backViewController->m_pNavigationController = NULL;
    backViewController->removeViewFromSuperview();
    backViewController->retain()->autorelease();
    m_pViewControllers.popBack();
    
    m_pContainers.back()->removeFromSuperview();
    m_pContainers.popBack();
    
    m_pSecondContainers.popBack();
    
    m_pNavigationBars.popBack();
    
    m_pContainers.back()->setFrameOrigin(DPointZero);
    
    CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsTrue();
}
Esempio n. 26
0
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;
}
Esempio n. 27
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();
    }

}
Esempio n. 28
0
void CANavigationController::replaceViewControllerFinish()
{
    m_pContainer->setFrame(CCRect(0, m_pContainer->getFrame().origin.y, 0, 0));

    CAViewController* lastViewController = m_pViewControllers.back();
    m_pViewControllers.pop_back();
    m_pNavigationBar->popItem();
    lastViewController->removeViewFromSuperview();
    lastViewController->autorelease();

    CAViewController* viewController = m_pViewControllers.back();

    if (viewController->getNavigationBarItem() == NULL && viewController->getTitle().compare("") != 0)
    {
        viewController->setNavigationBarItem(CANavigationBarItem::create(viewController->getTitle()));
    }
    m_pNavigationBar->pushItem(viewController->getNavigationBarItem());
}
Esempio n. 29
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());
    }
}
Esempio n. 30
0
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();
}