add move frame buttons

This commit is contained in:
2019-11-10 14:54:20 +01:00
parent 35937ad4c6
commit 802bce7383
5 changed files with 48 additions and 5 deletions

View File

@@ -228,10 +228,11 @@ bool Layer::create(int width, int height, std::string name)
return true;
}
bool Layer::add_frame()
bool Layer::add_frame(int index /*= -1*/)
{
m_frames.emplace_back();
m_frames.back().create(w, h);
auto pos = index == -1 ? m_frames.end() : m_frames.begin() + index;
auto it = m_frames.emplace(pos);
it->create(w, h);
frames_gpu_update();
return true;
}
@@ -267,6 +268,21 @@ void Layer::frames_gpu_update()
});
}
int Layer::move_frame_offset(int frame, int offset) noexcept
{
int new_pos = glm::clamp(frame + offset, 0, (int)m_frames.size() - 1);
auto from = m_frames.begin() + frame;
auto to = m_frames.begin() + new_pos;
if (new_pos < frame)
std::rotate(to, from, from + 1);
if (new_pos > frame)
std::rotate(from, from + 1, to + 1);
frames_gpu_update();
return new_pos;
}
int Layer::total_duration() const noexcept
{
int duration = 0;