summaryrefslogtreecommitdiff
path: root/src/ui/helpers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/helpers.cpp')
-rw-r--r--src/ui/helpers.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/ui/helpers.cpp b/src/ui/helpers.cpp
index 74876c0..e4b25c8 100644
--- a/src/ui/helpers.cpp
+++ b/src/ui/helpers.cpp
@@ -2,7 +2,44 @@
#include "imgui.h"
#include "locales.hpp"
-void view_draw_required_tag()
+static float toast_timer = 0.0f;
+static const char* toast_msg = nullptr;
+void ui_helper_show_toast(const char* msg)
+{
+ toast_msg = msg;
+ toast_timer = 3.0f;
+}
+
+void ui_helper_draw_toasts()
+{
+ if (toast_timer > 0.0f && toast_msg)
+ {
+ toast_timer -= ImGui::GetIO().DeltaTime;
+
+ const float pad = 10.0f;
+ const ImVec2 window_pos = ImVec2(
+ ImGui::GetIO().DisplaySize.x - pad,
+ ImGui::GetIO().DisplaySize.y - pad
+ );
+ const ImVec2 window_pos_pivot = ImVec2(1.0f, 1.0f);
+
+ ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
+ ImGui::SetNextWindowBgAlpha(0.85f); // semi-transparent
+
+ ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration |
+ ImGuiWindowFlags_AlwaysAutoResize |
+ ImGuiWindowFlags_NoFocusOnAppearing |
+ ImGuiWindowFlags_NoNav;
+
+ if (ImGui::Begin("##Toast", nullptr, flags))
+ {
+ ImGui::TextUnformatted(toast_msg);
+ }
+ ImGui::End();
+ }
+}
+
+void ui_helper_draw_required_tag()
{
ImDrawList* draw_list = ImGui::GetWindowDrawList();