void WStackedWidget::setCurrentIndex(int index, const WAnimation& animation, bool autoReverse) { if (!animation.empty() && WApplication::instance()->environment().supportsCss3Animations() && ((isRendered() && javaScriptDefined_) || !canOptimizeUpdates())) { if (canOptimizeUpdates() && index == currentIndex_) return; loadAnimateJS(); WWidget *previous = currentWidget(); doJavaScript("$('#" + id() + "').data('obj').adjustScroll(" + widget(currentIndex_)->jsRef() + ");"); setJavaScriptMember("wtAutoReverse", autoReverse ? "true" : "false"); if (previous) previous->animateHide(animation); widget(index)->animateShow(animation); currentIndex_ = index; } else { currentIndex_ = index; for (int i = 0; i < count(); ++i) if (widget(i)->isHidden() != (currentIndex_ != i)) widget(i)->setHidden(currentIndex_ != i); if (currentIndex_ >= 0 && isRendered() && javaScriptDefined_) doJavaScript("$('#" + id() + "').data('obj').setCurrent(" + widget(currentIndex_)->jsRef() + ");"); } }
void WStackedWidget::setCurrentIndex(int index, const WAnimation& animation, bool autoReverse) { if (!animation.empty() && loadAnimateJS() && (isRendered() || !canOptimizeUpdates())) { if (canOptimizeUpdates() && index == currentIndex_) return; WWidget *previous = currentWidget(); setJavaScriptMember("wtAutoReverse", autoReverse ? "true" : "false"); if (previous) previous->animateHide(animation); widget(index)->animateShow(animation); currentIndex_ = index; } else { currentIndex_ = index; for (int i = 0; i < count(); ++i) if (widget(i)->isHidden() != (currentIndex_ != i)) widget(i)->setHidden(currentIndex_ != i); if (isRendered()) doJavaScript("$('#" + id() + "').data('obj').setCurrent(" + widget(currentIndex_)->jsRef() + ");"); } }