SpiecsEngine
 
Loading...
Searching...
No Matches
ImguiFloattingInfo.cpp
Go to the documentation of this file.
1/**
2* @file ImguiGizmos.cpp.
3* @brief The ImguiGizmos Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9
10#include "Systems/SlateSystem.h"
11#include "World/World/World.h"
12#include "World/Entity.h"
13#include "Core/Library/ProcessLibrary.h"
14
15namespace Spices {
16
17 void ImguiFloatingInfo::OnRender()
18 {
20
21 const ImVec2 work_pos = m_Owner->GetPanelPos();
22 const ImVec2 work_size = m_Owner->GetPanelSize();
23
24 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(4.0f, 4.0f));
25 ImGui::PushStyleColor(ImGuiCol_WindowBg, ImGui::GetStyleColorVec4(ImGuiCol_FrameBg));
26
27 static int location = 1;
28 const ImGuiIO& io = ImGui::GetIO();
29 ImGuiWindowFlags window_flags =
30 ImGuiWindowFlags_NoDecoration |
31 ImGuiWindowFlags_NoDocking |
32 ImGuiWindowFlags_AlwaysAutoResize |
33 ImGuiWindowFlags_NoSavedSettings |
34 ImGuiWindowFlags_NoFocusOnAppearing |
35 ImGuiWindowFlags_NoNav |
36 ImGuiWindowFlags_NoTitleBar;
37
38 if (location >= 0)
39 {
40 const float PAD = ImGui::GetStyle().WindowPadding.x;
41
42 ImVec2 window_pos, window_pos_pivot;
43 window_pos.x = (location & 1) ? (work_pos.x + work_size.x - PAD) : (work_pos.x + PAD);
44 window_pos.y = (location & 2) ? (work_pos.y + work_size.y - PAD) : (work_pos.y + PAD + ImGuiH::GetLineItemSize().x * 1.5f + 2.0f + ImGui::GetStyle().WindowPadding.y);
45 window_pos_pivot.x = (location & 1) ? 1.0f : 0.0f;
46 window_pos_pivot.y = (location & 2) ? 1.0f : 0.0f;
47
48 ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
49
50 window_flags |= ImGuiWindowFlags_NoMove;
51 }
52 else if (location == -2)
53 {
54 // Center window
55 ImGui::SetNextWindowPos(work_pos + work_size * 0.5, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
56 window_flags |= ImGuiWindowFlags_NoMove;
57 }
58
59 ImGui::SetNextWindowBgAlpha(0.7f); // Transparent background
60 bool open = true;
61
62 std::stringstream ss;
63 ss << m_Owner->GetName() << "_" << m_PanelName;
64 if (ImGui::Begin(ss.str().c_str(), &open, window_flags))
65 {
66 ImGui::Text("FPS: %.2f | Frame time: %.2f ms", io.Framerate, 1000.0f / io.Framerate);
67 ImGui::Text("ViewPort Size: ( %d, %d )", (int)work_size.x, (int)work_size.y);
68
69 if (ImGui::IsMousePosValid())
70 {
71 ImGui::Text("Mouse Position: ( %d, %d )", (int)io.MousePos.x, (int)io.MousePos.y);
72 }
73 else
74 {
75 ImGui::Text("Mouse Position: <invalid>");
76 }
77
79 ImGui::Text("Memory in Used: %.2f GB", size);
80
81 if (ImGui::BeginPopupContextWindow())
82 {
83 if (ImGui::MenuItem("Custom", NULL, location == -1)) location = -1;
84 if (ImGui::MenuItem("Center", NULL, location == -2)) location = -2;
85 if (ImGui::MenuItem("Top-left", NULL, location == 0)) location = 0;
86 if (ImGui::MenuItem("Top-right", NULL, location == 1)) location = 1;
87 if (ImGui::MenuItem("Bottom-left", NULL, location == 2)) location = 2;
88 if (ImGui::MenuItem("Bottom-right", NULL, location == 3)) location = 3;
89 if (open && ImGui::MenuItem("Close")) open = false;
90 ImGui::EndPopup();
91 }
92 }
93
94 ImGui::PopStyleColor();
95 ImGui::PopStyleVar();
96 ImGui::End();
97 }
98}
#define SPICES_PROFILE_ZONE
std::string m_PanelName
This slate's name.
Definition ImguiUtils.h:161
const std::string & GetName() const
Get this panel Name.
Definition ImguiUtils.h:144
static float ProcessMemoryInUsed()
Get this Process Memory used( GB ).
Process Static Function Library.