From d3c2e904d8e3b7310fb4e2a8a3984caf3f94171d Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 19 Oct 2017 19:29:59 +0200 Subject: [PATCH] Internals: Added ImLinearSweep() helper. --- TODO.txt | 1 + imgui_internal.h | 1 + 2 files changed, 2 insertions(+) diff --git a/TODO.txt b/TODO.txt index 04e795fa..f1976f2f 100644 --- a/TODO.txt +++ b/TODO.txt @@ -236,6 +236,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL) - misc: provide HoveredTime and ActivatedTime to ease the creation of animations. - misc: fix for compilation settings where stdcall isn't the default (e.g. vectorcall) (#1230) + - misc: detect user not calling Render() and suggest to call EndFrame()? - remote: make a system like RemoteImGui first-class citizen/project (#75) - demo: add vertical separator demo diff --git a/imgui_internal.h b/imgui_internal.h index 4e34b8b8..c9d522e6 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -154,6 +154,7 @@ static inline float ImFloor(float f) static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); } static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; } static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); } +static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; } // We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax. // Defining a custom placement new() with a dummy parameter allows us to bypass including which on some platforms complains when user has disabled exceptions.