mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-31 18:46:29 +03:00
Minor clean up.
--HG-- branch : dev-css
This commit is contained in:
@@ -51,3 +51,5 @@ bin/libeepp.dylib
|
||||
.idea
|
||||
eepp.kdev4
|
||||
bin/eepp-MapEditor*
|
||||
eepp.tags
|
||||
eepp.geany
|
||||
|
||||
@@ -31,7 +31,7 @@ class EE_API UIStyle : public UIState {
|
||||
|
||||
Ease::Interpolation getTimingFunction() const { return timingFunction; }
|
||||
|
||||
const Time& getDelay() const { return delay; };
|
||||
const Time& getDelay() const { return delay; }
|
||||
|
||||
const Time& getDuration() const { return duration; }
|
||||
|
||||
@@ -77,6 +77,8 @@ class EE_API UIStyle : public UIState {
|
||||
std::vector<CSS::StyleSheetProperty> mTransitionAttributes;
|
||||
TransitionsMap mTransitions;
|
||||
|
||||
void tryApplyStyle( const CSS::StyleSheetStyle& style );
|
||||
|
||||
void updateState();
|
||||
|
||||
void parseTransitions();
|
||||
|
||||
@@ -20,8 +20,8 @@ void StyleSheet::combineStyle( const StyleSheetStyle& node ) {
|
||||
auto currentNode = nodeIt->second;
|
||||
|
||||
if ( node.getSelector().getSpecificity() > currentNode.getSelector().getSpecificity() ) {
|
||||
for ( auto pit = node.getProperties().begin(); pit != node.getProperties().end(); ++pit )
|
||||
currentNode.setProperty( pit->second );
|
||||
for ( auto& pit : node.getProperties() )
|
||||
currentNode.setProperty( pit.second );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,33 +31,35 @@ bool StyleSheet::isEmpty() const {
|
||||
}
|
||||
|
||||
void StyleSheet::print() {
|
||||
for ( auto it = mNodes.begin(); it != mNodes.end(); ++it ) {
|
||||
StyleSheetStyle& style = it->second;
|
||||
for ( auto& it : mNodes ) {
|
||||
StyleSheetStyle& style = it.second;
|
||||
|
||||
style.print();
|
||||
}
|
||||
}
|
||||
|
||||
void StyleSheet::combineStyleSheet( const StyleSheet& styleSheet ) {
|
||||
for ( auto it = styleSheet.getStyles().begin(); it != styleSheet.getStyles().end(); ++it ) {
|
||||
combineStyle( it->second );
|
||||
for ( auto& it : styleSheet.getStyles() ) {
|
||||
combineStyle( it.second );
|
||||
}
|
||||
}
|
||||
|
||||
StyleSheet::StyleSheetPseudoClassProperties StyleSheet::getElementPropertiesByState( StyleSheetElement * element ) {
|
||||
StyleSheetPseudoClassProperties propertiesSelectedByPseudoClass;
|
||||
|
||||
for ( auto it = mNodes.begin(); it != mNodes.end(); ++it ) {
|
||||
StyleSheetStyle& node = it->second;
|
||||
for ( const auto& it : mNodes ) {
|
||||
const StyleSheetStyle& node = it.second;
|
||||
const StyleSheetSelector& selector = node.getSelector();
|
||||
|
||||
if ( selector.isCacheable() && selector.select( element, false ) ) {
|
||||
for ( auto pit = node.getProperties().begin(); pit != node.getProperties().end(); ++pit ) {
|
||||
for ( const auto& pit : node.getProperties() ) {
|
||||
StyleSheetProperties& pseudoClassProperties = propertiesSelectedByPseudoClass[selector.getPseudoClass()];
|
||||
auto pcit = pseudoClassProperties.find( pit->second.getName() );
|
||||
const StyleSheetProperty& property = pit.second;
|
||||
const auto& pcit = pseudoClassProperties.find( property.getName() );
|
||||
const StyleSheetProperty& propertyRight = pcit->second;
|
||||
|
||||
if ( pcit == pseudoClassProperties.end() || pit->second.getSpecificity() >= pcit->second.getSpecificity() ) {
|
||||
pseudoClassProperties[ pit->second.getName() ] = pit->second;
|
||||
if ( pcit == pseudoClassProperties.end() || property.getSpecificity() >= propertyRight.getSpecificity() ) {
|
||||
pseudoClassProperties[ property.getName() ] = property;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,8 +71,8 @@ StyleSheet::StyleSheetPseudoClassProperties StyleSheet::getElementPropertiesBySt
|
||||
StyleSheetStyleVector StyleSheet::getElementStyles( StyleSheetElement * element , const bool& applyPseudo ) {
|
||||
StyleSheetStyleVector styles;
|
||||
|
||||
for ( auto it = mNodes.begin(); it != mNodes.end(); ++it ) {
|
||||
StyleSheetStyle& node = it->second;
|
||||
for ( const auto& it : mNodes ) {
|
||||
const StyleSheetStyle& node = it.second;
|
||||
const StyleSheetSelector& selector = node.getSelector();
|
||||
|
||||
if ( selector.select( element, applyPseudo ) ) {
|
||||
@@ -84,8 +86,8 @@ StyleSheetStyleVector StyleSheet::getElementStyles( StyleSheetElement * element
|
||||
StyleSheetStyleVector StyleSheet::getCacheableElementStyles( StyleSheetElement * element, const bool& applyPseudo ) {
|
||||
StyleSheetStyleVector styles;
|
||||
|
||||
for ( auto it = mNodes.begin(); it != mNodes.end(); ++it ) {
|
||||
StyleSheetStyle& node = it->second;
|
||||
for ( const auto& it : mNodes ) {
|
||||
const StyleSheetStyle& node = it.second;
|
||||
const StyleSheetSelector& selector = node.getSelector();
|
||||
|
||||
if ( selector.isCacheable() && selector.select( element, applyPseudo ) ) {
|
||||
@@ -99,8 +101,8 @@ StyleSheetStyleVector StyleSheet::getCacheableElementStyles( StyleSheetElement *
|
||||
StyleSheetStyleVector StyleSheet::getNoncacheableElementStyles( StyleSheetElement * element, const bool& applyPseudo ) {
|
||||
StyleSheetStyleVector styles;
|
||||
|
||||
for ( auto it = mNodes.begin(); it != mNodes.end(); ++it ) {
|
||||
StyleSheetStyle& node = it->second;
|
||||
for ( const auto& it : mNodes ) {
|
||||
const StyleSheetStyle& node = it.second;
|
||||
const StyleSheetSelector& selector = node.getSelector();
|
||||
|
||||
if ( !selector.isCacheable() && selector.select( element, applyPseudo ) ) {
|
||||
|
||||
@@ -25,13 +25,14 @@ const std::string &StyleSheetSelector::getName() const {
|
||||
|
||||
const std::string& StyleSheetSelector::getPseudoClass() const {
|
||||
return mPseudoClass;
|
||||
};
|
||||
}
|
||||
|
||||
const Uint32& StyleSheetSelector::getSpecificity() const {
|
||||
return mSpecificity;
|
||||
}
|
||||
|
||||
void removeExtraSpaces( std::string& string ) {
|
||||
// @TODO: Optimize this
|
||||
string = String::trim( string );
|
||||
String::replaceAll( string, " ", " " );
|
||||
String::replaceAll( string, " ", " " );
|
||||
|
||||
@@ -26,11 +26,11 @@ void StyleSheetStyle::print() {
|
||||
std::cout << "}" << std::endl;
|
||||
}
|
||||
|
||||
const StyleSheetSelector &StyleSheetStyle::getSelector() const {
|
||||
const StyleSheetSelector& StyleSheetStyle::getSelector() const {
|
||||
return mSelector;
|
||||
}
|
||||
|
||||
const StyleSheetProperties &StyleSheetStyle::getProperties() const {
|
||||
const StyleSheetProperties& StyleSheetStyle::getProperties() const {
|
||||
return mProperties;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,10 +61,8 @@ void UIStyle::load() {
|
||||
|
||||
void UIStyle::addStyleSheetProperties( const CSS::StyleSheetProperties& properties ) {
|
||||
if ( !properties.empty() ) {
|
||||
for ( auto it = properties.begin(); it != properties.end(); ++it ) {
|
||||
CSS::StyleSheetProperty property = it->second;
|
||||
|
||||
addStyleSheetProperty( property );
|
||||
for ( const auto& it : properties ) {
|
||||
addStyleSheetProperty( it.second );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,63 +83,43 @@ UIStyle::TransitionInfo UIStyle::getTransition( const std::string& propertyName
|
||||
return TransitionInfo();
|
||||
}
|
||||
|
||||
void UIStyle::tryApplyStyle( const StyleSheetStyle& style ) {
|
||||
if ( style.getSelector().select( mWidget ) ) {
|
||||
for ( const auto& prop : style.getProperties() ) {
|
||||
const StyleSheetProperty& property = prop.second;
|
||||
const auto& it = mProperties.find( property.getName() );
|
||||
|
||||
if ( it == mProperties.end() || property.getSpecificity() >= it->second.getSpecificity() ) {
|
||||
mProperties[ property.getName() ] = property;
|
||||
|
||||
if ( String::startsWith( property.getName(), "transition" ) )
|
||||
mTransitionAttributes.push_back( property );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIStyle::onStateChange() {
|
||||
if ( NULL != mWidget ) {
|
||||
mProperties.clear();
|
||||
mTransitionAttributes.clear();
|
||||
|
||||
if ( mElementStyle.getSelector().select( mWidget ) ) {
|
||||
for ( auto& prop : mElementStyle.getProperties() ) {
|
||||
auto& property = prop.second;
|
||||
auto it = mProperties.find( property.getName() );
|
||||
|
||||
if ( it == mProperties.end() || property.getSpecificity() >= it->second.getSpecificity() ) {
|
||||
mProperties[ property.getName() ] = property;
|
||||
|
||||
if ( String::startsWith( property.getName(), "transition" ) )
|
||||
mTransitionAttributes.push_back( property );
|
||||
}
|
||||
}
|
||||
}
|
||||
tryApplyStyle( mElementStyle );
|
||||
|
||||
for ( auto& style : mCacheableStyles ) {
|
||||
if ( style.getSelector().select( mWidget ) ) {
|
||||
for ( auto& prop : style.getProperties() ) {
|
||||
auto& property = prop.second;
|
||||
auto it = mProperties.find( property.getName() );
|
||||
|
||||
if ( it == mProperties.end() || property.getSpecificity() >= it->second.getSpecificity() ) {
|
||||
mProperties[ property.getName() ] = property;
|
||||
|
||||
if ( String::startsWith( property.getName(), "transition" ) )
|
||||
mTransitionAttributes.push_back( property );
|
||||
}
|
||||
}
|
||||
}
|
||||
tryApplyStyle( style );
|
||||
}
|
||||
|
||||
for ( auto& style : mNoncacheableStyles ) {
|
||||
if ( style.getSelector().select( mWidget ) ) {
|
||||
for ( auto& prop : style.getProperties() ) {
|
||||
auto& property = prop.second;
|
||||
auto it = mProperties.find( property.getName() );
|
||||
|
||||
if ( it == mProperties.end() || property.getSpecificity() >= it->second.getSpecificity() ) {
|
||||
mProperties[ property.getName() ] = property;
|
||||
|
||||
if ( String::startsWith( property.getName(), "transition" ) )
|
||||
mTransitionAttributes.push_back( property );
|
||||
}
|
||||
}
|
||||
}
|
||||
tryApplyStyle( style );
|
||||
}
|
||||
|
||||
parseTransitions();
|
||||
|
||||
mWidget->beginAttributesTransaction();
|
||||
|
||||
for ( auto& prop : mProperties ) {
|
||||
auto& property = prop.second;
|
||||
for ( const auto& prop : mProperties ) {
|
||||
const StyleSheetProperty& property = prop.second;
|
||||
|
||||
mWidget->setAttribute( property.getName(), property.getValue(), mCurrentState );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user