mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Fixed compilation warning
This commit is contained in:
3
Editor/Source/Editor/Misc/AnimatedValue.cpp
Normal file
3
Editor/Source/Editor/Misc/AnimatedValue.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "AnimatedValue.h"
|
||||
|
||||
std::vector<IAnimatedValue*> IAnimatedValue::Instances;
|
||||
62
Editor/Source/Editor/Misc/AnimatedValue.h
Normal file
62
Editor/Source/Editor/Misc/AnimatedValue.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
#include <Nuake/Core/Maths.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class IAnimatedValue
|
||||
{
|
||||
public:
|
||||
static std::vector<IAnimatedValue*> Instances;
|
||||
|
||||
static void UpdateAll (float ts)
|
||||
{
|
||||
for (auto& instance : Instances)
|
||||
{
|
||||
instance->Update(ts);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Update(float ts) = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class AnimatedValue : public IAnimatedValue
|
||||
{
|
||||
public:
|
||||
T Value;
|
||||
T TargetValue;
|
||||
float Speed = 20.0f;
|
||||
AnimatedValue(T value = T(), T targetValue = T())
|
||||
: Value(value), TargetValue(targetValue)
|
||||
{
|
||||
IAnimatedValue::Instances.push_back(this);
|
||||
}
|
||||
|
||||
~AnimatedValue()
|
||||
{
|
||||
auto it = std::remove(Instances.begin(), Instances.end(), this);
|
||||
IAnimatedValue::Instances.erase(it, Instances.end());
|
||||
}
|
||||
|
||||
virtual void Update(float ts) override
|
||||
{
|
||||
Value = glm::mix(Value, TargetValue, glm::clamp(Speed * ts, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
void SetValue(T value)
|
||||
{
|
||||
Value = value;
|
||||
TargetValue = value;
|
||||
}
|
||||
|
||||
operator T() const
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
|
||||
AnimatedValue<T>& operator =(T value)
|
||||
{
|
||||
TargetValue = value;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
#include "../Events/EditorRequests.h"
|
||||
#include "../../../../Nuake/Thirdparty/glfw/include/GLFW/glfw3.h"
|
||||
#include "../../../AnimatedValue.h"
|
||||
#include "../misc/AnimatedValue.h"
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "IEditorWidget.h"
|
||||
|
||||
#include "../../../../../AnimatedValue.h"
|
||||
#include "../../../misc/AnimatedValue.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "IEditorWidget.h"
|
||||
#include "../../EditorSelectionPanel.h"
|
||||
|
||||
#include "../../../../../AnimatedValue.h"
|
||||
#include "../../../misc/AnimatedValue.h"
|
||||
|
||||
class EditorContext;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "IEditorWidget.h"
|
||||
|
||||
#include <imgui/ImGuizmo.h>
|
||||
#include "../../../../../AnimatedValue.h"
|
||||
#include "../../../misc/AnimatedValue.h"
|
||||
|
||||
class EditorContext;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user