Updated ImGui.
This commit is contained in:
parent
5b05c6c09e
commit
72bee000a9
265
3rdparty/dear-imgui/imgui.cpp
vendored
265
3rdparty/dear-imgui/imgui.cpp
vendored
@ -372,6 +372,7 @@ CODE
|
|||||||
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||||
|
|
||||||
|
- 2020/06/23 (1.77) - removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems.
|
||||||
- 2020/06/15 (1.77) - renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete).
|
- 2020/06/15 (1.77) - renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete).
|
||||||
- 2020/06/15 (1.77) - removed CalcItemRectClosestPoint() entry point which was made obsolete and asserting in December 2017.
|
- 2020/06/15 (1.77) - removed CalcItemRectClosestPoint() entry point which was made obsolete and asserting in December 2017.
|
||||||
- 2020/04/23 (1.77) - removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular().
|
- 2020/04/23 (1.77) - removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular().
|
||||||
@ -600,7 +601,10 @@ CODE
|
|||||||
FREQUENTLY ASKED QUESTIONS (FAQ)
|
FREQUENTLY ASKED QUESTIONS (FAQ)
|
||||||
================================
|
================================
|
||||||
|
|
||||||
Read all answers online: https://www.dearimgui.org/faq, or in docs/FAQ.md (with a Markdown viewer)
|
Read all answers online:
|
||||||
|
https://www.dearimgui.org/faq or https://github.com/ocornut/imgui/blob/master/docs/FAQ.md (same url)
|
||||||
|
Read all answers locally (with a text editor or ideally a Markdown viewer):
|
||||||
|
docs/FAQ.md
|
||||||
Some answers are copied down here to facilitate searching in code.
|
Some answers are copied down here to facilitate searching in code.
|
||||||
|
|
||||||
Q&A: Basics
|
Q&A: Basics
|
||||||
@ -644,125 +648,10 @@ CODE
|
|||||||
Q&A: Usage
|
Q&A: Usage
|
||||||
----------
|
----------
|
||||||
|
|
||||||
Q: Why are multiple widgets reacting when I interact with a single one?
|
Q: How can I have widgets with an empty label?
|
||||||
Q: How can I have multiple widgets with the same label or with an empty label?
|
Q: How can I have multiple widgets with the same label?
|
||||||
A: A primer on labels and the ID Stack...
|
Q: Why are multiple widgets reacting when I interact with one?
|
||||||
|
|
||||||
Dear ImGui internally need to uniquely identify UI elements.
|
|
||||||
Elements that are typically not clickable (such as calls to the Text functions) don't need an ID.
|
|
||||||
Interactive widgets (such as calls to Button buttons) need a unique ID.
|
|
||||||
Unique ID are used internally to track active widgets and occasionally associate state to widgets.
|
|
||||||
Unique ID are implicitly built from the hash of multiple elements that identify the "path" to the UI element.
|
|
||||||
|
|
||||||
- Unique ID are often derived from a string label:
|
|
||||||
|
|
||||||
Button("OK"); // Label = "OK", ID = hash of (..., "OK")
|
|
||||||
Button("Cancel"); // Label = "Cancel", ID = hash of (..., "Cancel")
|
|
||||||
|
|
||||||
- ID are uniquely scoped within windows, tree nodes, etc. which all pushes to the ID stack. Having
|
|
||||||
two buttons labeled "OK" in different windows or different tree locations is fine.
|
|
||||||
We used "..." above to signify whatever was already pushed to the ID stack previously:
|
|
||||||
|
|
||||||
Begin("MyWindow");
|
|
||||||
Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "OK")
|
|
||||||
End();
|
|
||||||
Begin("MyOtherWindow");
|
|
||||||
Button("OK"); // Label = "OK", ID = hash of ("MyOtherWindow", "OK")
|
|
||||||
End();
|
|
||||||
|
|
||||||
- If you have a same ID twice in the same location, you'll have a conflict:
|
|
||||||
|
|
||||||
Button("OK");
|
|
||||||
Button("OK"); // ID collision! Interacting with either button will trigger the first one.
|
|
||||||
|
|
||||||
Fear not! this is easy to solve and there are many ways to solve it!
|
|
||||||
|
|
||||||
- Solving ID conflict in a simple/local context:
|
|
||||||
When passing a label you can optionally specify extra ID information within string itself.
|
|
||||||
Use "##" to pass a complement to the ID that won't be visible to the end-user.
|
|
||||||
This helps solving the simple collision cases when you know e.g. at compilation time which items
|
|
||||||
are going to be created:
|
|
||||||
|
|
||||||
Begin("MyWindow");
|
|
||||||
Button("Play"); // Label = "Play", ID = hash of ("MyWindow", "Play")
|
|
||||||
Button("Play##foo1"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo1") // Different from above
|
|
||||||
Button("Play##foo2"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo2") // Different from above
|
|
||||||
End();
|
|
||||||
|
|
||||||
- If you want to completely hide the label, but still need an ID:
|
|
||||||
|
|
||||||
Checkbox("##On", &b); // Label = "", ID = hash of (..., "##On") // No visible label, just a checkbox!
|
|
||||||
|
|
||||||
- Occasionally/rarely you might want change a label while preserving a constant ID. This allows
|
|
||||||
you to animate labels. For example you may want to include varying information in a window title bar,
|
|
||||||
but windows are uniquely identified by their ID. Use "###" to pass a label that isn't part of ID:
|
|
||||||
|
|
||||||
Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "###ID")
|
|
||||||
Button("World###ID"); // Label = "World", ID = hash of (..., "###ID") // Same as above, even though the label looks different
|
|
||||||
|
|
||||||
sprintf(buf, "My game (%f FPS)###MyGame", fps);
|
|
||||||
Begin(buf); // Variable title, ID = hash of "MyGame"
|
|
||||||
|
|
||||||
- Solving ID conflict in a more general manner:
|
|
||||||
Use PushID() / PopID() to create scopes and manipulate the ID stack, as to avoid ID conflicts
|
|
||||||
within the same window. This is the most convenient way of distinguishing ID when iterating and
|
|
||||||
creating many UI elements programmatically.
|
|
||||||
You can push a pointer, a string or an integer value into the ID stack.
|
|
||||||
Remember that ID are formed from the concatenation of _everything_ pushed into the ID stack.
|
|
||||||
At each level of the stack we store the seed used for items at this level of the ID stack.
|
|
||||||
|
|
||||||
Begin("Window");
|
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
{
|
|
||||||
PushID(i); // Push i to the id tack
|
|
||||||
Button("Click"); // Label = "Click", ID = hash of ("Window", i, "Click")
|
|
||||||
PopID();
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
{
|
|
||||||
MyObject* obj = Objects[i];
|
|
||||||
PushID(obj);
|
|
||||||
Button("Click"); // Label = "Click", ID = hash of ("Window", obj pointer, "Click")
|
|
||||||
PopID();
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
{
|
|
||||||
MyObject* obj = Objects[i];
|
|
||||||
PushID(obj->Name);
|
|
||||||
Button("Click"); // Label = "Click", ID = hash of ("Window", obj->Name, "Click")
|
|
||||||
PopID();
|
|
||||||
}
|
|
||||||
End();
|
|
||||||
|
|
||||||
- You can stack multiple prefixes into the ID stack:
|
|
||||||
|
|
||||||
Button("Click"); // Label = "Click", ID = hash of (..., "Click")
|
|
||||||
PushID("node");
|
|
||||||
Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
|
|
||||||
PushID(my_ptr);
|
|
||||||
Button("Click"); // Label = "Click", ID = hash of (..., "node", my_ptr, "Click")
|
|
||||||
PopID();
|
|
||||||
PopID();
|
|
||||||
|
|
||||||
- Tree nodes implicitly creates a scope for you by calling PushID().
|
|
||||||
|
|
||||||
Button("Click"); // Label = "Click", ID = hash of (..., "Click")
|
|
||||||
if (TreeNode("node")) // <-- this function call will do a PushID() for you (unless instructed not to, with a special flag)
|
|
||||||
{
|
|
||||||
Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
|
|
||||||
TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
- When working with trees, ID are used to preserve the open/close state of each tree node.
|
|
||||||
Depending on your use cases you may want to use strings, indices or pointers as ID.
|
|
||||||
e.g. when following a single pointer that may change over time, using a static string as ID
|
|
||||||
will preserve your node open/closed state when the targeted object change.
|
|
||||||
e.g. when displaying a list of objects, using indices or pointers as ID will preserve the
|
|
||||||
node open/closed state differently. See what makes more sense in your situation!
|
|
||||||
|
|
||||||
Q: How can I display an image? What is ImTextureID, how does it works?
|
Q: How can I display an image? What is ImTextureID, how does it works?
|
||||||
>> See https://www.dearimgui.org/faq and https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
|
|
||||||
|
|
||||||
Q: How can I use my own math types instead of ImVec2/ImVec4?
|
Q: How can I use my own math types instead of ImVec2/ImVec4?
|
||||||
Q: How can I interact with standard C++ types (such as std::string and std::vector)?
|
Q: How can I interact with standard C++ types (such as std::string and std::vector)?
|
||||||
Q: How can I display custom shapes? (using low-level ImDrawList API)
|
Q: How can I display custom shapes? (using low-level ImDrawList API)
|
||||||
@ -965,7 +854,7 @@ static void UpdateMouseInputs();
|
|||||||
static void UpdateMouseWheel();
|
static void UpdateMouseWheel();
|
||||||
static void UpdateTabFocus();
|
static void UpdateTabFocus();
|
||||||
static void UpdateDebugToolItemPicker();
|
static void UpdateDebugToolItemPicker();
|
||||||
static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
|
static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect);
|
||||||
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
||||||
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
|
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
|
||||||
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
|
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
|
||||||
@ -3257,11 +3146,21 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
|||||||
if (wrap_pos_x < 0.0f)
|
if (wrap_pos_x < 0.0f)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
if (wrap_pos_x == 0.0f)
|
if (wrap_pos_x == 0.0f)
|
||||||
|
{
|
||||||
|
// We could decide to setup a default wrapping max point for auto-resizing windows,
|
||||||
|
// or have auto-wrap (with unspecified wrapping pos) behave as a ContentSize extending function?
|
||||||
|
//if (window->Hidden && (window->Flags & ImGuiWindowFlags_AlwaysAutoResize))
|
||||||
|
// wrap_pos_x = ImMax(window->WorkRect.Min.x + g.FontSize * 10.0f, window->WorkRect.Max.x);
|
||||||
|
//else
|
||||||
wrap_pos_x = window->WorkRect.Max.x;
|
wrap_pos_x = window->WorkRect.Max.x;
|
||||||
|
}
|
||||||
else if (wrap_pos_x > 0.0f)
|
else if (wrap_pos_x > 0.0f)
|
||||||
|
{
|
||||||
wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space
|
wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space
|
||||||
|
}
|
||||||
|
|
||||||
return ImMax(wrap_pos_x - pos.x, 1.0f);
|
return ImMax(wrap_pos_x - pos.x, 1.0f);
|
||||||
}
|
}
|
||||||
@ -3460,7 +3359,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
|
|||||||
// Handle the edge case of a popup being closed while clicking in its empty space.
|
// Handle the edge case of a popup being closed while clicking in its empty space.
|
||||||
// If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more.
|
// If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more.
|
||||||
ImGuiWindow* root_window = g.HoveredRootWindow;
|
ImGuiWindow* root_window = g.HoveredRootWindow;
|
||||||
const bool is_closed_popup = root_window && (root_window->Flags & ImGuiWindowFlags_Popup) && !IsPopupOpenAtAnyLevel(root_window->PopupId);
|
const bool is_closed_popup = root_window && (root_window->Flags & ImGuiWindowFlags_Popup) && !IsPopupOpen(root_window->PopupId, ImGuiPopupFlags_AnyPopupLevel);
|
||||||
|
|
||||||
if (root_window != NULL && !is_closed_popup)
|
if (root_window != NULL && !is_closed_popup)
|
||||||
{
|
{
|
||||||
@ -5122,7 +5021,7 @@ ImGuiID ImGui::GetWindowResizeID(ImGuiWindow* window, int n)
|
|||||||
|
|
||||||
// Handle resize for: Resize Grips, Borders, Gamepad
|
// Handle resize for: Resize Grips, Borders, Gamepad
|
||||||
// Return true when using auto-fit (double click on resize grip)
|
// Return true when using auto-fit (double click on resize grip)
|
||||||
static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4])
|
static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindowFlags flags = window->Flags;
|
ImGuiWindowFlags flags = window->Flags;
|
||||||
@ -5174,6 +5073,9 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
|||||||
// Resize from any of the four corners
|
// Resize from any of the four corners
|
||||||
// We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
|
// We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
|
||||||
ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(grip.InnerDir * grip_hover_outer_size, grip.InnerDir * -grip_hover_inner_size, grip.CornerPosN); // Corner of the window corresponding to our corner grip
|
ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(grip.InnerDir * grip_hover_outer_size, grip.InnerDir * -grip_hover_inner_size, grip.CornerPosN); // Corner of the window corresponding to our corner grip
|
||||||
|
ImVec2 clamp_min = ImVec2(grip.CornerPosN.x == 1.0f ? visibility_rect.Min.x : -FLT_MAX, grip.CornerPosN.y == 1.0f ? visibility_rect.Min.y : -FLT_MAX);
|
||||||
|
ImVec2 clamp_max = ImVec2(grip.CornerPosN.x == 0.0f ? visibility_rect.Max.x : +FLT_MAX, grip.CornerPosN.y == 0.0f ? visibility_rect.Max.y : +FLT_MAX);
|
||||||
|
corner_target = ImClamp(corner_target, clamp_min, clamp_max);
|
||||||
CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPosN, &pos_target, &size_target);
|
CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPosN, &pos_target, &size_target);
|
||||||
}
|
}
|
||||||
if (resize_grip_n == 0 || held || hovered)
|
if (resize_grip_n == 0 || held || hovered)
|
||||||
@ -5199,6 +5101,9 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
|||||||
if (border_n == 1) { border_posn = ImVec2(1, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Right
|
if (border_n == 1) { border_posn = ImVec2(1, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Right
|
||||||
if (border_n == 2) { border_posn = ImVec2(0, 1); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Bottom
|
if (border_n == 2) { border_posn = ImVec2(0, 1); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Bottom
|
||||||
if (border_n == 3) { border_posn = ImVec2(0, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Left
|
if (border_n == 3) { border_posn = ImVec2(0, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Left
|
||||||
|
ImVec2 clamp_min = ImVec2(border_n == 1 ? visibility_rect.Min.x : -FLT_MAX, border_n == 2 ? visibility_rect.Min.y : -FLT_MAX);
|
||||||
|
ImVec2 clamp_max = ImVec2(border_n == 3 ? visibility_rect.Max.x : +FLT_MAX, border_n == 0 ? visibility_rect.Max.y : +FLT_MAX);
|
||||||
|
border_target = ImClamp(border_target, clamp_min, clamp_max);
|
||||||
CalcResizePosSizeFromAnyCorner(window, border_target, border_posn, &pos_target, &size_target);
|
CalcResizePosSizeFromAnyCorner(window, border_target, border_posn, &pos_target, &size_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5220,6 +5125,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
|||||||
{
|
{
|
||||||
const float NAV_RESIZE_SPEED = 600.0f;
|
const float NAV_RESIZE_SPEED = 600.0f;
|
||||||
nav_resize_delta *= ImFloor(NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y));
|
nav_resize_delta *= ImFloor(NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y));
|
||||||
|
nav_resize_delta = ImMax(nav_resize_delta, visibility_rect.Min - window->Pos - window->Size);
|
||||||
g.NavWindowingToggleLayer = false;
|
g.NavWindowingToggleLayer = false;
|
||||||
g.NavDisableMouseHover = true;
|
g.NavDisableMouseHover = true;
|
||||||
resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive);
|
resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive);
|
||||||
@ -5244,13 +5150,13 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
|||||||
return ret_auto_fit;
|
return ret_auto_fit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& viewport_rect, const ImVec2& padding)
|
static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& visibility_rect)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImVec2 size_for_clamping = window->Size;
|
ImVec2 size_for_clamping = window->Size;
|
||||||
if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar))
|
if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar))
|
||||||
size_for_clamping.y = window->TitleBarHeight();
|
size_for_clamping.y = window->TitleBarHeight();
|
||||||
window->Pos = ImClamp(window->Pos, viewport_rect.Min + padding - size_for_clamping, viewport_rect.Max - padding);
|
window->Pos = ImClamp(window->Pos, visibility_rect.Min - size_for_clamping, visibility_rect.Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window)
|
static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window)
|
||||||
@ -5740,7 +5646,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
if (window_just_activated_by_user)
|
if (window_just_activated_by_user)
|
||||||
{
|
{
|
||||||
window->AutoPosLastDirection = ImGuiDir_None;
|
window->AutoPosLastDirection = ImGuiDir_None;
|
||||||
if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
|
if ((flags & ImGuiWindowFlags_Popup) != 0 && !(flags & ImGuiWindowFlags_Modal) && !window_pos_set_by_api) // FIXME: BeginPopup() could use SetNextWindowPos()
|
||||||
window->Pos = g.BeginPopupStack.back().OpenPopupPos;
|
window->Pos = g.BeginPopupStack.back().OpenPopupPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5764,17 +5670,17 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
||||||
window->Pos = FindBestWindowPosForPopup(window);
|
window->Pos = FindBestWindowPosForPopup(window);
|
||||||
|
|
||||||
|
// Calculate the range of allowed position for that window (to be movable and visible past safe area padding)
|
||||||
|
// When clamping to stay visible, we will enforce that window->Pos stays inside of visibility_rect.
|
||||||
|
ImRect viewport_rect(GetViewportRect());
|
||||||
|
ImVec2 visibility_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
|
||||||
|
ImRect visibility_rect(viewport_rect.Min + visibility_padding, viewport_rect.Max - visibility_padding);
|
||||||
|
|
||||||
// Clamp position/size so window stays visible within its viewport or monitor
|
// Clamp position/size so window stays visible within its viewport or monitor
|
||||||
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
|
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
|
||||||
ImRect viewport_rect(GetViewportRect());
|
|
||||||
if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
|
if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
|
||||||
{
|
if (viewport_rect.GetWidth() > 0.0f && viewport_rect.GetHeight() > 0.0f)
|
||||||
ImVec2 clamp_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
|
ClampWindowRect(window, visibility_rect);
|
||||||
if (viewport_rect.GetWidth() > 0 && viewport_rect.GetHeight() > 0.0f)
|
|
||||||
{
|
|
||||||
ClampWindowRect(window, viewport_rect, clamp_padding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
window->Pos = ImFloor(window->Pos);
|
window->Pos = ImFloor(window->Pos);
|
||||||
|
|
||||||
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
|
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
|
||||||
@ -5801,7 +5707,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // Allow resize from lower-left if we have the mouse cursor feedback for it.
|
const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // Allow resize from lower-left if we have the mouse cursor feedback for it.
|
||||||
const float resize_grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f));
|
const float resize_grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f));
|
||||||
if (!window->Collapsed)
|
if (!window->Collapsed)
|
||||||
if (UpdateWindowManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]))
|
if (UpdateWindowManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0], visibility_rect))
|
||||||
use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y = true;
|
use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y = true;
|
||||||
window->ResizeBorderHeld = (signed char)border_held;
|
window->ResizeBorderHeld = (signed char)border_held;
|
||||||
|
|
||||||
@ -7611,35 +7517,45 @@ void ImGui::SetTooltip(const char* fmt, ...)
|
|||||||
// [SECTION] POPUPS
|
// [SECTION] POPUPS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Return true if the popup is open at the current BeginPopup() level of the popup stack
|
// Supported flags: ImGuiPopupFlags_AnyPopupId, ImGuiPopupFlags_AnyPopupLevel
|
||||||
bool ImGui::IsPopupOpen(ImGuiID id)
|
bool ImGui::IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id;
|
if (popup_flags & ImGuiPopupFlags_AnyPopupId)
|
||||||
|
{
|
||||||
|
// Return true if any popup is open at the current BeginPopup() level of the popup stack
|
||||||
|
// This may be used to e.g. test for another popups already opened to handle popups priorities at the same level.
|
||||||
|
IM_ASSERT(id == 0);
|
||||||
|
if (popup_flags & ImGuiPopupFlags_AnyPopupLevel)
|
||||||
|
return g.OpenPopupStack.Size > 0;
|
||||||
|
else
|
||||||
|
return g.OpenPopupStack.Size > g.BeginPopupStack.Size;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// Return true if the popup is open at the current BeginPopup() level of the popup stack
|
|
||||||
bool ImGui::IsPopupOpen(const char* str_id)
|
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
if (popup_flags & ImGuiPopupFlags_AnyPopupLevel)
|
||||||
return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == g.CurrentWindow->GetID(str_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGui::IsPopupOpenAtAnyLevel(ImGuiID id)
|
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
// Return true if the popup is open anywhere in the popup stack
|
||||||
for (int n = 0; n < g.OpenPopupStack.Size; n++)
|
for (int n = 0; n < g.OpenPopupStack.Size; n++)
|
||||||
if (g.OpenPopupStack[n].PopupId == id)
|
if (g.OpenPopupStack[n].PopupId == id)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Return true if the popup is open at the current BeginPopup() level of the popup stack (this is the most-common query)
|
||||||
|
return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return true if any popup is open at the current BeginPopup() level of the popup stack
|
bool ImGui::IsPopupOpen(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||||
// This may be used to e.g. test for another popups already opened in the same frame to handle popups priorities at the same level.
|
|
||||||
bool ImGui::IsAnyPopupOpen()
|
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
return g.OpenPopupStack.Size > g.BeginPopupStack.Size;
|
ImGuiID id = (popup_flags & ImGuiPopupFlags_AnyPopupId) ? 0 : g.CurrentWindow->GetID(str_id);
|
||||||
|
if ((popup_flags & ImGuiPopupFlags_AnyPopupLevel) && id != 0)
|
||||||
|
IM_ASSERT(0 && "Cannot use IsPopupOpen() with a string id and ImGuiPopupFlags_AnyPopupLevel."); // But non-string version is legal and used internally
|
||||||
|
return IsPopupOpen(id, popup_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiWindow* ImGui::GetTopMostPopupModal()
|
ImGuiWindow* ImGui::GetTopMostPopupModal()
|
||||||
@ -7652,21 +7568,26 @@ ImGuiWindow* ImGui::GetTopMostPopupModal()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::OpenPopup(const char* str_id)
|
void ImGui::OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
OpenPopupEx(g.CurrentWindow->GetID(str_id));
|
OpenPopupEx(g.CurrentWindow->GetID(str_id), popup_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark popup as open (toggle toward open state).
|
// Mark popup as open (toggle toward open state).
|
||||||
// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
|
// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
|
||||||
// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||||
// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
|
// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
|
||||||
void ImGui::OpenPopupEx(ImGuiID id)
|
void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* parent_window = g.CurrentWindow;
|
ImGuiWindow* parent_window = g.CurrentWindow;
|
||||||
int current_stack_size = g.BeginPopupStack.Size;
|
const int current_stack_size = g.BeginPopupStack.Size;
|
||||||
|
|
||||||
|
if (popup_flags & ImGuiPopupFlags_NoOpenOverExistingPopup)
|
||||||
|
if (IsPopupOpen(0u, ImGuiPopupFlags_AnyPopupId))
|
||||||
|
return;
|
||||||
|
|
||||||
ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack.
|
ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack.
|
||||||
popup_ref.PopupId = id;
|
popup_ref.PopupId = id;
|
||||||
popup_ref.Window = NULL;
|
popup_ref.Window = NULL;
|
||||||
@ -7799,10 +7720,11 @@ void ImGui::CloseCurrentPopup()
|
|||||||
window->DC.NavHideHighlightOneFrame = true;
|
window->DC.NavHideHighlightOneFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attention! BeginPopup() adds default flags which BeginPopupEx()!
|
||||||
bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (!IsPopupOpen(id))
|
if (!IsPopupOpen(id, ImGuiPopupFlags_None))
|
||||||
{
|
{
|
||||||
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
|
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
|
||||||
return false;
|
return false;
|
||||||
@ -7841,18 +7763,19 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
const ImGuiID id = window->GetID(name);
|
const ImGuiID id = window->GetID(name);
|
||||||
if (!IsPopupOpen(id))
|
if (!IsPopupOpen(id, ImGuiPopupFlags_None))
|
||||||
{
|
{
|
||||||
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
|
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center modal windows by default
|
// Center modal windows by default for increased visibility
|
||||||
|
// (this won't really last as settings will kick in, and is mostly for backward compatibility. user may do the same themselves)
|
||||||
// FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
|
// FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
|
||||||
if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0)
|
if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0)
|
||||||
SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f));
|
||||||
|
|
||||||
flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings;
|
flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse;
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -7883,14 +7806,15 @@ void ImGui::EndPopup()
|
|||||||
g.WithinEndChild = false;
|
g.WithinEndChild = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::OpenPopupContextItem(const char* str_id, ImGuiMouseButton mouse_button)
|
bool ImGui::OpenPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
|
int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_);
|
||||||
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
||||||
{
|
{
|
||||||
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
||||||
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
||||||
OpenPopupEx(id);
|
OpenPopupEx(id, popup_flags);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -7901,39 +7825,42 @@ bool ImGui::OpenPopupContextItem(const char* str_id, ImGuiMouseButton mouse_butt
|
|||||||
// - You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
|
// - You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
|
||||||
// - This is essentially the same as calling OpenPopupContextItem() + BeginPopup() but written to avoid
|
// - This is essentially the same as calling OpenPopupContextItem() + BeginPopup() but written to avoid
|
||||||
// computing the ID twice because BeginPopupContextXXX functions are called very frequently.
|
// computing the ID twice because BeginPopupContextXXX functions are called very frequently.
|
||||||
bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiMouseButton mouse_button)
|
bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return false;
|
return false;
|
||||||
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
||||||
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
||||||
|
int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_);
|
||||||
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
||||||
OpenPopupEx(id);
|
OpenPopupEx(id, popup_flags);
|
||||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mouse_button, bool also_over_items)
|
bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
if (!str_id)
|
if (!str_id)
|
||||||
str_id = "window_context";
|
str_id = "window_context";
|
||||||
ImGuiID id = window->GetID(str_id);
|
ImGuiID id = window->GetID(str_id);
|
||||||
|
int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_);
|
||||||
if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
||||||
if (also_over_items || !IsAnyItemHovered())
|
if (!(popup_flags & ImGuiPopupFlags_NoOpenOverItems) || !IsAnyItemHovered())
|
||||||
OpenPopupEx(id);
|
OpenPopupEx(id, popup_flags);
|
||||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiMouseButton mouse_button)
|
bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
if (!str_id)
|
if (!str_id)
|
||||||
str_id = "void_context";
|
str_id = "void_context";
|
||||||
ImGuiID id = window->GetID(str_id);
|
ImGuiID id = window->GetID(str_id);
|
||||||
|
int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_);
|
||||||
if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow))
|
if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow))
|
||||||
if (GetTopMostPopupModal() == NULL)
|
if (GetTopMostPopupModal() == NULL)
|
||||||
OpenPopupEx(id);
|
OpenPopupEx(id, popup_flags);
|
||||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
48
3rdparty/dear-imgui/imgui.h
vendored
48
3rdparty/dear-imgui/imgui.h
vendored
@ -161,6 +161,7 @@ typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: f
|
|||||||
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
||||||
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
||||||
typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
|
typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
|
||||||
|
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
||||||
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
||||||
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
|
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
|
||||||
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
|
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
|
||||||
@ -605,20 +606,27 @@ namespace ImGui
|
|||||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
|
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
|
||||||
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
||||||
// Popups: open/close functions
|
// Popups: open/close functions
|
||||||
// - OpenPopup(): set popup state to open.
|
// - OpenPopup(): set popup state to open. ImGuiPopupFlags are available for opening options.
|
||||||
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||||
// - CloseCurrentPopup(): use inside the BeginPopup()/EndPopup() scope to close manually.
|
// - CloseCurrentPopup(): use inside the BeginPopup()/EndPopup() scope to close manually.
|
||||||
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
||||||
IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!).
|
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
||||||
IMGUI_API bool OpenPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_b = 1); // helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
||||||
|
IMGUI_API bool OpenPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||||
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
||||||
IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open at the current BeginPopup() level of the popup stack
|
|
||||||
// Popups: open+begin combined functions helpers
|
// Popups: open+begin combined functions helpers
|
||||||
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
||||||
// - They are convenient to easily create context menus, hence the name.
|
// - They are convenient to easily create context menus, hence the name.
|
||||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_b = 1); // open+begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
||||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiMouseButton mouse_b = 1, bool also_over_items = true); // open+begin popup when clicked on current window.
|
// - We exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter. Passing a mouse button to ImGuiPopupFlags is guaranteed to be legal.
|
||||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiMouseButton mouse_b = 1); // open+begin popup when clicked in void (where there are no windows).
|
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||||
|
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
||||||
|
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||||
|
// Popups: test function
|
||||||
|
// - IsPopupOpen(): return true if the popup is open at the current BeginPopup() level of the popup stack.
|
||||||
|
// - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId: return true if any popup is open at the current BeginPopup() level of the popup stack.
|
||||||
|
// - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId + ImGuiPopupFlags_AnyPopupLevel: return true if any popup is open.
|
||||||
|
IMGUI_API bool IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0); // return true if the popup is open.
|
||||||
|
|
||||||
// Columns
|
// Columns
|
||||||
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
||||||
@ -865,6 +873,26 @@ enum ImGuiTreeNodeFlags_
|
|||||||
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog
|
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions.
|
||||||
|
// - To be backward compatible with older API which took an 'int mouse_button = 1' argument, we need to treat
|
||||||
|
// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
|
||||||
|
// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags.
|
||||||
|
// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
|
||||||
|
enum ImGuiPopupFlags_
|
||||||
|
{
|
||||||
|
ImGuiPopupFlags_None = 0,
|
||||||
|
ImGuiPopupFlags_MouseButtonLeft = 0, // For BeginPopupContext*(): open on Left Mouse release. Guaranted to always be == 0 (same as ImGuiMouseButton_Left)
|
||||||
|
ImGuiPopupFlags_MouseButtonRight = 1, // For BeginPopupContext*(): open on Right Mouse release. Guaranted to always be == 1 (same as ImGuiMouseButton_Right)
|
||||||
|
ImGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranted to always be == 2 (same as ImGuiMouseButton_Middle)
|
||||||
|
ImGuiPopupFlags_MouseButtonMask_ = 0x1F,
|
||||||
|
ImGuiPopupFlags_MouseButtonDefault_ = 1,
|
||||||
|
ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
|
||||||
|
ImGuiPopupFlags_NoOpenOverItems = 1 << 6, // For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space
|
||||||
|
ImGuiPopupFlags_AnyPopupId = 1 << 7, // For IsPopupOpen(): ignore the ImGuiID parameter and test for any popup.
|
||||||
|
ImGuiPopupFlags_AnyPopupLevel = 1 << 8, // For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level)
|
||||||
|
ImGuiPopupFlags_AnyPopup = ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel
|
||||||
|
};
|
||||||
|
|
||||||
// Flags for ImGui::Selectable()
|
// Flags for ImGui::Selectable()
|
||||||
enum ImGuiSelectableFlags_
|
enum ImGuiSelectableFlags_
|
||||||
{
|
{
|
||||||
@ -1277,7 +1305,8 @@ enum ImGuiMouseCursor_
|
|||||||
// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
|
// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
|
||||||
enum ImGuiCond_
|
enum ImGuiCond_
|
||||||
{
|
{
|
||||||
ImGuiCond_Always = 1 << 0, // Set the variable
|
ImGuiCond_None = 0, // No condition (always set the variable), same as _Always
|
||||||
|
ImGuiCond_Always = 1 << 0, // No condition (always set the variable)
|
||||||
ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed)
|
ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed)
|
||||||
ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
|
ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
|
||||||
ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
|
ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
|
||||||
@ -1641,7 +1670,8 @@ struct ImGuiPayload
|
|||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
// OBSOLETED in 1.77 (from June 2020)
|
// OBSOLETED in 1.77 (from June 2020)
|
||||||
static inline bool OpenPopupOnItemClick(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1) { return OpenPopupContextItem(str_id, mouse_button); }
|
static inline bool OpenPopupOnItemClick(const char* str_id = NULL, ImGuiMouseButton mb = 1) { return OpenPopupContextItem(str_id, mb); } // Passing a mouse button to ImGuiPopupFlags is legal
|
||||||
|
static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); }
|
||||||
// OBSOLETED in 1.72 (from July 2019)
|
// OBSOLETED in 1.72 (from July 2019)
|
||||||
static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); }
|
static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); }
|
||||||
// OBSOLETED in 1.71 (from June 2019)
|
// OBSOLETED in 1.71 (from June 2019)
|
||||||
|
4
3rdparty/dear-imgui/imgui_demo.cpp
vendored
4
3rdparty/dear-imgui/imgui_demo.cpp
vendored
@ -2865,6 +2865,10 @@ static void ShowDemoWindowPopups()
|
|||||||
if (ImGui::Button("Delete.."))
|
if (ImGui::Button("Delete.."))
|
||||||
ImGui::OpenPopup("Delete?");
|
ImGui::OpenPopup("Delete?");
|
||||||
|
|
||||||
|
// Always center this window when appearing
|
||||||
|
ImVec2 center(ImGui::GetIO().DisplaySize.x * 0.5f, ImGui::GetIO().DisplaySize.y * 0.5f);
|
||||||
|
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||||
|
|
||||||
if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
||||||
{
|
{
|
||||||
ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
|
ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
|
||||||
|
7
3rdparty/dear-imgui/imgui_internal.h
vendored
7
3rdparty/dear-imgui/imgui_internal.h
vendored
@ -1850,12 +1850,10 @@ namespace ImGui
|
|||||||
|
|
||||||
// Popups, Modals, Tooltips
|
// Popups, Modals, Tooltips
|
||||||
IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
|
IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
|
||||||
IMGUI_API void OpenPopupEx(ImGuiID id);
|
IMGUI_API void OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags = ImGuiPopupFlags_None);
|
||||||
IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
|
IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
|
||||||
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); // Test for id at the current BeginPopup() level of the popup stack (this doesn't scan the whole popup stack!)
|
IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
|
||||||
IMGUI_API bool IsPopupOpenAtAnyLevel(ImGuiID id);
|
|
||||||
IMGUI_API bool IsAnyPopupOpen(); // Return true if any popup is open at the current BeginPopup() level of the popup stack
|
|
||||||
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 void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
||||||
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
||||||
@ -1958,6 +1956,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
|
IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
|
||||||
IMGUI_API void Scrollbar(ImGuiAxis axis);
|
IMGUI_API void Scrollbar(ImGuiAxis axis);
|
||||||
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawCornerFlags rounding_corners);
|
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawCornerFlags rounding_corners);
|
||||||
|
IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col);
|
||||||
IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
|
IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
|
||||||
IMGUI_API ImGuiID GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis);
|
IMGUI_API ImGuiID GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis);
|
||||||
IMGUI_API ImGuiID GetWindowResizeID(ImGuiWindow* window, int n); // 0..3: corners, 4..7: borders
|
IMGUI_API ImGuiID GetWindowResizeID(ImGuiWindow* window, int n); // 0..3: corners, 4..7: borders
|
||||||
|
53
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
53
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
@ -981,28 +981,16 @@ void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// frame_padding < 0: uses FramePadding from style (default)
|
// ImageButton() is flawed as 'id' is always derived from 'texture_id' (see #2464 #1390)
|
||||||
// frame_padding = 0: no framing
|
// We provide this internal helper to write your own variant while we figure out how to redesign the public ImageButton() API.
|
||||||
// frame_padding > 0: set framing size
|
bool ImGui::ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col)
|
||||||
// The color used are the button colors.
|
|
||||||
bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col)
|
|
||||||
{
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
const ImGuiStyle& style = g.Style;
|
|
||||||
|
|
||||||
// Default to using texture ID as ID. User can still push string/integer prefixes.
|
|
||||||
// We could hash the size/uv to create a unique ID but that would prevent the user from animating UV.
|
|
||||||
PushID((void*)(intptr_t)user_texture_id);
|
|
||||||
const ImGuiID id = window->GetID("#image");
|
|
||||||
PopID();
|
|
||||||
|
|
||||||
const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding;
|
|
||||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2);
|
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2);
|
||||||
const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size);
|
|
||||||
ItemSize(bb);
|
ItemSize(bb);
|
||||||
if (!ItemAdd(bb, id))
|
if (!ItemAdd(bb, id))
|
||||||
return false;
|
return false;
|
||||||
@ -1013,14 +1001,33 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
|
|||||||
// Render
|
// Render
|
||||||
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||||
RenderNavHighlight(bb, id);
|
RenderNavHighlight(bb, id);
|
||||||
RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding));
|
RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding));
|
||||||
if (bg_col.w > 0.0f)
|
if (bg_col.w > 0.0f)
|
||||||
window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col));
|
window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col));
|
||||||
window->DrawList->AddImage(user_texture_id, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col));
|
window->DrawList->AddImage(texture_id, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col));
|
||||||
|
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// frame_padding < 0: uses FramePadding from style (default)
|
||||||
|
// frame_padding = 0: no framing
|
||||||
|
// frame_padding > 0: set framing size
|
||||||
|
bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
if (window->SkipItems)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Default to using texture ID as ID. User can still push string/integer prefixes.
|
||||||
|
PushID((void*)(intptr_t)user_texture_id);
|
||||||
|
const ImGuiID id = window->GetID("#image");
|
||||||
|
PopID();
|
||||||
|
|
||||||
|
const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : g.Style.FramePadding;
|
||||||
|
return ImageButtonEx(id, user_texture_id, size, uv0, uv1, padding, bg_col, tint_col);
|
||||||
|
}
|
||||||
|
|
||||||
bool ImGui::Checkbox(const char* label, bool* v)
|
bool ImGui::Checkbox(const char* label, bool* v)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
@ -1485,7 +1492,7 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|||||||
|
|
||||||
bool hovered, held;
|
bool hovered, held;
|
||||||
bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held);
|
bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held);
|
||||||
bool popup_open = IsPopupOpen(id);
|
bool popup_open = IsPopupOpen(id, ImGuiPopupFlags_None);
|
||||||
|
|
||||||
const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
||||||
const float value_x2 = ImMax(frame_bb.Min.x, frame_bb.Max.x - arrow_size);
|
const float value_x2 = ImMax(frame_bb.Min.x, frame_bb.Max.x - arrow_size);
|
||||||
@ -1510,7 +1517,7 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|||||||
{
|
{
|
||||||
if (window->DC.NavLayerCurrent == 0)
|
if (window->DC.NavLayerCurrent == 0)
|
||||||
window->NavLastIds[0] = id;
|
window->NavLastIds[0] = id;
|
||||||
OpenPopupEx(id);
|
OpenPopupEx(id, ImGuiPopupFlags_None);
|
||||||
popup_open = true;
|
popup_open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6296,7 +6303,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const ImGuiID id = window->GetID(label);
|
const ImGuiID id = window->GetID(label);
|
||||||
bool menu_is_open = IsPopupOpen(id);
|
bool menu_is_open = IsPopupOpen(id, ImGuiPopupFlags_None);
|
||||||
|
|
||||||
// Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
|
// Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
|
||||||
ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus;
|
ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus;
|
||||||
@ -6422,7 +6429,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|||||||
|
|
||||||
if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
|
if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
|
||||||
want_close = true;
|
want_close = true;
|
||||||
if (want_close && IsPopupOpen(id))
|
if (want_close && IsPopupOpen(id, ImGuiPopupFlags_None))
|
||||||
ClosePopupToLevel(g.BeginPopupStack.Size, true);
|
ClosePopupToLevel(g.BeginPopupStack.Size, true);
|
||||||
|
|
||||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0));
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0));
|
||||||
|
Loading…
Reference in New Issue
Block a user