Added animations to file selector

This commit is contained in:
Yousef Khadadeh 2026-04-24 11:07:15 +03:00
parent 4e17d6e40c
commit 2d039dc47b
10 changed files with 250 additions and 178 deletions

View file

@ -506,6 +506,19 @@ void GUIManager::update_invalidated_draw_area_from_layout() {
void GUIManager::update() {
for(ElementContainer* e : orderedElements)
e->elem->update();
for(auto& [id, animation] : animations)
animation.update(*this);
}
GUIFloatAnimation* GUIManager::float_animation(const char* animationID, const GUIFloatAnimationData& animation) {
GUIFloatAnimation* toRet = nullptr;
new_id(animationID, [&] {
auto [it, placed] = animations.emplace(idStack, animation);
GUIFloatAnimation& actualInternalAnim = it->second;
actualInternalAnim.isUsedThisFrame = true;
toRet = &actualInternalAnim;
});
return toRet;
}
void GUIManager::update_window(const Vector2f& windowPos, const Vector2f& windowSize, float guiScaleMultiplier) {
@ -539,6 +552,8 @@ void GUIManager::layout() {
void GUIManager::layout_begin() {
for(auto& [id, e] : elements)
e.isUsedThisFrame = false;
for(auto& [id, a] : animations)
a.isUsedThisFrame = false;
Clay_SetLayoutDimensions(Clay_Dimensions(io.windowSize.x(), io.windowSize.y()));
Clay_SetCurrentContext(clayInstance);
@ -557,6 +572,9 @@ void GUIManager::layout_end() {
std::erase_if(elements, [](auto& p) {
return !p.second.isUsedThisFrame;
});
std::erase_if(animations, [](auto& p) {
return !p.second.isUsedThisFrame;
});
std::stable_sort(orderedElements.begin(), orderedElements.end(), [](ElementContainer* a, ElementContainer* b) {
return b->elem->zIndex < a->elem->zIndex; // Order from highest to lowest zIndex
});