mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
CSS Transitions WIP.
--HG-- branch : dev
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef EE_MATH_EASE
|
||||
#define EE_MATH_EASE
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace EE { namespace Math {
|
||||
|
||||
/** @brief Container class of the Interpolation types. */
|
||||
@@ -40,6 +42,41 @@ class Ease {
|
||||
ElasticOut,
|
||||
ElasticInOut
|
||||
};
|
||||
|
||||
static Interpolation fromName( const std::string& name, const Interpolation& defaultInterpolation = Ease::Linear ) {
|
||||
if ( "linear" == name ) return Ease::Linear;
|
||||
if ( "quadraticin" == name || "quadratic-in" == name ) return Ease::QuadraticIn;
|
||||
if ( "quadraticout" == name || "quadratic-out" == name ) return Ease::QuadraticOut;
|
||||
if ( "quadraticinout" == name || "quadratic-in-out" == name ) return Ease::QuadraticInOut;
|
||||
if ( "sinein" == name || "sine-in" == name ) return Ease::SineIn;
|
||||
if ( "sineout" == name || "sine-out" == name ) return Ease::SineOut;
|
||||
if ( "sineinout" == name || "sine-in-out" == name ) return Ease::SineInOut;
|
||||
if ( "exponentialin" == name || "exponential-in" == name ) return Ease::ExponentialIn;
|
||||
if ( "exponentialout" == name || "exponential-out" == name ) return Ease::ExponentialOut;
|
||||
if ( "exponentialinout" == name || "exponential-in-out" == name ) return Ease::ExponentialInOut;
|
||||
if ( "quarticin" == name || "quartic-in" == name ) return Ease::QuarticIn;
|
||||
if ( "quarticout" == name || "quartic-out" == name ) return Ease::QuarticOut;
|
||||
if ( "quarticinout" == name || "quartic-in-out" == name ) return Ease::QuarticInOut;
|
||||
if ( "quinticin" == name || "quintic-in" == name ) return Ease::QuinticIn;
|
||||
if ( "quinticout" == name || "quintic-out" == name ) return Ease::QuinticOut;
|
||||
if ( "quinticinout" == name || "quintic-in-out" == name ) return Ease::QuinticInOut;
|
||||
if ( "circularin" == name || "circular-in" == name ) return Ease::CircularIn;
|
||||
if ( "circularout" == name || "circular-out" == name ) return Ease::CircularOut;
|
||||
if ( "circularinout" == name || "circular-in-out" == name ) return Ease::CircularInOut;
|
||||
if ( "cubicin" == name || "cubic-in" == name ) return Ease::CubicIn;
|
||||
if ( "cubicout" == name || "cubic-out" == name ) return Ease::CubicOut;
|
||||
if ( "cubicinout" == name || "cubic-in-out" == name ) return Ease::CubicInOut;
|
||||
if ( "backin" == name || "back-in" == name ) return Ease::BackIn;
|
||||
if ( "backout" == name || "back-out" == name ) return Ease::BackOut;
|
||||
if ( "backinout" == name || "back-in-out" == name ) return Ease::BackInOut;
|
||||
if ( "bouncein" == name || "bounce-in" == name ) return Ease::BounceIn;
|
||||
if ( "bounceout" == name || "bounce-out" == name ) return Ease::BounceOut;
|
||||
if ( "bounceinout" == name || "bounce-in-out" == name ) return Ease::BounceInOut;
|
||||
if ( "elasticin" == name || "elastic-in" == name ) return Ease::ElasticIn;
|
||||
if ( "elasticout" == name || "elastic-out" == name ) return Ease::ElasticOut;
|
||||
if ( "elasticinout" == name || "elastic-in-out" == name ) return Ease::ElasticInOut;
|
||||
return defaultInterpolation;
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
#include <string>
|
||||
#include <eepp/math/rect.hpp>
|
||||
#include <eepp/core/string.hpp>
|
||||
#include <eepp/system/time.hpp>
|
||||
#include <eepp/system/color.hpp>
|
||||
#include <eepp/math/originpoint.hpp>
|
||||
#include <eepp/math/ease.hpp>
|
||||
#include <eepp/graphics/blendmode.hpp>
|
||||
|
||||
using namespace EE::System;
|
||||
@@ -116,6 +118,10 @@ class NodeAttribute {
|
||||
Rectf asRectf( const Rectf& defaultValue = Rectf() ) const;
|
||||
|
||||
Uint32 asFontStyle() const;
|
||||
|
||||
Time asTime( const Time& defaultTime = Seconds(0) );
|
||||
|
||||
Ease::Interpolation asInterpolation( const Ease::Interpolation& defaultInterpolation = Ease::Linear );
|
||||
protected:
|
||||
std::string mName;
|
||||
std::string mValue;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <eepp/scene/nodeattribute.hpp>
|
||||
#include <eepp/ui/css/stylesheetproperty.hpp>
|
||||
#include <eepp/graphics/fontstyleconfig.hpp>
|
||||
#include <eepp/math/ease.hpp>
|
||||
|
||||
using namespace EE::Scene;
|
||||
|
||||
@@ -18,6 +19,27 @@ class UIWidget;
|
||||
|
||||
class EE_API UIStyle : public UIState {
|
||||
public:
|
||||
class TransitionInfo
|
||||
{
|
||||
public:
|
||||
TransitionInfo() :
|
||||
timingFunction( Ease::Linear )
|
||||
{}
|
||||
|
||||
const std::string& getProperty() const { return property; }
|
||||
|
||||
Ease::Interpolation getTimingFunction() const { return timingFunction; }
|
||||
|
||||
const Time& getDelay() const { return delay; };
|
||||
|
||||
const Time& getDuration() const { return duration; }
|
||||
|
||||
std::string property;
|
||||
Ease::Interpolation timingFunction;
|
||||
Time delay;
|
||||
Time duration;
|
||||
};
|
||||
|
||||
static UIStyle * New( UIWidget * widget );
|
||||
|
||||
explicit UIStyle( UIWidget * widget );
|
||||
@@ -50,16 +72,25 @@ class EE_API UIStyle : public UIState {
|
||||
|
||||
NodeAttribute getAttribute( const Uint32& state, std::vector<std::string> attributeNames ) const;
|
||||
|
||||
void addStyleSheetProperties( int state, const CSS::StyleSheetProperties& properties );
|
||||
void addStyleSheetProperties( const Uint32& state, const CSS::StyleSheetProperties& properties );
|
||||
|
||||
void addStyleSheetProperty( int state, const CSS::StyleSheetProperty& property );
|
||||
void addStyleSheetProperty( const Uint32& state, const CSS::StyleSheetProperty& property );
|
||||
|
||||
bool hasTransition( const Uint32& state, const std::string& propertyName );
|
||||
|
||||
TransitionInfo getTransition( const Uint32& state, const std::string& propertyName );
|
||||
protected:
|
||||
typedef std::map<std::string, NodeAttribute> AttributesMap;
|
||||
typedef std::map<std::string, TransitionInfo> TransitionsMap;
|
||||
|
||||
UIWidget * mWidget;
|
||||
std::map<int, AttributesMap> mStates;
|
||||
std::map<Uint32, AttributesMap> mStates;
|
||||
std::map<Uint32, TransitionsMap> mTransitions;
|
||||
std::map<Uint32, std::vector<NodeAttribute>> mTransitionAttributes;
|
||||
|
||||
void updateState();
|
||||
|
||||
void parseTransitions( const Uint32& state );
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user