mirror of
https://github.com/Drezil/imgui.git
synced 2025-09-20 10:03:13 +02:00
Compare commits
7 Commits
docking
...
features/n
Author | SHA1 | Date | |
---|---|---|---|
e32b72c12c | |||
f0c7981b01 | |||
0920ad9f04 | |||
698743c849 | |||
1848480798 | |||
f4edca3e65 | |||
8035405481 |
@ -429,8 +429,10 @@ provide similar or better string helpers.
|
|||||||
### Q: How can I display custom shapes? (using low-level ImDrawList API)
|
### Q: How can I display custom shapes? (using low-level ImDrawList API)
|
||||||
|
|
||||||
- You can use the low-level `ImDrawList` api to render shapes within a window.
|
- You can use the low-level `ImDrawList` api to render shapes within a window.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
ImGui::Begin("My shapes");
|
if (!ImGui::Begin("My shapes"))
|
||||||
|
return;
|
||||||
|
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ Result:
|
|||||||
Code:
|
Code:
|
||||||
```cpp
|
```cpp
|
||||||
// Create a window called "My First Tool", with a menu bar.
|
// Create a window called "My First Tool", with a menu bar.
|
||||||
ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar);
|
if (!ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar))
|
||||||
|
return;
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenu("File"))
|
if (ImGui::BeginMenu("File"))
|
||||||
|
@ -122,17 +122,21 @@ int main(int, char**)
|
|||||||
ImGui_ImplWin32_NewFrame();
|
ImGui_ImplWin32_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
// Enable Debugging
|
||||||
|
io.ConfigDebugBeginReturnValue = io.KeyShift;
|
||||||
|
#endif
|
||||||
|
|
||||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
if (show_demo_window)
|
if (show_demo_window)
|
||||||
ImGui::ShowDemoWindow(&show_demo_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
|
|
||||||
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
|
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
|
||||||
|
if (ImGui::Begin("Hello, world!")) // Create a window called "Hello, world!" and append into it.
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
|
|
||||||
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
|
||||||
|
|
||||||
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||||
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||||
ImGui::Checkbox("Another Window", &show_another_window);
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
@ -150,9 +154,9 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show another simple window.
|
// 3. Show another simple window.
|
||||||
if (show_another_window)
|
// Passing a pointer to our bool variable in the Begin() call: the window will have a closing button that will clear the bool when clicked.
|
||||||
|
if (show_another_window && ImGui::Begin("Another Window", &show_another_window))
|
||||||
{
|
{
|
||||||
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
|
||||||
ImGui::Text("Hello from another window!");
|
ImGui::Text("Hello from another window!");
|
||||||
if (ImGui::Button("Close Me"))
|
if (ImGui::Button("Close Me"))
|
||||||
show_another_window = false;
|
show_another_window = false;
|
||||||
|
147
imgui.cpp
147
imgui.cpp
@ -1083,6 +1083,9 @@ ImGuiIO::ImGuiIO()
|
|||||||
ConfigWindowsMoveFromTitleBarOnly = false;
|
ConfigWindowsMoveFromTitleBarOnly = false;
|
||||||
ConfigMemoryCompactTimer = 60.0f;
|
ConfigMemoryCompactTimer = 60.0f;
|
||||||
|
|
||||||
|
// Debug options
|
||||||
|
ConfigDebugBeginReturnValue = false;
|
||||||
|
|
||||||
// Platform Functions
|
// Platform Functions
|
||||||
BackendPlatformName = BackendRendererName = NULL;
|
BackendPlatformName = BackendRendererName = NULL;
|
||||||
BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL;
|
BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL;
|
||||||
@ -4107,13 +4110,29 @@ void ImGui::NewFrame()
|
|||||||
UpdateDebugToolItemPicker();
|
UpdateDebugToolItemPicker();
|
||||||
|
|
||||||
// Create implicit/fallback window - which we will only render it if the user has added something to it.
|
// Create implicit/fallback window - which we will only render it if the user has added something to it.
|
||||||
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
// - We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
||||||
// This fallback is particularly important as it avoid ImGui:: calls from crashing.
|
// - This fallback is particularly important as it avoid ImGui:: calls from crashing.
|
||||||
|
// - The fallback window exceptionally doesn't call End() automatically if Begin() returns false (this is intended).
|
||||||
g.WithinFrameScopeWithImplicitWindow = true;
|
g.WithinFrameScopeWithImplicitWindow = true;
|
||||||
SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver);
|
SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver);
|
||||||
Begin("Debug##Default");
|
bool ret = Begin("Debug##Default");
|
||||||
|
IM_UNUSED(ret);
|
||||||
|
IM_ASSERT(ret);
|
||||||
IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true);
|
IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true);
|
||||||
|
|
||||||
|
// [DEBUG] When io.ConfigDebugBeginReturnValue is set, we make Begin() return false at different level of the window stack to validate Begin()/End() behavior in user code.
|
||||||
|
if (g.IO.ConfigDebugBeginReturnValue)
|
||||||
|
{
|
||||||
|
g.DebugBeginReturnValueCullDepth = (g.DebugBeginReturnValueCullDepth == -1) ? 0 : ((g.DebugBeginReturnValueCullDepth + ((g.FrameCount % 4) == 0 ? 1 : 0)) % 10);
|
||||||
|
char buf[64];
|
||||||
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "Cull depth %d", g.DebugBeginReturnValueCullDepth);
|
||||||
|
GetForegroundDrawList()->AddText(ImVec2(0, 0), IM_COL32(255, 255, 0, 255), buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.DebugBeginReturnValueCullDepth = -1;
|
||||||
|
}
|
||||||
|
|
||||||
CallContextHooks(&g, ImGuiContextHookType_NewFramePost);
|
CallContextHooks(&g, ImGuiContextHookType_NewFramePost);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4134,13 +4153,15 @@ void ImGui::UpdateDebugToolItemPicker()
|
|||||||
g.DebugItemPickerActive = false;
|
g.DebugItemPickerActive = false;
|
||||||
}
|
}
|
||||||
ImGui::SetNextWindowBgAlpha(0.60f);
|
ImGui::SetNextWindowBgAlpha(0.60f);
|
||||||
ImGui::BeginTooltip();
|
if (ImGui::BeginTooltip())
|
||||||
|
{
|
||||||
ImGui::Text("HoveredId: 0x%08X", hovered_id);
|
ImGui::Text("HoveredId: 0x%08X", hovered_id);
|
||||||
ImGui::Text("Press ESC to abort picking.");
|
ImGui::Text("Press ESC to abort picking.");
|
||||||
ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
|
ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::Initialize(ImGuiContext* context)
|
void ImGui::Initialize(ImGuiContext* context)
|
||||||
{
|
{
|
||||||
@ -5120,15 +5141,10 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
|
|||||||
bool ret = Begin(title, NULL, flags);
|
bool ret = Begin(title, NULL, flags);
|
||||||
g.Style.ChildBorderSize = backup_border_size;
|
g.Style.ChildBorderSize = backup_border_size;
|
||||||
|
|
||||||
ImGuiWindow* child_window = g.CurrentWindow;
|
ImGuiWindow* child_window = g.LastBeginWindow; // FIXME-NEWBEGIN
|
||||||
child_window->ChildId = id;
|
child_window->ChildId = id;
|
||||||
child_window->AutoFitChildAxises = (ImS8)auto_fit_axises;
|
child_window->AutoFitChildAxises = (ImS8)auto_fit_axises;
|
||||||
|
|
||||||
// Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually.
|
|
||||||
// While this is not really documented/defined, it seems that the expected thing to do.
|
|
||||||
if (child_window->BeginCount == 1)
|
|
||||||
parent_window->DC.CursorPos = child_window->Pos;
|
|
||||||
|
|
||||||
// Process navigation-in immediately so NavInit can run on first frame
|
// Process navigation-in immediately so NavInit can run on first frame
|
||||||
if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll))
|
if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll))
|
||||||
{
|
{
|
||||||
@ -5160,6 +5176,11 @@ void ImGui::EndChild()
|
|||||||
IM_ASSERT(g.WithinEndChild == false);
|
IM_ASSERT(g.WithinEndChild == false);
|
||||||
IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls
|
IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls
|
||||||
|
|
||||||
|
// Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually.
|
||||||
|
// While this is not really documented/defined, it seems that the expected thing to do.
|
||||||
|
if (window->BeginCount == 1)
|
||||||
|
window->ParentWindow->DC.CursorPos = window->Pos;
|
||||||
|
|
||||||
g.WithinEndChild = true;
|
g.WithinEndChild = true;
|
||||||
if (window->BeginCount > 1)
|
if (window->BeginCount > 1)
|
||||||
{
|
{
|
||||||
@ -5981,6 +6002,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
|
// We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
|
||||||
g.CurrentWindowStack.push_back(window);
|
g.CurrentWindowStack.push_back(window);
|
||||||
g.CurrentWindow = window;
|
g.CurrentWindow = window;
|
||||||
|
g.LastBeginWindow = window;
|
||||||
window->DC.StackSizesOnBegin.SetToCurrentState();
|
window->DC.StackSizesOnBegin.SetToCurrentState();
|
||||||
g.CurrentWindow = NULL;
|
g.CurrentWindow = NULL;
|
||||||
|
|
||||||
@ -6740,7 +6762,24 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->SkipItems = skip_items;
|
window->SkipItems = skip_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !window->SkipItems;
|
// FIXME-OPT
|
||||||
|
bool debug_skip = (g.DebugBeginReturnValueCullDepth == g.CurrentWindowStack.Size) && (window->Flags & ImGuiWindowFlags_DockNodeHost) == 0;
|
||||||
|
if (window->SkipItems || debug_skip)
|
||||||
|
{
|
||||||
|
// The implicit fallback is NOT automatically ended as an exception to the rule,
|
||||||
|
// allowing it to always be able to receive commands without crashing.
|
||||||
|
if (window->IsFallbackWindow)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (window->Flags & ImGuiWindowFlags_Popup)
|
||||||
|
EndPopup();
|
||||||
|
else if (window->Flags & ImGuiWindowFlags_ChildWindow)
|
||||||
|
EndChild();
|
||||||
|
else
|
||||||
|
End();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::End()
|
void ImGui::End()
|
||||||
@ -6751,6 +6790,34 @@ void ImGui::End()
|
|||||||
// Error checking: verify that user hasn't called End() too many times!
|
// Error checking: verify that user hasn't called End() too many times!
|
||||||
if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow)
|
if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow)
|
||||||
{
|
{
|
||||||
|
// - IMPORTANT: SINCE 1.XX (XXXX 2020): Only call a matching End() if Begin() returned true!.
|
||||||
|
// - IMPORTANT: BEFORE 1.XX (XXXX 2020): The return value of Begin() was inconsistent with most other BeginXXX()
|
||||||
|
// functions, and would require the user to always call End() even if Begin() returned false.
|
||||||
|
|
||||||
|
// - When transitioning a codebase from < 1.XX to >= 1.XX, code needs to be refactored the following way:
|
||||||
|
// Before ------------------------------------> After
|
||||||
|
// ImGui::Begin("Hello"); if (ImGui::Begin("Hello"))
|
||||||
|
// ImGui::Button("OK"); {
|
||||||
|
// ImGui::End(); ImGui::Button("OK");
|
||||||
|
// ImGui::End();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Before ------------------------------------> After
|
||||||
|
// if (ImGui::Begin("Hello")) if (ImGui::Begin("Hello"))
|
||||||
|
// { {
|
||||||
|
// ImGui::Button("OK"); ImGui::Button("OK");
|
||||||
|
// } ImGui::End();
|
||||||
|
// ImGui::End(); }
|
||||||
|
//
|
||||||
|
// Before ------------------------------------> After
|
||||||
|
// if (!ImGui::Begin("Hello")) if (!ImGui::Begin("Hello"))
|
||||||
|
// { return;
|
||||||
|
// ImGui::End(); ImGui::Button("OK");
|
||||||
|
// return; ImGui::End();
|
||||||
|
// }
|
||||||
|
// ImGui::Button("OK");
|
||||||
|
// ImGui::End();
|
||||||
|
|
||||||
IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size > 1, "Calling End() too many times!");
|
IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size > 1, "Calling End() too many times!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -8475,12 +8542,12 @@ void ImGui::SetScrollHereY(float center_y_ratio)
|
|||||||
// [SECTION] TOOLTIPS
|
// [SECTION] TOOLTIPS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ImGui::BeginTooltip()
|
bool ImGui::BeginTooltip()
|
||||||
{
|
{
|
||||||
BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None);
|
return BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags)
|
bool ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
@ -8509,7 +8576,11 @@ void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags toolt
|
|||||||
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
|
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
|
||||||
}
|
}
|
||||||
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking;
|
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking;
|
||||||
Begin(window_name, NULL, flags | extra_flags);
|
bool ret = Begin(window_name, NULL, flags | extra_flags);
|
||||||
|
// FIXME-NEWBEGIN: adding a bool to API...
|
||||||
|
//IM_UNUSED(ret);
|
||||||
|
//IM_ASSERT(ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::EndTooltip()
|
void ImGui::EndTooltip()
|
||||||
@ -8520,7 +8591,8 @@ void ImGui::EndTooltip()
|
|||||||
|
|
||||||
void ImGui::SetTooltipV(const char* fmt, va_list args)
|
void ImGui::SetTooltipV(const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip);
|
if (!BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip))
|
||||||
|
return;
|
||||||
TextV(fmt, args);
|
TextV(fmt, args);
|
||||||
EndTooltip();
|
EndTooltip();
|
||||||
}
|
}
|
||||||
@ -8765,11 +8837,9 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
|||||||
else
|
else
|
||||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
|
ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
|
||||||
|
|
||||||
|
// NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
|
||||||
flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoDocking;
|
flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoDocking;
|
||||||
bool is_open = Begin(name, NULL, flags);
|
bool is_open = Begin(name, NULL, flags);
|
||||||
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
|
|
||||||
EndPopup();
|
|
||||||
|
|
||||||
return is_open;
|
return is_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8811,9 +8881,11 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
|
|||||||
const bool is_open = Begin(name, p_open, flags);
|
const bool is_open = Begin(name, p_open, flags);
|
||||||
if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||||
{
|
{
|
||||||
EndPopup();
|
|
||||||
if (is_open)
|
if (is_open)
|
||||||
|
{
|
||||||
|
EndPopup();
|
||||||
ClosePopupToLevel(g.BeginPopupStack.Size, true);
|
ClosePopupToLevel(g.BeginPopupStack.Size, true);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return is_open;
|
return is_open;
|
||||||
@ -10188,7 +10260,10 @@ void ImGui::NavUpdateWindowingOverlay()
|
|||||||
SetNextWindowSizeConstraints(ImVec2(viewport->Size.x * 0.20f, viewport->Size.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX));
|
SetNextWindowSizeConstraints(ImVec2(viewport->Size.x * 0.20f, viewport->Size.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX));
|
||||||
SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||||
PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
|
PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
|
||||||
Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
|
bool ret = Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
|
||||||
|
PopStyleVar();
|
||||||
|
if (!ret)
|
||||||
|
return;
|
||||||
for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)
|
for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.WindowsFocusOrder[n];
|
ImGuiWindow* window = g.WindowsFocusOrder[n];
|
||||||
@ -10200,7 +10275,6 @@ void ImGui::NavUpdateWindowingOverlay()
|
|||||||
Selectable(label, g.NavWindowingTarget == window);
|
Selectable(label, g.NavWindowingTarget == window);
|
||||||
}
|
}
|
||||||
End();
|
End();
|
||||||
PopStyleVar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -10312,7 +10386,9 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|||||||
{
|
{
|
||||||
// Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
|
// Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
|
||||||
// We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
|
// We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
|
||||||
BeginTooltip();
|
bool ret = BeginTooltip(); // FIXME-NEWBEGIN: problematic
|
||||||
|
IM_UNUSED(ret);
|
||||||
|
IM_ASSERT(ret);
|
||||||
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
|
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
|
||||||
{
|
{
|
||||||
ImGuiWindow* tooltip_window = g.CurrentWindow;
|
ImGuiWindow* tooltip_window = g.CurrentWindow;
|
||||||
@ -13201,8 +13277,10 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
|
|||||||
window_flags |= ImGuiWindowFlags_NoTitleBar;
|
window_flags |= ImGuiWindowFlags_NoTitleBar;
|
||||||
|
|
||||||
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||||
Begin(window_label, NULL, window_flags);
|
bool ret = Begin(window_label, NULL, window_flags);
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
|
IM_UNUSED(ret);
|
||||||
|
IM_ASSERT(ret); // FIXME-NEWBEGIN
|
||||||
beginned_into_host_window = true;
|
beginned_into_host_window = true;
|
||||||
|
|
||||||
node->HostWindow = host_window = g.CurrentWindow;
|
node->HostWindow = host_window = g.CurrentWindow;
|
||||||
@ -13385,7 +13463,8 @@ bool ImGui::DockNodeBeginAmendTabBar(ImGuiDockNode* node)
|
|||||||
return false;
|
return false;
|
||||||
if (node->SharedFlags & ImGuiDockNodeFlags_KeepAliveOnly)
|
if (node->SharedFlags & ImGuiDockNodeFlags_KeepAliveOnly)
|
||||||
return false;
|
return false;
|
||||||
Begin(node->HostWindow->Name);
|
if (!Begin(node->HostWindow->Name))
|
||||||
|
return false;
|
||||||
PushOverrideID(node->ID);
|
PushOverrideID(node->ID);
|
||||||
bool ret = BeginTabBarEx(node->TabBar, node->TabBar->BarRect, node->TabBar->Flags, node);
|
bool ret = BeginTabBarEx(node->TabBar, node->TabBar->BarRect, node->TabBar->Flags, node);
|
||||||
IM_ASSERT(ret);
|
IM_ASSERT(ret);
|
||||||
@ -14472,10 +14551,12 @@ void ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags fla
|
|||||||
if (node->Windows.Size > 0 || node->IsSplitNode())
|
if (node->Windows.Size > 0 || node->IsSplitNode())
|
||||||
PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 0, 0));
|
PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 0, 0));
|
||||||
PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f);
|
PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f);
|
||||||
Begin(title, NULL, window_flags);
|
bool ret = Begin(title, NULL, window_flags);
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
if (node->Windows.Size > 0 || node->IsSplitNode())
|
if (node->Windows.Size > 0 || node->IsSplitNode())
|
||||||
PopStyleColor();
|
PopStyleColor();
|
||||||
|
if (!ret)
|
||||||
|
return; // FIXME-NEWBEGIN
|
||||||
|
|
||||||
ImGuiWindow* host_window = g.CurrentWindow;
|
ImGuiWindow* host_window = g.CurrentWindow;
|
||||||
host_window->DockNodeAsHost = node;
|
host_window->DockNodeAsHost = node;
|
||||||
@ -14526,12 +14607,16 @@ ImGuiID ImGui::DockSpaceOverViewport(ImGuiViewport* viewport, ImGuiDockNodeFlags
|
|||||||
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||||
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
Begin(label, NULL, host_window_flags);
|
bool ret = Begin(label, NULL, host_window_flags);
|
||||||
PopStyleVar(3);
|
PopStyleVar(3);
|
||||||
|
|
||||||
ImGuiID dockspace_id = GetID("DockSpace");
|
ImGuiID dockspace_id = GetID("DockSpace");
|
||||||
|
|
||||||
|
// FIXME-NEWBEGIN: KeepAlive if not visible?
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags, window_class);
|
DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags, window_class);
|
||||||
End();
|
End();
|
||||||
|
}
|
||||||
|
|
||||||
return dockspace_id;
|
return dockspace_id;
|
||||||
}
|
}
|
||||||
@ -15667,9 +15752,8 @@ static void RenderViewportsThumbnails()
|
|||||||
static void MetricsHelpMarker(const char* desc)
|
static void MetricsHelpMarker(const char* desc)
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled("(?)");
|
ImGui::TextDisabled("(?)");
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && ImGui::BeginTooltip())
|
||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
|
||||||
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
|
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
|
||||||
ImGui::TextUnformatted(desc);
|
ImGui::TextUnformatted(desc);
|
||||||
ImGui::PopTextWrapPos();
|
ImGui::PopTextWrapPos();
|
||||||
@ -15680,10 +15764,7 @@ static void MetricsHelpMarker(const char* desc)
|
|||||||
void ImGui::ShowMetricsWindow(bool* p_open)
|
void ImGui::ShowMetricsWindow(bool* p_open)
|
||||||
{
|
{
|
||||||
if (!Begin("Dear ImGui Metrics/Debugger", p_open))
|
if (!Begin("Dear ImGui Metrics/Debugger", p_open))
|
||||||
{
|
|
||||||
End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiIO& io = g.IO;
|
ImGuiIO& io = g.IO;
|
||||||
|
41
imgui.h
41
imgui.h
@ -68,6 +68,9 @@ Index of this file:
|
|||||||
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
||||||
#define IMGUI_HAS_DOCK 1 // Docking WIP branch
|
#define IMGUI_HAS_DOCK 1 // Docking WIP branch
|
||||||
|
|
||||||
|
// Features
|
||||||
|
#define IMGUI_HAS_NEWBEGIN 1
|
||||||
|
|
||||||
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
||||||
// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default backends files (imgui_impl_xxx.h)
|
// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default backends files (imgui_impl_xxx.h)
|
||||||
// Using dear imgui via a shared library is not recommended, because we don't guarantee backward nor forward ABI compatibility (also function call overhead, as dear imgui is a call-heavy API)
|
// Using dear imgui via a shared library is not recommended, because we don't guarantee backward nor forward ABI compatibility (also function call overhead, as dear imgui is a call-heavy API)
|
||||||
@ -101,6 +104,16 @@ Index of this file:
|
|||||||
#define IM_FMTLIST(FMT)
|
#define IM_FMTLIST(FMT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (__cplusplus >= 201703)
|
||||||
|
#define IM_NODISCARD [[nodiscard]]
|
||||||
|
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
|
#define IM_NODISCARD __attribute__ ((warn_unused_result))
|
||||||
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1700)
|
||||||
|
#define IM_NODISCARD _Check_return_
|
||||||
|
#else
|
||||||
|
#define IM_NODISCARD
|
||||||
|
#endif
|
||||||
|
|
||||||
// Warnings
|
// Warnings
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
@ -297,24 +310,23 @@ namespace ImGui
|
|||||||
// - You may append multiple times to the same window during the same frame by calling Begin()/End() pairs multiple times.
|
// - You may append multiple times to the same window during the same frame by calling Begin()/End() pairs multiple times.
|
||||||
// Some information such as 'flags' or 'p_open' will only be considered by the first call to Begin().
|
// Some information such as 'flags' or 'p_open' will only be considered by the first call to Begin().
|
||||||
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
|
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
|
||||||
// anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
|
// anything to the window.
|
||||||
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
|
// - IMPORTANT: SINCE 1.XX (XXXX 2020): Only call a matching End() if Begin() returned true!.
|
||||||
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
|
// - IMPORTANT: BEFORE 1.XX (XXXX 2020): The return value of Begin() was inconsistent with most other BeginXXX()
|
||||||
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
|
// functions, and would require the user to always call End() even if Begin() returned false.
|
||||||
// - Note that the bottom of window stack always contains a window called "Debug".
|
// - Note that the bottom of window stack always contains a window called "Debug".
|
||||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
|
IM_NODISCARD IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
|
||||||
IMGUI_API void End();
|
IMGUI_API void End();
|
||||||
|
|
||||||
// Child Windows
|
// Child Windows
|
||||||
// - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
|
// - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
|
||||||
// - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
|
// - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
|
||||||
// - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
|
// - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
|
||||||
// Always call a matching EndChild() for each BeginChild() call, regardless of its return value.
|
// - IMPORTANT: SINCE 1.XX (XXXX 2020): Only call a matching EndChild() if BeginChild() returned true!.
|
||||||
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
|
// - IMPORTANT: BEFORE 1.XX (XXXX 2020): The return value of BeginChild() was inconsistent with most other BeginXXX()
|
||||||
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
|
// functions, and would require the user to always call EndChild() even if BeginChild() returned false. This has been changed.
|
||||||
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
|
IM_NODISCARD IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
IM_NODISCARD IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
|
||||||
IMGUI_API void EndChild();
|
IMGUI_API void EndChild();
|
||||||
|
|
||||||
// Windows Utilities
|
// Windows Utilities
|
||||||
@ -622,7 +634,7 @@ namespace ImGui
|
|||||||
|
|
||||||
// Tooltips
|
// Tooltips
|
||||||
// - Tooltip are windows following the mouse which do not take focus away.
|
// - Tooltip are windows following the mouse which do not take focus away.
|
||||||
IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items).
|
IMGUI_API bool BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items).
|
||||||
IMGUI_API void EndTooltip();
|
IMGUI_API void EndTooltip();
|
||||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip().
|
IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip().
|
||||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
|
IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||||
@ -822,7 +834,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
|
IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
|
||||||
IMGUI_API ImGuiStorage* GetStateStorage();
|
IMGUI_API ImGuiStorage* GetStateStorage();
|
||||||
IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can.
|
IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can.
|
||||||
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame
|
IM_NODISCARD IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame
|
||||||
IMGUI_API void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window)
|
IMGUI_API void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window)
|
||||||
|
|
||||||
// Text Utilities
|
// Text Utilities
|
||||||
@ -1821,6 +1833,9 @@ struct ImGuiIO
|
|||||||
bool ConfigWindowsMoveFromTitleBarOnly; // = false // [BETA] Set to true to only allow moving windows when clicked+dragged from the title bar. Windows without a title bar are not affected.
|
bool ConfigWindowsMoveFromTitleBarOnly; // = false // [BETA] Set to true to only allow moving windows when clicked+dragged from the title bar. Windows without a title bar are not affected.
|
||||||
float ConfigMemoryCompactTimer; // = 60.0f // [BETA] Free transient windows/tables memory buffers when unused for given amount of time. Set to -1.0f to disable.
|
float ConfigMemoryCompactTimer; // = 60.0f // [BETA] Free transient windows/tables memory buffers when unused for given amount of time. Set to -1.0f to disable.
|
||||||
|
|
||||||
|
// Debug options
|
||||||
|
bool ConfigDebugBeginReturnValue; // = false // When set, some calls to Begin() will return false to facilitate testing and transitioning to 1.78 Begin()/End() pairing behavior. Will cycle through each unique window depth then repeat. Suggested use: add "io.ConfigDebugBeginReturnValue = io.KeyShift" in your main loop then occasionally press SHIFT. Windows should be flickering. Your code will assert in End() if calling End() incorrectly.
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Platform Functions
|
// Platform Functions
|
||||||
// (the imgui_impl_xxxx backend files are setting those up for you)
|
// (the imgui_impl_xxxx backend files are setting those up for you)
|
||||||
|
219
imgui_demo.cpp
219
imgui_demo.cpp
@ -179,9 +179,8 @@ static void ShowExampleMenuFile();
|
|||||||
static void HelpMarker(const char* desc)
|
static void HelpMarker(const char* desc)
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled("(?)");
|
ImGui::TextDisabled("(?)");
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && ImGui::BeginTooltip())
|
||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
|
||||||
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
|
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
|
||||||
ImGui::TextUnformatted(desc);
|
ImGui::TextUnformatted(desc);
|
||||||
ImGui::PopTextWrapPos();
|
ImGui::PopTextWrapPos();
|
||||||
@ -300,10 +299,12 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); }
|
if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); }
|
||||||
if (show_app_style_editor)
|
if (show_app_style_editor)
|
||||||
{
|
{
|
||||||
ImGui::Begin("Dear ImGui Style Editor", &show_app_style_editor);
|
if (ImGui::Begin("Dear ImGui Style Editor", &show_app_style_editor))
|
||||||
|
{
|
||||||
ImGui::ShowStyleEditor();
|
ImGui::ShowStyleEditor();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Demonstrate the various window flags. Typically you would just use the default!
|
// Demonstrate the various window flags. Typically you would just use the default!
|
||||||
static bool no_titlebar = false;
|
static bool no_titlebar = false;
|
||||||
@ -339,11 +340,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
|
|
||||||
// Main body of the Demo window starts here.
|
// Main body of the Demo window starts here.
|
||||||
if (!ImGui::Begin("Dear ImGui Demo", p_open, window_flags))
|
if (!ImGui::Begin("Dear ImGui Demo", p_open, window_flags))
|
||||||
{
|
|
||||||
// Early out if the window is collapsed, as an optimization.
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Most "big" widgets share a common width settings by default. See 'Demo->Layout->Widgets Width' for details.
|
// Most "big" widgets share a common width settings by default. See 'Demo->Layout->Widgets Width' for details.
|
||||||
|
|
||||||
@ -623,9 +620,8 @@ static void ShowDemoWindowWidgets()
|
|||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text("- or me");
|
ImGui::Text("- or me");
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && ImGui::BeginTooltip())
|
||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
|
||||||
ImGui::Text("I am a fancy tooltip");
|
ImGui::Text("I am a fancy tooltip");
|
||||||
static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
|
static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
|
||||||
ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr));
|
ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr));
|
||||||
@ -1008,9 +1004,8 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
|
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
|
||||||
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); // 50% opaque white
|
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); // 50% opaque white
|
||||||
ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col);
|
ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col);
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && ImGui::BeginTooltip())
|
||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
|
||||||
float region_sz = 32.0f;
|
float region_sz = 32.0f;
|
||||||
float region_x = io.MousePos.x - pos.x - region_sz * 0.5f;
|
float region_x = io.MousePos.x - pos.x - region_sz * 0.5f;
|
||||||
float region_y = io.MousePos.y - pos.y - region_sz * 0.5f;
|
float region_y = io.MousePos.y - pos.y - region_sz * 0.5f;
|
||||||
@ -2109,9 +2104,12 @@ static void ShowDemoWindowWidgets()
|
|||||||
|
|
||||||
static bool embed_all_inside_a_child_window = false;
|
static bool embed_all_inside_a_child_window = false;
|
||||||
ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window);
|
ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window);
|
||||||
|
bool visible = true;
|
||||||
if (embed_all_inside_a_child_window)
|
if (embed_all_inside_a_child_window)
|
||||||
ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20.0f), true);
|
visible = ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20.0f), true);
|
||||||
|
|
||||||
|
if (visible)
|
||||||
|
{
|
||||||
// Testing IsWindowFocused() function with its various flags.
|
// Testing IsWindowFocused() function with its various flags.
|
||||||
// Note that the ImGuiFocusedFlags_XXX flags can be combined.
|
// Note that the ImGuiFocusedFlags_XXX flags can be combined.
|
||||||
ImGui::BulletText(
|
ImGui::BulletText(
|
||||||
@ -2146,11 +2144,14 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow));
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow));
|
||||||
|
|
||||||
ImGui::BeginChild("child", ImVec2(0, 50), true);
|
if (ImGui::BeginChild("child", ImVec2(0, 50), true))
|
||||||
|
{
|
||||||
ImGui::Text("This is another child window for testing the _ChildWindows flag.");
|
ImGui::Text("This is another child window for testing the _ChildWindows flag.");
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
if (embed_all_inside_a_child_window)
|
if (embed_all_inside_a_child_window)
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
static char unused_str[] = "This widget is only here to be able to tab-out of the widgets above.";
|
static char unused_str[] = "This widget is only here to be able to tab-out of the widgets above.";
|
||||||
ImGui::InputText("unused", unused_str, IM_ARRAYSIZE(unused_str), ImGuiInputTextFlags_ReadOnly);
|
ImGui::InputText("unused", unused_str, IM_ARRAYSIZE(unused_str), ImGuiInputTextFlags_ReadOnly);
|
||||||
@ -2159,12 +2160,11 @@ static void ShowDemoWindowWidgets()
|
|||||||
// This is useful in particular if you want to create a context menu associated to the title bar of a window.
|
// This is useful in particular if you want to create a context menu associated to the title bar of a window.
|
||||||
// This will also work when docked into a Tab (the Tab replace the Title Bar and guarantee the same properties).
|
// This will also work when docked into a Tab (the Tab replace the Title Bar and guarantee the same properties).
|
||||||
static bool test_window = false;
|
static bool test_window = false;
|
||||||
ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
|
|
||||||
if (test_window)
|
|
||||||
{
|
|
||||||
// FIXME-DOCK: This window cannot be docked within the ImGui Demo window, this will cause a feedback loop and get them stuck.
|
// FIXME-DOCK: This window cannot be docked within the ImGui Demo window, this will cause a feedback loop and get them stuck.
|
||||||
// Could we fix this through an ImGuiWindowClass feature? Or an API call to tag our parent as "don't skip items"?
|
// Could we fix this through an ImGuiWindowClass feature? Or an API call to tag our parent as "don't skip items"?
|
||||||
ImGui::Begin("Title bar Hovered/Active tests", &test_window);
|
ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
|
||||||
|
if (test_window && ImGui::Begin("Title bar Hovered/Active tests", &test_window))
|
||||||
|
{
|
||||||
if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
|
if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem("Close")) { test_window = false; }
|
if (ImGui::MenuItem("Close")) { test_window = false; }
|
||||||
@ -2199,11 +2199,13 @@ static void ShowDemoWindowLayout()
|
|||||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar;
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar;
|
||||||
if (disable_mouse_wheel)
|
if (disable_mouse_wheel)
|
||||||
window_flags |= ImGuiWindowFlags_NoScrollWithMouse;
|
window_flags |= ImGuiWindowFlags_NoScrollWithMouse;
|
||||||
ImGui::BeginChild("ChildL", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
|
if (ImGui::BeginChild("ChildL", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags))
|
||||||
|
{
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
ImGui::Text("%04d: scrollable region", i);
|
ImGui::Text("%04d: scrollable region", i);
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
@ -2215,7 +2217,10 @@ static void ShowDemoWindowLayout()
|
|||||||
if (!disable_menu)
|
if (!disable_menu)
|
||||||
window_flags |= ImGuiWindowFlags_MenuBar;
|
window_flags |= ImGuiWindowFlags_MenuBar;
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
|
||||||
ImGui::BeginChild("ChildR", ImVec2(0, 260), true, window_flags);
|
bool visible = ImGui::BeginChild("ChildR", ImVec2(0, 260), true, window_flags);
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
if (visible)
|
||||||
|
{
|
||||||
if (!disable_menu && ImGui::BeginMenuBar())
|
if (!disable_menu && ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenu("Menu"))
|
if (ImGui::BeginMenu("Menu"))
|
||||||
@ -2237,7 +2242,7 @@ static void ShowDemoWindowLayout()
|
|||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::PopStyleVar();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@ -2256,14 +2261,17 @@ static void ShowDemoWindowLayout()
|
|||||||
|
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)offset_x);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)offset_x);
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100));
|
||||||
ImGui::BeginChild("Red", ImVec2(200, 100), true, ImGuiWindowFlags_None);
|
bool visible = ImGui::BeginChild("Red", ImVec2(200, 100), true, ImGuiWindowFlags_None);
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
if (visible)
|
||||||
|
{
|
||||||
for (int n = 0; n < 50; n++)
|
for (int n = 0; n < 50; n++)
|
||||||
ImGui::Text("Some test %d", n);
|
ImGui::Text("Some test %d", n);
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
bool child_is_hovered = ImGui::IsItemHovered();
|
bool child_is_hovered = ImGui::IsItemHovered();
|
||||||
ImVec2 child_rect_min = ImGui::GetItemRectMin();
|
ImVec2 child_rect_min = ImGui::GetItemRectMin();
|
||||||
ImVec2 child_rect_max = ImGui::GetItemRectMax();
|
ImVec2 child_rect_max = ImGui::GetItemRectMax();
|
||||||
ImGui::PopStyleColor();
|
|
||||||
ImGui::Text("Hovered: %d", child_is_hovered);
|
ImGui::Text("Hovered: %d", child_is_hovered);
|
||||||
ImGui::Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y);
|
ImGui::Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y);
|
||||||
}
|
}
|
||||||
@ -2780,7 +2788,8 @@ static void ShowDemoWindowLayout()
|
|||||||
|
|
||||||
const ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0;
|
const ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0;
|
||||||
const ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i);
|
const ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i);
|
||||||
const bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(child_w, 200.0f), true, child_flags);
|
if (ImGui::BeginChild(child_id, ImVec2(child_w, 200.0f), true, child_flags))
|
||||||
|
{
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
ImGui::TextUnformatted("abc");
|
ImGui::TextUnformatted("abc");
|
||||||
@ -2790,8 +2799,6 @@ static void ShowDemoWindowLayout()
|
|||||||
ImGui::SetScrollY(scroll_to_off_px);
|
ImGui::SetScrollY(scroll_to_off_px);
|
||||||
if (scroll_to_pos)
|
if (scroll_to_pos)
|
||||||
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
|
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
|
||||||
if (child_is_visible) // Avoid calling SetScrollHereY when running with culled items
|
|
||||||
{
|
|
||||||
for (int item = 0; item < 100; item++)
|
for (int item = 0; item < 100; item++)
|
||||||
{
|
{
|
||||||
if (enable_track && item == track_item)
|
if (enable_track && item == track_item)
|
||||||
@ -2804,11 +2811,15 @@ static void ShowDemoWindowLayout()
|
|||||||
ImGui::Text("Item %d", item);
|
ImGui::Text("Item %d", item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
float scroll_y = ImGui::GetScrollY();
|
float scroll_y = ImGui::GetScrollY();
|
||||||
float scroll_max_y = ImGui::GetScrollMaxY();
|
float scroll_max_y = ImGui::GetScrollMaxY();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::Text("%.0f/%.0f", scroll_y, scroll_max_y);
|
ImGui::Text("%.0f/%.0f", scroll_y, scroll_max_y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::Text("N/A");
|
||||||
|
}
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
@ -2826,13 +2837,14 @@ static void ShowDemoWindowLayout()
|
|||||||
float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
|
float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
|
||||||
ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0);
|
ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0);
|
||||||
ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i);
|
ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i);
|
||||||
bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(-100, child_height), true, child_flags);
|
float scroll_x = 0.0f;
|
||||||
|
float scroll_max_x = 0.0f;
|
||||||
|
if (ImGui::BeginChild(child_id, ImVec2(-100, child_height), true, child_flags))
|
||||||
|
{
|
||||||
if (scroll_to_off)
|
if (scroll_to_off)
|
||||||
ImGui::SetScrollX(scroll_to_off_px);
|
ImGui::SetScrollX(scroll_to_off_px);
|
||||||
if (scroll_to_pos)
|
if (scroll_to_pos)
|
||||||
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
|
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
|
||||||
if (child_is_visible) // Avoid calling SetScrollHereY when running with culled items
|
|
||||||
{
|
|
||||||
for (int item = 0; item < 100; item++)
|
for (int item = 0; item < 100; item++)
|
||||||
{
|
{
|
||||||
if (enable_track && item == track_item)
|
if (enable_track && item == track_item)
|
||||||
@ -2846,10 +2858,10 @@ static void ShowDemoWindowLayout()
|
|||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
}
|
scroll_x = ImGui::GetScrollX();
|
||||||
float scroll_x = ImGui::GetScrollX();
|
scroll_max_x = ImGui::GetScrollMaxX();
|
||||||
float scroll_max_x = ImGui::GetScrollMaxX();
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
const char* names[] = { "Left", "25%", "Center", "75%", "Right" };
|
const char* names[] = { "Left", "25%", "Center", "75%", "Right" };
|
||||||
ImGui::Text("%s\n%.0f/%.0f", names[i], scroll_x, scroll_max_x);
|
ImGui::Text("%s\n%.0f/%.0f", names[i], scroll_x, scroll_max_x);
|
||||||
@ -2866,7 +2878,10 @@ static void ShowDemoWindowLayout()
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f));
|
||||||
ImVec2 scrolling_child_size = ImVec2(0, ImGui::GetFrameHeightWithSpacing() * 7 + 30);
|
ImVec2 scrolling_child_size = ImVec2(0, ImGui::GetFrameHeightWithSpacing() * 7 + 30);
|
||||||
ImGui::BeginChild("scrolling", scrolling_child_size, true, ImGuiWindowFlags_HorizontalScrollbar);
|
float scroll_x = 0.0f;
|
||||||
|
float scroll_max_x = 0.0f;
|
||||||
|
if (ImGui::BeginChild("scrolling", scrolling_child_size, true, ImGuiWindowFlags_HorizontalScrollbar))
|
||||||
|
{
|
||||||
for (int line = 0; line < lines; line++)
|
for (int line = 0; line < lines; line++)
|
||||||
{
|
{
|
||||||
// Display random stuff. For the sake of this trivial demo we are using basic Button() + SameLine()
|
// Display random stuff. For the sake of this trivial demo we are using basic Button() + SameLine()
|
||||||
@ -2890,9 +2905,10 @@ static void ShowDemoWindowLayout()
|
|||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float scroll_x = ImGui::GetScrollX();
|
scroll_x = ImGui::GetScrollX();
|
||||||
float scroll_max_x = ImGui::GetScrollMaxX();
|
scroll_max_x = ImGui::GetScrollMaxX();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
ImGui::PopStyleVar(2);
|
ImGui::PopStyleVar(2);
|
||||||
float scroll_x_delta = 0.0f;
|
float scroll_x_delta = 0.0f;
|
||||||
ImGui::SmallButton("<<");
|
ImGui::SmallButton("<<");
|
||||||
@ -2909,10 +2925,13 @@ static void ShowDemoWindowLayout()
|
|||||||
{
|
{
|
||||||
// Demonstrate a trick: you can use Begin to set yourself in the context of another window
|
// 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)
|
// (here we are already out of your child window)
|
||||||
ImGui::BeginChild("scrolling");
|
// FIXME-NEWBEGIN: Becomes more awkward
|
||||||
|
if (ImGui::BeginChild("scrolling"))
|
||||||
|
{
|
||||||
ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta);
|
ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta);
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
static bool show_horizontal_contents_size_demo_window = false;
|
static bool show_horizontal_contents_size_demo_window = false;
|
||||||
@ -2931,7 +2950,8 @@ static void ShowDemoWindowLayout()
|
|||||||
static float contents_size_x = 300.0f;
|
static float contents_size_x = 300.0f;
|
||||||
if (explicit_content_size)
|
if (explicit_content_size)
|
||||||
ImGui::SetNextWindowContentSize(ImVec2(contents_size_x, 0.0f));
|
ImGui::SetNextWindowContentSize(ImVec2(contents_size_x, 0.0f));
|
||||||
ImGui::Begin("Horizontal contents size demo window", &show_horizontal_contents_size_demo_window, show_h_scrollbar ? ImGuiWindowFlags_HorizontalScrollbar : 0);
|
if (ImGui::Begin("Horizontal contents size demo window", &show_horizontal_contents_size_demo_window, show_h_scrollbar ? ImGuiWindowFlags_HorizontalScrollbar : 0))
|
||||||
|
{
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 0));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 0));
|
||||||
HelpMarker("Test of different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\nUse 'Metrics->Tools->Show windows rectangles' to visualize rectangles.");
|
HelpMarker("Test of different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\nUse 'Metrics->Tools->Show windows rectangles' to visualize rectangles.");
|
||||||
@ -3009,11 +3029,12 @@ static void ShowDemoWindowLayout()
|
|||||||
}
|
}
|
||||||
if (show_child)
|
if (show_child)
|
||||||
{
|
{
|
||||||
ImGui::BeginChild("child", ImVec2(0, 0), true);
|
if (ImGui::BeginChild("child", ImVec2(0, 0), true))
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
@ -5147,10 +5168,10 @@ static void ShowDemoWindowColumns()
|
|||||||
{
|
{
|
||||||
ImGui::SetNextWindowContentSize(ImVec2(1500.0f, 0.0f));
|
ImGui::SetNextWindowContentSize(ImVec2(1500.0f, 0.0f));
|
||||||
ImVec2 child_size = ImVec2(0, ImGui::GetFontSize() * 20.0f);
|
ImVec2 child_size = ImVec2(0, ImGui::GetFontSize() * 20.0f);
|
||||||
ImGui::BeginChild("##ScrollingRegion", child_size, false, ImGuiWindowFlags_HorizontalScrollbar);
|
if (ImGui::BeginChild("##ScrollingRegion", child_size, false, ImGuiWindowFlags_HorizontalScrollbar))
|
||||||
ImGui::Columns(10);
|
{
|
||||||
|
|
||||||
// Also demonstrate using clipper for large vertical lists
|
// Also demonstrate using clipper for large vertical lists
|
||||||
|
ImGui::Columns(10);
|
||||||
int ITEMS_COUNT = 2000;
|
int ITEMS_COUNT = 2000;
|
||||||
ImGuiListClipper clipper;
|
ImGuiListClipper clipper;
|
||||||
clipper.Begin(ITEMS_COUNT);
|
clipper.Begin(ITEMS_COUNT);
|
||||||
@ -5165,6 +5186,7 @@ static void ShowDemoWindowColumns()
|
|||||||
}
|
}
|
||||||
ImGui::Columns(1);
|
ImGui::Columns(1);
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5388,10 +5410,8 @@ static void ShowDemoWindowMisc()
|
|||||||
void ImGui::ShowAboutWindow(bool* p_open)
|
void ImGui::ShowAboutWindow(bool* p_open)
|
||||||
{
|
{
|
||||||
if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize))
|
if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize))
|
||||||
{
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
|
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("By Omar Cornut and all Dear ImGui contributors.");
|
ImGui::Text("By Omar Cornut and all Dear ImGui contributors.");
|
||||||
@ -5399,14 +5419,13 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
|
|
||||||
static bool show_config_info = false;
|
static bool show_config_info = false;
|
||||||
ImGui::Checkbox("Config/Build Information", &show_config_info);
|
ImGui::Checkbox("Config/Build Information", &show_config_info);
|
||||||
if (show_config_info)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
const bool copy_to_clipboard = show_config_info && ImGui::Button("Copy to clipboard");
|
||||||
bool copy_to_clipboard = ImGui::Button("Copy to clipboard");
|
const ImVec2 child_size = ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18);
|
||||||
ImVec2 child_size = ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18);
|
if (show_config_info && ImGui::BeginChildFrame(ImGui::GetID("cfg_infos"), child_size, ImGuiWindowFlags_NoMove))
|
||||||
ImGui::BeginChildFrame(ImGui::GetID("cfg_infos"), child_size, ImGuiWindowFlags_NoMove);
|
{
|
||||||
if (copy_to_clipboard)
|
if (copy_to_clipboard)
|
||||||
{
|
{
|
||||||
ImGui::LogToClipboard();
|
ImGui::LogToClipboard();
|
||||||
@ -5660,9 +5679,8 @@ static void NodeFont(ImFont* font)
|
|||||||
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
|
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
|
||||||
if (glyph)
|
if (glyph)
|
||||||
font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
|
font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
|
||||||
if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
|
if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2) && ImGui::BeginTooltip())
|
||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
|
||||||
ImGui::Text("Codepoint: U+%04X", base + n);
|
ImGui::Text("Codepoint: U+%04X", base + n);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("Visible: %d", glyph->Visible);
|
ImGui::Text("Visible: %d", glyph->Visible);
|
||||||
@ -5804,7 +5822,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
"Left-click on color square to open color picker,\n"
|
"Left-click on color square to open color picker,\n"
|
||||||
"Right-click to open edit options menu.");
|
"Right-click to open edit options menu.");
|
||||||
|
|
||||||
ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened);
|
if (ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened))
|
||||||
|
{
|
||||||
ImGui::PushItemWidth(-160);
|
ImGui::PushItemWidth(-160);
|
||||||
for (int i = 0; i < ImGuiCol_COUNT; i++)
|
for (int i = 0; i < ImGuiCol_COUNT; i++)
|
||||||
{
|
{
|
||||||
@ -5827,6 +5846,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
}
|
}
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
@ -5890,7 +5910,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
if (ImGui::IsItemActive())
|
if (ImGui::IsItemActive())
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos());
|
ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos());
|
||||||
ImGui::BeginTooltip();
|
if (ImGui::BeginTooltip())
|
||||||
|
{
|
||||||
ImVec2 p = ImGui::GetCursorScreenPos();
|
ImVec2 p = ImGui::GetCursorScreenPos();
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
float RAD_MIN = 10.0f, RAD_MAX = 80.0f;
|
float RAD_MIN = 10.0f, RAD_MAX = 80.0f;
|
||||||
@ -5904,6 +5925,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGui::Dummy(ImVec2(off_x, RAD_MAX * 2.0f));
|
ImGui::Dummy(ImVec2(off_x, RAD_MAX * 2.0f));
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
HelpMarker("When drawing circle primitives with \"num_segments == 0\" tesselation will be calculated automatically.");
|
HelpMarker("When drawing circle primitives with \"num_segments == 0\" tesselation will be calculated automatically.");
|
||||||
|
|
||||||
@ -5986,10 +6008,12 @@ static void ShowExampleMenuFile()
|
|||||||
{
|
{
|
||||||
static bool enabled = true;
|
static bool enabled = true;
|
||||||
ImGui::MenuItem("Enabled", "", &enabled);
|
ImGui::MenuItem("Enabled", "", &enabled);
|
||||||
ImGui::BeginChild("child", ImVec2(0, 60), true);
|
if (ImGui::BeginChild("child", ImVec2(0, 60), true))
|
||||||
|
{
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
ImGui::Text("Scrolling Text %d", i);
|
ImGui::Text("Scrolling Text %d", i);
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
static float f = 0.5f;
|
static float f = 0.5f;
|
||||||
static int n = 0;
|
static int n = 0;
|
||||||
ImGui::SliderFloat("Value", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("Value", &f, 0.0f, 1.0f);
|
||||||
@ -6099,10 +6123,7 @@ struct ExampleAppConsole
|
|||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
|
||||||
if (!ImGui::Begin(title, p_open))
|
if (!ImGui::Begin(title, p_open))
|
||||||
{
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar.
|
// As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar.
|
||||||
// So e.g. IsItemHovered() will return true when hovering the title bar.
|
// So e.g. IsItemHovered() will return true when hovering the title bar.
|
||||||
@ -6148,7 +6169,8 @@ struct ExampleAppConsole
|
|||||||
|
|
||||||
// Reserve enough left-over height for 1 separator + 1 input text
|
// Reserve enough left-over height for 1 separator + 1 input text
|
||||||
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
||||||
ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar);
|
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar))
|
||||||
|
{
|
||||||
if (ImGui::BeginPopupContextWindow())
|
if (ImGui::BeginPopupContextWindow())
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable("Clear")) ClearLog();
|
if (ImGui::Selectable("Clear")) ClearLog();
|
||||||
@ -6209,6 +6231,7 @@ struct ExampleAppConsole
|
|||||||
|
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
// Command-line
|
// Command-line
|
||||||
@ -6432,10 +6455,7 @@ struct ExampleAppLog
|
|||||||
void Draw(const char* title, bool* p_open = NULL)
|
void Draw(const char* title, bool* p_open = NULL)
|
||||||
{
|
{
|
||||||
if (!ImGui::Begin(title, p_open))
|
if (!ImGui::Begin(title, p_open))
|
||||||
{
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Options menu
|
// Options menu
|
||||||
if (ImGui::BeginPopup("Options"))
|
if (ImGui::BeginPopup("Options"))
|
||||||
@ -6455,8 +6475,8 @@ struct ExampleAppLog
|
|||||||
Filter.Draw("Filter", -100.0f);
|
Filter.Draw("Filter", -100.0f);
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::BeginChild("scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar);
|
if (ImGui::BeginChild("scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar))
|
||||||
|
{
|
||||||
if (clear)
|
if (clear)
|
||||||
Clear();
|
Clear();
|
||||||
if (copy)
|
if (copy)
|
||||||
@ -6513,6 +6533,7 @@ struct ExampleAppLog
|
|||||||
ImGui::SetScrollHereY(1.0f);
|
ImGui::SetScrollHereY(1.0f);
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -6526,7 +6547,8 @@ static void ShowExampleAppLog(bool* p_open)
|
|||||||
// We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window.
|
// We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window.
|
||||||
// Most of the contents of the window will be added by the log.Draw() call.
|
// Most of the contents of the window will be added by the log.Draw() call.
|
||||||
ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
|
||||||
ImGui::Begin("Example: Log", p_open);
|
if (ImGui::Begin("Example: Log", p_open))
|
||||||
|
{
|
||||||
if (ImGui::SmallButton("[Debug] Add 5 entries"))
|
if (ImGui::SmallButton("[Debug] Add 5 entries"))
|
||||||
{
|
{
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
@ -6542,6 +6564,7 @@ static void ShowExampleAppLog(bool* p_open)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
// Actually call in the regular Log helper (which will Begin() into the same window as we just did)
|
// Actually call in the regular Log helper (which will Begin() into the same window as we just did)
|
||||||
log.Draw("Example: Log", p_open);
|
log.Draw("Example: Log", p_open);
|
||||||
@ -6555,8 +6578,8 @@ static void ShowExampleAppLog(bool* p_open)
|
|||||||
static void ShowExampleAppLayout(bool* p_open)
|
static void ShowExampleAppLayout(bool* p_open)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver);
|
||||||
if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
|
if (!ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
|
||||||
{
|
return;
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenu("File"))
|
if (ImGui::BeginMenu("File"))
|
||||||
@ -6570,7 +6593,8 @@ static void ShowExampleAppLayout(bool* p_open)
|
|||||||
// Left
|
// Left
|
||||||
static int selected = 0;
|
static int selected = 0;
|
||||||
{
|
{
|
||||||
ImGui::BeginChild("left pane", ImVec2(150, 0), true);
|
if (ImGui::BeginChild("left pane", ImVec2(150, 0), true))
|
||||||
|
{
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
char label[128];
|
char label[128];
|
||||||
@ -6580,12 +6604,14 @@ static void ShowExampleAppLayout(bool* p_open)
|
|||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
// Right
|
// Right
|
||||||
{
|
{
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
|
if (ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()))) // Leave room for 1 line below us
|
||||||
|
{
|
||||||
ImGui::Text("MyObject: %d", selected);
|
ImGui::Text("MyObject: %d", selected);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
|
if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
|
||||||
@ -6603,12 +6629,12 @@ static void ShowExampleAppLayout(bool* p_open)
|
|||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
if (ImGui::Button("Revert")) {}
|
if (ImGui::Button("Revert")) {}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Save")) {}
|
if (ImGui::Button("Save")) {}
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6668,10 +6694,7 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
|||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
|
||||||
if (!ImGui::Begin("Example: Property editor", p_open))
|
if (!ImGui::Begin("Example: Property editor", p_open))
|
||||||
{
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
HelpMarker(
|
HelpMarker(
|
||||||
"This example shows how you may implement a property editor using two columns.\n"
|
"This example shows how you may implement a property editor using two columns.\n"
|
||||||
@ -6703,10 +6726,7 @@ static void ShowExampleAppLongText(bool* p_open)
|
|||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
|
||||||
if (!ImGui::Begin("Example: Long text display", p_open))
|
if (!ImGui::Begin("Example: Long text display", p_open))
|
||||||
{
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
static int test_type = 0;
|
static int test_type = 0;
|
||||||
static ImGuiTextBuffer log;
|
static ImGuiTextBuffer log;
|
||||||
@ -6725,7 +6745,9 @@ static void ShowExampleAppLongText(bool* p_open)
|
|||||||
log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i);
|
log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i);
|
||||||
lines += 1000;
|
lines += 1000;
|
||||||
}
|
}
|
||||||
ImGui::BeginChild("Log");
|
|
||||||
|
if (ImGui::BeginChild("Log"))
|
||||||
|
{
|
||||||
switch (test_type)
|
switch (test_type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -6753,6 +6775,7 @@ static void ShowExampleAppLongText(bool* p_open)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6764,10 +6787,7 @@ static void ShowExampleAppLongText(bool* p_open)
|
|||||||
static void ShowExampleAppAutoResize(bool* p_open)
|
static void ShowExampleAppAutoResize(bool* p_open)
|
||||||
{
|
{
|
||||||
if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize))
|
if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize))
|
||||||
{
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
static int lines = 10;
|
static int lines = 10;
|
||||||
ImGui::TextUnformatted(
|
ImGui::TextUnformatted(
|
||||||
@ -6817,10 +6837,12 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|||||||
if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)(intptr_t)100); // Fixed Step
|
if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)(intptr_t)100); // Fixed Step
|
||||||
|
|
||||||
ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0;
|
ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0;
|
||||||
if (ImGui::Begin("Example: Constrained Resize", p_open, flags))
|
if (!ImGui::Begin("Example: Constrained Resize", p_open, flags))
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (ImGui::IsWindowDocked())
|
if (ImGui::IsWindowDocked())
|
||||||
ImGui::Text("Warning: Sizing Constraints won't work if the window is docked!");
|
ImGui::Text("Warning: Sizing Constraints won't work if the window is docked!");
|
||||||
|
|
||||||
if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
|
if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
|
||||||
if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
|
if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
|
||||||
if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
|
if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
|
||||||
@ -6831,7 +6853,6 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|||||||
ImGui::Checkbox("Auto-resize", &auto_resize);
|
ImGui::Checkbox("Auto-resize", &auto_resize);
|
||||||
for (int i = 0; i < display_lines; i++)
|
for (int i = 0; i < display_lines; i++)
|
||||||
ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
|
ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
|
||||||
}
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6860,8 +6881,9 @@ static void ShowExampleAppSimpleOverlay(bool* p_open)
|
|||||||
ImGui::SetNextWindowViewport(viewport->ID);
|
ImGui::SetNextWindowViewport(viewport->ID);
|
||||||
}
|
}
|
||||||
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
|
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
|
||||||
if (ImGui::Begin("Example: Simple overlay", p_open, window_flags))
|
if (!ImGui::Begin("Example: Simple overlay", p_open, window_flags))
|
||||||
{
|
return;
|
||||||
|
|
||||||
ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
|
ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::IsMousePosValid())
|
if (ImGui::IsMousePosValid())
|
||||||
@ -6878,7 +6900,6 @@ static void ShowExampleAppSimpleOverlay(bool* p_open)
|
|||||||
if (p_open && ImGui::MenuItem("Close")) *p_open = false;
|
if (p_open && ImGui::MenuItem("Close")) *p_open = false;
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6896,23 +6917,29 @@ static void ShowExampleAppWindowTitles(bool*)
|
|||||||
|
|
||||||
// Using "##" to display same title but have unique identifier.
|
// Using "##" to display same title but have unique identifier.
|
||||||
ImGui::SetNextWindowPos(ImVec2(100, 100), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(100, 100), ImGuiCond_FirstUseEver);
|
||||||
ImGui::Begin("Same title as another window##1");
|
if (ImGui::Begin("Same title as another window##1"))
|
||||||
|
{
|
||||||
ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.");
|
ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_FirstUseEver);
|
||||||
ImGui::Begin("Same title as another window##2");
|
if (ImGui::Begin("Same title as another window##2"))
|
||||||
|
{
|
||||||
ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
|
ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
// Using "###" to display a changing title but keep a static identifier "AnimatedTitle"
|
// Using "###" to display a changing title but keep a static identifier "AnimatedTitle"
|
||||||
char buf[128];
|
char buf[128];
|
||||||
sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount());
|
sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount());
|
||||||
ImGui::SetNextWindowPos(ImVec2(100, 300), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(100, 300), ImGuiCond_FirstUseEver);
|
||||||
ImGui::Begin(buf);
|
if (ImGui::Begin(buf))
|
||||||
|
{
|
||||||
ImGui::Text("This window has a changing title.");
|
ImGui::Text("This window has a changing title.");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
||||||
@ -6922,10 +6949,7 @@ static void ShowExampleAppWindowTitles(bool*)
|
|||||||
static void ShowExampleAppCustomRendering(bool* p_open)
|
static void ShowExampleAppCustomRendering(bool* p_open)
|
||||||
{
|
{
|
||||||
if (!ImGui::Begin("Example: Custom rendering", p_open))
|
if (!ImGui::Begin("Example: Custom rendering", p_open))
|
||||||
{
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of
|
// Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of
|
||||||
// overloaded operators, etc. Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your
|
// overloaded operators, etc. Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your
|
||||||
@ -7201,12 +7225,14 @@ void ShowExampleAppDockSpace(bool* p_open)
|
|||||||
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
|
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
|
||||||
if (!opt_padding)
|
if (!opt_padding)
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
ImGui::Begin("DockSpace Demo", p_open, window_flags);
|
bool ret = ImGui::Begin("DockSpace Demo", p_open, window_flags);
|
||||||
|
|
||||||
if (!opt_padding)
|
if (!opt_padding)
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
if (opt_fullscreen)
|
if (opt_fullscreen)
|
||||||
ImGui::PopStyleVar(2);
|
ImGui::PopStyleVar(2);
|
||||||
|
if (!ret)
|
||||||
|
return; // FIXME-NEWBEGIN: KeepAlive?
|
||||||
|
|
||||||
// DockSpace
|
// DockSpace
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -7376,11 +7402,8 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
// Another solution may be to make the "Example: Documents" window use the ImGuiWindowFlags_NoDocking.
|
// Another solution may be to make the "Example: Documents" window use the ImGuiWindowFlags_NoDocking.
|
||||||
|
|
||||||
bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
|
bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
|
||||||
if (!window_contents_visible && opt_target != Target_DockSpaceAndWindow)
|
if (!window_contents_visible && opt_target != Target_DockSpaceAndWindow) // FIXME-NEWBEGIN
|
||||||
{
|
|
||||||
ImGui::End();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
|
@ -1438,6 +1438,7 @@ struct ImGuiContext
|
|||||||
ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
|
ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
|
||||||
ImGuiDockNode* HoveredDockNode; // Hovered dock node.
|
ImGuiDockNode* HoveredDockNode; // Hovered dock node.
|
||||||
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow.
|
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow.
|
||||||
|
ImGuiWindow* LastBeginWindow; // Track the last window we called Begin() on, this is used to easily access it even if Begin() returned false.
|
||||||
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
|
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
|
||||||
ImVec2 WheelingWindowRefMousePos;
|
ImVec2 WheelingWindowRefMousePos;
|
||||||
float WheelingWindowTimer;
|
float WheelingWindowTimer;
|
||||||
@ -1640,6 +1641,7 @@ struct ImGuiContext
|
|||||||
// Debug Tools
|
// Debug Tools
|
||||||
bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker())
|
bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker())
|
||||||
ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this id
|
ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this id
|
||||||
|
int DebugBeginReturnValueCullDepth; // Cycle between 0..9 then wrap around.
|
||||||
ImGuiMetricsConfig DebugMetricsConfig;
|
ImGuiMetricsConfig DebugMetricsConfig;
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
@ -1675,6 +1677,7 @@ struct ImGuiContext
|
|||||||
HoveredWindowUnderMovingWindow = NULL;
|
HoveredWindowUnderMovingWindow = NULL;
|
||||||
HoveredDockNode = NULL;
|
HoveredDockNode = NULL;
|
||||||
MovingWindow = NULL;
|
MovingWindow = NULL;
|
||||||
|
LastBeginWindow = NULL;
|
||||||
WheelingWindow = NULL;
|
WheelingWindow = NULL;
|
||||||
WheelingWindowTimer = 0.0f;
|
WheelingWindowTimer = 0.0f;
|
||||||
|
|
||||||
@ -1793,6 +1796,7 @@ struct ImGuiContext
|
|||||||
|
|
||||||
DebugItemPickerActive = false;
|
DebugItemPickerActive = false;
|
||||||
DebugItemPickerBreakId = 0;
|
DebugItemPickerBreakId = 0;
|
||||||
|
DebugBeginReturnValueCullDepth = -1;
|
||||||
|
|
||||||
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
|
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
|
||||||
FramerateSecPerFrameIdx = 0;
|
FramerateSecPerFrameIdx = 0;
|
||||||
@ -2445,7 +2449,7 @@ namespace ImGui
|
|||||||
IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
|
IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
|
||||||
IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
|
IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
|
||||||
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
||||||
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
IMGUI_API bool BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
||||||
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
||||||
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
||||||
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
||||||
|
@ -1627,7 +1627,6 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
EndPopup();
|
|
||||||
IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above
|
IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3838,7 +3837,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
PopStyleColor();
|
PopStyleColor();
|
||||||
if (!child_visible)
|
if (!child_visible)
|
||||||
{
|
{
|
||||||
EndChild();
|
|
||||||
EndGroup();
|
EndGroup();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -5355,7 +5353,8 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip);
|
if (!BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip))
|
||||||
|
return;
|
||||||
const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text;
|
const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text;
|
||||||
if (text_end > text)
|
if (text_end > text)
|
||||||
{
|
{
|
||||||
@ -6133,8 +6132,11 @@ bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg)
|
|||||||
if (label_size.x > 0)
|
if (label_size.x > 0)
|
||||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||||
|
|
||||||
BeginChildFrame(id, frame_bb.GetSize());
|
// FIXME-NEWBEGIN: Use to be return true so we'll trigger more issues.
|
||||||
return true;
|
bool ret = BeginChildFrame(id, frame_bb.GetSize());
|
||||||
|
if (!ret)
|
||||||
|
EndGroup();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature.
|
// FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature.
|
||||||
@ -6568,10 +6570,7 @@ bool ImGui::BeginMainMenuBar()
|
|||||||
|
|
||||||
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
|
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
|
||||||
if (!is_open)
|
if (!is_open)
|
||||||
{
|
|
||||||
End();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return true; //-V1020
|
return true; //-V1020
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,8 @@ struct FreeTypeTest
|
|||||||
// Call to draw interface
|
// Call to draw interface
|
||||||
void ShowFreetypeOptionsWindow()
|
void ShowFreetypeOptionsWindow()
|
||||||
{
|
{
|
||||||
ImGui::Begin("FreeType Options");
|
if (!ImGui::Begin("FreeType Options"))
|
||||||
|
return;
|
||||||
ImGui::ShowFontSelector("Fonts");
|
ImGui::ShowFontSelector("Fonts");
|
||||||
WantRebuild |= ImGui::RadioButton("FreeType", (int*)&BuildMode, FontBuildMode_FreeType);
|
WantRebuild |= ImGui::RadioButton("FreeType", (int*)&BuildMode, FontBuildMode_FreeType);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
Reference in New Issue
Block a user