SpiecsEngine
 
Loading...
Searching...
No Matches

◆ OnRender()

void Spices::ImguiInfoBar::OnRender ( )
overridevirtual

This interface is called On SlateRenderer Render.

Begin render ContentBrowser.

Skip if no InfoBar Instance.

End render ContentBrowser.

Begin render ContentBrowser.

Skip if no InfoBar Instance.

End render ContentBrowser.

Implements Spices::ImguiSlate.

Definition at line 50 of file ImguiInfoBar.cpp.

51 {
53
57 Begin(m_PanelName, 1.0f, ImGuiWindowFlags_NoTitleBar);
58
59 {
60 SPICES_PROFILE_ZONEN("ImguiInfoBar");
61
62 float width = ImGui::GetContentRegionAvail().x;
63 ImGui::Spacing();
64
68 if (m_InfoBars.size() == 0)
69 {
70 End();
71 return;
72 }
73
74 ImGui::PushID("ImguiInfoBar");
75
76 auto item = m_SelectedInfoBar ? m_SelectedInfoBar : *m_InfoBars.first();
77
78 ImGui::Columns(3, 0);
79
80 ImGui::SetColumnWidth(0, 0.5f * width);
81 ImGui::NextColumn();
82
83 ImGui::SetColumnWidth(1, 0.39f * width);
84 ImGui::Text(item->GetInfo().c_str());
85 ImGui::NextColumn();
86
87 switch (item->GetType())
88 {
90 {
91 float rate = std::any_cast<float>(item->GetRate());
92 ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImVec4(0.310f, 0.49f, 0.627f, 1.0f));
93 ImGui::ProgressBar(rate);
94 ImGui::PopStyleColor();
95 break;
96 }
98 {
99 int count = std::any_cast<int>(item->GetRate());
100 std::stringstream ss;
101 ss << count;
102
103 ImGui::Text(ss.str().c_str());
104 break;
105 }
106 }
107
108 ImGui::Columns(1);
109
110 ImGui::PopID();
111 }
112
113 {
114 SPICES_PROFILE_ZONEN("ImguiInfoBar::DisplayList");
115
116 if (ImGui::BeginPopupContextWindow(0, 1))
117 {
118 m_InfoBars.for_each([&](auto& k, auto& v) {
119
120 if (ImGui::MenuItem(k.c_str()))
121 {
122 m_SelectedInfoBar = v;
123 }
124 return false;
125
126 });
127
128 ImGui::EndPopup();
129 }
130 }
131
135 End();
136 }
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
scl::linked_unordered_map< std::string, std::shared_ptr< SlateInfoBar > > m_InfoBars
InfoBar instances.
std::shared_ptr< SlateInfoBar > m_SelectedInfoBar
Selected InfoBar.
void Begin(float alpha=1.0f, ImGuiWindowFlags flags=0)
Begin a common slate.
void End()
End a slate.
std::string m_PanelName
This slate's name.
Definition ImguiUtils.h:161
constexpr int count
Calculate count that meets requirement.
Definition TypeList.h:289

References Spices::ImguiSlate::End().