void valueChanged (CControl* pControl) { if (pControl->getValue ()) { switch (pControl->getTag ()) { case 0: { CView* view = desc->createView ("ModalView", this); if (view) { CFrame* frame = pControl->getFrame (); CPoint center = frame->getViewSize ().getCenter (); CRect viewSize = view->getViewSize (); viewSize.offset (center.x - viewSize.getWidth () / 2, center.y - viewSize.getHeight () / 2); view->setViewSize (viewSize); view->setMouseableArea (viewSize); frame->setModalView (view); view->setAlphaValue (0.f); view->addAnimation ("AlphaAnimation", new Animation::AlphaValueAnimation (1.f), new Animation::PowerTimingFunction (240, 2)); pControl->setValue (0); view->forget (); } break; } case 1: { CView* modalView = pControl->getFrame ()->getModalView (); modalView->addAnimation ("AlphaAnimation", new RemoveModalViewAnimation (0.f), new Animation::PowerTimingFunction (240, 0.5)); pControl->setMouseEnabled (false); break; } } } }
//---------------------------------------------------------------------------------------------------- void UIDialogController::run (UTF8StringPtr _templateName, UTF8StringPtr _dialogTitle, UTF8StringPtr _button1, UTF8StringPtr _button2, IController* _dialogController, UIDescription* _description) { collectOpenGLViews (frame); templateName = _templateName; dialogTitle = _dialogTitle; dialogButton1 = _button1; dialogButton2 = _button2 != 0 ? _button2 : ""; dialogController = dynamic_cast<CBaseObject*> (_dialogController); dialogDescription = _description; CView* view = UIEditController::getEditorDescription ().createView ("dialog", this); if (view) { CLayeredViewContainer* layeredView = dynamic_cast<CLayeredViewContainer*>(view); if (layeredView) layeredView->setZIndex (10); CRect size = view->getViewSize (); size.right += sizeDiff.x; size.bottom += sizeDiff.y; CRect frameSize = frame->getViewSize (); size.centerInside (frameSize); size.makeIntegral (); view->setViewSize (size); view->setMouseableArea (size); view->setAlphaValue (0.f); frame->setModalView (view); frame->registerKeyboardHook (this); frame->registerViewListener (this); view->registerViewListener (this); if (button1) frame->setFocusView (button1); setOpenGLViewsVisible (false); if (dialogController) dialogController->notify (this, kMsgDialogShow); view->addAnimation ("AlphaAnimation", new Animation::AlphaValueAnimation (1.f), new Animation::LinearTimingFunction (160)); } else { forget (); } }
//---------------------------------------------------------------------------------------------------- void UIDialogController::valueChanged (CControl* control) { if (control->getValue () == control->getMax ()) { switch (control->getTag ()) { case kButton1Tag: { if (dialogController) dialogController->notify (this, kMsgDialogButton1Clicked); break; } case kButton2Tag: { if (dialogController) dialogController->notify (this, kMsgDialogButton2Clicked); break; } } CView* modalView = frame->getModalView (); modalView->addAnimation ("AlphaAnimation", new Animation::AlphaValueAnimation (0.f), new Animation::LinearTimingFunction (160), this); } }