diff --git a/Nuake/src/UI/Font/FontLoader.h b/Nuake/src/UI/Font/FontLoader.h index 43060f60..f4132c72 100644 --- a/Nuake/src/UI/Font/FontLoader.h +++ b/Nuake/src/UI/Font/FontLoader.h @@ -29,7 +29,7 @@ namespace NuakeUI msdf_atlas::GeneratorAttributes generatorAttributes; bool preprocessGeometry; bool kerning; - int threadCount = 1; + int threadCount = 2; }; diff --git a/Nuake/src/UI/Nodes/Node.h b/Nuake/src/UI/Nodes/Node.h index d3d85ee9..7dccccff 100644 --- a/Nuake/src/UI/Nodes/Node.h +++ b/Nuake/src/UI/Nodes/Node.h @@ -125,6 +125,8 @@ namespace NuakeUI Vector2 ComputedPosition = { 0, 0 }; int32_t ComputedZIndex = 0; NodeStyle ComputedStyle; + NodeStyle TargetStyle; + static NodePtr New(const std::string id, const std::string& value = ""); Node(const std::string& id, const std::string& value = ""); diff --git a/Nuake/src/UI/Nodes/Text.cpp b/Nuake/src/UI/Nodes/Text.cpp index 825f6a0d..bab3b67f 100644 --- a/Nuake/src/UI/Nodes/Text.cpp +++ b/Nuake/src/UI/Nodes/Text.cpp @@ -130,8 +130,8 @@ namespace NuakeUI // Iterate over each character and add up the advance. for (char const& c : l) { - Char letter = mFont->GetChar((int)c); - textWidth += (letter.Advance); + Char letter = ComputedStyle.FontFamily->GetChar((int)c); + textWidth += (letter.Advance * fontSize); } if (textWidth > maxWidth) @@ -139,7 +139,7 @@ namespace NuakeUI } // Scale the width by the font size. - return maxWidth * fontSize; + return maxWidth; } void Text::Calculate() diff --git a/Nuake/src/UI/Styles/StyleSheet.h b/Nuake/src/UI/Styles/StyleSheet.h index bd80c59b..2a03a9c8 100644 --- a/Nuake/src/UI/Styles/StyleSheet.h +++ b/Nuake/src/UI/Styles/StyleSheet.h @@ -55,6 +55,9 @@ namespace NuakeUI Value value; std::string string; + Value targetValue; + float transitionTime = 0.2f; + PropValue() { @@ -64,20 +67,35 @@ namespace NuakeUI { type = t; value.Number = f; + targetValue.Number = f; } PropValue(int i) { type = PropValueType::Enum; value.Enum = i; + targetValue.Enum = i; } PropValue(Color c) { type = PropValueType::Color; value.Color = c; + targetValue.Color = c; } + Value GetInterpolatedValue(float t) + { + Value resultValue = value; + switch (type) { + case PropValueType::Percent: + case PropValueType::Pixel: + resultValue.Number = glm::mix(resultValue.Number, targetValue.Number, t); + break; + } + + return resultValue; + } };