//----------------------------------------------------------------------------- void UIViewSwitchContainer::setCurrentViewIndex (int32_t viewIndex) { if (controller) { CView* view = controller->createViewForIndex (viewIndex); if (view) { if (view->getAutosizeFlags () & kAutosizeAll) { CRect vs (getViewSize ()); vs.offset (-vs.left, -vs.top); view->setViewSize (vs); view->setMouseableArea (vs); } if (animationTime) { if (getFrame ()) getFrame ()->getAnimator ()->removeAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex"); CView* oldView = getView (0); if (isAttached () && oldView && getFrame ()) { getFrame ()->getAnimator ()->addAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex", new Animation::ExchangeViewAnimation (oldView, view, Animation::ExchangeViewAnimation::kAlphaValueFade), new Animation::LinearTimingFunction (animationTime)); } else { removeAll (); addView (view); } } else { CViewContainer::removeAll (); CViewContainer::addView (view); } currentViewIndex = viewIndex; invalid (); } } }
//----------------------------------------------------------------------------- void UIViewSwitchContainer::setCurrentViewIndex (int32_t viewIndex) { if (controller && viewIndex != currentViewIndex) { CView* view = controller->createViewForIndex (viewIndex); if (view) { if (view->getAutosizeFlags () & kAutosizeAll) { CRect vs (getViewSize ()); vs.offset (-vs.left, -vs.top); view->setViewSize (vs); view->setMouseableArea (vs); } if (animationTime) { if (getFrame ()) getFrame ()->getAnimator ()->removeAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex"); CView* oldView = getView (0); if (isAttached () && oldView && getFrame ()) { Animation::IAnimationTarget* animation = 0; switch (animationStyle) { case kFadeInOut: { animation = new Animation::ExchangeViewAnimation (oldView, view, Animation::ExchangeViewAnimation::kAlphaValueFade); break; } case kMoveInOut: { Animation::ExchangeViewAnimation::AnimationStyle style = Animation::ExchangeViewAnimation::kPushInFromLeft; if (viewIndex > currentViewIndex) { style = Animation::ExchangeViewAnimation::kPushInFromRight; } animation = new Animation::ExchangeViewAnimation (oldView, view, style); break; } case kPushInOut: { Animation::ExchangeViewAnimation::AnimationStyle style = Animation::ExchangeViewAnimation::kPushInOutFromLeft; if (viewIndex > currentViewIndex) { style = Animation::ExchangeViewAnimation::kPushInOutFromRight; } animation = new Animation::ExchangeViewAnimation (oldView, view, style); break; } } if (animation) getFrame ()->getAnimator ()->addAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex", animation, new Animation::LinearTimingFunction (animationTime)); else { removeAll (); addView (view); } } else { removeAll (); addView (view); } } else { CViewContainer::removeAll (); CViewContainer::addView (view); } currentViewIndex = viewIndex; invalid (); } } }
//----------------------------------------------------------------------------- void CTabView::setViewSize (const CRect &rect, bool invalid) { if (rect == getViewSize ()) return; CRect oldSize (getViewSize ()); CCoord widthDelta = rect.getWidth () - oldSize.getWidth (); CCoord heightDelta = rect.getHeight () - oldSize.getHeight (); if (widthDelta != 0 || heightDelta != 0) { uint32_t numSubviews = getNbViews(); int32_t counter = 1; bool treatAsColumn = (getAutosizeFlags () & kAutosizeColumn) ? true : false; bool treatAsRow = (getAutosizeFlags () & kAutosizeRow) ? true : false; CTabChildView* v = firstChild; while (v) { if (v != currentChild) { CView* pV = v->view; int32_t autosize = pV->getAutosizeFlags (); CRect viewSize (pV->getViewSize ()); CRect mouseSize (pV->getMouseableArea ()); if (treatAsColumn) { if (counter) { viewSize.offset (counter * (widthDelta / (numSubviews)), 0); mouseSize.offset (counter * (widthDelta / (numSubviews)), 0); } viewSize.setWidth (viewSize.getWidth () + (widthDelta / (numSubviews))); mouseSize.setWidth (mouseSize.getWidth () + (widthDelta / (numSubviews))); } else if (widthDelta != 0 && autosize & kAutosizeRight) { viewSize.right += widthDelta; mouseSize.right += widthDelta; if (!(autosize & kAutosizeLeft)) { viewSize.left += widthDelta; mouseSize.left += widthDelta; } } if (treatAsRow) { if (counter) { viewSize.offset (0, counter * (heightDelta / (numSubviews))); mouseSize.offset (0, counter * (heightDelta / (numSubviews))); } viewSize.setHeight (viewSize.getHeight () + (heightDelta / (numSubviews))); mouseSize.setHeight (mouseSize.getHeight () + (heightDelta / (numSubviews))); } else if (heightDelta != 0 && autosize & kAutosizeBottom) { viewSize.bottom += heightDelta; mouseSize.bottom += heightDelta; if (!(autosize & kAutosizeTop)) { viewSize.top += heightDelta; mouseSize.top += heightDelta; } } if (viewSize != pV->getViewSize ()) { pV->setViewSize (viewSize); pV->setMouseableArea (mouseSize); } } v = v->next; // counter++; } } CViewContainer::setViewSize (rect, invalid); }