mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-27 16:38:20 +03:00
CSS Fixes.
--HG-- branch : dev
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -55,6 +55,8 @@ class EE_API UITheme : protected ResourceManager<UISkin> {
|
||||
|
||||
UIFontStyleConfig getFontStyleConfig() const;
|
||||
|
||||
Font * getDefaultFont() const;
|
||||
|
||||
void setFontStyleConfig(UIFontStyleConfig fontConfig);
|
||||
|
||||
virtual UITabWidgetStyleConfig getTabWidgetStyleConfig();
|
||||
|
||||
@@ -162,6 +162,8 @@ class EE_API UIWidget : public UINode, public CSS::StyleSheetElement {
|
||||
|
||||
virtual void onPaddingChange();
|
||||
|
||||
virtual void onThemeLoaded();
|
||||
|
||||
void beginAttributesTransaction();
|
||||
|
||||
void endAttributesTransaction();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,4 +329,8 @@ UIFontStyleConfig UITheme::getFontStyleConfig() const {
|
||||
return mFontStyleConfig;
|
||||
}
|
||||
|
||||
Font *UITheme::getDefaultFont() const {
|
||||
return mFontStyleConfig.Font;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -505,6 +505,11 @@ void UIWidget::onPaddingChange() {
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
void UIWidget::onThemeLoaded() {
|
||||
if ( NULL != mStyle )
|
||||
mStyle->onStateChange();
|
||||
}
|
||||
|
||||
void UIWidget::beginAttributesTransaction() {
|
||||
mAttributesTransactionCount++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user