mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Merge branch 'master' into docking
# Conflicts: # imgui.cpp
This commit is contained in:
@ -1167,7 +1167,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::Checkbox("With Drag and Drop", &drag_and_drop);
|
||||
ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); HelpMarker("Right-click on the individual color widget to show options.");
|
||||
ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); HelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
|
||||
int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (drag_and_drop ? 0 : ImGuiColorEditFlags_NoDragDrop) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
|
||||
ImGuiColorEditFlags misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (drag_and_drop ? 0 : ImGuiColorEditFlags_NoDragDrop) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
|
||||
|
||||
ImGui::Text("Color widget:");
|
||||
ImGui::SameLine(); HelpMarker("Click on the colored square to open a color picker.\nCTRL+click on individual component to input value.\n");
|
||||
@ -3528,7 +3528,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()
|
||||
@ -3549,7 +3549,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)
|
||||
@ -3562,8 +3561,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)
|
||||
@ -3592,8 +3589,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();
|
||||
@ -3601,9 +3597,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();
|
||||
}
|
||||
|
||||
@ -3652,9 +3646,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();
|
||||
@ -3846,13 +3842,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();
|
||||
}
|
||||
|
||||
@ -3873,8 +3867,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)
|
||||
@ -3888,9 +3880,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();
|
||||
}
|
||||
|
||||
@ -3955,9 +3945,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