コード例 #1
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();
}
コード例 #2
0
ファイル: CAViewController.cpp プロジェクト: wjm0729/CrossApp
// [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();
    }
}
コード例 #3
0
ファイル: CAViewController.cpp プロジェクト: wjm0729/CrossApp
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();
    }
}
コード例 #4
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;
}
コード例 #5
0
ファイル: CAViewController.cpp プロジェクト: wjm0729/CrossApp
void CANavigationController::layoutNewContainer()
{
    CAViewController* viewController = m_pViewControllers.back();
    
    DRect navigation_bar_rect = DRectZero;
    navigation_bar_rect.size = m_tNavigationBarSize;
    
    DRect container_rect = this->getView()->getBounds();
    
    if (m_bNavigationBarHidden || viewController->getNavigationBarItem()->isNagigationBarHidden())
    {
        navigation_bar_rect.origin = this->getNavigationBarTakeBackPoint();
    }
    else
    {
        container_rect.size.height -= m_tNavigationBarSize.height;
        navigation_bar_rect.origin = this->getNavigationBarOpenPoint();
        
        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);
    
    
    viewController->addViewFromSuperview(secondContainer);
    if (m_pViewControllers.size() > 1)
    {
        viewController->viewDidAppear();
    }
}
コード例 #6
0
ファイル: CAViewController.cpp プロジェクト: dlpc/CrossApp
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;
}
コード例 #7
0
ファイル: CAViewController.cpp プロジェクト: garyyyy/CrossApp
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;
}