From 957768cf611d9e41239cc3420ff51c4f2df09d39 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Tue, 11 Apr 2023 13:17:30 +0200 Subject: [PATCH] settable vFlip --- src/Layer.h | 1 + src/LayerComposition.cpp | 8 ++++++++ src/LayerComposition.h | 4 ++-- src/MsdfLayer.cpp | 3 +++ src/MsdfLayer.h | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Layer.h b/src/Layer.h index 7f6c269..6341445 100644 --- a/src/Layer.h +++ b/src/Layer.h @@ -57,6 +57,7 @@ class Layer { virtual void setShader(shared_ptr _shader) = 0; virtual shared_ptr getShader() const = 0; virtual const Type & getType() const = 0; + virtual void setVFlip(const VFlipState vFlip) = 0; static int n_layers; }; } diff --git a/src/LayerComposition.cpp b/src/LayerComposition.cpp index da2846f..c957e82 100644 --- a/src/LayerComposition.cpp +++ b/src/LayerComposition.cpp @@ -100,6 +100,7 @@ LayerID LayerComposition::addLayer(const ComboIdentifier & identifier, auto combo = make_shared (); combo->setup(identifier); // TODO: add here text and variations auto layer = make_shared (); + layer->vFlip = vFlipState; layer->setProps(props); layer->setup(); std::vector msdfVariations; @@ -145,4 +146,11 @@ const unordered_map > & LayerComp return atlasLayerCombos; } +void LayerComposition::setVFlip(bool vFlip){ + vFlipState = vFlip ? V_FLIP_ON : V_FLIP_OFF; + for(auto & layer : layers){ + layer.second->setVFlip(vFlipState); + } +} + } diff --git a/src/LayerComposition.h b/src/LayerComposition.h index fa7ddb3..127a61f 100644 --- a/src/LayerComposition.h +++ b/src/LayerComposition.h @@ -100,10 +100,10 @@ class LayerComposition { shared_ptr getLayer(const LayerID & layerID); const std::vector getAvailableComboIdentifiers() const; const unordered_map > & getAtlasLayerCombos() const; - + void setVFlip(bool vFlip); private: - + VFlipState vFlipState = V_FLIP_UNKNOWN; unordered_map > layers; unordered_map > atlasLayerCombos; //unordered_map > layers; diff --git a/src/MsdfLayer.cpp b/src/MsdfLayer.cpp index 643fbaf..4ba1966 100644 --- a/src/MsdfLayer.cpp +++ b/src/MsdfLayer.cpp @@ -273,6 +273,9 @@ shared_ptr MsdfLayer::getShader() const { const Layer::Type & MsdfLayer::getType() const { return type; } +void MsdfLayer::setVFlip(const VFlipState vFlip){ + this->vFlip = vFlip; +} void MsdfLayer::setAtlas(shared_ptr _atlas){ atlas = _atlas; diff --git a/src/MsdfLayer.h b/src/MsdfLayer.h index d4216f6..4fc72a7 100644 --- a/src/MsdfLayer.h +++ b/src/MsdfLayer.h @@ -27,6 +27,7 @@ class MsdfLayer : public Layer { void setShader(shared_ptr _shader) override; shared_ptr getShader() const override; const Type & getType() const override; + void setVFlip(const VFlipState vFlip) override; void setAtlas(shared_ptr _atlas); shared_ptr getAtlas() const;