mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-18 12:25:36 +00:00
Internals: refactor RenderRectFilledRangeH() into RenderRectFilledInRangeH() to take absolute coordinates instead of normalized ones.
Amend 01d4bf299a (#1296)
This commit is contained in:
@@ -2045,10 +2045,12 @@ static void DemoWindowWidgetsProgressBars()
|
||||
if (ImGui::TreeNode("Progress Bars"))
|
||||
{
|
||||
// Animate a simple progress bar
|
||||
static float progress = 0.0f, progress_dir = 1.0f;
|
||||
progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
|
||||
if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; }
|
||||
if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; }
|
||||
static float progress_accum = 0.0f, progress_dir = 1.0f;
|
||||
progress_accum += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
|
||||
if (progress_accum >= +1.1f) { progress_accum = +1.1f; progress_dir *= -1.0f; }
|
||||
if (progress_accum <= -0.1f) { progress_accum = -0.1f; progress_dir *= -1.0f; }
|
||||
|
||||
const float progress = IM_CLAMP(progress_accum, 0.0f, 1.0f);
|
||||
|
||||
// Typically we would use ImVec2(-1.0f,0.0f) or ImVec2(-FLT_MIN,0.0f) to use all available width,
|
||||
// or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
|
||||
@@ -2056,9 +2058,8 @@ static void DemoWindowWidgetsProgressBars()
|
||||
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
|
||||
ImGui::Text("Progress Bar");
|
||||
|
||||
float progress_saturated = IM_CLAMP(progress, 0.0f, 1.0f);
|
||||
char buf[32];
|
||||
sprintf(buf, "%d/%d", (int)(progress_saturated * 1753), 1753);
|
||||
sprintf(buf, "%d/%d", (int)(progress * 1753), 1753);
|
||||
ImGui::ProgressBar(progress, ImVec2(0.f, 0.f), buf);
|
||||
|
||||
// Pass an animated negative value, e.g. -1.0f * (float)ImGui::GetTime() is the recommended value.
|
||||
|
||||
Reference in New Issue
Block a user