SpiecsEngine
 
Loading...
Searching...
No Matches
ImguiMainMenu.cpp
Go to the documentation of this file.
1/**
2* @file ImguiMainMenu.cpp.
3* @brief The ImguiGizmos Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9#include "Core/Input/Input.h"
10#include "Systems/SlateSystem.h"
11#include "ImguiFile.h"
12#include "Edit/ImguiEdit.h"
13#include "Window/ImguiWindow.h"
14#include "Create/ImguiCreateEntity.h"
15#include "Help/ImguiHelp.h"
16#include "Render/Vulkan/VulkanRenderBackend.h"
17#include "..\..\..\Core\Thread\ThreadModel.h"
18#include "Slate/SlateStyleLayout.h"
19#include <imgui_internal.h>
20
21namespace Spices {
22
24 const std::string& panelName ,
25 FrameInfo& frameInfo
26 )
27 : ImguiSlate(panelName, frameInfo)
28 {
30
31 /**
32 * @brief Instance Child Item.
33 */
34 {
35 m_File = SlateSystem::GetRegister()->Register<ImguiFile> (false, "File");
36 m_Edit = SlateSystem::GetRegister()->Register<ImguiEdit> (false, "Edit");
37 m_Create = SlateSystem::GetRegister()->Register<ImguiCreateEntity>(false, "Create");
38 m_Window = SlateSystem::GetRegister()->Register<ImguiWindow> (false, "Window");
39 m_Help = SlateSystem::GetRegister()->Register<ImguiHelp> (false, "Help");
40 }
41 }
42
44 {
46
47 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(6.0f, 6.0f));
48 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4.0f, 4.0f));
49 //ImGui::PushItemFlag(ImGuiItemFlags_SelectableDontClosePopup, true);
50
51 /**
52 * @brief MainMenu do not need call Begin(), End().
53 * ImGui::BeginMainMenuBar() does it automatically.
54 */
55 if (ImGui::BeginMainMenuBar())
56 {
57 m_PanelSize = ImGui::GetContentRegionAvail();
58
59 /**
60 * @brief Render Menu File.
61 */
62 m_File->OnRender();
63
64
65 /**
66 * @brief Render Menu Edit.
67 */
68 m_Edit->OnRender();
69
70
71 /**
72 * @brief Render Menu Create.
73 */
74 m_Create->OnRender();
75
76
77 /**
78 * @brief Render Menu Window.
79 */
80 m_Window->OnRender();
81
82
83 /**
84 * @brief Render Menu Tools.
85 */
86 {
87 SPICES_PROFILE_ZONEN("Render Menu Tools");
88
89 if (ImGui::BeginMenu("Tools"))
90 {
92
93 if (ImGui::BeginMenu(ICON_TEXT(ICON_MD_CHECK, Variants)))
94 {
95 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Variant Editor))) {}
96 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Variant Presenter))) {}
97
98 ImGui::EndMenu();
99 }
100 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Section))) {}
101 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Paint))) {}
102 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Pivot))) {}
103 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Randomizer))) {}
104 if (ImGui::BeginMenu(ICON_TEXT(ICON_MD_CHECK, Animation)))
105 {
106 if (ImGui::BeginMenu(ICON_TEXT(ICON_MD_CHECK, Curve Processing)))
107 {
108 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Simplify Curve))) {}
109
110 ImGui::EndMenu();
111 }
112 if (ImGui::BeginMenu(ICON_TEXT(ICON_MD_CHECK, Convert)))
113 {
114 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, USD TimeSample to Curves))) {}
115
116 ImGui::EndMenu();
117 }
118
119 ImGui::EndMenu();
120 }
121 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Measure))) {}
122 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Array))) {}
123 if (ImGui::MenuItem(ICON_TEXT(ICON_MD_CHECK, Distribute))) {}
124
125 ImGui::EndMenu();
126 }
127 }
128
129 /**
130 * @brief Render Menu Layout.
131 */
132 if (ImGui::BeginMenu("Layout"))
133 {
135
136 SPICES_PROFILE_ZONEN("Render Menu Layout");
137
138 if (ImGui::MenuItem("Default", "Ctrl+1"))
139 {
140 AsyncTask(ThreadPoolEnum::Game, []() {
141 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::Default);
142 });
143 }
144 if (ImGui::MenuItem("Animation", "Ctrl+2"))
145 {
146 AsyncTask(ThreadPoolEnum::Game, []() {
147 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::Animation);
148 });
149 }
150 if (ImGui::MenuItem("Animation Graph", "Ctrl+3"))
151 {
152 AsyncTask(ThreadPoolEnum::Game, []() {
153 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::AnimationGraph);
154 });
155 }
156 if (ImGui::MenuItem("Paint", "Ctrl+4"))
157 {
158 AsyncTask(ThreadPoolEnum::Game, []() {
159 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::Paint);
160 });
161 }
162 if (ImGui::MenuItem("Rendering", "Ctrl+5"))
163 {
164 AsyncTask(ThreadPoolEnum::Game, []() {
165 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::Rendering);
166 });
167 }
168 if (ImGui::MenuItem("Visual Scripting", "Ctrl+6"))
169 {
170 AsyncTask(ThreadPoolEnum::Game, []() {
171 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::VisualScripting);
172 });
173 }
174 if (ImGui::MenuItem("Physics Authoring", "Ctrl+9"))
175 {
176 AsyncTask(ThreadPoolEnum::Game, []() {
177 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::PhysicsAuthoring);
178 });
179 }
180 ImGui::Separator();
181 if (ImGui::MenuItem("UI Toggle Visibility", "F11"))
182 {
183 AsyncTask(ThreadPoolEnum::Game, []() {
184 SlateSystem::GetRegister()->GetViewPort()->Toggle();
185 });
186 }
187 if (ImGui::MenuItem("Fullscreen Mode"))
188 {
189 static bool isFullScreen = false;
190 isFullScreen = !isFullScreen;
191
192 const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
193
194 if (isFullScreen)
195 {
196 glfwSetWindowMonitor(VulkanRenderBackend::GetState().m_Windows, glfwGetPrimaryMonitor(), 0, 0, mode->width, mode->height, mode->refreshRate);
197 }
198 else
199 {
200 glfwSetWindowMonitor(VulkanRenderBackend::GetState().m_Windows, nullptr, 0.05 * mode->width, 0.05 * mode->height, 0.9 * mode->width, 0.9 * mode->height, mode->refreshRate);
201 }
202 }
203 ImGui::Separator();
204 if (ImGui::MenuItem("Save Layout"))
205 {
206 SlateStyleLayout::Get()->StoreLayout();
207 }
208 if (ImGui::MenuItem("Load Layout"))
209 {
210 SlateStyleLayout::Get()->LoadLayout();
211 }
212 ImGui::Separator();
213 if (ImGui::MenuItem("Quick Save", "Ctrl+7"))
214 {
215 AsyncTask(ThreadPoolEnum::Game, []() {
216 SlateStyleLayout::Get()->QuickStoreLayout();
217 });
218 }
219 if (ImGui::MenuItem("Quick Load", "Ctrl+8"))
220 {
221 AsyncTask(ThreadPoolEnum::Game, []() {
222 SlateStyleLayout::Get()->QuickLoadLayout();
223 });
224 }
225
226 ImGui::EndMenu();
227 }
228
229 /**
230 * @brief Render Menu Help.
231 */
232 m_Help->OnRender();
233
234
235 /**
236 * @brief Render Menu Live.
237 */
238 {
239 SPICES_PROFILE_ZONEN("Render Menu Live");
240
241 ImGui::SameLine(m_PanelSize.x - 6.0f * ImGuiH::GetLineItemSize().x);
242 ImGui::Text(ICON_TEXT(ICON_MD_FLASH_ON,LIVE));
243 ImGui::Button(ICON_MD_KEYBOARD_ARROW_DOWN, ImGuiH::GetLineItemSize());
244 ImGui::Text("CACHE:ON");
245 }
246
247 /**
248 * @brief End MainMenu;
249 */
250 ImGui::EndMainMenuBar();
251 }
252
253 //ImGui::PopItemFlag();
254 ImGui::PopStyleVar(2);
255 }
256
258 {
259 EventDispatcher dispatcher(event);
260
261 dispatcher.Dispatch<KeyPressedEvent>([](KeyPressedEvent& event) {
262
263 const auto isPressedCtrl = []() {
265 };
266
267 switch (event.GetKeyCode())
268 {
269 case Key::D1:
270 {
271 if (isPressedCtrl())
272 {
273 AsyncTask(ThreadPoolEnum::Game, []() {
274 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::Default);
275 });
276 }
277 break;
278 }
279 case Key::D2:
280 {
281 if (isPressedCtrl())
282 {
283 AsyncTask(ThreadPoolEnum::Game, []() {
284 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::Animation);
285 });
286 }
287 break;
288 }
289 case Key::D3:
290 {
291 if (isPressedCtrl())
292 {
293 AsyncTask(ThreadPoolEnum::Game, []() {
294 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::AnimationGraph);
295 });
296 }
297 break;
298 }
299 case Key::D4:
300 {
301 if (isPressedCtrl())
302 {
303 AsyncTask(ThreadPoolEnum::Game, []() {
304 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::Paint);
305 });
306 }
307 break;
308 }
309 case Key::D5:
310 {
311 if (isPressedCtrl())
312 {
313 AsyncTask(ThreadPoolEnum::Game, []() {
314 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::Rendering);
315 });
316 }
317 break;
318 }
319 case Key::D6:
320 {
321 if (isPressedCtrl())
322 {
323 AsyncTask(ThreadPoolEnum::Game, []() {
324 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::VisualScripting);
325 });
326 }
327 break;
328 }
329 case Key::D7:
330 {
331 if (isPressedCtrl())
332 {
333 AsyncTask(ThreadPoolEnum::Game, []() {
334 SlateStyleLayout::Get()->QuickStoreLayout();
335 });
336 }
337 break;
338 }
339 case Key::D8:
340 {
341 if (isPressedCtrl())
342 {
343 AsyncTask(ThreadPoolEnum::Game, []() {
344 SlateStyleLayout::Get()->QuickLoadLayout();
345 });
346 }
347 break;
348 }
349 case Key::D9:
350 {
351 if (isPressedCtrl())
352 {
353 AsyncTask(ThreadPoolEnum::Game, []() {
354 SlateStyleLayout::Get()->SetLayout(StyleLayoutEnum::PhysicsAuthoring);
355 });
356 }
357 break;
358 }
359 }
360
361 return false;
362 });
363 }
364}
#define ICON_TEXT(icon, text)
Definition ImguiHelper.h:24
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
EventDispatcher(Event &event)
Constructor Function.
Definition Event.h:172
This Class store a Specific Event type first and Dispatch a event handle function to it.
Definition Event.h:156
This Class is the basic Event Class. Inherit from it and create specific event class.
Definition Event.h:96
FrameInfo Class. This class defines the FrameInfo data.
Definition FrameInfo.h:32
static void MainMenuTitleSeparator()
Draw main menu titile separator.
The ImGuiH Class. This class defines helper function for slate render.
Definition ImguiHelper.h:61
virtual void OnRender() override
This interface is called On SlateRenderer Render.
ImguiMainMenu(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
The ImguiMainMenu Class. This class defines how to render a main menu.
ImguiSlate(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function. Init with Slate's name.
Definition ImguiUtils.h:35
This Class defines the basic behaves of specific slate. When we add an new Slate, we need inherit fro...
Definition ImguiUtils.h:27
static bool IsKeyPressed(const int &keycode)
Query If given Key is Pressed.
Definition Input.h:34
This Class Is a wrapper of Platform Specific Input Query.
Definition Input.h:16
const int & GetKeyCode() const
Get Key Input Code.
Definition KeyEvent.h:30
This Class is inherited from KeyEvent Class.
Definition KeyEvent.h:57
static std::shared_ptr< SlateStyleLayout > Get()
Get this single instance.
Wrappers of Slate StyleLayout Functions.