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