Tables: Internals: Added FindTableByID(), removing trailing spaces.

# Conflicts:
#	imgui_internal.h
This commit is contained in:
omar 2020-04-15 11:05:50 +02:00 committed by ocornut
parent e60b5a3f75
commit 8eb1c925f0
3 changed files with 13 additions and 6 deletions

View File

@ -176,7 +176,7 @@ typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: f
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
typedef int ImGuiTableFlags; // -> enum ImGuiTableFlags_ // Flags: For BeginTable()
typedef int ImGuiTableColumnFlags; // -> enum ImGuiTableColumnFlags_// Flags: For TableSetupColumn()
typedef int ImGuiTableColumnFlags; // -> enum ImGuiTableColumnFlags_// Flags: For TableSetupColumn()
typedef int ImGuiTableRowFlags; // -> enum ImGuiTableRowFlags_ // Flags: For TableNextRow()
typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader()
typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin(), BeginChild()
@ -672,7 +672,7 @@ namespace ImGui
// - If you are using tables as a sort of grid, populating every columns with the same type of contents,
// you may prefer using TableNextCell() instead of TableNextRow() + TableSetColumnIndex().
// - See Demo->Tables for details.
// - See ImGuiTableFlags_ enums for a description of available flags.
// - See ImGuiTableFlags_ enums for a description of available flags.
#define IMGUI_HAS_TABLE 1
IMGUI_API bool BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!

View File

@ -547,7 +547,7 @@ struct ImSpanAllocator
inline void SetArenaBasePtr(void* base_ptr) { BasePtr = (char*)base_ptr; }
inline void* GetSpanPtrBegin(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrSpan == CHUNKS); return (void*)(BasePtr + Offsets[n]); }
inline void* GetSpanPtrEnd(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrSpan == CHUNKS); return (n + 1 < CHUNKS) ? BasePtr + Offsets[n + 1] : (void*)(BasePtr + TotalSize); }
template<typename T>
template<typename T>
inline void GetSpan(int n, ImSpan<T>* span) { span->set((T*)GetSpanPtrBegin(n), (T*)GetSpanPtrEnd(n)); }
};
@ -1901,7 +1901,7 @@ struct ImGuiTableColumn
float WidthRequested; // Master width data when !(Flags & _WidthStretch)
float WidthGiven; // == (MaxX - MinX). FIXME-TABLE: Store all persistent width in multiple of FontSize?
float StartXRows; // Start position for the frame, currently ~(MinX + CellPaddingX)
float StartXHeaders;
float StartXHeaders;
float ContentMaxPosRowsFrozen; // Submitted contents absolute maximum position, from which we can infer width.
float ContentMaxPosRowsUnfrozen; // (kept as float because we need to manipulate those between each cell change)
float ContentMaxPosHeadersUsed;
@ -2003,7 +2003,7 @@ struct ImGuiTable
ImS8 HoveredColumnBorder; // Index of column whose right-border is being hovered (for resizing).
ImS8 ResizedColumn; // Index of column being resized. Reset when InstanceCurrent==0.
ImS8 LastResizedColumn; // Index of column being resized from previous frame.
ImS8 HeldHeaderColumn; // Index of column header being held.
ImS8 HeldHeaderColumn; // Index of column header being held.
ImS8 ReorderColumn; // Index of column being reordered. (not cleared)
ImS8 ReorderColumnDir; // -1 or +1
ImS8 RightMostActiveColumn; // Index of right-most non-hidden column.
@ -2246,6 +2246,7 @@ namespace ImGui
IMGUI_API float GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset);
// Tables
IMGUI_API ImGuiTable* FindTableByID(ImGuiID id);
IMGUI_API bool BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
IMGUI_API void TableBeginUpdateColumns(ImGuiTable* table);
IMGUI_API void TableUpdateDrawChannels(ImGuiTable* table);

View File

@ -127,6 +127,12 @@ inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags)
return flags;
}
ImGuiTable* ImGui::FindTableByID(ImGuiID id)
{
ImGuiContext& g = *GImGui;
return g.Tables.GetByKey(id);
}
// About 'outer_size':
// The meaning of outer_size needs to differ slightly depending of if we are using ScrollX/ScrollY flags.
// With ScrollX/ScrollY: using a child window for scrolling:
@ -2137,7 +2143,7 @@ void ImGui::TableSortSpecsClickColumn(ImGuiTable* table, ImGuiTableColumn* click
table->IsSortSpecsDirty = true;
}
// Return NULL if no sort specs (most often when ImGuiTableFlags_Sortable is not set)
// Return NULL if no sort specs (most often when ImGuiTableFlags_Sortable is not set)
// You can sort your data again when 'SpecsChanged == true'. It will be true with sorting specs have changed since last call, or the first time.
// Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable()!
const ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()