Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
StatusBar.cpp
Go to the documentation of this file.
1
2
3#include "Headers/StatusBar.h"
4
7
8#include <imgui_internal.h>
9
10namespace Divide {
11
14{
15}
16
17void StatusBar::draw() const {
19
20 ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)ImGui::GetMainViewport();
21 ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
22
23 if (ImGui::BeginViewportSideBar("##MainStatusBar", viewport, ImGuiDir_Down, ImGui::GetFrameHeight(), window_flags))
24 {
25 if (ImGui::BeginMenuBar())
26 {
27 if (!_messages.empty()) {
28 const Message& frontMsg = _messages.front();
29 if (!frontMsg._text.empty()) {
30 if (frontMsg._error) {
31 ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 50, 0, 255));
32 }
33
34 ImGui::Text(frontMsg._text.c_str());
35
36 if (frontMsg._error) {
37 ImGui::PopStyleColor();
38 }
39 }
40 }
41 ImGui::EndMenuBar();
42 }
43 ImGui::End();
44 }
45}
46
47void StatusBar::update(const U64 deltaTimeUS) noexcept {
48 if (_messages.empty()) {
49 return;
50 }
51
52 Message& frontMsg = _messages.front();
53 if (frontMsg._durationMS > 0.f) {
54 frontMsg._durationMS -= Time::MicrosecondsToMilliseconds(deltaTimeUS);
55 if (frontMsg._text.empty() || frontMsg._durationMS < 0.f) {
56 _messages.pop();
57 }
58 }
59}
60
61void StatusBar::showMessage(const string& message, const F32 durationMS, const bool error) {
62 _messages.push({message, durationMS, error});
63}
64
65} //namespace Divide
#define PROFILE_SCOPE_AUTO(CATEGORY)
Definition: Profiler.h:87
void draw() const
Definition: StatusBar.cpp:17
eastl::queue< Message > _messages
Definition: StatusBar.h:54
void update(U64 deltaTimeUS) noexcept
Definition: StatusBar.cpp:47
void showMessage(const string &message, F32 durationMS, bool error)
Definition: StatusBar.cpp:61
StatusBar(PlatformContext &context) noexcept
Definition: StatusBar.cpp:12
constexpr Optick::Category::Type GUI
Definition: Profiler.h:64
constexpr T MicrosecondsToMilliseconds(U a) noexcept
Definition: MathHelper.inl:731
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint64_t U64