mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Internals: Merge in minor noise from wip Tables branch to simplify further merging.
This commit is contained in:
parent
51853292cc
commit
baae057a03
40
imgui.cpp
40
imgui.cpp
@ -3934,6 +3934,11 @@ void ImGui::Shutdown(ImGuiContext* context)
|
||||
g.DrawDataBuilder.ClearFreeMemory();
|
||||
g.BackgroundDrawList.ClearFreeMemory();
|
||||
g.ForegroundDrawList.ClearFreeMemory();
|
||||
|
||||
g.TabBars.Clear();
|
||||
g.CurrentTabBarStack.clear();
|
||||
g.ShrinkWidthBuffer.clear();
|
||||
|
||||
g.PrivateClipboard.clear();
|
||||
g.InputTextState.ClearFreeMemory();
|
||||
|
||||
@ -6744,7 +6749,8 @@ void ImGui::SetNextWindowBgAlpha(float alpha)
|
||||
// FIXME: This is in window space (not screen space!). We should try to obsolete all those functions.
|
||||
ImVec2 ImGui::GetContentRegionMax()
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
|
||||
if (window->DC.CurrentColumns)
|
||||
mx.x = window->WorkRect.Max.x - window->Pos.x;
|
||||
@ -6754,7 +6760,8 @@ ImVec2 ImGui::GetContentRegionMax()
|
||||
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
|
||||
ImVec2 ImGui::GetContentRegionMaxAbs()
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = window->ContentsRegionRect.Max;
|
||||
if (window->DC.CurrentColumns)
|
||||
mx.x = window->WorkRect.Max.x;
|
||||
@ -9650,14 +9657,16 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
return;
|
||||
}
|
||||
|
||||
// State
|
||||
enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Contents, WRT_ContentsRegionRect, WRT_Count }; // Windows Rect Type
|
||||
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Contents", "ContentsRegionRect" };
|
||||
|
||||
static bool show_windows_begin_order = false;
|
||||
static bool show_windows_rects = false;
|
||||
static int show_windows_rect_type = WRT_WorkRect;
|
||||
static bool show_windows_begin_order = false;
|
||||
static bool show_drawcmd_clip_rects = true;
|
||||
|
||||
// Basic info
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||
@ -9666,6 +9675,12 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::Text("%d active allocations", io.MetricsActiveAllocations);
|
||||
ImGui::Separator();
|
||||
|
||||
// Helper functions to display common structures:
|
||||
// - NodeDrawList
|
||||
// - NodeColumns
|
||||
// - NodeWindow
|
||||
// - NodeWindows
|
||||
// - NodeTabBar
|
||||
struct Funcs
|
||||
{
|
||||
static ImRect GetWindowRect(ImGuiWindow* window, int rect_type)
|
||||
@ -9830,8 +9845,6 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
}
|
||||
};
|
||||
|
||||
// Access private state, we are going to display the draw lists from last frame
|
||||
ImGuiContext& g = *GImGui;
|
||||
Funcs::NodeWindows(g.Windows, "Windows");
|
||||
if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size))
|
||||
{
|
||||
@ -9857,6 +9870,20 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (ImGui::TreeNode("Docking"))
|
||||
{
|
||||
ImGui::TreePop();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (ImGui::TreeNode("Tables", "Tables (%d)", g.Tables.Data.Size))
|
||||
{
|
||||
ImGui::TreePop();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ImGui::TreeNode("Internal state"))
|
||||
{
|
||||
const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
|
||||
@ -9903,6 +9930,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
// Tool: Display windows Rectangles and Begin Order
|
||||
if (show_windows_rects || show_windows_begin_order)
|
||||
{
|
||||
for (int n = 0; n < g.Windows.Size; n++)
|
||||
|
@ -358,7 +358,8 @@ enum ImGuiSelectableFlagsPrivate_
|
||||
ImGuiSelectableFlags_PressedOnClick = 1 << 21,
|
||||
ImGuiSelectableFlags_PressedOnRelease = 1 << 22,
|
||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 23, // FIXME: We may be able to remove this (added in 6251d379 for menus)
|
||||
ImGuiSelectableFlags_AllowItemOverlap = 1 << 24
|
||||
ImGuiSelectableFlags_AllowItemOverlap = 1 << 24,
|
||||
ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 25 // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
||||
};
|
||||
|
||||
// Extend ImGuiTreeNodeFlags_
|
||||
@ -827,13 +828,13 @@ struct ImGuiShrinkWidthItem
|
||||
float Width;
|
||||
};
|
||||
|
||||
struct ImGuiTabBarRef
|
||||
struct ImGuiPtrOrIndex
|
||||
{
|
||||
ImGuiTabBar* Ptr; // Either field can be set, not both. Dock node tab bars are loose while BeginTabBar() ones are in a pool.
|
||||
int IndexInMainPool;
|
||||
void* Ptr; // Either field can be set, not both. e.g. Dock node tab bars are loose while BeginTabBar() ones are in a pool.
|
||||
int Index; // Usually index in a main pool.
|
||||
|
||||
ImGuiTabBarRef(ImGuiTabBar* ptr) { Ptr = ptr; IndexInMainPool = -1; }
|
||||
ImGuiTabBarRef(int index_in_main_pool) { Ptr = NULL; IndexInMainPool = index_in_main_pool; }
|
||||
ImGuiPtrOrIndex(void* ptr) { Ptr = ptr; Index = -1; }
|
||||
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -986,9 +987,9 @@ struct ImGuiContext
|
||||
unsigned char DragDropPayloadBufLocal[8]; // Local buffer for small payloads
|
||||
|
||||
// Tab bars
|
||||
ImPool<ImGuiTabBar> TabBars;
|
||||
ImGuiTabBar* CurrentTabBar;
|
||||
ImVector<ImGuiTabBarRef> CurrentTabBarStack;
|
||||
ImPool<ImGuiTabBar> TabBars;
|
||||
ImVector<ImGuiPtrOrIndex> CurrentTabBarStack;
|
||||
ImVector<ImGuiShrinkWidthItem> ShrinkWidthBuffer;
|
||||
|
||||
// Widget state
|
||||
@ -1425,7 +1426,7 @@ struct ImGuiTabBar
|
||||
float ScrollingSpeed;
|
||||
ImGuiTabBarFlags Flags;
|
||||
ImGuiID ReorderRequestTabId;
|
||||
int ReorderRequestDir;
|
||||
ImS8 ReorderRequestDir;
|
||||
bool WantLayout;
|
||||
bool VisibleTabWasSubmitted;
|
||||
short LastTabItemIdx; // For BeginTabItem()/EndTabItem()
|
||||
|
@ -5490,6 +5490,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection;
|
||||
|
||||
// Render
|
||||
if (held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld))
|
||||
hovered = true;
|
||||
if (hovered || selected)
|
||||
{
|
||||
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
|
||||
@ -6271,18 +6273,18 @@ static int IMGUI_CDECL TabItemComparerByVisibleOffset(const void* lhs, const voi
|
||||
return (int)(a->Offset - b->Offset);
|
||||
}
|
||||
|
||||
static ImGuiTabBar* GetTabBarFromTabBarRef(const ImGuiTabBarRef& ref)
|
||||
static ImGuiTabBar* GetTabBarFromTabBarRef(const ImGuiPtrOrIndex& ref)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return ref.Ptr ? ref.Ptr : g.TabBars.GetByIndex(ref.IndexInMainPool);
|
||||
return ref.Ptr ? (ImGuiTabBar*)ref.Ptr : g.TabBars.GetByIndex(ref.Index);
|
||||
}
|
||||
|
||||
static ImGuiTabBarRef GetTabBarRefFromTabBar(ImGuiTabBar* tab_bar)
|
||||
static ImGuiPtrOrIndex GetTabBarRefFromTabBar(ImGuiTabBar* tab_bar)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.TabBars.Contains(tab_bar))
|
||||
return ImGuiTabBarRef(g.TabBars.GetIndex(tab_bar));
|
||||
return ImGuiTabBarRef(tab_bar);
|
||||
return ImGuiPtrOrIndex(g.TabBars.GetIndex(tab_bar));
|
||||
return ImGuiPtrOrIndex(tab_bar);
|
||||
}
|
||||
|
||||
bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
|
||||
@ -6637,7 +6639,7 @@ void ImGui::TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem*
|
||||
IM_ASSERT(dir == -1 || dir == +1);
|
||||
IM_ASSERT(tab_bar->ReorderRequestTabId == 0);
|
||||
tab_bar->ReorderRequestTabId = tab->ID;
|
||||
tab_bar->ReorderRequestDir = dir;
|
||||
tab_bar->ReorderRequestDir = (ImS8)dir;
|
||||
}
|
||||
|
||||
static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
|
||||
|
Loading…
Reference in New Issue
Block a user