1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-24 07:40:22 +01:00

Demo: Split the contents of ShowDemoWindow() into smaller functions as it appears to speed up link time with VS. (#2152)

This commit is contained in:
omar 2018-10-25 23:34:05 +02:00
parent faecf90383
commit eed1fba157
2 changed files with 59 additions and 29 deletions

View File

@ -69,6 +69,7 @@ Other Changes:
- RenderText(): Some optimization for very large text buffers, useful for non-optimized builds.
- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f.
- ArrowButton(): Fixed arrow shape being horizontally misaligned by (FramePadding.y-FramePadding.x) if they are different.
- Demo: Split the contents of ShowDemoWindow() into smaller functions as it appears to speed up link time with VS. (#2152)
- Drag and Drop: Added GetDragDropPayload() to peek directly into the payload (if any) from anywhere. (#143)
- ImGuiTextBuffer: Avoid heap allocation when empty.
- ImDrawList: Fixed AddConvexPolyFilled() undefined behavior when passing points_count smaller than 3,

View File

@ -155,6 +155,13 @@ void ImGui::ShowUserGuide()
// [SECTION] Demo Window / ShowDemoWindow()
//-----------------------------------------------------------------------------
// We split the contents of the big ShowDemoWindow() function into smaller functions (because the link time of very large functions grow non-linearly)
static void ShowDemoWindowWidgets();
static void ShowDemoWindowLayout();
static void ShowDemoWindowPopups();
static void ShowDemoWindowColumns();
static void ShowDemoWindowMisc();
// Demonstrate most Dear ImGui features (this is big function!)
// You may execute this function to experiment with the UI and understand what it does. You may then search for keywords in the code when you are interested by a specific feature.
void ImGui::ShowDemoWindow(bool* p_open)
@ -371,6 +378,19 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::Checkbox("No bring to front", &no_bring_to_front);
}
// All demo contents
ShowDemoWindowWidgets();
ShowDemoWindowLayout();
ShowDemoWindowPopups();
ShowDemoWindowColumns();
ShowDemoWindowMisc();
// End of ShowDemoWindow()
ImGui::End();
}
static void ShowDemoWindowWidgets()
{
if (ImGui::CollapsingHeader("Widgets"))
{
if (ImGui::TreeNode("Basic"))
@ -601,13 +621,13 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::Checkbox("Enable extra group", &closable_group);
if (ImGui::CollapsingHeader("Header"))
{
ImGui::Text("IsItemHovered: %d", IsItemHovered());
ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
for (int i = 0; i < 5; i++)
ImGui::Text("Some content %d", i);
}
if (ImGui::CollapsingHeader("Header with a close button", &closable_group))
{
ImGui::Text("IsItemHovered: %d", IsItemHovered());
ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
for (int i = 0; i < 5; i++)
ImGui::Text("More content %d", i);
}
@ -1049,11 +1069,11 @@ void ImGui::ShowDemoWindow(bool* p_open)
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 3);
if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F))
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F))
memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 4);
EndDragDropTarget();
ImGui::EndDragDropTarget();
}
ImGui::PopID();
@ -1469,7 +1489,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::Text("This is another child window for testing with the _ChildWindows flag.");
ImGui::EndChild();
if (embed_all_inside_a_child_window)
EndChild();
ImGui::EndChild();
// Calling IsItemHovered() after begin returns the hovered status of the title bar.
// This is useful in particular if you want to create a context menu (with BeginPopupContextItem) associated to the title bar of a window.
@ -1493,7 +1513,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::TreePop();
}
}
}
static void ShowDemoWindowLayout()
{
if (ImGui::CollapsingHeader("Layout"))
{
if (ImGui::TreeNode("Child regions"))
@ -1802,7 +1825,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
{
if (track && line == track_line)
{
ImGui::TextColored(ImColor(255,255,0), "Line %d", line);
ImGui::TextColored(ImVec4(1,1,0,1), "Line %d", line);
ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
}
else
@ -1880,7 +1903,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::TreePop();
}
}
}
static void ShowDemoWindowPopups()
{
if (ImGui::CollapsingHeader("Popups & Modal windows"))
{
// Popups are windows with a few special properties:
@ -2084,7 +2110,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::TreePop();
}
}
}
static void ShowDemoWindowColumns()
{
if (ImGui::CollapsingHeader("Columns"))
{
ImGui::PushID("Columns");
@ -2264,7 +2293,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
}
ImGui::PopID();
}
}
static void ShowDemoWindowMisc()
{
if (ImGui::CollapsingHeader("Filtering"))
{
static ImGuiTextFilter filter;
@ -2422,9 +2454,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::TreePop();
}
}
// End of ShowDemoWindow()
ImGui::End();
}
//-----------------------------------------------------------------------------