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);
    }
}
Example #2
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());
    }
}
Example #3
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());
}
Example #4
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);
}
Example #5
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();
    }
}
Example #6
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());
}
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());
    }
}
Example #8
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;
}
Example #9
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(CCPointZero);
    }
    
    size_t index = m_pViewControllers.size() - 2;
    CAViewController* showViewController = m_pViewControllers.at(index);
    showViewController->viewDidAppear();
    
    CAView* showContainer = m_pContainers.at(index);
    showContainer->setVisible(true);
    
    
    {
        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)
    {
        showContainer->setFrameOrigin(CCPoint(-x/2.0f, 0));
        
        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;
}