CSS Fixes.

--HG--
branch : dev
This commit is contained in:
Martín Lucas Golini
2018-12-29 22:49:20 -03:00
parent 8094b26310
commit 5d3990ecd7
10 changed files with 46 additions and 12 deletions
+5 -3
View File
@@ -99,11 +99,13 @@ class NodeAttribute {
BlendMode asBlendMode() const;
Vector2f asVector( const Vector2f& defaultValue = Vector2f::Zero );
Vector2f asVector2f( const Vector2f& defaultValue = Vector2f::Zero ) const;
Rect asRect( const Rect& defaultValue = Rect() );
Vector2i asVector2i( const Vector2i& defaultValue = Vector2i::Zero ) const;
Rectf asRectf( const Rectf& defaultValue = Rectf() );
Rect asRect( const Rect& defaultValue = Rect() ) const;
Rectf asRectf( const Rectf& defaultValue = Rectf() ) const;
protected:
std::string mName;
std::string mValue;
+2 -1
View File
@@ -18,7 +18,8 @@ class EE_API StyleSheetSelector {
SpecificityId = 1000000,
SpecificityClass = 100000,
SpecificityTag = 10000,
SpecificityPseudoClass = 100
SpecificityPseudoClass = 100,
SpecificityGlobal = 1
};
explicit StyleSheetSelector( const std::string& selectorName );
+2 -2
View File
@@ -24,6 +24,8 @@ class EE_API UIStyle : public UIState {
void addAttribute( int state, NodeAttribute attribute );
void load();
void onStateChange();
protected:
typedef std::map<std::string, NodeAttribute> AttributesMap;
@@ -31,8 +33,6 @@ class EE_API UIStyle : public UIState {
std::map<int, AttributesMap> mStates;
void addStyleSheetProperties( int state, const CSS::StyleSheetProperties& properties );
void onStateChange();
};
}}
+2
View File
@@ -55,6 +55,8 @@ class EE_API UITheme : protected ResourceManager<UISkin> {
UIFontStyleConfig getFontStyleConfig() const;
Font * getDefaultFont() const;
void setFontStyleConfig(UIFontStyleConfig fontConfig);
virtual UITabWidgetStyleConfig getTabWidgetStyleConfig();
+2
View File
@@ -162,6 +162,8 @@ class EE_API UIWidget : public UINode, public CSS::StyleSheetElement {
virtual void onPaddingChange();
virtual void onThemeLoaded();
void beginAttributesTransaction();
void endAttributesTransaction();
+21 -3
View File
@@ -154,7 +154,7 @@ BlendMode NodeAttribute::asBlendMode() const {
return toBlendMode( mValue );
}
Vector2f NodeAttribute::asVector( const Vector2f & defaultValue ) {
Vector2f NodeAttribute::asVector2f( const Vector2f & defaultValue ) const {
if ( !mValue.empty() && mValue.find( "," ) != std::string::npos ) {
Vector2f vector;
auto xySplit = String::split( mValue, ',', true );
@@ -172,7 +172,25 @@ Vector2f NodeAttribute::asVector( const Vector2f & defaultValue ) {
return defaultValue;
}
Rect NodeAttribute::asRect( const Rect& defaultValue ) {
Vector2i NodeAttribute::asVector2i( const Vector2i & defaultValue ) const {
if ( !mValue.empty() && mValue.find( "," ) != std::string::npos ) {
Vector2i vector;
auto xySplit = String::split( mValue, ',', true );
if ( xySplit.size() == 2 ) {
int val;
vector.x = String::fromString<int>( val, xySplit[0] ) ? val : defaultValue.x;
vector.y = String::fromString<int>( val, xySplit[1] ) ? val : defaultValue.y;
return vector;
}
}
return defaultValue;
}
Rect NodeAttribute::asRect( const Rect& defaultValue ) const {
if ( !mValue.empty() && mValue.find( " " ) != std::string::npos ) {
Rect rect( defaultValue );
@@ -200,7 +218,7 @@ Rect NodeAttribute::asRect( const Rect& defaultValue ) {
return defaultValue;
}
Rectf NodeAttribute::asRectf( const Rectf& defaultValue ) {
Rectf NodeAttribute::asRectf( const Rectf& defaultValue ) const {
if ( !mValue.empty() && mValue.find( " " ) != std::string::npos ) {
Rectf rect( defaultValue );
+2
View File
@@ -68,6 +68,8 @@ void StyleSheetSelector::parseSelector( const std::string& selector ) {
} else if ( selector[0] == '#' ) {
id = rselector.substr(1);
specificity += SpecificityId;
} else if ( selector[0] == '*' ) {
specificity += SpecificityGlobal;
} else {
tagName = rselector;
specificity += SpecificityTag;
+1 -3
View File
@@ -40,8 +40,6 @@ void UIStyle::load() {
addStyleSheetProperties( StateFlagSelectedHover, styleSheet.getElementProperties( mWidget, "selectedhover" ) );
addStyleSheetProperties( StateFlagSelectedPressed, styleSheet.getElementProperties( mWidget, "selectedpressed" ) );
addStyleSheetProperties( StateFlagDisabled, styleSheet.getElementProperties( mWidget, "disabled" ) );
onStateChange();
}
}
}
@@ -63,7 +61,7 @@ void UIStyle::onStateChange() {
for ( auto it = attrs.begin(); it != attrs.end(); ++it ) {
NodeAttribute& nodeAttr = it->second;
mWidget->setAttribute( nodeAttr );
mWidget->setAttribute( nodeAttr, mCurrentState );
}
}
}
+4
View File
@@ -329,4 +329,8 @@ UIFontStyleConfig UITheme::getFontStyleConfig() const {
return mFontStyleConfig;
}
Font *UITheme::getDefaultFont() const {
return mFontStyleConfig.Font;
}
}}
+5
View File
@@ -505,6 +505,11 @@ void UIWidget::onPaddingChange() {
invalidateDraw();
}
void UIWidget::onThemeLoaded() {
if ( NULL != mStyle )
mStyle->onStateChange();
}
void UIWidget::beginAttributesTransaction() {
mAttributesTransactionCount++;
}