mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 01:01:25 +03:00
CSS clean up.
--HG-- branch : dev
This commit is contained in:
@@ -20,6 +20,8 @@ class EE_API StyleSheetElement {
|
||||
virtual StyleSheetElement * getStyleSheetPreviousSiblingElement() const = 0;
|
||||
|
||||
virtual StyleSheetElement * getStyleSheetNextSiblingElement() const = 0;
|
||||
|
||||
virtual const std::vector<std::string>& getStyleSheetPseudoClasses() const = 0;
|
||||
};
|
||||
}}}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define EE_UI_CSS_STYLESHEETSELECTOR_HPP
|
||||
|
||||
#include <eepp/core.hpp>
|
||||
#include <eepp/ui/css/stylesheetselectorrule.hpp>
|
||||
|
||||
namespace EE { namespace UI { namespace CSS {
|
||||
|
||||
@@ -9,72 +10,6 @@ class StyleSheetElement;
|
||||
|
||||
class EE_API StyleSheetSelector {
|
||||
public:
|
||||
enum SelectorType {
|
||||
TagName = 1 << 0,
|
||||
Id = 1 << 1,
|
||||
Class = 1 << 2,
|
||||
PseudoClass = 1 << 3
|
||||
};
|
||||
|
||||
enum SpecificityVal {
|
||||
SpecificityId = 1000000,
|
||||
SpecificityClass = 100000,
|
||||
SpecificityTag = 10000,
|
||||
SpecificityPseudoClass = 100,
|
||||
SpecificityGlobal = 1
|
||||
};
|
||||
|
||||
enum PatternMatch {
|
||||
ANY = '*',
|
||||
DESCENDANT = ' ',
|
||||
CHILD = '>',
|
||||
DIRECT_SIBLING = '+',
|
||||
SIBLING = '~'
|
||||
};
|
||||
|
||||
enum SelectoryTypeIdentifier {
|
||||
TAG = 0,
|
||||
GLOBAL = '*',
|
||||
CLASS = '.',
|
||||
ID = '#',
|
||||
PSEUDO_CLASS = ':',
|
||||
STRUCTURAL_PSEUDO_CLASS = ':'
|
||||
};
|
||||
|
||||
class SelectorRule {
|
||||
public:
|
||||
SelectorRule( const std::string& selectorFragment, PatternMatch patternMatch );
|
||||
|
||||
void pushSelectorTypeIdentifier( SelectoryTypeIdentifier selectorTypeIdentifier, std::string name );
|
||||
|
||||
void parseFragment( const std::string& selectorFragment );
|
||||
|
||||
const PatternMatch& getPatternMatch() const { return patternMatch; }
|
||||
|
||||
const int& getSpecificity() const { return specificity; }
|
||||
|
||||
bool matches( StyleSheetElement * element ) const;
|
||||
|
||||
bool hasClass( const std::string& cls ) const;
|
||||
|
||||
bool hasPseudoClasses() const;
|
||||
|
||||
const std::vector<std::string>& getPseudoClasses() const;
|
||||
|
||||
bool hasStructuralPseudoClasses() const;
|
||||
|
||||
const std::vector<std::string>& getStructuralPseudoClasses() const;
|
||||
|
||||
int specificity;
|
||||
PatternMatch patternMatch;
|
||||
std::string tagName;
|
||||
std::string id;
|
||||
std::vector<std::string> classes;
|
||||
std::vector<std::string> pseudoClasses;
|
||||
std::vector<std::string> structuralPseudoClasses;
|
||||
Uint32 requirementFlags;
|
||||
};
|
||||
|
||||
StyleSheetSelector();
|
||||
|
||||
explicit StyleSheetSelector( const std::string& selectorName );
|
||||
@@ -86,13 +21,16 @@ class EE_API StyleSheetSelector {
|
||||
const Uint32& getSpecificity() const;
|
||||
|
||||
bool matches( StyleSheetElement * element ) const;
|
||||
|
||||
const bool& isCacheable() const;
|
||||
protected:
|
||||
std::string mName;
|
||||
std::string mPseudoClass;
|
||||
Uint32 mSpecificity;
|
||||
std::vector<SelectorRule> mSelectorRules;
|
||||
std::vector<StyleSheetSelectorRule> mSelectorRules;
|
||||
bool mCacheable;
|
||||
|
||||
void addSelectorRule(std::string& buffer, PatternMatch& curPatternMatch, const PatternMatch & newPatternMatch );
|
||||
void addSelectorRule(std::string& buffer, StyleSheetSelectorRule::PatternMatch& curPatternMatch, const StyleSheetSelectorRule::PatternMatch & newPatternMatch );
|
||||
|
||||
void parseSelector( std::string selector );
|
||||
};
|
||||
|
||||
82
include/eepp/ui/css/stylesheetselectorrule.hpp
Normal file
82
include/eepp/ui/css/stylesheetselectorrule.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef STYLESHEETSELECTORRULE_HPP
|
||||
#define STYLESHEETSELECTORRULE_HPP
|
||||
|
||||
#include <eepp/core.hpp>
|
||||
|
||||
namespace EE { namespace UI { namespace CSS {
|
||||
|
||||
class StyleSheetElement;
|
||||
|
||||
class StyleSheetSelectorRule {
|
||||
public:
|
||||
enum TypeIdentifier {
|
||||
TAG = 0,
|
||||
GLOBAL = '*',
|
||||
CLASS = '.',
|
||||
ID = '#',
|
||||
PSEUDO_CLASS = ':',
|
||||
STRUCTURAL_PSEUDO_CLASS = ':'
|
||||
};
|
||||
|
||||
enum SelectorType {
|
||||
TagName = 1 << 0,
|
||||
Id = 1 << 1,
|
||||
Class = 1 << 2,
|
||||
PseudoClass = 1 << 3
|
||||
};
|
||||
|
||||
enum SpecificityVal {
|
||||
SpecificityId = 1000000,
|
||||
SpecificityClass = 100000,
|
||||
SpecificityTag = 10000,
|
||||
SpecificityPseudoClass = 100,
|
||||
SpecificityGlobal = 1
|
||||
};
|
||||
|
||||
enum PatternMatch {
|
||||
ANY = '*',
|
||||
DESCENDANT = ' ',
|
||||
CHILD = '>',
|
||||
DIRECT_SIBLING = '+',
|
||||
SIBLING = '~'
|
||||
};
|
||||
|
||||
StyleSheetSelectorRule( const std::string& selectorFragment, PatternMatch mPatternMatch );
|
||||
|
||||
void pushSelectorTypeIdentifier( TypeIdentifier selectorTypeIdentifier, std::string name );
|
||||
|
||||
void parseFragment( const std::string& selectorFragment );
|
||||
|
||||
const PatternMatch& getPatternMatch() const { return mPatternMatch; }
|
||||
|
||||
const int& getSpecificity() const { return mSpecificity; }
|
||||
|
||||
bool matches( StyleSheetElement * element ) const;
|
||||
|
||||
bool hasClass( const std::string& cls ) const;
|
||||
|
||||
bool hasPseudoClasses() const;
|
||||
|
||||
bool hasPseudoClass(const std::string & cls) const;
|
||||
|
||||
const std::vector<std::string>& getPseudoClasses() const;
|
||||
|
||||
bool hasStructuralPseudoClasses() const;
|
||||
|
||||
const std::vector<std::string>& getStructuralPseudoClasses() const;
|
||||
|
||||
bool hasStructuralPseudoClass(const std::string & cls) const;
|
||||
|
||||
int mSpecificity;
|
||||
PatternMatch mPatternMatch;
|
||||
std::string mTagName;
|
||||
std::string mId;
|
||||
std::vector<std::string> mClasses;
|
||||
std::vector<std::string> mPseudoClasses;
|
||||
std::vector<std::string> mStructuralPseudoClasses;
|
||||
Uint32 mRequirementFlags;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -112,6 +112,8 @@ class EE_API UIWidget : public UINode, public CSS::StyleSheetElement {
|
||||
|
||||
StyleSheetElement * getStyleSheetNextSiblingElement() const;
|
||||
|
||||
const std::vector<std::string>& getStyleSheetPseudoClasses() const;
|
||||
|
||||
void addClass( const std::string& cls );
|
||||
|
||||
void addClasses( const std::vector<std::string>& classes );
|
||||
@@ -161,9 +163,12 @@ class EE_API UIWidget : public UINode, public CSS::StyleSheetElement {
|
||||
int mAttributesTransactionCount;
|
||||
std::string mSkinName;
|
||||
std::vector<std::string> mClasses;
|
||||
std::vector<std::string> mPseudoClasses;
|
||||
|
||||
explicit UIWidget( const std::string& tag );
|
||||
|
||||
void updatePseudoClasses();
|
||||
|
||||
void createTooltip();
|
||||
|
||||
virtual Uint32 onMouseMove( const Vector2i& Pos, const Uint32& Flags );
|
||||
|
||||
Reference in New Issue
Block a user