diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-04 09:25:36 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-04 09:25:36 +0200 |
| commit | 4cfbd259d1a6fbe7592b8975eed399b46082edc1 (patch) | |
| tree | c6095f5d2e0f1eabae41ddb62a6adc74d2210f97 /libs/imgui-1.92.1 | |
| parent | 485e5ebf340857db07b1c8ecb5c63dcf3a908377 (diff) | |
import ui
Diffstat (limited to 'libs/imgui-1.92.1')
| -rw-r--r-- | libs/imgui-1.92.1/imgui.cpp | 40 | ||||
| -rw-r--r-- | libs/imgui-1.92.1/imgui.h | 4 |
2 files changed, 44 insertions, 0 deletions
diff --git a/libs/imgui-1.92.1/imgui.cpp b/libs/imgui-1.92.1/imgui.cpp index 99819ff..b41a167 100644 --- a/libs/imgui-1.92.1/imgui.cpp +++ b/libs/imgui-1.92.1/imgui.cpp @@ -16677,6 +16677,46 @@ void ImGui::DebugBreakButtonTooltip(bool keyboard_only, const char* description_ EndTooltip(); } +// From https://github.com/ocornut/imgui/issues/1901#issuecomment-444929973 +void ImGui::LoadingIndicatorCircle(const char* label, const float indicator_radius, + const ImVec4& main_color, const ImVec4& backdrop_color, + const int circle_count, const float speed) { + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) { + return; + } + + ImGuiContext& g = *GImGui; + const ImGuiID id = window->GetID(label); + + const ImVec2 pos = window->DC.CursorPos; + const float circle_radius = indicator_radius / 15.0f; + const float updated_indicator_radius = indicator_radius - 4.0f * circle_radius; + const ImRect bb(pos, ImVec2(pos.x + indicator_radius * 2.0f, pos.y + indicator_radius * 2.0f)); + ItemSize(bb); + if (!ItemAdd(bb, id)) { + return; + } + const double t = g.Time; + const auto degree_offset = 2.0f * IM_PI / circle_count; + for (int i = 0; i < circle_count; ++i) { + const auto x = updated_indicator_radius * sin(degree_offset * i); + const auto y = updated_indicator_radius * cos(degree_offset * i); + + #define max(a,b) (((a)>(b))?(a):(b)) + + const auto growth = max(0.0f, sin(t * speed - i * degree_offset)); + ImVec4 color; + color.x = (float)(main_color.x * growth + backdrop_color.x * (1.0f - growth)); + color.y = (float)(main_color.y * growth + backdrop_color.y * (1.0f - growth)); + color.z = (float)(main_color.z * growth + backdrop_color.z * (1.0f - growth)); + color.w = 1.0f; + window->DrawList->AddCircleFilled(ImVec2((float)(pos.x + indicator_radius + x), + (float)(pos.y + indicator_radius - y)), + (float)(circle_radius + growth * circle_radius), GetColorU32(color)); + } +} + // Special button that doesn't take focus, doesn't take input owner, and can be activated without a click etc. // In order to reduce interferences with the contents we are trying to debug into. bool ImGui::DebugBreakButton(const char* label, const char* description_of_location) diff --git a/libs/imgui-1.92.1/imgui.h b/libs/imgui-1.92.1/imgui.h index a2b2a1f..29c89b9 100644 --- a/libs/imgui-1.92.1/imgui.h +++ b/libs/imgui-1.92.1/imgui.h @@ -375,6 +375,10 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE namespace ImGui { + IMGUI_API void LoadingIndicatorCircle(const char* label, const float indicator_radius, + const ImVec4& main_color, const ImVec4& backdrop_color, + const int circle_count, const float speed); + // Context creation and access // - Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between contexts. // - DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() |
