mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-20 17:52:50 +03:00
More CSS and UIStyle clean up.
--HG-- branch : dev
This commit is contained in:
@@ -25,7 +25,7 @@ class EE_API StyleSheet {
|
||||
|
||||
StyleSheetPseudoClassProperties getElementPropertiesByState( StyleSheetElement * element );
|
||||
|
||||
StyleSheetStyleVector getElementStyles( StyleSheetElement * element );
|
||||
StyleSheetStyleVector getElementStyles( StyleSheetElement * element, const bool& applyPseudo = false );
|
||||
|
||||
const StyleSheetStyleList& getStyles() const;
|
||||
protected:
|
||||
|
||||
@@ -13,6 +13,8 @@ class EE_API StyleSheetProperty {
|
||||
|
||||
explicit StyleSheetProperty( const std::string& name, const std::string& value );
|
||||
|
||||
explicit StyleSheetProperty( const std::string& name, const std::string& value, const Uint32& specificity );
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
const std::string& getValue() const;
|
||||
@@ -20,6 +22,12 @@ class EE_API StyleSheetProperty {
|
||||
const Uint32& getSpecificity() const;
|
||||
|
||||
void setSpecificity( const Uint32& specificity );
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
void setName(const std::string & name);
|
||||
|
||||
void setValue(const std::string & value);
|
||||
protected:
|
||||
std::string mName;
|
||||
std::string mValue;
|
||||
|
||||
@@ -48,33 +48,17 @@ class EE_API UIStyle : public UIState {
|
||||
|
||||
bool stateExists( const Uint32& state ) const;
|
||||
|
||||
void addAttribute( int state, NodeAttribute attribute );
|
||||
|
||||
void load();
|
||||
|
||||
void onStateChange();
|
||||
|
||||
Font * getFontFamily( const Uint32& state = StateFlagNormal ) const;
|
||||
CSS::StyleSheetProperty getStyleSheetProperty( const Uint32& state, const std::string& attributeName ) const;
|
||||
|
||||
int getFontCharacterSize( const Uint32& state = StateFlagNormal, const int& defaultValue = 12 ) const;
|
||||
CSS::StyleSheetProperty getStyleSheetPropertyFromNames( const Uint32& state, const std::vector<std::string>& propertiesNames ) const;
|
||||
|
||||
Color getTextColor( const Uint32& state = StateFlagNormal ) const;
|
||||
NodeAttribute getNodeAttribute( const Uint32& state, const std::string& attributeName ) const;
|
||||
|
||||
Color getTextShadowColor( const Uint32& state = StateFlagNormal ) const;
|
||||
|
||||
Uint32 getTextStyle( const Uint32& state = StateFlagNormal ) const;
|
||||
|
||||
Float getFontOutlineThickness( const Uint32& state = StateFlagNormal ) const;
|
||||
|
||||
Color getFontOutlineColor( const Uint32& state = StateFlagNormal ) const;
|
||||
|
||||
FontStyleConfig getFontStyleConfig( const Uint32& state = StateFlagNormal ) const;
|
||||
|
||||
NodeAttribute getAttribute( const Uint32& state, const std::string& attributeName ) const;
|
||||
|
||||
bool hasAttribute( const Uint32& state, const std::string& attributeName ) const;
|
||||
|
||||
NodeAttribute getAttributeFromNames( const Uint32& state, const std::vector<std::string>& attributeNames ) const;
|
||||
bool hasStyleSheetProperty( const Uint32& state, const std::string& propertyName ) const;
|
||||
|
||||
void addStyleSheetProperties( const Uint32& state, const CSS::StyleSheetProperties& properties );
|
||||
|
||||
@@ -84,13 +68,12 @@ class EE_API UIStyle : public UIState {
|
||||
|
||||
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<Uint32, AttributesMap> mStates;
|
||||
std::map<Uint32, CSS::StyleSheetProperties> mStates;
|
||||
std::map<Uint32, TransitionsMap> mTransitions;
|
||||
std::map<Uint32, std::vector<NodeAttribute>> mTransitionAttributes;
|
||||
std::map<Uint32, std::vector<CSS::StyleSheetProperty>> mTransitionAttributes;
|
||||
|
||||
void updateState();
|
||||
|
||||
|
||||
@@ -66,14 +66,14 @@ StyleSheet::StyleSheetPseudoClassProperties StyleSheet::getElementPropertiesBySt
|
||||
return propertiesSelectedByPseudoClass;
|
||||
}
|
||||
|
||||
StyleSheetStyleVector StyleSheet::getElementStyles( StyleSheetElement * element ) {
|
||||
StyleSheetStyleVector StyleSheet::getElementStyles( StyleSheetElement * element , const bool& applyPseudo ) {
|
||||
StyleSheetStyleVector styles;
|
||||
|
||||
for ( auto it = mNodes.begin(); it != mNodes.end(); ++it ) {
|
||||
StyleSheetStyle& node = it->second;
|
||||
const StyleSheetSelector& selector = node.getSelector();
|
||||
|
||||
if ( selector.select( element, false ) ) {
|
||||
if ( selector.select( element, applyPseudo ) ) {
|
||||
styles.push_back( node );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include <eepp/ui/css/stylesheetproperty.hpp>
|
||||
#include <eepp/core/string.hpp>
|
||||
#include <eepp/graphics/pixeldensity.hpp>
|
||||
#include <eepp/graphics/text.hpp>
|
||||
#include <eepp/ui/uihelper.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace EE { namespace UI { namespace CSS {
|
||||
|
||||
@@ -11,6 +15,12 @@ StyleSheetProperty::StyleSheetProperty( const std::string& name, const std::stri
|
||||
mValue( String::trim( value ) )
|
||||
{}
|
||||
|
||||
StyleSheetProperty::StyleSheetProperty( const std::string & name, const std::string& value, const Uint32 & specificity ) :
|
||||
mName( String::toLower( String::trim( name ) ) ),
|
||||
mValue( String::trim( value ) ),
|
||||
mSpecificity( specificity )
|
||||
{}
|
||||
|
||||
const std::string &StyleSheetProperty::getName() const {
|
||||
return mName;
|
||||
}
|
||||
@@ -27,4 +37,16 @@ void StyleSheetProperty::setSpecificity( const Uint32 & specificity ) {
|
||||
mSpecificity = specificity;
|
||||
}
|
||||
|
||||
bool StyleSheetProperty::isEmpty() const {
|
||||
return mName.empty();
|
||||
}
|
||||
|
||||
void StyleSheetProperty::setName( const std::string& name ) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
void StyleSheetProperty::setValue( const std::string& value ) {
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
@@ -105,7 +105,7 @@ const bool &StyleSheetSelector::isCacheable() const {
|
||||
return mCacheable;
|
||||
}
|
||||
|
||||
bool StyleSheetSelector::select( StyleSheetElement * element , const bool& applyPseudo ) const {
|
||||
bool StyleSheetSelector::select( StyleSheetElement * element, const bool& applyPseudo ) const {
|
||||
if ( mSelectorRules.empty() )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <eepp/ui/uithememanager.hpp>
|
||||
#include <eepp/graphics/fontmanager.hpp>
|
||||
|
||||
using namespace EE::UI::CSS;
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
@@ -24,24 +25,23 @@ bool UIStyle::stateExists( const EE::Uint32 & state ) const {
|
||||
return mStates.find( state ) != mStates.end();
|
||||
}
|
||||
|
||||
void UIStyle::addAttribute( int state, NodeAttribute attribute ) {
|
||||
void UIStyle::addStyleSheetProperty( const Uint32& state, const StyleSheetProperty& attribute ) {
|
||||
if ( attribute.getName() == "padding" ) {
|
||||
Rectf rect( attribute.asRectf() );
|
||||
mStates[ state ][ "paddingleft" ] = NodeAttribute( "paddingleft", String::toStr( rect.Left ) );
|
||||
mStates[ state ][ "paddingright" ] = NodeAttribute( "paddingright", String::toStr( rect.Right ) );
|
||||
mStates[ state ][ "paddingtop" ] = NodeAttribute( "paddingtop", String::toStr( rect.Top ) );
|
||||
mStates[ state ][ "paddingbottom" ] = NodeAttribute( "paddingbottom", String::toStr( rect.Bottom ) );
|
||||
Rectf rect( NodeAttribute( attribute.getName(), attribute.getValue() ).asRectf() );
|
||||
mStates[ state ][ "paddingleft" ] = StyleSheetProperty( "paddingleft", String::toStr( rect.Left ), attribute.getSpecificity() );
|
||||
mStates[ state ][ "paddingright" ] = StyleSheetProperty( "paddingright", String::toStr( rect.Right ), attribute.getSpecificity() );
|
||||
mStates[ state ][ "paddingtop" ] = StyleSheetProperty( "paddingtop", String::toStr( rect.Top ), attribute.getSpecificity() );
|
||||
mStates[ state ][ "paddingbottom" ] = StyleSheetProperty( "paddingbottom", String::toStr( rect.Bottom ), attribute.getSpecificity() );
|
||||
} else if ( attribute.getName() == "layout_margin" ) {
|
||||
Rect rect( attribute.asRect() );
|
||||
mStates[ state ][ "layout_marginleft" ] = NodeAttribute( "layout_marginleft", String::toStr( rect.Left ) );
|
||||
mStates[ state ][ "layout_marginright" ] = NodeAttribute( "layout_marginright", String::toStr( rect.Right ) );
|
||||
mStates[ state ][ "layout_margintop" ] = NodeAttribute( "layout_margintop", String::toStr( rect.Top ) );
|
||||
mStates[ state ][ "layout_marginbottom" ] = NodeAttribute( "layout_marginbottom", String::toStr( rect.Bottom ) );
|
||||
Rect rect( NodeAttribute( attribute.getName(), attribute.getValue() ).asRect() );
|
||||
mStates[ state ][ "layout_marginleft" ] = StyleSheetProperty( "layout_marginleft", String::toStr( rect.Left ), attribute.getSpecificity() );
|
||||
mStates[ state ][ "layout_marginright" ] = StyleSheetProperty( "layout_marginright", String::toStr( rect.Right ), attribute.getSpecificity() );
|
||||
mStates[ state ][ "layout_margintop" ] = StyleSheetProperty( "layout_margintop", String::toStr( rect.Top ), attribute.getSpecificity() );
|
||||
mStates[ state ][ "layout_marginbottom" ] = StyleSheetProperty( "layout_marginbottom", String::toStr( rect.Bottom ), attribute.getSpecificity() );
|
||||
} else {
|
||||
mStates[ state ][ attribute.getName() ] = attribute;
|
||||
}
|
||||
|
||||
|
||||
if ( String::startsWith( attribute.getName(), "transition" ) ) {
|
||||
mTransitionAttributes[ state ].push_back( attribute );
|
||||
|
||||
@@ -81,15 +81,11 @@ void UIStyle::addStyleSheetProperties(const Uint32 & state, const CSS::StyleShee
|
||||
for ( auto it = properties.begin(); it != properties.end(); ++it ) {
|
||||
CSS::StyleSheetProperty property = it->second;
|
||||
|
||||
addAttribute( state, NodeAttribute( property.getName(), property.getValue() ) );
|
||||
addStyleSheetProperty( state, property );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIStyle::addStyleSheetProperty( const Uint32& state, const CSS::StyleSheetProperty& property ) {
|
||||
addAttribute( state, NodeAttribute( property.getName(), property.getValue() ) );
|
||||
}
|
||||
|
||||
bool UIStyle::hasTransition( const Uint32& state, const std::string& propertyName ) {
|
||||
bool ret = mTransitions.find( state ) != mTransitions.end() &&
|
||||
( mTransitions[ state ].find( propertyName ) != mTransitions[ state ].end() ||
|
||||
@@ -139,15 +135,13 @@ UIStyle::TransitionInfo UIStyle::getTransition( const Uint32& state, const std::
|
||||
|
||||
void UIStyle::onStateChange() {
|
||||
if ( NULL != mWidget && stateExists( mCurrentState ) ) {
|
||||
AttributesMap& attrs = mStates[ mCurrentState ];
|
||||
auto& attrs = mStates[ mCurrentState ];
|
||||
|
||||
if ( !attrs.empty() ) {
|
||||
mWidget->beginAttributesTransaction();
|
||||
|
||||
for ( auto it = attrs.begin(); it != attrs.end(); ++it ) {
|
||||
NodeAttribute& nodeAttr = it->second;
|
||||
|
||||
mWidget->setAttribute( nodeAttr, mCurrentState );
|
||||
for ( auto& nodeAttr : attrs ) {
|
||||
mWidget->setAttribute( NodeAttribute( nodeAttr.second.getName(), nodeAttr.second.getValue() ), mCurrentState );
|
||||
}
|
||||
|
||||
mWidget->endAttributesTransaction();
|
||||
@@ -155,10 +149,9 @@ void UIStyle::onStateChange() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NodeAttribute UIStyle::getAttribute( const Uint32& state, const std::string& attributeName ) const {
|
||||
StyleSheetProperty UIStyle::getStyleSheetProperty( const Uint32& state, const std::string& attributeName ) const {
|
||||
if ( !attributeName.empty() && stateExists( state ) ) {
|
||||
const AttributesMap& attributesMap = mStates.at( state );
|
||||
auto& attributesMap = mStates.at( state );
|
||||
|
||||
auto attributeFound = attributesMap.find( attributeName );
|
||||
|
||||
@@ -167,24 +160,15 @@ NodeAttribute UIStyle::getAttribute( const Uint32& state, const std::string& att
|
||||
}
|
||||
}
|
||||
|
||||
return NodeAttribute();
|
||||
return StyleSheetProperty();
|
||||
}
|
||||
|
||||
bool UIStyle::hasAttribute(const Uint32 & state, const std::string & attributeName) const {
|
||||
if ( !attributeName.empty() && stateExists( state ) ) {
|
||||
const AttributesMap& attributesMap = mStates.at( state );
|
||||
return attributesMap.find( attributeName ) != attributesMap.end();
|
||||
}
|
||||
StyleSheetProperty UIStyle::getStyleSheetPropertyFromNames( const Uint32& state, const std::vector<std::string>& propertiesNames ) const {
|
||||
if ( !propertiesNames.empty() && stateExists( state ) ) {
|
||||
auto& attributesMap = mStates.at( state );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NodeAttribute UIStyle::getAttributeFromNames( const Uint32& state, const std::vector<std::string>& attributeNames ) const {
|
||||
if ( !attributeNames.empty() && stateExists( state ) ) {
|
||||
const AttributesMap& attributesMap = mStates.at( state );
|
||||
|
||||
for ( size_t i = 0; i < attributeNames.size(); i++ ) {
|
||||
const std::string& name = attributeNames[i];
|
||||
for ( size_t i = 0; i < propertiesNames.size(); i++ ) {
|
||||
const std::string& name = propertiesNames[i];
|
||||
auto attributeFound = attributesMap.find( name );
|
||||
|
||||
if ( attributeFound != attributesMap.end() ) {
|
||||
@@ -194,69 +178,21 @@ NodeAttribute UIStyle::getAttributeFromNames( const Uint32& state, const std::ve
|
||||
}
|
||||
}
|
||||
|
||||
return NodeAttribute();
|
||||
return StyleSheetProperty();
|
||||
}
|
||||
|
||||
Font * UIStyle::getFontFamily( const Uint32& state ) const {
|
||||
NodeAttribute attribute = getAttributeFromNames( state, { "fontfamily", "fontname" } );
|
||||
NodeAttribute UIStyle::getNodeAttribute( const Uint32& state, const std::string& attributeName ) const {
|
||||
StyleSheetProperty property( getStyleSheetProperty( state, attributeName ) );
|
||||
return NodeAttribute( property.getName(), property.getValue() );
|
||||
}
|
||||
|
||||
if ( !attribute.isEmpty() ) {
|
||||
return FontManager::instance()->getByName( attribute.asString() );
|
||||
bool UIStyle::hasStyleSheetProperty( const Uint32 & state, const std::string& propertyName ) const {
|
||||
if ( !propertyName.empty() && stateExists( state ) ) {
|
||||
auto& attributesMap = mStates.at( state );
|
||||
return attributesMap.find( propertyName ) != attributesMap.end();
|
||||
}
|
||||
|
||||
return UIThemeManager::instance()->getDefaultFont();
|
||||
}
|
||||
|
||||
int UIStyle::getFontCharacterSize(const Uint32& state, const int& defaultValue ) const {
|
||||
NodeAttribute attribute = getAttributeFromNames( state, { "textsize", "fontsize", "charactersize" } );
|
||||
|
||||
if ( !attribute.isEmpty() ) {
|
||||
return attribute.asDpDimensionI();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Color UIStyle::getTextColor( const Uint32& state ) const {
|
||||
NodeAttribute attribute = getAttribute( state, "textcolor" );
|
||||
|
||||
return attribute.isEmpty() ? Color::White : attribute.asColor();
|
||||
}
|
||||
|
||||
Color UIStyle::getTextShadowColor( const Uint32& state ) const {
|
||||
NodeAttribute attribute = getAttribute( state, "textshadowcolor" );
|
||||
|
||||
return attribute.isEmpty() ? Color::Black : attribute.asColor();
|
||||
}
|
||||
|
||||
Uint32 UIStyle::getTextStyle( const Uint32& state ) const {
|
||||
NodeAttribute attribute = getAttribute( state, "textstyle" );
|
||||
|
||||
return attribute.isEmpty() ? 0 : attribute.asFontStyle();
|
||||
}
|
||||
|
||||
Float UIStyle::getFontOutlineThickness( const Uint32& state ) const {
|
||||
NodeAttribute attribute = getAttribute( state, "fontoutlinethickness" );
|
||||
|
||||
return attribute.isEmpty() ? 0.f : attribute.asFloat();
|
||||
}
|
||||
|
||||
Color UIStyle::getFontOutlineColor( const Uint32& state ) const {
|
||||
NodeAttribute attribute = getAttribute( state, "fontoutlinecolor" );
|
||||
|
||||
return attribute.isEmpty() ? Color::White : attribute.asColor();
|
||||
}
|
||||
|
||||
FontStyleConfig UIStyle::getFontStyleConfig( const Uint32& state ) const {
|
||||
FontStyleConfig fontStyleConfig;
|
||||
fontStyleConfig.Font = getFontFamily( state );
|
||||
fontStyleConfig.CharacterSize = getFontCharacterSize( state );
|
||||
fontStyleConfig.Style = getTextStyle( state );
|
||||
fontStyleConfig.FontColor = getTextColor( state );
|
||||
fontStyleConfig.ShadowColor = getTextShadowColor( state );
|
||||
fontStyleConfig.OutlineColor = getFontOutlineColor( state );
|
||||
fontStyleConfig.OutlineThickness = getFontOutlineThickness( state );
|
||||
return fontStyleConfig;
|
||||
return false;
|
||||
}
|
||||
|
||||
void UIStyle::updateState() {
|
||||
@@ -295,8 +231,7 @@ void UIStyle::parseTransitions( const Uint32& state ) {
|
||||
|
||||
auto transitionAttributes = mTransitionAttributes[ state ];
|
||||
|
||||
for ( auto it = transitionAttributes.begin(); it != transitionAttributes.end(); ++it ) {
|
||||
NodeAttribute& attr = *it;
|
||||
for ( auto& attr : transitionAttributes ) {
|
||||
if ( attr.getName() == "transition" ) {
|
||||
auto strTransitions = String::split( attr.getValue(), ',' );
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <eepp/window/clipboard.hpp>
|
||||
#include <eepp/scene/actions/actions.hpp>
|
||||
#include <pugixml/pugixml.hpp>
|
||||
#include <eepp/ui/css/stylesheetproperty.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
@@ -552,9 +553,9 @@ void UITextView::resetSelCache() {
|
||||
}
|
||||
|
||||
#define SAVE_NORMAL_STATE_ATTR( ATTR_FORMATED ) \
|
||||
NodeAttribute oldAttribute = mStyle->getAttribute( UIState::StateFlagNormal, attribute.getName() ); \
|
||||
CSS::StyleSheetProperty oldAttribute = mStyle->getStyleSheetProperty( UIState::StateFlagNormal, attribute.getName() ); \
|
||||
if ( oldAttribute.isEmpty() && mStyle->getPreviousState() == UIState::StateFlagNormal ) \
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), ATTR_FORMATED ) ); \
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), ATTR_FORMATED ) ); \
|
||||
|
||||
bool UITextView::setAttribute( const NodeAttribute& attribute, const Uint32& state ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <eepp/scene/actions/actions.hpp>
|
||||
#include <pugixml/pugixml.hpp>
|
||||
#include <eepp/ui/css/stylesheetproperty.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
@@ -639,10 +640,9 @@ bool UIWidget::setAttribute( const std::string& name, const std::string& value,
|
||||
}
|
||||
|
||||
#define SAVE_NORMAL_STATE_ATTR( ATTR_FORMATED ) \
|
||||
NodeAttribute oldAttribute = mStyle->getAttribute( UIState::StateFlagNormal, attribute.getName() ); \
|
||||
CSS::StyleSheetProperty oldAttribute = mStyle->getStyleSheetProperty( UIState::StateFlagNormal, attribute.getName() ); \
|
||||
if ( oldAttribute.isEmpty() && mStyle->getPreviousState() == UIState::StateFlagNormal ) \
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), ATTR_FORMATED ) ); \
|
||||
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), ATTR_FORMATED ) ); \
|
||||
|
||||
bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state ) {
|
||||
const std::string& name = attribute.getName();
|
||||
@@ -971,19 +971,19 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) );
|
||||
Action * action = Actions::MarginMove::New( mLayoutMargin, margin, transitionInfo.duration, transitionInfo.timingFunction, marginFlag );
|
||||
|
||||
NodeAttribute oldAttribute = mStyle->getAttribute( UIState::StateFlagNormal, attribute.getName() );
|
||||
CSS::StyleSheetProperty oldAttribute = mStyle->getStyleSheetProperty( UIState::StateFlagNormal, attribute.getName() );
|
||||
if ( oldAttribute.isEmpty() && mStyle->getPreviousState() == UIState::StateFlagNormal ) {
|
||||
if ( "layout_marginleft" == name || "layout_margin" == name )
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d", mLayoutMargin.Left ) ) );
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), String::format( "%d", mLayoutMargin.Left ) ) );
|
||||
|
||||
if ( "layout_marginright" == name || "layout_margin" == name )
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d", mLayoutMargin.Right ) ) );
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), String::format( "%d", mLayoutMargin.Right ) ) );
|
||||
|
||||
if ( "layout_margintop" == name || "layout_margin" == name )
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d", mLayoutMargin.Top ) ) );
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), String::format( "%d", mLayoutMargin.Top ) ) );
|
||||
|
||||
if ( "layout_marginbottom" == name || "layout_margin" == name )
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d", mLayoutMargin.Bottom ) ) );
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), String::format( "%d", mLayoutMargin.Bottom ) ) );
|
||||
}
|
||||
|
||||
if ( Time::Zero != transitionInfo.delay )
|
||||
@@ -1085,7 +1085,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
} else if ( "rotation" == name ) {
|
||||
if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( state, attribute.getName() ) ) {
|
||||
UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) );
|
||||
Float newRotation( mStyle->getAttribute( state, attribute.getName() ).asFloat() );
|
||||
Float newRotation( mStyle->getNodeAttribute( state, attribute.getName() ).asFloat() );
|
||||
Action * action = Actions::Rotate::New( mRotation, newRotation, transitionInfo.duration, transitionInfo.timingFunction );
|
||||
|
||||
SAVE_NORMAL_STATE_ATTR( String::format( "%2.f", mRotation ) )
|
||||
@@ -1100,7 +1100,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
} else if ( "scale" == name ) {
|
||||
if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( state, attribute.getName() ) ) {
|
||||
UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) );
|
||||
Vector2f newScale( mStyle->getAttribute( state, attribute.getName() ).asVector2f() );
|
||||
Vector2f newScale( mStyle->getNodeAttribute( state, attribute.getName() ).asVector2f() );
|
||||
Action * action = Actions::Scale::New( mScale, newScale, transitionInfo.duration, transitionInfo.timingFunction );
|
||||
|
||||
SAVE_NORMAL_STATE_ATTR( String::format( "%2.f, %2.f", mScale.x, mScale.y ) )
|
||||
@@ -1143,19 +1143,19 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) );
|
||||
Action * action = Actions::PaddingTransition::New( mPadding, padding, transitionInfo.duration, transitionInfo.timingFunction, paddingFlag );
|
||||
|
||||
NodeAttribute oldAttribute = mStyle->getAttribute( UIState::StateFlagNormal, attribute.getName() );
|
||||
CSS::StyleSheetProperty oldAttribute = mStyle->getStyleSheetProperty( UIState::StateFlagNormal, attribute.getName() );
|
||||
if ( oldAttribute.isEmpty() && mStyle->getPreviousState() == UIState::StateFlagNormal ) {
|
||||
if ( "paddingleft" == name || "padding" == name )
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f", mPadding.Left ) ) );
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), String::format( "%2.f", mPadding.Left ) ) );
|
||||
|
||||
if ( "paddingright" == name || "padding" == name )
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f", mPadding.Right ) ) );
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), String::format( "%2.f", mPadding.Right ) ) );
|
||||
|
||||
if ( "paddingtop" == name || "padding" == name )
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f", mPadding.Top ) ) );
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), String::format( "%2.f", mPadding.Top ) ) );
|
||||
|
||||
if ( "paddingbottom" == name || "padding" == name )
|
||||
mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f", mPadding.Bottom ) ) );
|
||||
mStyle->addStyleSheetProperty( UIState::StateFlagNormal, CSS::StyleSheetProperty( attribute.getName(), String::format( "%2.f", mPadding.Bottom ) ) );
|
||||
}
|
||||
|
||||
if ( Time::Zero != transitionInfo.delay )
|
||||
|
||||
Reference in New Issue
Block a user