From 2cf031b91d5248561fbeff78ceccb0b2d6c73809 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 9 Aug 2025 11:18:02 +0200 Subject: refactors, working on settings view --- src/ui/helpers.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/ui/helpers.cpp') 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(); -- cgit v1.2.3-70-g09d2