コード例 #1
0
ファイル: AXRController.cpp プロジェクト: lumirayz/Prototype
std::vector< std::vector<HSSDisplayObject::p> > AXRController::selectHierarchical(const std::vector<HSSDisplayObject::p> & scope, HSSDisplayObject::p thisObj, bool negating, bool processing)
{
    std::vector< std::vector<HSSDisplayObject::p> > selections = this->selectOnLevel(scope, thisObj, negating, processing);
    unsigned i, size;
    for (i=0, size=selections.size(); i<size; i++) {
        std::vector<HSSDisplayObject::p> selection = selections[i];
        if(selection.size() > 0){
            if(!this->isAtEndOfSelector()){
                if(this->currentSelectorNode->isA(HSSParserNodeTypeCombinator)){
                    HSSCombinator::p combinator = boost::static_pointer_cast<HSSCombinator>(this->currentSelectorNode);
                    HSSCombinatorType combinatorType = combinator->getCombinatorType();
                    switch (combinatorType) {
                        case HSSCombinatorTypeChildren:
                        {
                            std::vector<HSSDisplayObject::p> newScope;
                            unsigned j, size2, k, size3;
                            for(j=0, size2 = selection.size(); j<size2; j++){
                                if(selection[j]->isA(HSSObjectTypeContainer)){
                                    HSSContainer::p theContainer = boost::static_pointer_cast<HSSContainer>(selection[j]);
                                    const std::vector<HSSDisplayObject::p> children = theContainer->getChildren();
                                    for(k=0, size3 = children.size(); k<size3; k++){
                                        newScope.push_back(children[k]);
                                    }
                                }
                            }
                            this->readNextSelectorNode();
                            return this->selectHierarchical(newScope, thisObj, false, processing);
                            break;
                        }
                            
                        case HSSCombinatorTypeDescendants:
                        {
                            std::vector<HSSDisplayObject::p> newScope;
                            unsigned j, size2, k, size3;
                            for(j=0, size2 = selection.size(); j<size2; j++){
                                if(selection[j]->isA(HSSObjectTypeContainer)){
                                    HSSContainer::p theContainer = boost::static_pointer_cast<HSSContainer>(selection[j]);
                                    const std::vector<HSSDisplayObject::p> children = theContainer->getChildren();
                                    for(k=0, size3 = children.size(); k<size3; k++){
                                        newScope.push_back(children[k]);
                                    }
                                }
                            }
                            
                            this->readNextSelectorNode();
                            return this->selectAllHierarchical(newScope, thisObj, false, processing);
                            break;
                        }
                            
                        default:
                            break;
                    }
                }
            }
        }
    }
    
    return selections;
}
コード例 #2
0
const std::vector<HSSDisplayObject::p> AXRController::selectOnLevel(const std::vector<HSSDisplayObject::p> & scope)
{
    std::vector<HSSDisplayObject::p> left = this->selectSimple(scope);
    //only continue if it actually found anything
    if(left.size() > 0){
        if(this->readNextSelectorNode()){
            std::vector<HSSDisplayObject::p> ret;
            if(this->currentSelectorNode->isA(HSSParserNodeTypeCombinator))
            {
                HSSCombinator::p combinator = boost::static_pointer_cast<HSSCombinator>(this->currentSelectorNode);
                HSSCombinatorType combinatorType = combinator->getCombinatorType();
                switch (combinatorType) {
                    case HSSCombinatorTypeSiblings:
                    {
                        //if found, just select the right part
                        this->readNextSelectorNode();
                        ret = this->selectSimple(scope);
                        break;
                    }
                        
                    case HSSCombinatorTypeNextSiblings:
                    {
                        //find the selected ones on the left, and select all the following ones that match
                        std::vector<HSSDisplayObject::p> vect(scope);
                        std::vector<HSSDisplayObject::p>::iterator it;
                        it = std::find(vect.begin(), vect.end(), left.front());
                        std::vector<HSSDisplayObject::p> right(it+1, vect.end());
                        this->readNextSelectorNode();
                        ret = this->selectSimple(right);
                        break;
                    }
                        
                    case HSSCombinatorTypePreviousSiblings:
                    {
                        //find the selected ones on the left, and select all the previous ones that match
                        std::vector<HSSDisplayObject::p> vect(scope);
                        std::vector<HSSDisplayObject::p>::iterator it;
                        it = std::find(vect.begin(), vect.end(), left.back());
                        std::vector<HSSDisplayObject::p> right(vect.begin(), it);
                        this->readNextSelectorNode();
                        ret = this->selectSimple(right);
                        break;
                    }
                        
                    default:
                        break;
                }
            }
            
            return ret;
        }
        
    }
    return left;
}
コード例 #3
0
ファイル: AXRController.cpp プロジェクト: lumirayz/Prototype
std::vector< std::vector<HSSDisplayObject::p> > AXRController::selectOnLevel(const std::vector<HSSDisplayObject::p> & scope, HSSDisplayObject::p thisObj, bool negating, bool processing)
{
    std::vector< std::vector<HSSDisplayObject::p> > selections = this->selectSimple(scope, thisObj, negating, processing);
    bool atEnd = this->isAtEndOfSelector();
    if(!atEnd){
        if(this->currentSelectorNode->isA(HSSParserNodeTypeCombinator))
        {
            std::vector< std::vector<HSSDisplayObject::p> > ret;
            HSSCombinator::p combinator = boost::static_pointer_cast<HSSCombinator>(this->currentSelectorNode);
            HSSCombinatorType combinatorType = combinator->getCombinatorType();
            switch (combinatorType) {
                case HSSCombinatorTypeSiblings:
                {
                    //if found, just select the right part
                    this->readNextSelectorNode();
                    unsigned i, size;
                    for (i=0, size=selections.size(); i<size; i++) {
                        std::vector<HSSDisplayObject::p> selection = selections[i];
                        std::vector< std::vector<HSSDisplayObject::p> > newSelection = this->selectSimple(scope, thisObj, negating, processing);
                        ret.insert(ret.end(), newSelection.begin(), newSelection.end());
                    }
                    return ret;
                }
                    
                case HSSCombinatorTypeNextSiblings:
                {
                    //find the selected ones on the right, and select all the following ones that match
                    unsigned i, size;
                    for (i=0, size=selections.size(); i<size; i++) {
                        std::vector<HSSDisplayObject::p> selection = selections[i];
                        std::vector<HSSDisplayObject::p> vect(scope);
                        if(selection.size() > 0){
                            std::vector<HSSDisplayObject::p>::iterator it;
                            it = std::find(vect.begin(), vect.end(), selection.front());
                            std::vector<HSSDisplayObject::p> right(it+1, vect.end());
                            this->readNextSelectorNode();
                            std::vector< std::vector<HSSDisplayObject::p> > newSelection = this->selectSimple(right, thisObj, negating, processing);
                            ret.insert(ret.end(), newSelection.begin(), newSelection.end());
                        }
                    }
                    return ret;
                }
                    
                case HSSCombinatorTypePreviousSiblings:
                {
                    //find the selected ones on the left, and select all the previous ones that match
                    this->readNextSelectorNode();
                    unsigned i, size;
                    for (i=0, size=selections.size(); i<size; i++) {
                        std::vector<HSSDisplayObject::p> selection = selections[i];
                        if(selection.size() > 0){
                            std::vector<HSSDisplayObject::p> vect(scope);
                            std::vector<HSSDisplayObject::p>::iterator it;
                            it = std::find(vect.begin(), vect.end(), selection.back());
                            std::vector<HSSDisplayObject::p> right(vect.begin(), it);
                            this->readNextSelectorNode();
                            std::vector< std::vector<HSSDisplayObject::p> > newSelection = this->selectSimple(right, thisObj, negating, processing);
                            ret.insert(ret.end(), newSelection.begin(), newSelection.end());
                        }
                        
                    }
                    return ret;
                }
                    
                default:
                    break;
            }
        }  
    }
    
    return selections;
}