implement animation panel interaction

This commit is contained in:
2019-10-17 20:42:52 +02:00
parent 62863e7224
commit 7487feb168
14 changed files with 399 additions and 16 deletions

View File

@@ -227,8 +227,23 @@ bool Layer::create(int width, int height, std::string name)
bool Layer::add_frame()
{
m_frames.emplace_back();
m_frame_index = m_frames.size() - 1;
return frame().create(w, h);
return m_frames.back().create(w, h);
}
int Layer::total_duration() const noexcept
{
int duration = 0;
for (auto& f : m_frames)
duration += f.m_duration;
return duration;
}
void Layer::goto_frame(int frame) noexcept
{
int i = 0;
for (i = 0; i < m_frames.size() && frame >= 0; i++)
frame -= m_frames[i].m_duration;
m_frame_index = i - 1;
}
void Layer::resize(int width, int height)