mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Updated ImGui.
This commit is contained in:
34
3rdparty/dear-imgui/imgui_demo.cpp
vendored
34
3rdparty/dear-imgui/imgui_demo.cpp
vendored
@@ -2593,7 +2593,9 @@ static void ShowDemoWindowColumns()
|
||||
static int columns_count = 4;
|
||||
const int lines_count = 3;
|
||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||
ImGui::DragInt("##columns_count", &columns_count, 0.1f, 1, 10, "%d columns");
|
||||
ImGui::DragInt("##columns_count", &columns_count, 0.1f, 2, 10, "%d columns");
|
||||
if (columns_count < 2)
|
||||
columns_count = 2;
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("horizontal", &h_borders);
|
||||
ImGui::SameLine();
|
||||
@@ -3447,7 +3449,7 @@ struct ExampleAppConsole
|
||||
Commands.push_back("CLEAR");
|
||||
Commands.push_back("CLASSIFY"); // "classify" is only here to provide an example of "C"+[tab] completing to "CL" and displaying matches.
|
||||
AutoScroll = true;
|
||||
ScrollToBottom = true;
|
||||
ScrollToBottom = false;
|
||||
AddLog("Welcome to Dear ImGui!");
|
||||
}
|
||||
~ExampleAppConsole()
|
||||
@@ -3468,7 +3470,6 @@ struct ExampleAppConsole
|
||||
for (int i = 0; i < Items.Size; i++)
|
||||
free(Items[i]);
|
||||
Items.clear();
|
||||
ScrollToBottom = true;
|
||||
}
|
||||
|
||||
void AddLog(const char* fmt, ...) IM_FMTARGS(2)
|
||||
@@ -3481,8 +3482,6 @@ struct ExampleAppConsole
|
||||
buf[IM_ARRAYSIZE(buf)-1] = 0;
|
||||
va_end(args);
|
||||
Items.push_back(Strdup(buf));
|
||||
if (AutoScroll)
|
||||
ScrollToBottom = true;
|
||||
}
|
||||
|
||||
void Draw(const char* title, bool* p_open)
|
||||
@@ -3511,8 +3510,7 @@ struct ExampleAppConsole
|
||||
if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine();
|
||||
bool copy_to_clipboard = ImGui::SmallButton("Copy"); ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
|
||||
bool copy_to_clipboard = ImGui::SmallButton("Copy");
|
||||
//static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
|
||||
|
||||
ImGui::Separator();
|
||||
@@ -3520,9 +3518,7 @@ struct ExampleAppConsole
|
||||
// Options menu
|
||||
if (ImGui::BeginPopup("Options"))
|
||||
{
|
||||
if (ImGui::Checkbox("Auto-scroll", &AutoScroll))
|
||||
if (AutoScroll)
|
||||
ScrollToBottom = true;
|
||||
ImGui::Checkbox("Auto-scroll", &AutoScroll);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
@@ -3571,9 +3567,11 @@ struct ExampleAppConsole
|
||||
}
|
||||
if (copy_to_clipboard)
|
||||
ImGui::LogFinish();
|
||||
if (ScrollToBottom)
|
||||
|
||||
if (ScrollToBottom || (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()))
|
||||
ImGui::SetScrollHereY(1.0f);
|
||||
ScrollToBottom = false;
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::EndChild();
|
||||
ImGui::Separator();
|
||||
@@ -3765,13 +3763,11 @@ struct ExampleAppLog
|
||||
ImGuiTextBuffer Buf;
|
||||
ImGuiTextFilter Filter;
|
||||
ImVector<int> LineOffsets; // Index to lines offset. We maintain this with AddLog() calls, allowing us to have a random access on lines
|
||||
bool AutoScroll;
|
||||
bool ScrollToBottom;
|
||||
bool AutoScroll; // Keep scrolling if already at the bottom
|
||||
|
||||
ExampleAppLog()
|
||||
{
|
||||
AutoScroll = true;
|
||||
ScrollToBottom = false;
|
||||
Clear();
|
||||
}
|
||||
|
||||
@@ -3792,8 +3788,6 @@ struct ExampleAppLog
|
||||
for (int new_size = Buf.size(); old_size < new_size; old_size++)
|
||||
if (Buf[old_size] == '\n')
|
||||
LineOffsets.push_back(old_size + 1);
|
||||
if (AutoScroll)
|
||||
ScrollToBottom = true;
|
||||
}
|
||||
|
||||
void Draw(const char* title, bool* p_open = NULL)
|
||||
@@ -3807,9 +3801,7 @@ struct ExampleAppLog
|
||||
// Options menu
|
||||
if (ImGui::BeginPopup("Options"))
|
||||
{
|
||||
if (ImGui::Checkbox("Auto-scroll", &AutoScroll))
|
||||
if (AutoScroll)
|
||||
ScrollToBottom = true;
|
||||
ImGui::Checkbox("Auto-scroll", &AutoScroll);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
@@ -3874,9 +3866,9 @@ struct ExampleAppLog
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if (ScrollToBottom)
|
||||
if (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
|
||||
ImGui::SetScrollHereY(1.0f);
|
||||
ScrollToBottom = false;
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user