//---------------------------------------------------------------------------------------------------- void UIDialogController::valueChanged (CControl* control) { if (control->getValue () == control->getMax ()) { switch (control->getTag ()) { case kButton1Tag: { dialogController->notify (this, kMsgDialogButton1Clicked); break; } case kButton2Tag: { dialogController->notify (this, kMsgDialogButton2Clicked); break; } } CView* modalView = frame->getModalView (); frame->setModalView (0); modalView->forget (); frame->unregisterKeyboardHook (this); if (button1) button1->setListener (0); if (button2) button2->setListener (0); setOpenGLViewsVisible (true); forget (); } }
//---------------------------------------------------------------------------------------------------- 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) { 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); frame->setModalView (view); frame->registerKeyboardHook (this); if (button1) frame->setFocusView (button1); setOpenGLViewsVisible (false); dialogController->notify (this, kMsgDialogShow); } else { forget (); } }
//---------------------------------------------------------------------------------------------------- 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::close () { frame->unregisterKeyboardHook (this); frame->unregisterViewListener (this); if (button1) button1->setListener (0); if (button2) button2->setListener (0); setOpenGLViewsVisible (true); CView* dialog = frame->getModalView (); if (dialog) { dialog->unregisterViewListener (this); frame->setModalView (0); dialog->forget (); } forget (); }