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

@@ -1,12 +1,98 @@
#include "node_border.h"
#pragma once
class NodePanelAnimation : public NodeBorder
#include "node_border.h"
#include "node_scroll.h"
#include "node_text.h"
#include "node_checkbox.h"
#include "node_button_custom.h"
class NodeAnimationFrame : public NodeButtonCustom
{
public:
using this_class = NodePanelAnimation;
std::function<void(NodeAnimationFrame* target)> on_selected;
using this_class = NodeAnimationFrame;
using parent = NodeButtonCustom;
virtual Node* clone_instantiate() const override { return new this_class; }
};
//////////////////////////////////////////////////////////////////////////
class NodeAnimationTimeline : public NodeBorder
{
bool m_dragging = false;
glm::vec2 m_drag_start_pos = { 0, 0 };
int m_drag_start_frame = 0;
public:
using this_class = NodeAnimationTimeline;
using parent = NodeBorder;
std::function<void(NodeAnimationTimeline* target, int frame)> on_frame_changed;
int m_frames_count = 1;
int m_frame = 0;
glm::vec4 m_cursor_color = { 1, 0, 0, 1 };
virtual Node* clone_instantiate() const override { return new this_class; }
virtual void draw() override;
virtual kEventResult handle_event(Event* e) override;
};
//////////////////////////////////////////////////////////////////////////
class NodePanelAnimation : public Node
{
NodeButtonCustom* btn_add = nullptr;
NodeButtonCustom* btn_remove = nullptr;
NodeButtonCustom* btn_up = nullptr;
NodeButtonCustom* btn_down = nullptr;
NodeButtonCustom* btn_duplicate = nullptr;
NodeScroll* m_container = nullptr;
NodeAnimationFrame* m_selected_frame = nullptr;
NodeAnimationTimeline* m_timeline = nullptr;
int m_selected_frame_index = -1;
uint32_t m_selected_frame_layer_id = 0;
public:
using this_class = NodePanelAnimation;
using parent = Node;
virtual Node* clone_instantiate() const override;
virtual void clone_finalize(Node* dest) const override;
virtual void init() override;
virtual void added(Node* parent) override;
void init_controls();
void load_layers();
};
//////////////////////////////////////////////////////////////////////////
class NodeAnimationLayer : public NodeBorder
{
bool m_selected = false;
glm::vec4 m_color_normal = glm::vec4(.4, .4, .4, 1);
glm::vec4 m_color_selected = glm::vec4(.3, .3, .3, 1);
glm::vec4 m_color_hover = glm::vec4(.5, .5, .5, 1);
NodeText* m_label = nullptr;
NodeCheckBox* m_visibility = nullptr;
NodeScroll* m_container = nullptr;
public:
std::function<void(NodeAnimationLayer* target)> on_selected;
std::function<void(NodeAnimationLayer* target, bool visible)> on_visibility_changed;
std::function<void(NodeAnimationLayer* target, bool highlight)> on_highlight;
using this_class = NodeAnimationLayer;
using parent = NodeBorder;
virtual Node* clone_instantiate() const override;
virtual void clone_finalize(Node* dest) const override;
virtual void init() override;
virtual void draw() override;
void init_controls();
std::shared_ptr<NodeAnimationFrame> add_frame(int duration);
void set_text(const std::string& text) { m_label->set_text(text.c_str()); }
void set_selected(bool selected) { m_selected = selected; }
void set_chekcbox(bool checked) { m_visibility->set_value(checked); }
};