| 510 | } |
| 511 | |
| 512 | void UIStyle::applyStyleSheetProperty( const StyleSheetProperty& property, |
| 513 | std::shared_ptr<ElementDefinition> prevDefinition ) { |
| 514 | const PropertyDefinition* propertyDefinition = property.getPropertyDefinition(); |
| 515 | |
| 516 | // Save default value if possible and not available. |
| 517 | if ( mCurrentState != UIState::StateFlagNormal || |
| 518 | ( mCurrentState == UIState::StateFlagNormal && property.isVolatile() ) ) { |
| 519 | const StyleSheetProperty* oldAttribute = getStatelessStyleSheetProperty( property.getId() ); |
| 520 | if ( nullptr == oldAttribute && getPreviousState() == UIState::StateFlagNormal ) { |
| 521 | std::string value( |
| 522 | mWidget->getPropertyString( propertyDefinition, property.getIndex() ) ); |
| 523 | if ( !value.empty() ) { |
| 524 | setStyleSheetProperty( StyleSheetProperty( propertyDefinition, value, |
| 525 | property.getIndex(), true, true ) ); |
| 526 | } |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | if ( !mDisableAnimations && !mFirstState && !mWidget->isSceneNodeLoading() && |
| 531 | NULL != propertyDefinition && |
| 532 | StyleSheetPropertyAnimation::animationSupported( propertyDefinition->getType() ) && |
| 533 | hasTransition( property.getName() ) && |
| 534 | !hasAnimation( property.getPropertyDefinition() ) ) { |
| 535 | std::string currentValue = |
| 536 | mWidget->getPropertyString( propertyDefinition, property.getIndex() ); |
| 537 | std::string startValue( currentValue ); |
| 538 | |
| 539 | if ( !startValue.empty() ) { |
| 540 | // Get the real start value |
| 541 | if ( nullptr != prevDefinition ) { |
| 542 | auto prevProp = prevDefinition->getProperty( property.getId() ); |
| 543 | if ( nullptr != prevProp ) { |
| 544 | StyleSheetProperty* curProperty = prevProp; |
| 545 | if ( propertyDefinition->isIndexed() && |
| 546 | property.getIndex() < curProperty->getPropertyIndexCount() ) { |
| 547 | applyVarValues( curProperty->getPropertyIndexRef( property.getIndex() ) ); |
| 548 | startValue = |
| 549 | curProperty->getPropertyIndex( property.getIndex() ).getValue(); |
| 550 | } else { |
| 551 | applyVarValues( curProperty ); |
| 552 | startValue = curProperty->getValue(); |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | TransitionDefinition transitionInfo( getTransition( property.getName() ) ); |
| 558 | |
| 559 | std::vector<Action*> previousTransitions = |
| 560 | mWidget->getActionsByTag( propertyDefinition->getId() ); |
| 561 | std::vector<Action*> removeTransitions; |
| 562 | StyleSheetPropertyAnimation* prevTransition = NULL; |
| 563 | |
| 564 | if ( !previousTransitions.empty() ) { |
| 565 | for ( auto& transition : previousTransitions ) { |
| 566 | if ( transition->getId() == StyleSheetPropertyAnimation::ID ) { |
| 567 | StyleSheetPropertyAnimation* tmpTransition = |
| 568 | static_cast<StyleSheetPropertyAnimation*>( transition ); |
| 569 | if ( tmpTransition->getAnimationOrigin() == AnimationOrigin::Transition ) { |
nothing calls this directly
no test coverage detected