void ItemForm::OnFormBackRequested(Osp::Ui::Controls::Form & source) { AppLog("OnFormBackRequested()"); Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); MainForm * pForm = static_cast<MainForm*> (pFrame->GetControl(kMainFormNameString)); /* pFrame->SetCurrentForm(*pForm); pForm->Draw(); pForm->Show(); */ FrameAnimator * pAnimator = pFrame->GetFrameAnimator(); pAnimator->SetFormTransitionAnimation(FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_RIGHT, 800, ANIMATION_INTERPOLATOR_EASE_IN_OUT); pAnimator->SetCurrentForm(*pForm); }
void FormNavigationManager::OnUserEventReceivedN(RequestId requestId, IList* pArgs) { switch (requestId) { case SET_ROOT_FORM: { AppLog("FormNavigationManager: setting root form"); AppAssertf(NumberOfFormsInCurrentStack() == 0, "This navigation stack has already a root form"); Frame * pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); StackBasedNavigationForm * nextForm = static_cast<StackBasedNavigationForm *> (pArgs->GetAt(0)); // Add new form in the stack _currentFormsStack.Add(*nextForm); // Add new form on display, the form is automatically set as the current form pFrame->AddControl(*nextForm); // Call FormWillAppear() on the root form nextForm->FormWillAppear(); // Show new form nextForm->Draw(); nextForm->Show(); delete pArgs; } break; case PUSH_FORM: { AppLog("FormNavigationManager: pushing form"); AppAssertf(NumberOfFormsInCurrentStack() > 0, "This navigation stack has no root form, please set a root form with SetRootForm()"); StackBasedNavigationForm * nextForm = static_cast<StackBasedNavigationForm *> (pArgs->GetAt(0)); StackBasedNavigationForm * currentForm = static_cast<StackBasedNavigationForm *> (_currentFormsStack.GetAt(_currentFormsStack.GetCount() - 1)); Frame * pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); // Call FormWillDisappear() on the old form currentForm->FormWillDisappear(); // Add new form in the stack _currentFormsStack.Add(*nextForm); // Add new form on display, nextForm becomes the current form pFrame->AddControl(*nextForm); // Re-set currentForm as the current form so we can perform a nice animation pFrame->SetCurrentForm(*currentForm); // Call FormWillAppear() on the new form nextForm->FormWillAppear(); // Perform the transition with a nice slide-in animation FrameAnimator * pAnimator = pFrame->GetFrameAnimator(); pAnimator->SetFormTransitionAnimation( FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_LEFT, 600, ANIMATION_INTERPOLATOR_EASE_IN_OUT); pAnimator->SetCurrentForm(*nextForm); delete pArgs; } break; case POP_FORM: { AppLog("FormNavigationManager: popping form"); AppAssertf(NumberOfFormsInCurrentStack() > 0, "This navigation stack has no root form, please set a root form with SetRootForm()"); Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); AppAssertf(_currentFormsStack.GetCount() > 1, "Illegal: Trying to pop the root form"); StackBasedNavigationForm * previousForm = static_cast<StackBasedNavigationForm *> (_currentFormsStack.GetAt(_currentFormsStack.GetCount() - 2)); StackBasedNavigationForm * currentForm = static_cast<StackBasedNavigationForm *> (_currentFormsStack.GetAt(_currentFormsStack.GetCount() - 1)); // Call FormWillDisappear() on the current form currentForm->FormWillDisappear(); // Call FormWillAppear() on the previous form previousForm->FormWillAppear(); // Perform the transition with a nice slide-out animation FrameAnimator * pAnimator = pFrame->GetFrameAnimator(); pAnimator->SetFormTransitionAnimation( FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_RIGHT, 600, ANIMATION_INTERPOLATOR_EASE_IN_OUT); pAnimator->SetCurrentForm(*previousForm); pFrame->RemoveControl(*currentForm); _currentFormsStack.RemoveAt(_currentFormsStack.GetCount() - 1, false); } break; } }