Added animations to file selector
This commit is contained in:
parent
4e17d6e40c
commit
2d039dc47b
10 changed files with 250 additions and 178 deletions
|
|
@ -11,59 +11,6 @@ void LayoutElement::layout(const Clay_ElementId& id, const std::function<void(La
|
|||
layout(this, id);
|
||||
}
|
||||
|
||||
void LayoutElement::update() {
|
||||
for(auto& [id, animation] : animations) {
|
||||
switch(animation.state) {
|
||||
case InternalFloatAnimation::State::RUN: {
|
||||
animation.currentTime += gui.io.deltaTime;
|
||||
if(animation.currentTime >= animation.anim.duration) {
|
||||
animation.currentTime = animation.anim.duration;
|
||||
animation.state = InternalFloatAnimation::State::DONE;
|
||||
}
|
||||
gui.set_to_layout();
|
||||
break;
|
||||
}
|
||||
case InternalFloatAnimation::State::RUN_REVERSE: {
|
||||
animation.currentTime -= gui.io.deltaTime;
|
||||
if(animation.currentTime <= 0.0f) {
|
||||
animation.currentTime = 0.0f;
|
||||
animation.state = InternalFloatAnimation::State::DONE;
|
||||
}
|
||||
gui.set_to_layout();
|
||||
break;
|
||||
}
|
||||
case InternalFloatAnimation::State::DONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float LayoutElement::get_float_animation(const char* animationID, const FloatAnimation& animation) {
|
||||
InternalFloatAnimation internalAnim;
|
||||
internalAnim.anim = animation;
|
||||
auto [it, placed] = animations.emplace(animationID, internalAnim);
|
||||
const InternalFloatAnimation& actualInternalAnim = it->second;
|
||||
return std::lerp(actualInternalAnim.anim.startVal, actualInternalAnim.anim.endVal, actualInternalAnim.anim.easing(it->second.currentTime / actualInternalAnim.anim.duration));
|
||||
}
|
||||
|
||||
void LayoutElement::animation_trigger(const char* animationID) {
|
||||
auto it = animations.find(animationID);
|
||||
if(it != animations.end()) {
|
||||
InternalFloatAnimation& animation = it->second;
|
||||
if(animation.currentTime < animation.anim.duration)
|
||||
animation.state = InternalFloatAnimation::State::RUN;
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutElement::animation_trigger_reverse(const char* animationID) {
|
||||
auto it = animations.find(animationID);
|
||||
if(it != animations.end()) {
|
||||
InternalFloatAnimation& animation = it->second;
|
||||
if(animation.currentTime > 0.0f)
|
||||
animation.state = InternalFloatAnimation::State::RUN_REVERSE;
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutElement::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
||||
if(c.mouseButton) c.mouseButton(this, button);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue