diff --git a/src/LayerComposition.cpp b/src/LayerComposition.cpp index 4442e2e..d45105b 100644 --- a/src/LayerComposition.cpp +++ b/src/LayerComposition.cpp @@ -54,6 +54,14 @@ const ComboIdentifier & MsdfAtlasLayerCombo::getIdentifier() const { return identifier; } +const ofImage & MsdfAtlasLayerCombo::getAtlasImage(){ + return atlas->getAtlasImage(); +} + +string MsdfAtlasLayerCombo::getAtlasImagePath(){ + return atlas->getAtlasPath(); +} + void LayerComposition::setup(){ } @@ -66,6 +74,17 @@ void LayerComposition::update(){ LayerID LayerComposition::addLayer(const ComboIdentifier & identifier, const string & text, const std::vector & variations){ + auto props = Layer::Props(); + props.text = text; + props.fontPath = identifier.fontPath; + return addLayer(identifier, + props, + variations); +} + +LayerID LayerComposition::addLayer(const ComboIdentifier & identifier, + const Layer::Props & props, + const std::vector & variations){ string layerID = ""; if(atlasLayerCombos.count(identifier) <= 0){ switch(identifier.type){ @@ -81,9 +100,6 @@ LayerID LayerComposition::addLayer(const ComboIdentifier & identifier, auto combo = make_shared (); combo->setup(identifier); // TODO: add here text and variations auto layer = make_shared (); - auto props = Layer::Props(); - props.text = text; - props.fontPath = identifier.fontPath; layer->setProps(props); layer->setup(); std::vector msdfVariations; @@ -107,10 +123,26 @@ shared_ptr LayerComposition::getLayer(const LayerID & layerID){ return layers[layerID]; } +const ofImage & LayerComposition::getAtlasImage(const ComboIdentifier & identifier){ + return atlasLayerCombos[identifier]->getAtlasImage(); +} + void LayerComposition::draw() const { for(const auto & layer_it : layers){ layer_it.second->draw(glm::vec3(0, 0, 0)); } } +const std::vector LayerComposition::getAvailableComboIdentifiers() const { + std::vector combos; + for(const auto & combo : atlasLayerCombos){ + combos.push_back(combo.first); + } + return combos; +} + +const unordered_map > & LayerComposition::getAtlasLayerCombos() const { + return atlasLayerCombos; +} + } diff --git a/src/LayerComposition.h b/src/LayerComposition.h index cdd003b..fa7ddb3 100644 --- a/src/LayerComposition.h +++ b/src/LayerComposition.h @@ -27,6 +27,8 @@ class AtlasLayerCombo { virtual void update() = 0; virtual void careForChild(shared_ptr layer) = 0; virtual const ComboIdentifier & getIdentifier() const = 0; + virtual const ofImage & getAtlasImage() = 0; + virtual string getAtlasImagePath() = 0; bool operator==(const AtlasLayerCombo & other) const { return (this->getIdentifier() == other.getIdentifier()); @@ -70,6 +72,8 @@ class MsdfAtlasLayerCombo : public AtlasLayerCombo { void update() override; void careForChild(shared_ptr layer) override; const ComboIdentifier & getIdentifier() const override; + const ofImage & getAtlasImage() override; + string getAtlasImagePath() override; shared_ptr getLayer(); shared_ptr atlas; @@ -86,10 +90,17 @@ class LayerComposition { void setup(); void update(); void draw() const; + const ofImage & getAtlasImage(const ComboIdentifier & identifier); LayerID addLayer(const ComboIdentifier & identifier, const string & text, const std::vector & variations); + LayerID addLayer(const ComboIdentifier & identifier, + const Layer::Props & props, + const std::vector & variations); shared_ptr getLayer(const LayerID & layerID); + const std::vector getAvailableComboIdentifiers() const; + const unordered_map > & getAtlasLayerCombos() const; + private: