| 10 | } |
| 11 | |
| 12 | UnorderedMap<std::string, AnimationDefinition> AnimationDefinition::parseAnimationProperties( |
| 13 | const std::vector<const StyleSheetProperty*>& stylesheetProperties ) { |
| 14 | AnimationsMap animations; |
| 15 | std::vector<std::string> names; |
| 16 | std::vector<Time> durations; |
| 17 | std::vector<Time> delays; |
| 18 | std::vector<Int32> iterations; |
| 19 | std::vector<Ease::Interpolation> timingFunctions; |
| 20 | std::vector<std::vector<double>> timingFunctionParameters; |
| 21 | std::vector<AnimationDirection> directions; |
| 22 | std::vector<AnimationFillMode> fillModes; |
| 23 | std::vector<bool> pausedStates; |
| 24 | |
| 25 | for ( auto& prop : stylesheetProperties ) { |
| 26 | if ( prop->getPropertyDefinition() == NULL ) |
| 27 | continue; |
| 28 | |
| 29 | const PropertyDefinition* propDef = prop->getPropertyDefinition(); |
| 30 | |
| 31 | switch ( propDef->getPropertyId() ) { |
| 32 | case PropertyId::Animation: { |
| 33 | bool durationSet = false; |
| 34 | |
| 35 | for ( size_t i = 0; i < prop->getPropertyIndexCount(); i++ ) { |
| 36 | const StyleSheetProperty& iProp = prop->getPropertyIndex( i ); |
| 37 | |
| 38 | auto parts = String::split( iProp.getValue(), ' ' ); |
| 39 | |
| 40 | if ( parts.size() >= 2 ) { |
| 41 | AnimationDefinition animationDef; |
| 42 | |
| 43 | for ( auto& part : parts ) { |
| 44 | std::string val( String::trim( String::toLower( part ) ) ); |
| 45 | |
| 46 | if ( isDirectionString( val ) ) { |
| 47 | animationDef.setDirection( directionFromString( val ) ); |
| 48 | } else if ( isAnimationFillModeString( val ) ) { |
| 49 | animationDef.setFillMode( fillModeFromString( val ) ); |
| 50 | } else if ( "infinite" == val ) { |
| 51 | animationDef.setIterations( -1 ); |
| 52 | } else if ( "paused" == val ) { |
| 53 | animationDef.setPaused( true ); |
| 54 | } else if ( "running" == val ) { |
| 55 | animationDef.setPaused( false ); |
| 56 | } else if ( isTimingFunction( val ) ) { |
| 57 | TimingFunction tf( TimingFunction::parse( val ) ); |
| 58 | animationDef.setTimingFunction( tf.interpolation ); |
| 59 | animationDef.setTimingFunctionParameters( tf.parameters ); |
| 60 | } else if ( Time::isValid( val ) ) { |
| 61 | if ( durationSet ) { |
| 62 | animationDef.setDelay( Time::fromString( val ) ); |
| 63 | } else { |
| 64 | animationDef.setDuration( Time::fromString( val ) ); |
| 65 | durationSet = true; |
| 66 | } |
| 67 | } else if ( String::isNumber( val, true ) ) { |
| 68 | int iterations = 1; |
| 69 |
nothing calls this directly
no test coverage detected