diff --git a/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.cpp b/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.cpp index 161223a6..e829c954 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.cpp @@ -13,10 +13,6 @@ of DigiPen Institute of Technology is prohibited. #include "SHpch.h" // Primary Header #include "SHAnimationEditor.h" -// External Dependencies -#include -#include "Editor/IconsMaterialDesign.h" -#include "Editor/SHEditorUI.h" namespace SHADE { @@ -165,17 +161,19 @@ namespace SHADE { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::Text(channel.Name.c_str()); + const bool SHOW_ALL = ImGui::CollapsingHeader(channel.Name.c_str(), ImGuiTreeNodeFlags_DefaultOpen); ImGui::TableNextColumn(); - // Draw all the keyframes - const auto START_POS = ImGui::GetCursorPos(); - for (const auto& keyframe : channel.PositionKeyFrames) + if (SHOW_ALL) { - ImGui::SetCursorPos(ImVec2(START_POS.x + keyframe.FrameIndex * DIST_PER_FRAME, START_POS.y)); - SHEditorUI::OffsetText(ICON_MD_RADIO_BUTTON_CHECKED, 6.0f); // Hardcoded offset to align icon since ImGui can't calculate icon with properly + drawChannelKeyFrames("Position", channel.PositionKeyFrames); + drawChannelKeyFrames("Rotation", channel.RotationKeyFrames); + drawChannelKeyFrames("Scale", channel.ScaleKeyFrames); + } + else + { + // TODO: Show flattened view } - ImGui::SetCursorPos(START_POS); } ImGui::EndTable(); diff --git a/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.h b/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.h index ca2026da..529e9586 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.h +++ b/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.h @@ -36,9 +36,22 @@ namespace SHADE void Update() override; private: + /*---------------------------------------------------------------------------------*/ + /* Static Constants */ + /*---------------------------------------------------------------------------------*/ + static constexpr float DIST_PER_FRAME = 18.0f; + /*---------------------------------------------------------------------------------*/ /* Data Members */ /*---------------------------------------------------------------------------------*/ SHAnimationClip clip; + + /*---------------------------------------------------------------------------------*/ + /* Helper Functions */ + /*---------------------------------------------------------------------------------*/ + template + void drawChannelKeyFrames(const std::string& name, const std::vector>& keyframes); }; -} \ No newline at end of file +} + +#include "SHAnimationEditor.hpp" \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.hpp b/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.hpp new file mode 100644 index 00000000..255b68d5 --- /dev/null +++ b/SHADE_Engine/src/Editor/EditorWindow/AnimationEditor/SHAnimationEditor.hpp @@ -0,0 +1,47 @@ +/************************************************************************************//*! +\file SHAnimationEditor.hpp +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Jan 16, 2023 +\brief Contains the definition of the SHAnimationEditor function templates. + +Copyright (C) 2023 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +#pragma once +// Primary Include +#include "SHAnimationEditor.h" +// Project Include +#include "Editor/SHEditorUI.h" +// External Dependencies +#include +#include "Editor/IconsMaterialDesign.h" + +namespace SHADE +{ + template + void SHAnimationEditor::drawChannelKeyFrames(const std::string& name, const std::vector>& keyframes) + { + // Ignore if keyframes list is empty + if (keyframes.empty()) + return; + + // Title + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Indent(); + ImGui::Text(name.c_str()); + ImGui::Unindent(); + ImGui::TableNextColumn(); + + // Draw all the keyframes + const auto START_POS = ImGui::GetCursorPos(); + for (const auto& keyframe : keyframes) + { + ImGui::SetCursorPos(ImVec2(START_POS.x + keyframe.FrameIndex * DIST_PER_FRAME, START_POS.y)); + SHEditorUI::OffsetText(ICON_MD_RADIO_BUTTON_CHECKED, 6.0f); // Hardcoded offset to align icon since ImGui can't calculate icon with properly + } + ImGui::SetCursorPos(START_POS); + } +} \ No newline at end of file