mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
Merge remote-tracking branch 'origin' into 2016-07-navigation
This commit is contained in:
@ -1,11 +1,22 @@
|
||||
// dear imgui, v1.50 WIP
|
||||
// dear imgui, v1.51 WIP
|
||||
// (demo code)
|
||||
|
||||
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
||||
// Do NOT remove this file from your project! It is useful reference code that you and other users will want to refer to.
|
||||
// Don't do it! Do NOT remove this file from your project! It is useful reference code that you and other users will want to refer to.
|
||||
// Everything in this file will be stripped out by the linker if you don't call ImGui::ShowTestWindow().
|
||||
// During development, you can call ImGui::ShowTestWindow() in your code to learn about various features of ImGui.
|
||||
// Removing this file from your project is hindering your access to documentation, likely leading you to poorer usage of the library.
|
||||
// During development, you can call ImGui::ShowTestWindow() in your code to learn about various features of ImGui. Have it wired in a debug menu!
|
||||
// Removing this file from your project is hindering access to documentation for everyone in your team, likely leading you to poorer usage of the library.
|
||||
// Note that you can #define IMGUI_DISABLE_TEST_WINDOWS in imconfig.h for the same effect.
|
||||
// If you want to link core ImGui in your public builds but not those test windows, #define IMGUI_DISABLE_TEST_WINDOWS in imconfig.h and those functions will be empty.
|
||||
// For any other case, if you have ImGui available you probably want this to be available for reference and execution.
|
||||
// Thank you,
|
||||
// -Your beloved friend, imgui_demo.cpp (that you won't delete)
|
||||
|
||||
// Message to beginner C/C++ programmer about the meaning of 'static': in this demo code, we frequently we use 'static' variables inside functions.
|
||||
// We do this as a way to gather code and data in the same place, make the demo code faster to read, faster to write, and smaller. A static variable persist across calls,
|
||||
// so it is essentially like a global variable but declared inside the scope of the function.
|
||||
// It also happens to be a convenient way of storing simple UI related information as long as your function doesn't need to be reentrant or used in threads.
|
||||
// This may be a pattern you want to use in your code (simple is beautiful!), but most of the real data you would be editing is likely to be stored outside your function.
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
@ -15,7 +26,7 @@
|
||||
#include <ctype.h> // toupper, isprint
|
||||
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||
#include <stdlib.h> // NULL, malloc, free, qsort, atoi
|
||||
#include <stdlib.h> // NULL, malloc, free, atoi
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
@ -1087,9 +1098,9 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
static int track_line = 50, scroll_to_px = 200;
|
||||
ImGui::Checkbox("Track", &track);
|
||||
ImGui::PushItemWidth(100);
|
||||
ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line %.0f");
|
||||
bool scroll_to = ImGui::Button("Scroll To");
|
||||
ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "y = %.0f px");
|
||||
ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line = %.0f");
|
||||
bool scroll_to = ImGui::Button("Scroll To Pos");
|
||||
ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %.0f px");
|
||||
ImGui::PopItemWidth();
|
||||
if (scroll_to) track = false;
|
||||
|
||||
@ -1113,7 +1124,9 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::Text("Line %d", line);
|
||||
}
|
||||
}
|
||||
float scroll_y = ImGui::GetScrollY(), scroll_max_y = ImGui::GetScrollMaxY();
|
||||
ImGui::EndChild();
|
||||
ImGui::Text("%.0f/%0.f", scroll_y, scroll_max_y);
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
@ -1148,12 +1161,14 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
float scroll_x = ImGui::GetScrollX(), scroll_max_x = ImGui::GetScrollMaxX();
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar(2);
|
||||
float scroll_x_delta = 0.0f;
|
||||
ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f;
|
||||
ImGui::SameLine(); ImGui::Text("Scroll from code"); ImGui::SameLine();
|
||||
ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f;
|
||||
ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
|
||||
ImGui::Text("Scroll from code"); ImGui::SameLine();
|
||||
ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
|
||||
ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x);
|
||||
if (scroll_x_delta != 0.0f)
|
||||
{
|
||||
ImGui::BeginChild("scrolling"); // Demonstrate a trick: you can use Begin to set yourself in the context of another window (here we are already out of your child window)
|
||||
@ -2468,10 +2483,10 @@ static void ShowExampleAppLog(bool* p_open)
|
||||
{
|
||||
static ExampleAppLog log;
|
||||
|
||||
// Demo fill
|
||||
// Demo: add random items (unless Ctrl is held)
|
||||
static float last_time = -1.0f;
|
||||
float time = ImGui::GetTime();
|
||||
if (time - last_time >= 0.3f)
|
||||
if (time - last_time >= 0.20f && !ImGui::GetIO().KeyCtrl)
|
||||
{
|
||||
const char* random_words[] = { "system", "info", "warning", "error", "fatal", "notice", "log" };
|
||||
log.AddLog("[%s] Hello, time is %.1f, rand() %d\n", random_words[rand() % IM_ARRAYSIZE(random_words)], time, (int)rand());
|
||||
|
Reference in New Issue
Block a user