mirror of
https://github.com/Drezil/imgui.git
synced 2025-04-01 17:02:45 +00: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:
parent
faecf90383
commit
eed1fba157
@ -69,6 +69,7 @@ Other Changes:
|
|||||||
- RenderText(): Some optimization for very large text buffers, useful for non-optimized builds.
|
- 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.
|
- 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.
|
- 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)
|
- Drag and Drop: Added GetDragDropPayload() to peek directly into the payload (if any) from anywhere. (#143)
|
||||||
- ImGuiTextBuffer: Avoid heap allocation when empty.
|
- ImGuiTextBuffer: Avoid heap allocation when empty.
|
||||||
- ImDrawList: Fixed AddConvexPolyFilled() undefined behavior when passing points_count smaller than 3,
|
- ImDrawList: Fixed AddConvexPolyFilled() undefined behavior when passing points_count smaller than 3,
|
||||||
|
@ -155,6 +155,13 @@ void ImGui::ShowUserGuide()
|
|||||||
// [SECTION] Demo Window / ShowDemoWindow()
|
// [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!)
|
// 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.
|
// 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)
|
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);
|
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::CollapsingHeader("Widgets"))
|
||||||
{
|
{
|
||||||
if (ImGui::TreeNode("Basic"))
|
if (ImGui::TreeNode("Basic"))
|
||||||
@ -601,13 +621,13 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::Checkbox("Enable extra group", &closable_group);
|
ImGui::Checkbox("Enable extra group", &closable_group);
|
||||||
if (ImGui::CollapsingHeader("Header"))
|
if (ImGui::CollapsingHeader("Header"))
|
||||||
{
|
{
|
||||||
ImGui::Text("IsItemHovered: %d", IsItemHovered());
|
ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
ImGui::Text("Some content %d", i);
|
ImGui::Text("Some content %d", i);
|
||||||
}
|
}
|
||||||
if (ImGui::CollapsingHeader("Header with a close button", &closable_group))
|
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++)
|
for (int i = 0; i < 5; i++)
|
||||||
ImGui::Text("More content %d", i);
|
ImGui::Text("More content %d", i);
|
||||||
}
|
}
|
||||||
@ -1049,11 +1069,11 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
|
|
||||||
if (ImGui::BeginDragDropTarget())
|
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);
|
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);
|
memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 4);
|
||||||
EndDragDropTarget();
|
ImGui::EndDragDropTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopID();
|
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::Text("This is another child window for testing with the _ChildWindows flag.");
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
if (embed_all_inside_a_child_window)
|
if (embed_all_inside_a_child_window)
|
||||||
EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
// Calling IsItemHovered() after begin returns the hovered status of the title bar.
|
// 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.
|
// 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();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ShowDemoWindowLayout()
|
||||||
|
{
|
||||||
if (ImGui::CollapsingHeader("Layout"))
|
if (ImGui::CollapsingHeader("Layout"))
|
||||||
{
|
{
|
||||||
if (ImGui::TreeNode("Child regions"))
|
if (ImGui::TreeNode("Child regions"))
|
||||||
@ -1802,7 +1825,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
{
|
{
|
||||||
if (track && line == track_line)
|
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
|
ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1880,7 +1903,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ShowDemoWindowPopups()
|
||||||
|
{
|
||||||
if (ImGui::CollapsingHeader("Popups & Modal windows"))
|
if (ImGui::CollapsingHeader("Popups & Modal windows"))
|
||||||
{
|
{
|
||||||
// Popups are windows with a few special properties:
|
// Popups are windows with a few special properties:
|
||||||
@ -2084,7 +2110,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ShowDemoWindowColumns()
|
||||||
|
{
|
||||||
if (ImGui::CollapsingHeader("Columns"))
|
if (ImGui::CollapsingHeader("Columns"))
|
||||||
{
|
{
|
||||||
ImGui::PushID("Columns");
|
ImGui::PushID("Columns");
|
||||||
@ -2264,7 +2293,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ShowDemoWindowMisc()
|
||||||
|
{
|
||||||
if (ImGui::CollapsingHeader("Filtering"))
|
if (ImGui::CollapsingHeader("Filtering"))
|
||||||
{
|
{
|
||||||
static ImGuiTextFilter filter;
|
static ImGuiTextFilter filter;
|
||||||
@ -2422,9 +2454,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of ShowDemoWindow()
|
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user