mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Updated ImGui.
This commit is contained in:
23
3rdparty/dear-imgui/imgui.cpp
vendored
23
3rdparty/dear-imgui/imgui.cpp
vendored
@@ -3768,7 +3768,7 @@ void ImGui::NewFrame()
|
||||
window->Active = false;
|
||||
window->WriteAccessed = false;
|
||||
|
||||
// Garbage collect (this is totally functional but we may need decide if the side-effects are desirable)
|
||||
// Garbage collect transient buffers of recently unused windows
|
||||
if (!window->WasActive && !window->MemoryCompacted && window->LastTimeActive < memory_compact_start_time)
|
||||
GcCompactTransientWindowBuffers(window);
|
||||
}
|
||||
@@ -3889,7 +3889,7 @@ void ImGui::Shutdown(ImGuiContext* context)
|
||||
IM_DELETE(g.Windows[i]);
|
||||
g.Windows.clear();
|
||||
g.WindowsFocusOrder.clear();
|
||||
g.WindowsSortBuffer.clear();
|
||||
g.WindowsTempSortBuffer.clear();
|
||||
g.CurrentWindow = NULL;
|
||||
g.CurrentWindowStack.clear();
|
||||
g.WindowsById.Clear();
|
||||
@@ -4125,19 +4125,19 @@ void ImGui::EndFrame()
|
||||
|
||||
// Sort the window list so that all child windows are after their parent
|
||||
// We cannot do that on FocusWindow() because childs may not exist yet
|
||||
g.WindowsSortBuffer.resize(0);
|
||||
g.WindowsSortBuffer.reserve(g.Windows.Size);
|
||||
g.WindowsTempSortBuffer.resize(0);
|
||||
g.WindowsTempSortBuffer.reserve(g.Windows.Size);
|
||||
for (int i = 0; i != g.Windows.Size; i++)
|
||||
{
|
||||
ImGuiWindow* window = g.Windows[i];
|
||||
if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it
|
||||
continue;
|
||||
AddWindowToSortBuffer(&g.WindowsSortBuffer, window);
|
||||
AddWindowToSortBuffer(&g.WindowsTempSortBuffer, window);
|
||||
}
|
||||
|
||||
// This usually assert if there is a mismatch between the ImGuiWindowFlags_ChildWindow / ParentWindow values and DC.ChildWindows[] in parents, aka we've done something wrong.
|
||||
IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size);
|
||||
g.Windows.swap(g.WindowsSortBuffer);
|
||||
IM_ASSERT(g.Windows.Size == g.WindowsTempSortBuffer.Size);
|
||||
g.Windows.swap(g.WindowsTempSortBuffer);
|
||||
g.IO.MetricsActiveWindows = g.WindowsActiveCount;
|
||||
|
||||
// Unlock font atlas
|
||||
@@ -5163,10 +5163,14 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
||||
if (!(flags & ImGuiWindowFlags_NoBackground))
|
||||
{
|
||||
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
|
||||
bool override_alpha = false;
|
||||
float alpha = 1.0f;
|
||||
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha)
|
||||
{
|
||||
alpha = g.NextWindowData.BgAlphaVal;
|
||||
if (alpha != 1.0f)
|
||||
override_alpha = true;
|
||||
}
|
||||
if (override_alpha)
|
||||
bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT);
|
||||
window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
|
||||
}
|
||||
@@ -8764,7 +8768,7 @@ static void ImGui::NavUpdateWindowing()
|
||||
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
||||
if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
|
||||
{
|
||||
g.NavWindowingTarget = g.NavWindowingTargetAnim = window;
|
||||
g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // FIXME-DOCK: Will need to use RootWindowDockStop
|
||||
g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
|
||||
g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true;
|
||||
g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_NavKeyboard : ImGuiInputSource_NavGamepad;
|
||||
@@ -10117,6 +10121,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
};
|
||||
|
||||
Funcs::NodeWindows(g.Windows, "Windows");
|
||||
//Funcs::NodeWindows(g.WindowsFocusOrder, "WindowsFocusOrder");
|
||||
if (ImGui::TreeNode("DrawLists", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size))
|
||||
{
|
||||
for (int i = 0; i < g.DrawDataBuilder.Layers[0].Size; i++)
|
||||
|
||||
9
3rdparty/dear-imgui/imgui.h
vendored
9
3rdparty/dear-imgui/imgui.h
vendored
@@ -294,7 +294,7 @@ namespace ImGui
|
||||
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
|
||||
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin()
|
||||
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
|
||||
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
|
||||
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
|
||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
|
||||
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
||||
@@ -1987,8 +1987,11 @@ struct ImDrawList
|
||||
IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer.
|
||||
|
||||
// Advanced: Channels
|
||||
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
|
||||
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
|
||||
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
|
||||
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end)
|
||||
// - FIXME-OBSOLETE: This API shouldn't have been in ImDrawList in the first place!
|
||||
// Prefer using your own persistent copy of ImDrawListSplitter as you can stack them.
|
||||
// Using the ImDrawList::ChannelsXXXX you cannot stack a split over another.
|
||||
inline void ChannelsSplit(int count) { _Splitter.Split(this, count); }
|
||||
inline void ChannelsMerge() { _Splitter.Merge(this); }
|
||||
inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); }
|
||||
|
||||
6
3rdparty/dear-imgui/imgui_demo.cpp
vendored
6
3rdparty/dear-imgui/imgui_demo.cpp
vendored
@@ -1790,7 +1790,7 @@ static void ShowDemoWindowLayout()
|
||||
// Child 1: no border, enable horizontal scrollbar
|
||||
{
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar | (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0);
|
||||
ImGui::BeginChild("Child1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
|
||||
ImGui::BeginChild("ChildL", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
ImGui::Text("%04d: scrollable region", i);
|
||||
@@ -1808,7 +1808,7 @@ static void ShowDemoWindowLayout()
|
||||
{
|
||||
ImGuiWindowFlags window_flags = (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0) | (disable_menu ? 0 : ImGuiWindowFlags_MenuBar);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
|
||||
ImGui::BeginChild("Child2", ImVec2(0, 260), true, window_flags);
|
||||
ImGui::BeginChild("ChildR", ImVec2(0, 260), true, window_flags);
|
||||
if (!disable_menu && ImGui::BeginMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Menu"))
|
||||
@@ -1841,7 +1841,7 @@ static void ShowDemoWindowLayout()
|
||||
{
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 10);
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100));
|
||||
ImGui::BeginChild("blah", ImVec2(200, 100), true, ImGuiWindowFlags_None);
|
||||
ImGui::BeginChild("Red", ImVec2(200, 100), true, ImGuiWindowFlags_None);
|
||||
for (int n = 0; n < 50; n++)
|
||||
ImGui::Text("Some test %d", n);
|
||||
ImGui::EndChild();
|
||||
|
||||
2
3rdparty/dear-imgui/imgui_draw.cpp
vendored
2
3rdparty/dear-imgui/imgui_draw.cpp
vendored
@@ -1307,7 +1307,7 @@ void ImDrawListSplitter::ClearFreeMemory()
|
||||
|
||||
void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count)
|
||||
{
|
||||
IM_ASSERT(_Current == 0 && _Count <= 1);
|
||||
IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter.");
|
||||
int old_channels_count = _Channels.Size;
|
||||
if (old_channels_count < channels_count)
|
||||
_Channels.resize(channels_count);
|
||||
|
||||
12
3rdparty/dear-imgui/imgui_internal.h
vendored
12
3rdparty/dear-imgui/imgui_internal.h
vendored
@@ -270,9 +270,6 @@ static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs)
|
||||
#endif
|
||||
|
||||
// Helpers: File System
|
||||
#if defined(__EMSCRIPTEN__) && !defined(IMGUI_DISABLE_FILE_FUNCTIONS)
|
||||
#define IMGUI_DISABLE_FILE_FUNCTIONS
|
||||
#endif
|
||||
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
|
||||
#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
||||
typedef void* ImFileHandle;
|
||||
@@ -846,6 +843,7 @@ struct ImGuiColumns
|
||||
ImRect HostClipRect; // Backup of ClipRect at the time of BeginColumns()
|
||||
ImRect HostWorkRect; // Backup of WorkRect at the time of BeginColumns()
|
||||
ImVector<ImGuiColumnData> Columns;
|
||||
ImDrawListSplitter Splitter;
|
||||
|
||||
ImGuiColumns() { Clear(); }
|
||||
void Clear()
|
||||
@@ -939,7 +937,7 @@ struct ImGuiNextWindowData
|
||||
ImRect SizeConstraintRect;
|
||||
ImGuiSizeCallback SizeCallback;
|
||||
void* SizeCallbackUserData;
|
||||
float BgAlphaVal;
|
||||
float BgAlphaVal; // Override background alpha
|
||||
ImVec2 MenuBarOffsetMinVal; // *Always on* This is not exposed publicly, so we don't clear it.
|
||||
|
||||
ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); }
|
||||
@@ -1008,8 +1006,8 @@ struct ImGuiContext
|
||||
|
||||
// Windows state
|
||||
ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
|
||||
ImVector<ImGuiWindow*> WindowsFocusOrder; // Windows, sorted in focus order, back to front
|
||||
ImVector<ImGuiWindow*> WindowsSortBuffer;
|
||||
ImVector<ImGuiWindow*> WindowsFocusOrder; // Windows, sorted in focus order, back to front. (FIXME: We could only store root windows here! Need to sort out the Docking equivalent which is RootWindowDockStop and is unfortunately a little more dynamic)
|
||||
ImVector<ImGuiWindow*> WindowsTempSortBuffer; // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child
|
||||
ImVector<ImGuiWindow*> CurrentWindowStack;
|
||||
ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
|
||||
int WindowsActiveCount; // Number of unique windows submitted by frame
|
||||
@@ -1426,7 +1424,7 @@ struct IMGUI_API ImGuiWindowTempData
|
||||
// Storage for one window
|
||||
struct IMGUI_API ImGuiWindow
|
||||
{
|
||||
char* Name;
|
||||
char* Name; // Window name, owned by the window.
|
||||
ImGuiID ID; // == ImHashStr(Name)
|
||||
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
||||
ImVec2 Pos; // Position (always rounded-up to nearest pixel)
|
||||
|
||||
31
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
31
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
@@ -3473,14 +3473,23 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
EndGroup();
|
||||
return false;
|
||||
}
|
||||
if (!BeginChildFrame(id, frame_bb.GetSize()))
|
||||
|
||||
// We reproduce the contents of BeginChildFrame() in order to provide 'label' so our window internal data are easier to read/debug.
|
||||
PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]);
|
||||
PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding);
|
||||
PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize);
|
||||
PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
||||
bool child_visible = BeginChildEx(label, id, frame_bb.GetSize(), true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding);
|
||||
PopStyleVar(3);
|
||||
PopStyleColor();
|
||||
if (!child_visible)
|
||||
{
|
||||
EndChildFrame();
|
||||
EndChild();
|
||||
EndGroup();
|
||||
return false;
|
||||
}
|
||||
draw_window = g.CurrentWindow; // Child window
|
||||
draw_window->DC.NavLayerActiveMaskNext |= draw_window->DC.NavLayerCurrentMask; // This is to ensure that EndChild() will display a navigation highlight
|
||||
draw_window->DC.NavLayerActiveMaskNext |= draw_window->DC.NavLayerCurrentMask; // This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it.
|
||||
inner_size.x -= draw_window->ScrollbarSizes.x;
|
||||
}
|
||||
else
|
||||
@@ -4166,7 +4175,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
if (is_multiline)
|
||||
{
|
||||
Dummy(text_size + ImVec2(0.0f, g.FontSize)); // Always add room to scroll an extra line
|
||||
EndChildFrame();
|
||||
EndChild();
|
||||
EndGroup();
|
||||
}
|
||||
|
||||
@@ -7415,7 +7424,7 @@ void ImGui::PushColumnsBackground()
|
||||
ImGuiColumns* columns = window->DC.CurrentColumns;
|
||||
if (columns->Count == 1)
|
||||
return;
|
||||
window->DrawList->ChannelsSetCurrent(0);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, 0);
|
||||
int cmd_size = window->DrawList->CmdBuffer.Size;
|
||||
PushClipRect(columns->HostClipRect.Min, columns->HostClipRect.Max, false);
|
||||
IM_UNUSED(cmd_size);
|
||||
@@ -7428,7 +7437,7 @@ void ImGui::PopColumnsBackground()
|
||||
ImGuiColumns* columns = window->DC.CurrentColumns;
|
||||
if (columns->Count == 1)
|
||||
return;
|
||||
window->DrawList->ChannelsSetCurrent(columns->Current + 1);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1);
|
||||
PopClipRect();
|
||||
}
|
||||
|
||||
@@ -7519,8 +7528,8 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
||||
|
||||
if (columns->Count > 1)
|
||||
{
|
||||
window->DrawList->ChannelsSplit(1 + columns->Count);
|
||||
window->DrawList->ChannelsSetCurrent(1);
|
||||
columns->Splitter.Split(window->DrawList, 1 + columns->Count);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, 1);
|
||||
PushColumnClipRect(0);
|
||||
}
|
||||
|
||||
@@ -7559,14 +7568,14 @@ void ImGui::NextColumn()
|
||||
// Columns 1+ ignore IndentX (by canceling it out)
|
||||
// FIXME-COLUMNS: Unnecessary, could be locked?
|
||||
window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + column_padding;
|
||||
window->DrawList->ChannelsSetCurrent(columns->Current + 1);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// New row/line
|
||||
// Column 0 honor IndentX
|
||||
window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f);
|
||||
window->DrawList->ChannelsSetCurrent(1);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, 1);
|
||||
columns->Current = 0;
|
||||
columns->LineMinY = columns->LineMaxY;
|
||||
}
|
||||
@@ -7596,7 +7605,7 @@ void ImGui::EndColumns()
|
||||
if (columns->Count > 1)
|
||||
{
|
||||
PopClipRect();
|
||||
window->DrawList->ChannelsMerge();
|
||||
columns->Splitter.Merge(window->DrawList);
|
||||
}
|
||||
|
||||
const ImGuiColumnsFlags flags = columns->Flags;
|
||||
|
||||
Reference in New Issue
Block a user