Switching SceneItems to smarts

This commit is contained in:
2023-11-12 23:02:11 -06:00
parent 91a91a5404
commit 54da3733d7
124 changed files with 188 additions and 216 deletions

View File

@ -0,0 +1,51 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "SimpleAnimation.hpp"
namespace Dawn {
template<typename T, class I>
struct SimpleCallbackAnimation : public SimpleAnimation<T> {
protected:
I *instance;
void (I::*callback)(T arg);
T value;
/**
* Internally invoke the function that this animation is owning.
*/
void invoke() {
assertNotNull(this->instance);
((*this->instance).*(this->callback))(this->value);
}
void onValueModified() override {
SimpleAnimation<T>::onValueModified();
this->invoke();
}
public:
/**
* Construct a new Simple Function Animation object
*/
SimpleCallbackAnimation() :
SimpleAnimation<T>(&value)
{
}
/**
* Sets the callback for the animation to use.
*
* @param instance Instance of the object that has the callback.
* @param callback Callback method to be invoked.
*/
void setCallback(I *instance, void (I::*callback)(T arg)) {
assertNotNull(instance);
this->instance = instance;
this->callback = callback;
}
};
}