Exemple #1
0
void CompositeChar::addToComponents (Components &components, HorMetric &hm, UShort totalAdvance) {
    // Current "pen" position is hm.advanceWidth
    ComponentPtr c;
    GlyphPtr glyph = font.getGlyph (glyphId);
    if (!glyph->isEmpty()) {
        CompositeComponent::Flags flags;
        if (totalAdvance && totalAdvance == advance && position.x == 0) {
            flags = CompositeComponent::Flags (
                        CompositeComponent::cfRoundXYToGrid | CompositeComponent::cfUseMyMetrics);
        } else
            flags = CompositeComponent::cfRoundXYToGrid;

        CompositeComponent::Scale scale;// = {0x4000, 0, 0, 0x4000};
        scale.xx = scale.yy = 1;
        scale.xy = scale.yx = 0;
        if (thisAttachPoint == 0xFFFF) {
            CompositeComponent::Translation translation = {hm.advanceWidth -
                                                           glyph->getDisplacement() + position.x, position.y
                                                          };
            c = new PositionedCompositeComponent (font, glyphId, flags,
                                                  scale, translation);
        } else {
            c = new AttachedCompositeComponent (font, glyphId, flags,
                                                scale, baseAttachPoint, thisAttachPoint);
        }
        components.push_back (c);
    }
    hm.advanceWidth += advance;
}
poison::Components poison::DefaultEntityManager::getComponentsForEntity(Entity* entity) {
    ComponentsIndex::index<Component::byEntityIdTag>::type::iterator first, last;
    boost::tuples::tie(first, last) = componentsContainer_.get<Component::byEntityIdTag>().equal_range(entity->getId());
    Components components;
    
    if (first != componentsContainer_.get<Component::byEntityIdTag>().end()) {
        
        auto size = std::distance(first, last);
        components.reserve(size);
        for (auto it = first; it != last; ++it) {
            components.push_back( (*it).get() );
        }
    }
    
    return components;
}
 void add(Component::Ptr component){childs_.push_back(component);}