mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Updated ImGui.
This commit is contained in:
268
3rdparty/dear-imgui/imgui.cpp
vendored
268
3rdparty/dear-imgui/imgui.cpp
vendored
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.89.7 WIP
|
||||
// dear imgui, v1.89.8 WIP
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
@@ -9,22 +9,26 @@
|
||||
|
||||
// Resources:
|
||||
// - FAQ http://dearimgui.com/faq
|
||||
// - Homepage & latest https://github.com/ocornut/imgui
|
||||
// - Homepage https://github.com/ocornut/imgui
|
||||
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/6478 (please post your screenshots/video there!)
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||
// - Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
// - Tests & Automation https://github.com/ocornut/imgui_test_engine
|
||||
|
||||
// Getting Started?
|
||||
// - For first-time users having issues compiling/linking/running or issues loading fonts:
|
||||
// - Read https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||
// - For first-time users having issues compiling/linking/running/loading fonts:
|
||||
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
||||
|
||||
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
||||
// See LICENSE.txt for copyright and licensing details (standard MIT License).
|
||||
// This library is free but needs your support to sustain development and maintenance.
|
||||
// Businesses: you can support continued development via invoiced technical support, maintenance and sponsoring contracts. Please reach out to "contact AT dearimgui.com".
|
||||
// Individuals: you can support continued development via donations. See docs/README or web page.
|
||||
// Businesses: you can support continued development via B2B invoiced technical support, maintenance and sponsoring contracts.
|
||||
// PLEASE reach out at contact AT dearimgui DOT com. See https://github.com/ocornut/imgui/wiki/Sponsors
|
||||
// Businesses: you can also purchase licenses for the Dear ImGui Automation/Test Engine.
|
||||
|
||||
// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library.
|
||||
// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without
|
||||
@@ -107,9 +111,10 @@ CODE
|
||||
- Portable, minimize dependencies, run on target (consoles, phones, etc.).
|
||||
- Efficient runtime and memory consumption.
|
||||
|
||||
Designed for developers and content-creators, not the typical end-user! Some of the current weaknesses includes:
|
||||
Designed primarily for developers and content-creators, not the typical end-user!
|
||||
Some of the current weaknesses (which we aim to address in the future) includes:
|
||||
|
||||
- Doesn't look fancy, doesn't animate.
|
||||
- Doesn't look fancy.
|
||||
- Limited layout features, intricate layouts are typically crafted in code.
|
||||
|
||||
|
||||
@@ -188,9 +193,11 @@ CODE
|
||||
READ FIRST
|
||||
----------
|
||||
- Remember to check the wonderful Wiki (https://github.com/ocornut/imgui/wiki)
|
||||
- Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction or
|
||||
destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, fewer bugs.
|
||||
- Your code creates the UI every frame of your application loop, if your code doesn't run the UI is gone!
|
||||
The UI can be highly dynamic, there are no construction or destruction steps, less superfluous
|
||||
data retention on your side, less state duplication, less state synchronization, fewer bugs.
|
||||
- Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features.
|
||||
Or browse https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html for interactive web version.
|
||||
- The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build.
|
||||
- Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori).
|
||||
You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links in Wiki.
|
||||
@@ -198,18 +205,38 @@ CODE
|
||||
For every application frame, your UI code will be called only once. This is in contrast to e.g. Unity's implementation of an IMGUI,
|
||||
where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches.
|
||||
- Our origin is on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right.
|
||||
- This codebase is also optimized to yield decent performances with typical "Debug" builds settings.
|
||||
- Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected).
|
||||
If you get an assert, read the messages and comments around the assert.
|
||||
- C++: this is a very C-ish codebase: we don't rely on C++11, we don't include any C++ headers, and ImGui:: is a namespace.
|
||||
- C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types.
|
||||
See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that.
|
||||
However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase.
|
||||
- C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!).
|
||||
- This codebase aims to be highly optimized:
|
||||
- A typical idle frame should never call malloc/free.
|
||||
- We rely on a maximum of constant-time or O(N) algorithms. Limiting searches/scans as much as possible.
|
||||
- We put particular energy in making sure performances are decent with typical "Debug" build settings as well.
|
||||
Which mean we tend to avoid over-relying on "zero-cost abstraction" as they aren't zero-cost at all.
|
||||
- This codebase aims to be both highly opinionated and highly flexible:
|
||||
- This code works because of the things it choose to solve or not solve.
|
||||
- C++: this is a pragmatic C-ish codebase: we don't use fancy C++ features, we don't include C++ headers,
|
||||
and ImGui:: is a namespace. We rarely use member functions (and when we did, I am mostly regretting it now).
|
||||
This is to increase compatibility, increase maintainability and facilitate use from other languages.
|
||||
- C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types.
|
||||
See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that.
|
||||
We can can optionally export math operators for ImVec2/ImVec4 using IMGUI_DEFINE_MATH_OPERATORS, which we use internally.
|
||||
- C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction
|
||||
(so don't use ImVector in your code or at our own risk!).
|
||||
- Building: We don't use nor mandate a build system for the main library.
|
||||
This is in an effort to ensure that it works in the real world aka with any esoteric build setup.
|
||||
This is also because providing a build system for the main library would be of little-value.
|
||||
The build problems are almost never coming from the main library but from specific backends.
|
||||
|
||||
|
||||
HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
|
||||
----------------------------------------------
|
||||
- Update submodule or copy/overwrite every file.
|
||||
- About imconfig.h:
|
||||
- You may modify your copy of imconfig.h, in this case don't overwrite it.
|
||||
- or you may locally branch to modify imconfig.h and merge/rebase latest.
|
||||
- or you may '#define IMGUI_USER_CONFIG "my_config_file.h"' globally from your build system to
|
||||
specify a custom path for your imconfig.h file and instead not have to modify the default one.
|
||||
|
||||
- Overwrite all the sources files except for imconfig.h (if you have modified your copy of imconfig.h)
|
||||
- Or maintain your own branch where you have imconfig.h modified as a top-most commit which you can regularly rebase over "master".
|
||||
- You can also use '#define IMGUI_USER_CONFIG "my_config_file.h" to redirect configuration to your own file.
|
||||
@@ -218,11 +245,12 @@ CODE
|
||||
from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will
|
||||
likely be a comment about it. Please report any issue to the GitHub page!
|
||||
- To find out usage of old API, you can add '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in your configuration file.
|
||||
- Try to keep your copy of Dear ImGui reasonably up to date.
|
||||
- Try to keep your copy of Dear ImGui reasonably up to date!
|
||||
|
||||
|
||||
GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
|
||||
---------------------------------------------------------------
|
||||
- See https://github.com/ocornut/imgui/wiki/Getting-Started.
|
||||
- Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
|
||||
- In the majority of cases you should be able to use unmodified backends files available in the backends/ folder.
|
||||
- Add the Dear ImGui source files + selected backend source files to your projects or using your preferred build system.
|
||||
@@ -397,6 +425,7 @@ CODE
|
||||
When you are not sure about an 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.
|
||||
|
||||
- 2023/07/12 (1.89.8) - ImDrawData: CmdLists now owned, changed from ImDrawList** to ImVector<ImDrawList*>. Majority of users shouldn't be affected, but you cannot compare to NULL nor reassign manually anymore. Instead use AddDrawList(). (#6406, #4879, #1878)
|
||||
- 2023/06/28 (1.89.7) - overlapping items: obsoleted 'SetItemAllowOverlap()' (called after item) in favor of calling 'SetNextItemAllowOverlap()' (called before item). 'SetItemAllowOverlap()' didn't and couldn't work reliably since 1.89 (2022-11-15).
|
||||
- 2023/06/28 (1.89.7) - overlapping items: renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap', 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'. Kept redirecting enums (will obsolete).
|
||||
- 2023/06/28 (1.89.7) - overlapping items: IsItemHovered() now by default return false when querying an item using AllowOverlap mode which is being overlapped. Use ImGuiHoveredFlags_AllowWhenOverlappedByItem to revert to old behavior.
|
||||
@@ -803,11 +832,12 @@ CODE
|
||||
|
||||
Q: Where is the documentation?
|
||||
A: This library is poorly documented at the moment and expects the user to be acquainted with C/C++.
|
||||
- Run the examples/ and explore them.
|
||||
- Run the examples/ applications and explore them.
|
||||
- Read Getting Started (https://github.com/ocornut/imgui/wiki/Getting-Started) guide.
|
||||
- See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function.
|
||||
- The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
||||
- See documentation and comments at the top of imgui.cpp + effectively imgui.h.
|
||||
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the
|
||||
- 20+ standalone example applications using e.g. OpenGL/DirectX are provided in the
|
||||
examples/ folder to explain how to integrate Dear ImGui with your own engine/application.
|
||||
- The Wiki (https://github.com/ocornut/imgui/wiki) has many resources and links.
|
||||
- The Glossary (https://github.com/ocornut/imgui/wiki/Glossary) page also may be useful.
|
||||
@@ -823,14 +853,14 @@ CODE
|
||||
================
|
||||
|
||||
Q: How to get started?
|
||||
A: Read 'PROGRAMMER GUIDE' above. Read examples/README.txt.
|
||||
A: Read https://github.com/ocornut/imgui/wiki/Getting-Started. Read 'PROGRAMMER GUIDE' above. Read examples/README.txt.
|
||||
|
||||
Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?
|
||||
A: You should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
|
||||
>> See https://www.dearimgui.com/faq for a fully detailed answer. You really want to read this.
|
||||
|
||||
Q. How can I enable keyboard controls?
|
||||
Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)
|
||||
Q. How can I enable keyboard or gamepad controls?
|
||||
Q: How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)
|
||||
Q: I integrated Dear ImGui in my engine and little squares are showing instead of text...
|
||||
Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around...
|
||||
Q: I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries...
|
||||
@@ -845,7 +875,7 @@ CODE
|
||||
- How can I have multiple widgets with the same label?
|
||||
- How can I have multiple windows with the same label?
|
||||
Q: How can I display an image? What is ImTextureID, how does it work?
|
||||
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?
|
||||
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)
|
||||
>> See https://www.dearimgui.com/faq
|
||||
@@ -875,10 +905,10 @@ CODE
|
||||
Q: How can I help?
|
||||
A: - Businesses: please reach out to "contact AT dearimgui.com" if you work in a place using Dear ImGui!
|
||||
We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts.
|
||||
This is among the most useful thing you can do for Dear ImGui. With increased funding, we can hire more people working on this project.
|
||||
- Individuals: you can support continued development via PayPal donations. See README.
|
||||
- If you are experienced with Dear ImGui and C++, look at the GitHub issues, look at the Wiki, read docs/TODO.txt
|
||||
and see how you want to help and can help!
|
||||
This is among the most useful thing you can do for Dear ImGui. With increased funding, we sustain and grow work on this project.
|
||||
Also see https://github.com/ocornut/imgui/wiki/Sponsors
|
||||
- Businesses: you can also purchase licenses for the Dear ImGui Automation/Test Engine.
|
||||
- If you are experienced with Dear ImGui and C++, look at the GitHub issues, look at the Wiki, and see how you want to help and can help!
|
||||
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
||||
You may post screenshot or links in the gallery threads. Visuals are ideal as they inspire other programmers.
|
||||
But even without visuals, disclosing your use of dear imgui helps the library grow credibility, and help other teams and programmers with taking decisions.
|
||||
@@ -904,11 +934,7 @@ CODE
|
||||
|
||||
// System includes
|
||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
|
||||
// [Windows] On non-Visual Studio compilers, we default to IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS unless explicitly enabled
|
||||
#if defined(_WIN32) && !defined(_MSC_VER) && !defined(IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
|
||||
@@ -1011,7 +1037,6 @@ static void FindHoveredWindow();
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags);
|
||||
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window);
|
||||
|
||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
||||
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
|
||||
|
||||
// Settings
|
||||
@@ -1341,13 +1366,15 @@ void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Perhaps we could clear queued events as well?
|
||||
void ImGuiIO::ClearInputCharacters()
|
||||
// Clear all incoming events.
|
||||
void ImGuiIO::ClearEventsQueue()
|
||||
{
|
||||
InputQueueCharacters.resize(0);
|
||||
IM_ASSERT(Ctx != NULL);
|
||||
ImGuiContext& g = *Ctx;
|
||||
g.InputEventsQueue.clear();
|
||||
}
|
||||
|
||||
// FIXME: Perhaps we could clear queued events as well?
|
||||
// Clear current keyboard/mouse/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||
void ImGuiIO::ClearInputKeys()
|
||||
{
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
@@ -1368,8 +1395,18 @@ void ImGuiIO::ClearInputKeys()
|
||||
MouseDownDuration[n] = MouseDownDurationPrev[n] = -1.0f;
|
||||
}
|
||||
MouseWheel = MouseWheelH = 0.0f;
|
||||
InputQueueCharacters.resize(0); // Behavior of old ClearInputCharacters().
|
||||
}
|
||||
|
||||
// Removed this as it is ambiguous/misleading and generally incorrect to use with the existence of a higher-level input queue.
|
||||
// Current frame character buffer is now also cleared by ClearInputKeys().
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
void ImGuiIO::ClearInputCharacters()
|
||||
{
|
||||
InputQueueCharacters.resize(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1)
|
||||
{
|
||||
ImGuiContext& g = *ctx;
|
||||
@@ -2906,7 +2943,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
||||
const bool is_nav_request = (g.NavMoveScoringItems && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav);
|
||||
if (is_nav_request)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromPositions(g.NavScoringNoClipRect.Min.y, g.NavScoringNoClipRect.Max.y, 0, 0));
|
||||
if (is_nav_request && (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && g.NavTabbingDir == -1)
|
||||
if (is_nav_request && (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && g.NavTabbingDir == -1)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(clipper->ItemsCount - 1, clipper->ItemsCount));
|
||||
|
||||
// Add focused/active item
|
||||
@@ -4771,47 +4808,12 @@ static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, Im
|
||||
}
|
||||
}
|
||||
|
||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
||||
{
|
||||
if (draw_list->CmdBuffer.Size == 0)
|
||||
return;
|
||||
if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL)
|
||||
return;
|
||||
|
||||
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
||||
// May trigger for you if you are using PrimXXX functions incorrectly.
|
||||
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
|
||||
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
|
||||
if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
|
||||
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
|
||||
|
||||
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
|
||||
// If this assert triggers because you are drawing lots of stuff manually:
|
||||
// - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
|
||||
// Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents.
|
||||
// - If you want large meshes with more than 64K vertices, you can either:
|
||||
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
|
||||
// Most example backends already support this from 1.71. Pre-1.71 backends won't.
|
||||
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
|
||||
// (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
|
||||
// Most example backends already support this. For example, the OpenGL example code detect index size at compile-time:
|
||||
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
|
||||
// Your own engine or render API may use different parameters or function calls to specify index sizes.
|
||||
// 2 and 4 bytes indices are generally supported by most graphics API.
|
||||
// - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
|
||||
// the 64K limit to split your draw commands in multiple draw lists.
|
||||
if (sizeof(ImDrawIdx) == 2)
|
||||
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
|
||||
|
||||
out_list->push_back(draw_list);
|
||||
}
|
||||
|
||||
static void AddWindowToDrawData(ImGuiWindow* window, int layer)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiViewportP* viewport = g.Viewports[0];
|
||||
g.IO.MetricsRenderWindows++;
|
||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[layer], window->DrawList);
|
||||
ImGui::AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[layer], window->DrawList);
|
||||
for (int i = 0; i < window->DC.ChildWindows.Size; i++)
|
||||
{
|
||||
ImGuiWindow* child = window->DC.ChildWindows[i];
|
||||
@@ -4831,42 +4833,41 @@ static inline void AddRootWindowToDrawData(ImGuiWindow* window)
|
||||
AddWindowToDrawData(window, GetWindowDisplayLayer(window));
|
||||
}
|
||||
|
||||
void ImDrawDataBuilder::FlattenIntoSingleLayer()
|
||||
static void FlattenDrawDataIntoSingleLayer(ImDrawDataBuilder* builder)
|
||||
{
|
||||
int n = Layers[0].Size;
|
||||
int size = n;
|
||||
for (int i = 1; i < IM_ARRAYSIZE(Layers); i++)
|
||||
size += Layers[i].Size;
|
||||
Layers[0].resize(size);
|
||||
for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++)
|
||||
int n = builder->Layers[0]->Size;
|
||||
int full_size = n;
|
||||
for (int i = 1; i < IM_ARRAYSIZE(builder->Layers); i++)
|
||||
full_size += builder->Layers[i]->Size;
|
||||
builder->Layers[0]->resize(full_size);
|
||||
for (int layer_n = 1; layer_n < IM_ARRAYSIZE(builder->Layers); layer_n++)
|
||||
{
|
||||
ImVector<ImDrawList*>& layer = Layers[layer_n];
|
||||
if (layer.empty())
|
||||
ImVector<ImDrawList*>* layer = builder->Layers[layer_n];
|
||||
if (layer->empty())
|
||||
continue;
|
||||
memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*));
|
||||
n += layer.Size;
|
||||
layer.resize(0);
|
||||
memcpy(builder->Layers[0]->Data + n, layer->Data, layer->Size * sizeof(ImDrawList*));
|
||||
n += layer->Size;
|
||||
layer->resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector<ImDrawList*>* draw_lists)
|
||||
static void InitViewportDrawData(ImGuiViewportP* viewport)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImDrawData* draw_data = &viewport->DrawDataP;
|
||||
|
||||
viewport->DrawDataBuilder.Layers[0] = &draw_data->CmdLists;
|
||||
viewport->DrawDataBuilder.Layers[1] = &viewport->DrawDataBuilder.LayerData1;
|
||||
viewport->DrawDataBuilder.Layers[0]->resize(0);
|
||||
viewport->DrawDataBuilder.Layers[1]->resize(0);
|
||||
|
||||
draw_data->Valid = true;
|
||||
draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL;
|
||||
draw_data->CmdListsCount = draw_lists->Size;
|
||||
draw_data->CmdListsCount = 0;
|
||||
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
|
||||
draw_data->DisplayPos = viewport->Pos;
|
||||
draw_data->DisplaySize = viewport->Size;
|
||||
draw_data->FramebufferScale = io.DisplayFramebufferScale;
|
||||
for (int n = 0; n < draw_lists->Size; n++)
|
||||
{
|
||||
ImDrawList* draw_list = draw_lists->Data[n];
|
||||
draw_list->_PopUnusedDrawCmd();
|
||||
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
|
||||
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
|
||||
}
|
||||
draw_data->OwnerViewport = viewport;
|
||||
}
|
||||
|
||||
// Push a clipping rectangle for both ImGui logic (hit-testing etc.) and low-level ImDrawList rendering.
|
||||
@@ -4905,14 +4906,14 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
|
||||
ImDrawList* draw_list = window->RootWindow->DrawList;
|
||||
if (draw_list->CmdBuffer.Size == 0)
|
||||
draw_list->AddDrawCmd();
|
||||
draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // Ensure ImDrawCmd are not merged
|
||||
draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // FIXME: Need to stricty ensure ImDrawCmd are not merged (ElemCount==6 checks below will verify that)
|
||||
draw_list->AddRectFilled(viewport_rect.Min, viewport_rect.Max, col);
|
||||
ImDrawCmd cmd = draw_list->CmdBuffer.back();
|
||||
IM_ASSERT(cmd.ElemCount == 6);
|
||||
draw_list->CmdBuffer.pop_back();
|
||||
draw_list->CmdBuffer.push_front(cmd);
|
||||
draw_list->PopClipRect();
|
||||
draw_list->AddDrawCmd(); // We need to create a command as CmdBuffer.back().IdxOffset won't be correct if we append to same command.
|
||||
draw_list->PopClipRect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5087,9 +5088,9 @@ void ImGui::Render()
|
||||
for (int n = 0; n != g.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
viewport->DrawDataBuilder.Clear();
|
||||
InitViewportDrawData(viewport);
|
||||
if (viewport->DrawLists[0] != NULL)
|
||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
||||
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
||||
}
|
||||
|
||||
// Draw modal/window whitening backgrounds
|
||||
@@ -5120,14 +5121,18 @@ void ImGui::Render()
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
viewport->DrawDataBuilder.FlattenIntoSingleLayer();
|
||||
FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder);
|
||||
|
||||
// Add foreground ImDrawList (for each active viewport)
|
||||
if (viewport->DrawLists[1] != NULL)
|
||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
|
||||
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
|
||||
|
||||
SetupViewportDrawData(viewport, &viewport->DrawDataBuilder.Layers[0]);
|
||||
// We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch).
|
||||
ImDrawData* draw_data = &viewport->DrawDataP;
|
||||
IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount);
|
||||
for (int draw_list_n = 0; draw_list_n < draw_data->CmdLists.Size; draw_list_n++)
|
||||
draw_data->CmdLists[draw_list_n]->_PopUnusedDrawCmd();
|
||||
|
||||
g.IO.MetricsRenderVertices += draw_data->TotalVtxCount;
|
||||
g.IO.MetricsRenderIndices += draw_data->TotalIdxCount;
|
||||
}
|
||||
@@ -7653,7 +7658,7 @@ void ImGui::FocusItem()
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSelect;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSelect;
|
||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||
SetNavWindow(window);
|
||||
NavMoveRequestSubmit(ImGuiDir_None, ImGuiDir_Up, move_flags, scroll_flags);
|
||||
@@ -7688,7 +7693,7 @@ void ImGui::SetKeyboardFocusHere(int offset)
|
||||
|
||||
SetNavWindow(window);
|
||||
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi;
|
||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||
NavMoveRequestSubmit(ImGuiDir_None, offset < 0 ? ImGuiDir_Up : ImGuiDir_Down, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
||||
if (offset == -1)
|
||||
@@ -8621,14 +8626,12 @@ static void ImGui::UpdateMouseInputs()
|
||||
else
|
||||
io.MouseDelta = ImVec2(0.0f, 0.0f);
|
||||
|
||||
// Update stationary timer. Only reset on 2 successive moving frames.
|
||||
// FIXME: May need to expose threshold or treat touch inputs differently.
|
||||
// Update stationary timer.
|
||||
// FIXME: May need to rework again to have some tolerance for occasional small movement, while being functional on high-framerates.
|
||||
const float mouse_stationary_threshold = (io.MouseSource == ImGuiMouseSource_Mouse) ? 2.0f : 3.0f; // Slightly higher threshold for ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen, may need rework.
|
||||
g.MouseMovingFrames = (ImLengthSqr(io.MouseDelta) >= mouse_stationary_threshold * mouse_stationary_threshold) ? (g.MouseMovingFrames + 1) : 0;
|
||||
if (g.MouseMovingFrames == 0)
|
||||
g.MouseStationaryTimer += io.DeltaTime;
|
||||
else if (g.MouseMovingFrames > 1)
|
||||
g.MouseStationaryTimer = 0.0f;
|
||||
const bool mouse_stationary = (ImLengthSqr(io.MouseDelta) <= mouse_stationary_threshold * mouse_stationary_threshold);
|
||||
g.MouseStationaryTimer = mouse_stationary ? (g.MouseStationaryTimer + io.DeltaTime) : 0.0f;
|
||||
//IMGUI_DEBUG_LOG("%.4f\n", g.MouseStationaryTimer);
|
||||
|
||||
// If mouse moved we re-enable mouse hovering in case it was disabled by gamepad/keyboard. In theory should use a >0.0f threshold but would need to reset in everywhere we set this to true.
|
||||
if (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)
|
||||
@@ -11060,7 +11063,7 @@ static void ImGui::NavProcessItem()
|
||||
// FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy)
|
||||
if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
||||
{
|
||||
const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) != 0;
|
||||
const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) != 0;
|
||||
if (is_tabbing)
|
||||
{
|
||||
NavProcessItemForTabbingRequest(id, item_flags, g.NavMoveFlags);
|
||||
@@ -11166,7 +11169,7 @@ void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavM
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.NavWindow != NULL);
|
||||
|
||||
if (move_flags & ImGuiNavMoveFlags_Tabbing)
|
||||
if (move_flags & ImGuiNavMoveFlags_IsTabbing)
|
||||
move_flags |= ImGuiNavMoveFlags_AllowCurrentNavId;
|
||||
|
||||
g.NavMoveSubmitted = g.NavMoveScoringItems = true;
|
||||
@@ -11714,7 +11717,7 @@ void ImGui::NavUpdateCreateTabbingRequest()
|
||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.NavDisableHighlight == true && g.ActiveId == 0) ? 0 : +1;
|
||||
else
|
||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.ActiveId == 0) ? 0 : +1;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_Activate;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate;
|
||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||
ImGuiDir clip_dir = (g.NavTabbingDir < 0) ? ImGuiDir_Up : ImGuiDir_Down;
|
||||
NavMoveRequestSubmit(ImGuiDir_None, clip_dir, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
||||
@@ -11734,7 +11737,7 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther : NULL;
|
||||
|
||||
// Tabbing forward wrap
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && result == NULL)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && result == NULL)
|
||||
if ((g.NavTabbingCounter == 1 || g.NavTabbingDir == 0) && g.NavTabbingResultFirst.ID)
|
||||
result = &g.NavTabbingResultFirst;
|
||||
|
||||
@@ -11742,7 +11745,7 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
const ImGuiAxis axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||
if (result == NULL)
|
||||
{
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing)
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
||||
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavHighlight) == 0)
|
||||
NavRestoreHighlightAfterMove();
|
||||
@@ -11783,9 +11786,11 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
}
|
||||
if (g.ActiveId != result->ID)
|
||||
ClearActiveID();
|
||||
if (g.NavId != result->ID && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
||||
|
||||
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
||||
// PageUp/PageDown however sets always set NavJustMovedTo (vs Home/End which doesn't) mimicking Windows behavior.
|
||||
if ((g.NavId != result->ID || (g.NavMoveFlags & ImGuiNavMoveFlags_IsPageMove)) && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
||||
{
|
||||
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
||||
g.NavJustMovedToId = result->ID;
|
||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||
@@ -11798,14 +11803,14 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
|
||||
// Restore last preferred position for current axis
|
||||
// (storing in RootWindowForNav-> as the info is desirable at the beginning of a Move Request. In theory all storage should use RootWindowForNav..)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) == 0)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) == 0)
|
||||
{
|
||||
preferred_scoring_pos_rel[axis] = result->RectRel.GetCenter()[axis];
|
||||
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer] = preferred_scoring_pos_rel;
|
||||
}
|
||||
|
||||
// Tabbing: Activates Inputable, otherwise only Focus
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable) == 0)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && (result->InFlags & ImGuiItemFlags_Inputable) == 0)
|
||||
g.NavMoveFlags &= ~ImGuiNavMoveFlags_Activate;
|
||||
|
||||
// Activate
|
||||
@@ -11814,7 +11819,7 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
g.NavNextActivateId = result->ID;
|
||||
g.NavNextActivateFlags = ImGuiActivateFlags_None;
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing)
|
||||
g.NavNextActivateFlags |= ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState;
|
||||
}
|
||||
|
||||
@@ -11914,14 +11919,14 @@ static float ImGui::NavUpdatePageUpPageDown()
|
||||
nav_scoring_rect_offset_y = -page_offset_y;
|
||||
g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item)
|
||||
g.NavMoveClipDir = ImGuiDir_Up;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
|
||||
}
|
||||
else if (IsKeyPressed(ImGuiKey_PageDown, true))
|
||||
{
|
||||
nav_scoring_rect_offset_y = +page_offset_y;
|
||||
g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item)
|
||||
g.NavMoveClipDir = ImGuiDir_Down;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
|
||||
}
|
||||
else if (home_pressed)
|
||||
{
|
||||
@@ -13850,7 +13855,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
// DrawLists
|
||||
int drawlist_count = 0;
|
||||
for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++)
|
||||
drawlist_count += g.Viewports[viewport_i]->DrawDataBuilder.GetDrawListCount();
|
||||
drawlist_count += g.Viewports[viewport_i]->DrawDataP.CmdLists.Size;
|
||||
if (TreeNode("DrawLists", "DrawLists (%d)", drawlist_count))
|
||||
{
|
||||
Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh);
|
||||
@@ -13858,9 +13863,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[viewport_i];
|
||||
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
|
||||
DebugNodeDrawList(NULL, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataP.CmdLists.Size; draw_list_i++)
|
||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataP.CmdLists[draw_list_i], "DrawList");
|
||||
}
|
||||
TreePop();
|
||||
}
|
||||
@@ -14192,9 +14196,10 @@ void ImGui::DebugNodeColumns(ImGuiOldColumns* columns)
|
||||
}
|
||||
|
||||
// [DEBUG] Display contents of ImDrawList
|
||||
void ImGui::DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label)
|
||||
void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_UNUSED(viewport); // Used in docking branch
|
||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||
int cmd_count = draw_list->CmdBuffer.Size;
|
||||
if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL)
|
||||
@@ -14483,9 +14488,8 @@ void ImGui::DebugNodeViewport(ImGuiViewportP* viewport)
|
||||
(flags & ImGuiViewportFlags_IsPlatformWindow) ? " IsPlatformWindow" : "",
|
||||
(flags & ImGuiViewportFlags_IsPlatformMonitor) ? " IsPlatformMonitor" : "",
|
||||
(flags & ImGuiViewportFlags_OwnedByApp) ? " OwnedByApp" : "");
|
||||
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
|
||||
DebugNodeDrawList(NULL, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataP.CmdLists.Size; draw_list_i++)
|
||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataP.CmdLists[draw_list_i], "DrawList");
|
||||
TreePop();
|
||||
}
|
||||
}
|
||||
@@ -14513,7 +14517,7 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label)
|
||||
TextDisabled("Note: some memory buffers have been compacted/freed.");
|
||||
|
||||
ImGuiWindowFlags flags = window->Flags;
|
||||
DebugNodeDrawList(window, window->DrawList, "DrawList");
|
||||
DebugNodeDrawList(window, window->Viewport, window->DrawList, "DrawList");
|
||||
BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f) Ideal (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y, window->ContentSizeIdeal.x, window->ContentSizeIdeal.y);
|
||||
BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags,
|
||||
(flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "",
|
||||
@@ -14929,7 +14933,7 @@ void ImGui::ShowStackToolWindow(bool* p_open)
|
||||
void ImGui::ShowMetricsWindow(bool*) {}
|
||||
void ImGui::ShowFontAtlas(ImFontAtlas*) {}
|
||||
void ImGui::DebugNodeColumns(ImGuiOldColumns*) {}
|
||||
void ImGui::DebugNodeDrawList(ImGuiWindow*, const ImDrawList*, const char*) {}
|
||||
void ImGui::DebugNodeDrawList(ImGuiWindow*, ImGuiViewportP*, const ImDrawList*, const char*) {}
|
||||
void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList*, const ImDrawList*, const ImDrawCmd*, bool, bool) {}
|
||||
void ImGui::DebugNodeFont(ImFont*) {}
|
||||
void ImGui::DebugNodeStorage(ImGuiStorage*, const char*) {}
|
||||
|
||||
40
3rdparty/dear-imgui/imgui.h
vendored
40
3rdparty/dear-imgui/imgui.h
vendored
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.89.7 WIP
|
||||
// dear imgui, v1.89.8 WIP
|
||||
// (headers)
|
||||
|
||||
// Help:
|
||||
@@ -9,21 +9,24 @@
|
||||
|
||||
// Resources:
|
||||
// - FAQ http://dearimgui.com/faq
|
||||
// - Homepage & latest https://github.com/ocornut/imgui
|
||||
// - Homepage https://github.com/ocornut/imgui
|
||||
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/6478 (please post your screenshots/video there!)
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||
// - Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
// - Tests & Automation https://github.com/ocornut/imgui_test_engine
|
||||
|
||||
// Getting Started?
|
||||
// - For first-time users having issues compiling/linking/running or issues loading fonts:
|
||||
// - Read https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||
// - For first-time users having issues compiling/linking/running/loading fonts:
|
||||
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
||||
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.89.7 WIP"
|
||||
#define IMGUI_VERSION_NUM 18967
|
||||
#define IMGUI_VERSION "1.89.8 WIP"
|
||||
#define IMGUI_VERSION_NUM 18973
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
@@ -2056,8 +2059,11 @@ struct ImGuiIO
|
||||
|
||||
IMGUI_API void SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index = -1); // [Optional] Specify index for legacy <1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
|
||||
IMGUI_API void SetAppAcceptingEvents(bool accepting_events); // Set master flag for accepting key/mouse/text events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
|
||||
IMGUI_API void ClearInputCharacters(); // [Internal] Clear the text input buffer manually
|
||||
IMGUI_API void ClearInputKeys(); // [Internal] Release all keys
|
||||
IMGUI_API void ClearEventsQueue(); // Clear all incoming events.
|
||||
IMGUI_API void ClearInputKeys(); // Clear current keyboard/mouse/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
IMGUI_API void ClearInputCharacters(); // [Obsolete] Clear the current frame text input buffer. Now included within ClearInputKeys().
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Output - Updated by NewFrame() or EndFrame()/Render()
|
||||
@@ -2738,18 +2744,20 @@ struct ImDrawList
|
||||
// as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList)
|
||||
struct ImDrawData
|
||||
{
|
||||
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
|
||||
int CmdListsCount; // Number of ImDrawList* to render
|
||||
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
||||
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
||||
ImDrawList** CmdLists; // Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here.
|
||||
ImVec2 DisplayPos; // Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications)
|
||||
ImVec2 DisplaySize; // Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications)
|
||||
ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
|
||||
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
|
||||
int CmdListsCount; // Number of ImDrawList* to render (should always be == CmdLists.size)
|
||||
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
||||
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
||||
ImVector<ImDrawList*> CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here.
|
||||
ImVec2 DisplayPos; // Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications)
|
||||
ImVec2 DisplaySize; // Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications)
|
||||
ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
|
||||
ImGuiViewport* OwnerViewport; // Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not).
|
||||
|
||||
// Functions
|
||||
ImDrawData() { Clear(); }
|
||||
void Clear() { memset(this, 0, sizeof(*this)); } // The ImDrawList are owned by ImGuiContext!
|
||||
IMGUI_API void Clear();
|
||||
IMGUI_API void AddDrawList(ImDrawList* draw_list); // Helper to add an external draw list into an existing ImDrawData.
|
||||
IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||
IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||
};
|
||||
|
||||
83
3rdparty/dear-imgui/imgui_demo.cpp
vendored
83
3rdparty/dear-imgui/imgui_demo.cpp
vendored
@@ -1,10 +1,12 @@
|
||||
// dear imgui, v1.89.7 WIP
|
||||
// dear imgui, v1.89.8 WIP
|
||||
// (demo code)
|
||||
|
||||
// Help:
|
||||
// - Read FAQ at http://dearimgui.com/faq
|
||||
// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that.
|
||||
// - Need help integrating Dear ImGui in your codebase?
|
||||
// - Read Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||
// - Read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||
// Read imgui.cpp for more details, documentation and comments.
|
||||
// Get the latest version at https://github.com/ocornut/imgui
|
||||
|
||||
@@ -91,11 +93,7 @@ Index of this file:
|
||||
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||
#include <stdlib.h> // NULL, malloc, free, atoi
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
|
||||
// Visual Studio warnings
|
||||
#ifdef _MSC_VER
|
||||
@@ -1260,16 +1258,16 @@ static void ShowDemoWindowWidgets()
|
||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Basic");
|
||||
if (ImGui::TreeNode("Basic"))
|
||||
{
|
||||
static bool selection[5] = { false, true, false, false, false };
|
||||
static bool selection[5] = { false, true, false, false };
|
||||
ImGui::Selectable("1. I am selectable", &selection[0]);
|
||||
ImGui::Selectable("2. I am selectable", &selection[1]);
|
||||
ImGui::Text("(I am not selectable)");
|
||||
ImGui::Selectable("4. I am selectable", &selection[3]);
|
||||
if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
|
||||
ImGui::Selectable("3. I am selectable", &selection[2]);
|
||||
if (ImGui::Selectable("4. I am double clickable", selection[3], ImGuiSelectableFlags_AllowDoubleClick))
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
selection[4] = !selection[4];
|
||||
selection[3] = !selection[3];
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Single Selection");
|
||||
if (ImGui::TreeNode("Selection State: Single Selection"))
|
||||
{
|
||||
@@ -1301,17 +1299,18 @@ static void ShowDemoWindowWidgets()
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Rendering more text into the same line");
|
||||
if (ImGui::TreeNode("Rendering more text into the same line"))
|
||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Rendering more items on the same line");
|
||||
if (ImGui::TreeNode("Rendering more items on the same line"))
|
||||
{
|
||||
// Using the Selectable() override that takes "bool* p_selected" parameter,
|
||||
// this function toggle your bool value automatically.
|
||||
// (1) Using SetNextItemAllowOverlap()
|
||||
// (2) Using the Selectable() override that takes "bool* p_selected" parameter, the bool value is toggled automatically.
|
||||
static bool selected[3] = { false, false, false };
|
||||
ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
|
||||
ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes");
|
||||
ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
|
||||
ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(); ImGui::SmallButton("Link 1");
|
||||
ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(); ImGui::SmallButton("Link 2");
|
||||
ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(); ImGui::SmallButton("Link 3");
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
IMGUI_DEMO_MARKER("Widgets/Selectables/In columns");
|
||||
if (ImGui::TreeNode("In columns"))
|
||||
{
|
||||
@@ -1347,6 +1346,7 @@ static void ShowDemoWindowWidgets()
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Grid");
|
||||
if (ImGui::TreeNode("Grid"))
|
||||
{
|
||||
@@ -1480,6 +1480,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
IMGUI_DEMO_MARKER("Widgets/Text Input/Completion, History, Edit Callbacks");
|
||||
if (ImGui::TreeNode("Completion, History, Edit Callbacks"))
|
||||
{
|
||||
struct Funcs
|
||||
@@ -1579,6 +1580,18 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
IMGUI_DEMO_MARKER("Widgets/Text Input/Miscellaneous");
|
||||
if (ImGui::TreeNode("Miscellaneous"))
|
||||
{
|
||||
static char buf1[16];
|
||||
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_EscapeClearsAll;
|
||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_EscapeClearsAll", &flags, ImGuiInputTextFlags_EscapeClearsAll);
|
||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", &flags, ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_NoUndoRedo", &flags, ImGuiInputTextFlags_NoUndoRedo);
|
||||
ImGui::InputText("Hello", buf1, IM_ARRAYSIZE(buf1), flags);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
@@ -2793,11 +2806,11 @@ static void ShowDemoWindowLayout()
|
||||
// Text
|
||||
IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/SameLine");
|
||||
ImGui::Text("Two items: Hello"); ImGui::SameLine();
|
||||
ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
|
||||
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Sailor");
|
||||
|
||||
// Adjust spacing
|
||||
ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
|
||||
ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
|
||||
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Sailor");
|
||||
|
||||
// Button
|
||||
ImGui::AlignTextToFramePadding();
|
||||
@@ -3395,6 +3408,36 @@ static void ShowDemoWindowLayout()
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
IMGUI_DEMO_MARKER("Layout/Overlap Mode");
|
||||
if (ImGui::TreeNode("Overlap Mode"))
|
||||
{
|
||||
static bool enable_allow_overlap = true;
|
||||
|
||||
HelpMarker(
|
||||
"Hit-testing is by default performed in item submission order, which generally is perceived as 'back-to-front'.\n\n"
|
||||
"By using SetNextItemAllowOverlap() you can notify that an item may be overlapped by another. Doing so alters the hovering logic: items using AllowOverlap mode requires an extra frame to accept hovered state.");
|
||||
ImGui::Checkbox("Enable AllowOverlap", &enable_allow_overlap);
|
||||
|
||||
ImVec2 button1_pos = ImGui::GetCursorScreenPos();
|
||||
ImVec2 button2_pos = ImVec2(button1_pos.x + 50.0f, button1_pos.y + 50.0f);
|
||||
if (enable_allow_overlap)
|
||||
ImGui::SetNextItemAllowOverlap();
|
||||
ImGui::Button("Button 1", ImVec2(80, 80));
|
||||
ImGui::SetCursorScreenPos(button2_pos);
|
||||
ImGui::Button("Button 2", ImVec2(80, 80));
|
||||
|
||||
// This is typically used with width-spanning items.
|
||||
// (note that Selectable() has a dedicated flag ImGuiSelectableFlags_AllowOverlap, which is a shortcut
|
||||
// for using SetNextItemAllowOverlap(). For demo purpose we use SetNextItemAllowOverlap() here.)
|
||||
if (enable_allow_overlap)
|
||||
ImGui::SetNextItemAllowOverlap();
|
||||
ImGui::Selectable("Some Selectable", false);
|
||||
ImGui::SameLine();
|
||||
ImGui::SmallButton("++");
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
static void ShowDemoWindowPopups()
|
||||
|
||||
59
3rdparty/dear-imgui/imgui_draw.cpp
vendored
59
3rdparty/dear-imgui/imgui_draw.cpp
vendored
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.89.7 WIP
|
||||
// dear imgui, v1.89.8 WIP
|
||||
// (drawing and font code)
|
||||
|
||||
/*
|
||||
@@ -1808,6 +1808,63 @@ void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
||||
// [SECTION] ImDrawData
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ImDrawData::Clear()
|
||||
{
|
||||
Valid = false;
|
||||
CmdListsCount = TotalIdxCount = TotalVtxCount = 0;
|
||||
CmdLists.resize(0); // The ImDrawList are NOT owned by ImDrawData but e.g. by ImGuiContext, so we don't clear them.
|
||||
DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.0f, 0.0f);
|
||||
OwnerViewport = NULL;
|
||||
}
|
||||
|
||||
// Important: 'out_list' is generally going to be draw_data->CmdLists, but may be another temporary list
|
||||
// as long at it is expected that the result will be later merged into draw_data->CmdLists[].
|
||||
void ImGui::AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
||||
{
|
||||
if (draw_list->CmdBuffer.Size == 0)
|
||||
return;
|
||||
if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL)
|
||||
return;
|
||||
|
||||
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
||||
// May trigger for you if you are using PrimXXX functions incorrectly.
|
||||
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
|
||||
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
|
||||
if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
|
||||
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
|
||||
|
||||
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
|
||||
// If this assert triggers because you are drawing lots of stuff manually:
|
||||
// - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
|
||||
// Be mindful that the lower-level ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents.
|
||||
// - If you want large meshes with more than 64K vertices, you can either:
|
||||
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
|
||||
// Most example backends already support this from 1.71. Pre-1.71 backends won't.
|
||||
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
|
||||
// (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
|
||||
// Most example backends already support this. For example, the OpenGL example code detect index size at compile-time:
|
||||
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
|
||||
// Your own engine or render API may use different parameters or function calls to specify index sizes.
|
||||
// 2 and 4 bytes indices are generally supported by most graphics API.
|
||||
// - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
|
||||
// the 64K limit to split your draw commands in multiple draw lists.
|
||||
if (sizeof(ImDrawIdx) == 2)
|
||||
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
|
||||
|
||||
// Add to output list + records state in ImDrawData
|
||||
out_list->push_back(draw_list);
|
||||
draw_data->CmdListsCount++;
|
||||
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
|
||||
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
|
||||
}
|
||||
|
||||
void ImDrawData::AddDrawList(ImDrawList* draw_list)
|
||||
{
|
||||
IM_ASSERT(CmdLists.Size == CmdListsCount);
|
||||
draw_list->_PopUnusedDrawCmd();
|
||||
ImGui::AddDrawListToDrawDataEx(this, &CmdLists, draw_list);
|
||||
}
|
||||
|
||||
// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||
void ImDrawData::DeIndexAllBuffers()
|
||||
{
|
||||
|
||||
34
3rdparty/dear-imgui/imgui_internal.h
vendored
34
3rdparty/dear-imgui/imgui_internal.h
vendored
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.89.7 WIP
|
||||
// dear imgui, v1.89.8 WIP
|
||||
// (internal structures/api)
|
||||
|
||||
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
||||
@@ -772,12 +772,10 @@ struct IMGUI_API ImDrawListSharedData
|
||||
|
||||
struct ImDrawDataBuilder
|
||||
{
|
||||
ImVector<ImDrawList*> Layers[2]; // Global layers for: regular, tooltip
|
||||
ImVector<ImDrawList*>* Layers[2]; // Pointers to global layers for: regular, tooltip. LayersP[0] is owned by DrawData.
|
||||
ImVector<ImDrawList*> LayerData1;
|
||||
|
||||
void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
|
||||
void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
|
||||
int GetDrawListCount() const { int count = 0; for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) count += Layers[n].Size; return count; }
|
||||
IMGUI_API void FlattenIntoSingleLayer();
|
||||
ImDrawDataBuilder() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1493,10 +1491,11 @@ enum ImGuiNavMoveFlags_
|
||||
ImGuiNavMoveFlags_Forwarded = 1 << 7,
|
||||
ImGuiNavMoveFlags_DebugNoResult = 1 << 8, // Dummy scoring for debug purpose, don't apply result
|
||||
ImGuiNavMoveFlags_FocusApi = 1 << 9, // Requests from focus API can land/focus/activate items even if they are marked with _NoTabStop (see NavProcessItemForTabbingRequest() for details)
|
||||
ImGuiNavMoveFlags_Tabbing = 1 << 10, // == Focus + Activate if item is Inputable + DontChangeNavHighlight
|
||||
ImGuiNavMoveFlags_Activate = 1 << 11, // Activate/select target item.
|
||||
ImGuiNavMoveFlags_NoSelect = 1 << 12, // Don't trigger selection by not setting g.NavJustMovedTo
|
||||
ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 13, // Do not alter the visible state of keyboard vs mouse nav highlight
|
||||
ImGuiNavMoveFlags_IsTabbing = 1 << 10, // == Focus + Activate if item is Inputable + DontChangeNavHighlight
|
||||
ImGuiNavMoveFlags_IsPageMove = 1 << 11, // Identify a PageDown/PageUp request.
|
||||
ImGuiNavMoveFlags_Activate = 1 << 12, // Activate/select target item.
|
||||
ImGuiNavMoveFlags_NoSelect = 1 << 13, // Don't trigger selection by not setting g.NavJustMovedTo
|
||||
ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 14, // Do not alter the visible state of keyboard vs mouse nav highlight
|
||||
};
|
||||
|
||||
enum ImGuiNavLayer
|
||||
@@ -1604,8 +1603,7 @@ struct ImGuiViewportP : public ImGuiViewport
|
||||
int DrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
||||
ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
||||
ImDrawData DrawDataP;
|
||||
ImDrawDataBuilder DrawDataBuilder;
|
||||
|
||||
ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData
|
||||
ImVec2 WorkOffsetMin; // Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!)
|
||||
ImVec2 WorkOffsetMax; // Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height).
|
||||
ImVec2 BuildWorkOffsetMin; // Work Area: Offset being built during current frame. Generally >= 0.0f.
|
||||
@@ -1978,7 +1976,6 @@ struct ImGuiContext
|
||||
|
||||
// Mouse state
|
||||
ImGuiMouseCursor MouseCursor;
|
||||
int MouseMovingFrames;
|
||||
float MouseStationaryTimer; // Time the mouse has been stationary (with some loose heuristic)
|
||||
ImVec2 MouseLastValidPos;
|
||||
|
||||
@@ -2182,7 +2179,6 @@ struct ImGuiContext
|
||||
HoverItemDelayTimer = HoverItemDelayClearTimer = 0.0f;
|
||||
|
||||
MouseCursor = ImGuiMouseCursor_Arrow;
|
||||
MouseMovingFrames = 0;
|
||||
MouseStationaryTimer = 0.0f;
|
||||
|
||||
TempInputId = 0;
|
||||
@@ -2577,8 +2573,10 @@ struct ImGuiTableInstanceData
|
||||
float LastOuterHeight; // Outer height from last frame
|
||||
float LastFirstRowHeight; // Height of first row from last frame (FIXME: this is used as "header height" and may be reworked)
|
||||
float LastFrozenHeight; // Height of frozen section from last frame
|
||||
int HoveredRowLast; // Index of row which was hovered last frame.
|
||||
int HoveredRowNext; // Index of row hovered this frame, set after encountering it.
|
||||
|
||||
ImGuiTableInstanceData() { TableInstanceID = 0; LastOuterHeight = LastFirstRowHeight = LastFrozenHeight = 0.0f; }
|
||||
ImGuiTableInstanceData() { TableInstanceID = 0; LastOuterHeight = LastFirstRowHeight = LastFrozenHeight = 0.0f; HoveredRowLast = HoveredRowNext = -1; }
|
||||
};
|
||||
|
||||
// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs, incoming RowData
|
||||
@@ -2804,6 +2802,7 @@ namespace ImGui
|
||||
inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); return GetForegroundDrawList(); } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
|
||||
IMGUI_API ImDrawList* GetBackgroundDrawList(ImGuiViewport* viewport); // get background draw list for the given viewport. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
|
||||
IMGUI_API ImDrawList* GetForegroundDrawList(ImGuiViewport* viewport); // get foreground draw list for the given viewport. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
|
||||
IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
||||
|
||||
// Init
|
||||
IMGUI_API void Initialize();
|
||||
@@ -3059,7 +3058,8 @@ namespace ImGui
|
||||
IMGUI_API void TableOpenContextMenu(int column_n = -1);
|
||||
IMGUI_API void TableSetColumnWidth(int column_n, float width);
|
||||
IMGUI_API void TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs);
|
||||
IMGUI_API int TableGetHoveredColumn(); // May use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) instead. Return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered.
|
||||
IMGUI_API int TableGetHoveredColumn(); // May use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) instead. Return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered.
|
||||
IMGUI_API int TableGetHoveredRow(); // Retrieve *PREVIOUS FRAME* hovered row. This difference with TableGetHoveredColumn() is the reason why this is not public yet.
|
||||
IMGUI_API float TableGetHeaderRowHeight();
|
||||
IMGUI_API void TablePushBackgroundChannel();
|
||||
IMGUI_API void TablePopBackgroundChannel();
|
||||
@@ -3241,7 +3241,7 @@ namespace ImGui
|
||||
IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas);
|
||||
IMGUI_API void DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end);
|
||||
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
|
||||
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label);
|
||||
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label);
|
||||
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
||||
IMGUI_API void DebugNodeFont(ImFont* font);
|
||||
IMGUI_API void DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph);
|
||||
|
||||
31
3rdparty/dear-imgui/imgui_tables.cpp
vendored
31
3rdparty/dear-imgui/imgui_tables.cpp
vendored
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.89.7 WIP
|
||||
// dear imgui, v1.89.8 WIP
|
||||
// (tables and columns code)
|
||||
|
||||
/*
|
||||
@@ -198,11 +198,7 @@ Index of this file:
|
||||
#include "imgui_internal.h"
|
||||
|
||||
// System includes
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
|
||||
// Visual Studio warnings
|
||||
#ifdef _MSC_VER
|
||||
@@ -971,6 +967,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
// clear ActiveId, which is equivalent to the change provided by _AllowWhenBLockedByActiveItem).
|
||||
// - This allows columns to be marked as hovered when e.g. clicking a button inside the column, or using drag and drop.
|
||||
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
||||
table_instance->HoveredRowLast = table_instance->HoveredRowNext;
|
||||
table_instance->HoveredRowNext = -1;
|
||||
table->HoveredColumnBody = -1;
|
||||
table->HoveredColumnBorder = -1;
|
||||
const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table_instance->LastOuterHeight));
|
||||
@@ -1547,6 +1545,7 @@ void ImGui::TableSetupScrollFreeze(int columns, int rows)
|
||||
// - TableGetCellBgRect() [Internal]
|
||||
// - TableGetColumnResizeID() [Internal]
|
||||
// - TableGetHoveredColumn() [Internal]
|
||||
// - TableGetHoveredRow() [Internal]
|
||||
// - TableSetBgColor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -1651,6 +1650,19 @@ int ImGui::TableGetHoveredColumn()
|
||||
return (int)table->HoveredColumnBody;
|
||||
}
|
||||
|
||||
// Return -1 when table is not hovered. Return maxrow+1 if in table but below last submitted row.
|
||||
// *IMPORTANT* Unlike TableGetHoveredColumn(), this has a one frame latency in updating the value.
|
||||
// This difference with is the reason why this is not public yet.
|
||||
int ImGui::TableGetHoveredRow()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiTable* table = g.CurrentTable;
|
||||
if (!table)
|
||||
return -1;
|
||||
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
||||
return (int)table_instance->HoveredRowLast;
|
||||
}
|
||||
|
||||
void ImGui::TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@@ -1802,6 +1814,10 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
||||
const bool is_visible = (bg_y2 >= table->InnerClipRect.Min.y && bg_y1 <= table->InnerClipRect.Max.y);
|
||||
if (is_visible)
|
||||
{
|
||||
// Update data for TableGetHoveredRow()
|
||||
if (table->HoveredColumnBody != -1 && g.IO.MousePos.y >= bg_y1 && g.IO.MousePos.y < bg_y2)
|
||||
TableGetInstanceData(table, table->InstanceCurrent)->HoveredRowNext = table->CurrentRow;
|
||||
|
||||
// Decide of background color for the row
|
||||
ImU32 bg_col0 = 0;
|
||||
ImU32 bg_col1 = 0;
|
||||
@@ -3595,6 +3611,11 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
|
||||
BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", table->CellPaddingX, table->CellSpacingX1, table->CellSpacingX2, table->OuterPaddingX);
|
||||
BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", table->HoveredColumnBody, table->HoveredColumnBorder);
|
||||
BulletText("ResizedColumn: %d, ReorderColumn: %d, HeldHeaderColumn: %d", table->ResizedColumn, table->ReorderColumn, table->HeldHeaderColumn);
|
||||
for (int n = 0; n < table->InstanceCurrent + 1; n++)
|
||||
{
|
||||
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, n);
|
||||
BulletText("Instance %d: HoveredRow: %d, LastOuterHeight: %.2f", n, table_instance->HoveredRowLast, table_instance->LastOuterHeight);
|
||||
}
|
||||
//BulletText("BgDrawChannels: %d/%d", 0, table->BgDrawChannelUnfrozen);
|
||||
float sum_weights = 0.0f;
|
||||
for (int n = 0; n < table->ColumnsCount; n++)
|
||||
|
||||
42
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
42
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.89.7 WIP
|
||||
// dear imgui, v1.89.8 WIP
|
||||
// (widgets code)
|
||||
|
||||
/*
|
||||
@@ -41,11 +41,7 @@ Index of this file:
|
||||
#include "imgui_internal.h"
|
||||
|
||||
// System includes
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Warnings
|
||||
@@ -875,9 +871,9 @@ ImRect ImGui::GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis)
|
||||
const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; // (ScrollbarSizes.x = width of Y scrollbar; ScrollbarSizes.y = height of X scrollbar)
|
||||
IM_ASSERT(scrollbar_size > 0.0f);
|
||||
if (axis == ImGuiAxis_X)
|
||||
return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x, outer_rect.Max.y);
|
||||
return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x - border_size, outer_rect.Max.y - border_size);
|
||||
else
|
||||
return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x, inner_rect.Max.y);
|
||||
return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x - border_size, inner_rect.Max.y - border_size);
|
||||
}
|
||||
|
||||
void ImGui::Scrollbar(ImGuiAxis axis)
|
||||
@@ -3888,6 +3884,10 @@ void ImGuiInputTextCallbackData::DeleteChars(int pos, int bytes_count)
|
||||
|
||||
void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end)
|
||||
{
|
||||
// Accept null ranges
|
||||
if (new_text == new_text_end)
|
||||
return;
|
||||
|
||||
const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0;
|
||||
const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text);
|
||||
if (new_text_len + BufTextLen >= BufSize)
|
||||
@@ -4063,8 +4063,16 @@ void ImGui::InputTextDeactivateHook(ImGuiID id)
|
||||
if (id == 0 || state->ID != id)
|
||||
return;
|
||||
g.InputTextDeactivatedState.ID = state->ID;
|
||||
g.InputTextDeactivatedState.TextA.resize(state->CurLenA + 1);
|
||||
memcpy(g.InputTextDeactivatedState.TextA.Data, state->TextA.Data ? state->TextA.Data : "", state->CurLenA + 1);
|
||||
if (state->Flags & ImGuiInputTextFlags_ReadOnly)
|
||||
{
|
||||
g.InputTextDeactivatedState.TextA.resize(0); // In theory this data won't be used, but clear to be neat.
|
||||
}
|
||||
else
|
||||
{
|
||||
IM_ASSERT(state->TextA.Data != 0);
|
||||
g.InputTextDeactivatedState.TextA.resize(state->CurLenA + 1);
|
||||
memcpy(g.InputTextDeactivatedState.TextA.Data, state->TextA.Data, state->CurLenA + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Edit a string of text
|
||||
@@ -4496,7 +4504,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
{
|
||||
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
|
||||
{
|
||||
if (state->CurLenA > 0)
|
||||
if (buf[0] != 0)
|
||||
{
|
||||
revert_edit = true;
|
||||
}
|
||||
@@ -4584,9 +4592,10 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
|
||||
{
|
||||
// Clear input
|
||||
IM_ASSERT(buf[0] != 0);
|
||||
apply_new_text = "";
|
||||
apply_new_text_length = 0;
|
||||
value_changed |= (buf[0] != 0);
|
||||
value_changed = true;
|
||||
STB_TEXTEDIT_CHARTYPE empty_string;
|
||||
stb_textedit_replace(state, &state->Stb, &empty_string, 0);
|
||||
}
|
||||
@@ -4615,9 +4624,12 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
ImTextStrToUtf8(state->TextA.Data, state->TextA.Size, state->TextW.Data, NULL);
|
||||
}
|
||||
|
||||
// When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer before clearing ActiveId, even though strictly speaking it wasn't modified on this frame.
|
||||
// When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer
|
||||
// before clearing ActiveId, even though strictly speaking it wasn't modified on this frame.
|
||||
// If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail.
|
||||
// This also allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage (please note that if you use this property along ImGuiInputTextFlags_CallbackResize you can end up with your temporary string object unnecessarily allocating once a frame, either store your string data, either if you don't then don't use ImGuiInputTextFlags_CallbackResize).
|
||||
// This also allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage
|
||||
// (please note that if you use this property along ImGuiInputTextFlags_CallbackResize you can end up with your temporary string object
|
||||
// unnecessarily allocating once a frame, either store your string data, either if you don't then don't use ImGuiInputTextFlags_CallbackResize).
|
||||
const bool apply_edit_back_to_user_buffer = !revert_edit || (validated && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0);
|
||||
if (apply_edit_back_to_user_buffer)
|
||||
{
|
||||
@@ -4718,11 +4730,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
// Handle reapplying final data on deactivation (see InputTextDeactivateHook() for details)
|
||||
if (g.InputTextDeactivatedState.ID == id)
|
||||
{
|
||||
if (g.ActiveId != id && IsItemDeactivatedAfterEdit() && !is_readonly)
|
||||
if (g.ActiveId != id && IsItemDeactivatedAfterEdit() && !is_readonly && strcmp(g.InputTextDeactivatedState.TextA.Data, buf) != 0)
|
||||
{
|
||||
apply_new_text = g.InputTextDeactivatedState.TextA.Data;
|
||||
apply_new_text_length = g.InputTextDeactivatedState.TextA.Size - 1;
|
||||
value_changed |= (strcmp(g.InputTextDeactivatedState.TextA.Data, buf) != 0);
|
||||
value_changed = true;
|
||||
//IMGUI_DEBUG_LOG("InputText(): apply Deactivated data for 0x%08X: \"%.*s\".\n", id, apply_new_text_length, apply_new_text);
|
||||
}
|
||||
g.InputTextDeactivatedState.ID = 0;
|
||||
|
||||
Reference in New Issue
Block a user