add frame duplicate
This commit is contained in:
@@ -244,6 +244,11 @@ void Layer::remove_frame(int frame)
|
||||
m_frame_index = glm::clamp(m_frame_index, 0, (int)m_frames.size() - 1);
|
||||
}
|
||||
|
||||
void Layer::duplicate_frame(int frame)
|
||||
{
|
||||
m_frames.insert(m_frames.begin() + frame + 1, m_frames[frame].clone());
|
||||
}
|
||||
|
||||
int Layer::total_duration() const noexcept
|
||||
{
|
||||
int duration = 0;
|
||||
@@ -436,3 +441,18 @@ void LayerFrame::clear(const glm::vec4& c)
|
||||
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||
});
|
||||
}
|
||||
|
||||
LayerFrame LayerFrame::clone() const noexcept
|
||||
{
|
||||
LayerFrame dup;
|
||||
dup.m_duration = m_duration;
|
||||
dup.w = w;
|
||||
dup.h = h;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
dup.m_rtt[i] = m_rtt[i].clone();
|
||||
dup.m_dirty_box[i] = m_dirty_box[i];
|
||||
dup.m_dirty_face[i] = m_dirty_face[i];
|
||||
}
|
||||
return dup;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ struct LayerFrame
|
||||
bool create(int width, int height, int duration = 1);
|
||||
bool resize(int width, int height);
|
||||
void clear(const glm::vec4& c);
|
||||
LayerFrame clone() const noexcept;
|
||||
};
|
||||
|
||||
class Layer
|
||||
@@ -62,6 +63,7 @@ public:
|
||||
bool create(int width, int height, std::string name);
|
||||
bool add_frame();
|
||||
void remove_frame(int frame);
|
||||
void duplicate_frame(int frame);
|
||||
int total_duration() const noexcept;
|
||||
void goto_frame(int frame) noexcept;
|
||||
void clear(const glm::vec4& c, int frame = -1);
|
||||
|
||||
24
src/node.cpp
24
src/node.cpp
@@ -813,6 +813,30 @@ void Node::SetSize(glm::vec2 value)
|
||||
app_redraw();
|
||||
}
|
||||
|
||||
void Node::SetMinSize(float w, float h)
|
||||
{
|
||||
SetMinWidth(w);
|
||||
SetMinHeight(h);
|
||||
}
|
||||
|
||||
void Node::SetMinSize(glm::vec2 value)
|
||||
{
|
||||
SetMinWidth(value.x);
|
||||
SetMinHeight(value.y);
|
||||
}
|
||||
|
||||
void Node::SetMaxSize(float w, float h)
|
||||
{
|
||||
SetMaxWidth(w);
|
||||
SetMaxHeight(h);
|
||||
}
|
||||
|
||||
void Node::SetMaxSize(glm::vec2 value)
|
||||
{
|
||||
SetMaxWidth(value.x);
|
||||
SetMaxHeight(value.y);
|
||||
}
|
||||
|
||||
void Node::SetMaxWidth(float value)
|
||||
{
|
||||
YGNodeStyleSetMaxWidth(y_node, value);
|
||||
|
||||
@@ -156,6 +156,10 @@ public:
|
||||
void SetHeightP(float value);
|
||||
void SetSize(glm::vec2 value);
|
||||
void SetSize(float w, float h);
|
||||
void SetMinSize(float w, float h);
|
||||
void SetMaxSize(float w, float h);
|
||||
void SetMinSize(glm::vec2 value);
|
||||
void SetMaxSize(glm::vec2 value);
|
||||
void SetMaxWidth(float value);
|
||||
void SetMaxWidthP(float value);
|
||||
void SetMaxHeight(float value);
|
||||
|
||||
@@ -45,6 +45,10 @@ void NodePanelAnimation::init_controls()
|
||||
Canvas::I->layer().add_frame();
|
||||
load_layers();
|
||||
};
|
||||
btn_duplicate->on_click = [this](Node*) {
|
||||
Canvas::I->layer().duplicate_frame(m_selected_frame_index);
|
||||
load_layers();
|
||||
};
|
||||
btn_remove->on_click = [this](Node*) {
|
||||
Canvas::I->layer_with_id(m_selected_frame_layer_id)->remove_frame(m_selected_frame_index);
|
||||
load_layers();
|
||||
|
||||
@@ -174,6 +174,14 @@ void RTT::copy(const RTT& source, const glm::vec4& rect)
|
||||
});
|
||||
}
|
||||
|
||||
RTT RTT::clone() const noexcept
|
||||
{
|
||||
RTT dup;
|
||||
dup.create(w, h);
|
||||
dup.copy(*this);
|
||||
return dup;
|
||||
}
|
||||
|
||||
bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format, bool depth_buffer /*= false*/)
|
||||
{
|
||||
GLenum status = 0;
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
void copy(const RTT& source);
|
||||
// copy a region
|
||||
void copy(const RTT& source, const glm::vec4& rect);
|
||||
RTT clone() const noexcept;
|
||||
bool resize(int width, int height);
|
||||
bool create(int width, int height, int tex = -1, GLint internal_format = GL_RGBA8, bool depth_buffer = false);
|
||||
bool recreate() { return create(w, h); }
|
||||
|
||||
Reference in New Issue
Block a user