float Element::update(float tpf, float alpha, Input* pInput, float dimming) { // Activity animationa mActivity.update(tpf, !mActive); // Save current alpha (already animated by layout or other element) mAlpha = alpha; // Use activity and alpha to check whether input is necessary if (mAlpha < 1 || mActivity.getValue() < 1) { pInput = NULL; } // Check wether cursor is over element // Used for dimming etc, not affected by consumption of input bool penetrated = penetratedByInput(pInput); // Dimming if (mForceUndim) { // Undim it mDimming.update(-tpf / mpLayout->getConfig()->dimmingDecreaseDuration); } else if (mDimmable) { if (penetrated) { // Undim it mDimming.update(-tpf / mpLayout->getConfig()->dimmingDecreaseDuration); } else { // Dim it mDimming.update(tpf / mpLayout->getConfig()->dimmingIncreaseDuration); } } else { // Use dimming value of parent mDimming.setValue(dimming); } // Adaptive scaling if (mAdaptiveScaling) { // Set maximum of adaptive scale if (penetrated) { // Scale it up mAdaptiveScale.update(tpf / mpLayout->getConfig()->adaptiveScaleIncreaseDuration); } else { // Scale it down mAdaptiveScale.update(-tpf / mpLayout->getConfig()->adaptiveScaleDecreaseDuration); } } else { // Scale it down, because could have been set by using scale from special update (children!) mAdaptiveScale.update(-tpf / mpLayout->getConfig()->adaptiveScaleDecreaseDuration); } // Update replaced element if there is some if (mupReplacedElement.get() != NULL) { float replacedAlpha = mAlpha * (mupReplacedElement->getAlpha() - (tpf / mpLayout->getConfig()->animationDuration)); replacedAlpha = clamp(replacedAlpha, 0, 1); mupReplacedElement->update(tpf, replacedAlpha, NULL, mDimming.getValue()); // Check, whether replacement is still visible if (replacedAlpha <= 0) { // Give it to layout for destruction at end of frame mpFrame->commitDyingReplacedElement(std::move(mupReplacedElement)); } } // Call specialized update of subclasses float specialAdaptiveScale = specialUpdate(tpf, pInput); // Decide, which adaptive scale to save. Own adaptive scale decreases if adaptive scaling is deactivated! // If it would be not saved in member, nobody would know about it at rendering. mAdaptiveScale.setValue(std::max(mAdaptiveScale.getValue(), specialAdaptiveScale)); // Return adaptive scale return mAdaptiveScale.getValue(); }
double Dnode::localUpdate() { specialUpdate(); flag = true; return 0; }