Unravel Engine C++ Reference
Loading...
Searching...
No Matches
animation_panel.cpp
Go to the documentation of this file.
1#include "animation_panel.h"
2#include "../panels_defs.h"
3
4#include <imgui/imgui.h>
5#include <imgui/imgui_internal.h>
6#include <imgui_widgets/gizmo.h>
7#include <imgui_widgets/imanim/im_anim.h>
8
9namespace unravel
10{
11namespace
12{
13
14} // namespace
15
16void animation_panel::draw_menubar(rtti::context& ctx)
17{
18 if(ImGui::BeginMenuBar())
19 {
20 ImGui::EndMenuBar();
21 }
22}
23
27
29{
30 struct CustomNode : public ImFlow::BaseNode
31 {
32 explicit CustomNode()
33 {
34 setTitle("Custom");
35 setStyle(ImFlow::NodeStyle::brown());
36 addIN<int>("in<int>", "int", 0, ImFlow::ConnectionFilter::SameType(), ImFlow::PinStyle::red());
37
38 addOUT<int>("out<int>", "int", ImFlow::PinStyle::blue())
39 ->behaviour(
40 [this]()
41 {
42 return 0;
43 });
44 }
45 };
46
47 struct Custom2Node : public ImFlow::BaseNode
48 {
49 explicit Custom2Node()
50 {
51 setTitle("Custom2");
52 setStyle(ImFlow::NodeStyle::brown());
53 addIN<int>("in<int>", "int", 0, ImFlow::ConnectionFilter::SameType(), ImFlow::PinStyle::red());
54 addIN<float>("in<float>", "float", 0, ImFlow::ConnectionFilter::SameType(), ImFlow::PinStyle::red());
55
56 addOUT<int>("out<int>", "int", ImFlow::PinStyle::blue())
57 ->behaviour(
58 [this]()
59 {
60 return 0;
61 });
62 addOUT<float>("out<float>", "float", ImFlow::PinStyle::blue())
63 ->behaviour(
64 [this]()
65 {
66 return 0.0f;
67 });
68 }
69
70 void draw() override
71 {
73 ImGui::Text("%s", "some text here");
74
75 ImGui::PopFont();
76 }
77 };
78
79 auto callback = [this]()
80 {
81 /* omitted */
82
83 float size = 200.0f;
84 static ImGuiTextFilter filter_;
85
86 ImGui::DrawFilterWithHint(filter_, ICON_MDI_SELECT_SEARCH " Search...", size);
87 ImGui::DrawItemActivityOutline();
88
89 ImGui::Separator();
90 ImGui::BeginChild("COMPONENT_MENU_CONTEXT", ImVec2(ImGui::GetContentRegionAvail().x, size));
91
92 struct node_factory
93 {
94 std::string name;
95 std::function<void()> factory;
96 };
97
98 std::vector<node_factory> nodes{
99 {"Custom",
100 [this]()
101 {
102 flow_.placeNode<CustomNode>();
103 }},
104 {"Custom2",
105 [this]()
106 {
107 flow_.placeNode<Custom2Node>();
108 }},
109 };
110
111 for(const auto& factory : nodes)
112 {
113 if(!filter_.PassFilter(factory.name.c_str()))
114 continue;
115
116 if(ImGui::Selectable(factory.name.c_str()))
117 {
118 factory.factory();
119
120 ImGui::CloseCurrentPopup();
121 }
122 };
123
124 ImGui::EndChild();
125 };
126
127 flow_.rightClickPopUpContent(
128 [this, callback](ImFlow::BaseNode* node)
129 {
130 callback();
131 });
132
133 flow_.droppedLinkPopUpContent(
134 [this, callback](ImFlow::Pin* dragged)
135 {
136 callback();
137 });
138
139 flow_.addNode<CustomNode>({});
140 //show(true);
141}
142
146
148{
149 if(show_request_)
150 {
151 show_request_ = false;
152 show_ = true;
153 ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size * 0.5f, ImGuiCond_Once);
154 }
155 if(show_)
156 {
157 if(ImGui::Begin(name, &show_, ImGuiWindowFlags_MenuBar))
158 {
159 // ImGui::WindowTimeBlock block(ImGui::GetFont(ImGui::Font::Mono));
160
161 draw_ui(ctx);
162 }
163 ImGui::End();
164 }
165
166}
167
169{
170 show_request_ = s;
171}
172
173void animation_panel::draw_ui(rtti::context& ctx)
174{
175 flow_.update();
176}
177
178} // namespace unravel
void init(rtti::context &ctx)
animation_panel(imgui_panels *parent)
void on_frame_ui_render(rtti::context &ctx, const char *name)
void deinit(rtti::context &ctx)
float x
std::string name
Definition hub.cpp:33
#define ICON_MDI_SELECT_SEARCH
void PushFont(Font::Enum _font)
Definition imgui.cpp:646
void draw(DebugDrawEncoder &dde, const physics_sphere_shape &sh)
Definition gizmos.cpp:17