summaryrefslogtreecommitdiff
path: root/src/ui/helpers.cpp
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2025-10-26 17:23:28 +0100
committerAldrik Ramaekers <aldrikboy@gmail.com>2025-10-26 17:23:28 +0100
commit60488d722bf29f3ff0ce3e08b90f30523a8d7b6d (patch)
treec2e01243d8a0d970c35e250b66a66a226ab230dc /src/ui/helpers.cpp
parent5e06ad208e32330b662af90ce41613f5421095cb (diff)
loading animations and block navigation while writing to disk
Diffstat (limited to 'src/ui/helpers.cpp')
-rw-r--r--src/ui/helpers.cpp100
1 files changed, 0 insertions, 100 deletions
diff --git a/src/ui/helpers.cpp b/src/ui/helpers.cpp
deleted file mode 100644
index 476e780..0000000
--- a/src/ui/helpers.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
-* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
-*
-* Permission to use, copy, modify, and/or distribute this software for any
-* purpose with or without fee is hereby granted, provided that the above
-* copyright notice and this permission notice appear in all copies.
-*
-* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-
-#include "ui.hpp"
-#include "imgui.h"
-#include "strops.hpp"
-
-#define STATUS_DURATION 4.0f
-#define STATUS_FLASH_INTERVAL 0.1f
-#define STATUS_MAX_FLASHES 2
-
-namespace ui {
-
- ImFont* fontBold;
- ImFont* fontBig;
-
- static status current_status;
-
- void ui::draw_status()
- {
- float region_width = ImGui::GetContentRegionAvail().x;
- float text_width = ImGui::CalcTextSize(current_status.text).x;
-
- if (current_status.loading)
- {
- ImGui::SetCursorPosX(ImGui::GetCursorPosX() + region_width - text_width - 20.0f);
- ImGui::Text("%c", "|/-\\"[(int)(ImGui::GetTime() / 0.1f) & 3]);
- return;
- }
-
- if (current_status.visible)
- {
- ImGui::SetCursorPosX(ImGui::GetCursorPosX() + region_width - text_width);
- ImGui::PushStyleColor(ImGuiCol_Text, current_status.color);
- ImGui::TextUnformatted(current_status.text);
- ImGui::PopStyleColor();
- }
-
- ImGuiIO& io = ImGui::GetIO();
- current_status.time += io.DeltaTime;
-
- if (current_status.time >= STATUS_FLASH_INTERVAL && current_status.flash_count < STATUS_MAX_FLASHES)
- {
- current_status.visible = !current_status.visible;
- if (current_status.visible) current_status.flash_count++;
- current_status.time = 0.0f;
- }
-
- if (current_status.time >= STATUS_DURATION)
- {
- current_status.text[0] = 0;
- }
- }
-
- static void set_status_ex(const char* txt, int color)
- {
- current_status.flash_count = 0;
- current_status.visible = true;
- current_status.time = 0.0f;
- current_status.color = color;
- current_status.loading = false;
- strops::copy(current_status.text, txt, STATUS_TEXT_LEN);
- }
-
- void ui::set_status_error(const char* txt)
- {
- set_status_ex(txt, config::colors::COLOR_ERROR);
- }
-
- void ui::set_status(const char* txt)
- {
- set_status_ex(txt, config::colors::COLOR_DEFAULT);
- }
-
- void ui::set_status_loading(bool loading)
- {
- current_status.visible = true;
- current_status.time = 0.0f;
- current_status.loading = loading;
- }
-
- status ui::get_status()
- {
- return current_status;
- }
-
-} \ No newline at end of file