Version 1.80

This commit is contained in:
ocornut 2021-01-21 16:59:34 +01:00
parent 5178c3ce21
commit 58075c4414
10 changed files with 164 additions and 164 deletions

View File

@ -32,12 +32,12 @@ HOW TO UPDATE?
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.80 (In Progress) VERSION 1.80 (Released 2021-01-21)
----------------------------------------------------------------------- -----------------------------------------------------------------------
Breaking Changes: Breaking Changes:
- Added imgui_tables.cpp file! Manually constructed project files will need the new file added! - Added imgui_tables.cpp file! Manually constructed project files will need the new file added! (#3740)
- Backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/. (#3513) - Backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/. (#3513)
- Renamed ImDrawList::AddBezierCurve() to ImDrawList::AddBezierCubic(). Kept inline redirection function (will obsolete). - Renamed ImDrawList::AddBezierCurve() to ImDrawList::AddBezierCubic(). Kept inline redirection function (will obsolete).
- Renamed ImDrawList::PathBezierCurveTo() to ImDrawList::PathBezierCubicCurveTo(). Kept inline redirection function (will obsolete). - Renamed ImDrawList::PathBezierCurveTo() to ImDrawList::PathBezierCubicCurveTo(). Kept inline redirection function (will obsolete).
@ -58,25 +58,31 @@ Breaking Changes:
- If you were still using the old names, while you are cleaning up, considering enabling - If you were still using the old names, while you are cleaning up, considering enabling
IMGUI_DISABLE_OBSOLETE_FUNCTIONS in imconfig.h even temporarily to have a pass at finding IMGUI_DISABLE_OBSOLETE_FUNCTIONS in imconfig.h even temporarily to have a pass at finding
and removing up old API calls, if any remaining. and removing up old API calls, if any remaining.
- Columns: renamed undocumented/internals ImGuiColumnsFlags_* to ImGuiOldColumnFlags_* in prevision of - Internals: Columns: renamed undocumented/internals ImGuiColumnsFlags_* to ImGuiOldColumnFlags_* to reduce
incoming Tables API. Keep redirection enums (will obsolete). (#125, #513, #913, #1204, #1444, #2142, #2707) confusion with Tables API. Keep redirection enums (will obsolete). (#125, #513, #913, #1204, #1444, #2142, #2707)
- Renamed io.ConfigWindowsMemoryCompactTimer to io.ConfigMemoryCompactTimer as the feature will apply - Renamed io.ConfigWindowsMemoryCompactTimer to io.ConfigMemoryCompactTimer as the feature now applies
to other data structures. (#2636) to other data structures. (#2636)
Other Changes: Other Changes:
- Tables: added new Tables Beta API as a replacement for old Columns. (#2957, #125) - Tables: added new Tables Beta API as a replacement for old Columns. (#3740, #2957, #125)
Check out 'Demo->Tables' for many demos + API comments in imgui.h for details. Check out 'Demo->Tables' for many demos.
- Added 16 functions: BeginTable(), EndTable(), Read API comments in imgui.h for details. Read extra commentary in imgui_tables.cpp.
TableNextRow(), TableNextColumn(), TableSetColumnIndex(), TableGetColumnIndex(), TableGetRowIndex(), - Added 16 functions:
TableSetupColumn(), TableSetupScrollFreeze(), - BeginTable(), EndTable()
TableHeadersRow(), TableHeader(), TableSetBgColor(), TableGetSortSpecs(), - TableNextRow(), TableNextColumn(), TableSetColumnIndex()
TableGetColumnCount(), TableGetColumnName(), TableGetColumnFlags(). - TableSetupColumn(), TableSetupScrollFreeze()
- Added 2 structures: ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs. - TableHeadersRow(), TableHeader()
- Added 2 enums: ImGuiSortDirection, ImGuiTableBgTarget. - TableGetRowIndex(), TableGetColumnCount(), TableGetColumnIndex(), TableGetColumnName(), TableGetColumnFlags()
- Added 3 flags sets: ImGuiTableFlags (27 flags), ImGuiTableColumnFlags (24 flags), ImGuiTableRowFlags (1 flag). - TableGetSortSpecs(), TableSetBgColor()
- Added 5 colors: ImGuiCol_TableHeaderBg, ImGuiCol_TableBorderStrong, ImGuiCol_TableBorderLight, ImGuiCol_TableRowBg, ImGuiCol_TableRowBgAlt. - Added 3 flags sets:
- Added 1 style var: ImGuiStyleVar_CellPadding. - ImGuiTableFlags (29 flags for: features, decorations, sizing policies, padding, clipping, scrolling, sorting etc.)
- ImGuiTableColumnFlags (24 flags for: width policies, default settings, sorting options, indentation options etc.)
- ImGuiTableRowFlags (1 flag for: header row)
- Added 2 structures: ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs
- Added 2 enums: ImGuiSortDirection, ImGuiTableBgTarget
- Added 1 style variable: ImGuiStyleVar_CellPadding
- Added 5 style colors: ImGuiCol_TableHeaderBg, ImGuiCol_TableBorderStrong, ImGuiCol_TableBorderLight, ImGuiCol_TableRowBg, ImGuiCol_TableRowBgAlt.
- Tab Bar: Made it possible to append to an existing tab bar by calling BeginTabBar()/EndTabBar() again. - Tab Bar: Made it possible to append to an existing tab bar by calling BeginTabBar()/EndTabBar() again.
- Tab Bar: Fixed using more than 128 tabs in a tab bar (scrolling policy recommended). - Tab Bar: Fixed using more than 128 tabs in a tab bar (scrolling policy recommended).
- Tab Bar: Do not display a tooltip if the name already fits over a given tab. (#3521) - Tab Bar: Do not display a tooltip if the name already fits over a given tab. (#3521)
@ -84,13 +90,13 @@ Other Changes:
- Tab Bar: Requested ideal content size (for auto-fit) doesn't affect horizontal scrolling. (#3414) - Tab Bar: Requested ideal content size (for auto-fit) doesn't affect horizontal scrolling. (#3414)
- Drag and Drop: Fix losing drop source ActiveID (and often source tooltip) when opening a TreeNode() - Drag and Drop: Fix losing drop source ActiveID (and often source tooltip) when opening a TreeNode()
or CollapsingHeader() while dragging. (#1738) or CollapsingHeader() while dragging. (#1738)
- Drag and Drop: Fix drag and drop to tie same-size drop targets by choosen the later one. Fixes dragging - Drag and Drop: Fix drag and drop to tie same-size drop targets by chosen the later one. Fixes dragging
into a full-window-sized dockspace inside a zero-padded window. (#3519, #2717) [@Black-Cat] into a full-window-sized dockspace inside a zero-padded window. (#3519, #2717) [@Black-Cat]
- Checkbox: Added CheckboxFlags() helper with int* type. - Checkbox: Added CheckboxFlags() helper with int* type (internals have a template version, not exposed).
- Clipper: Fixed incorrect end-list positioning when using ImGuiListClipper with 1 item (bug in 1.79). (#3663) [@nyorain] - Clipper: Fixed incorrect end-list positioning when using ImGuiListClipper with 1 item (bug in 1.79). (#3663) [@nyorain]
- InputText: Fixed updating cursor/selection position when a callback altered the buffer in a way - InputText: Fixed updating cursor/selection position when a callback altered the buffer in a way
where the byte count is unchanged but the decoded character count changes. (#3587) [@gqw] where the byte count is unchanged but the decoded character count changes. (#3587) [@gqw]
- InputText: Fixed swiching from single to multi-line while preserving same ID. - InputText: Fixed switching from single to multi-line while preserving same ID.
- Combo: Fixed using IsItemEdited() after Combo() not matching the return value from Combo(). (#2034) - Combo: Fixed using IsItemEdited() after Combo() not matching the return value from Combo(). (#2034)
- DragFloat, DragInt: very slightly increased mouse drag threshold + expressing it as a factor of default value. - DragFloat, DragInt: very slightly increased mouse drag threshold + expressing it as a factor of default value.
- DragFloat, DragInt: added experimental io.ConfigDragClickToInputText feature to enable turning DragXXX widgets - DragFloat, DragInt: added experimental io.ConfigDragClickToInputText feature to enable turning DragXXX widgets
@ -126,7 +132,7 @@ Other Changes:
compatibility with legacy code. (#3671) compatibility with legacy code. (#3671)
- Backends: OpenGL3: Backup and restore GL_PRIMITIVE_RESTART state. (#3544) [@Xipiryon] - Backends: OpenGL3: Backup and restore GL_PRIMITIVE_RESTART state. (#3544) [@Xipiryon]
- Backends: OpenGL2, OpenGL3: Backup and restore GL_STENCIL_TEST enable state. (#3668) - Backends: OpenGL2, OpenGL3: Backup and restore GL_STENCIL_TEST enable state. (#3668)
- Backends: Vulkan: Added support for specifying which subpass to reference during VkPipeline creation. (@3579) [@bdero] - Backends: Vulkan: Added support for specifying which sub-pass to reference during VkPipeline creation. (@3579) [@bdero]
- Backends: DX12: Improve Windows 7 compatibility (for D3D12On7) by loading d3d12.dll dynamically. (#3696) [@Mattiwatti] - Backends: DX12: Improve Windows 7 compatibility (for D3D12On7) by loading d3d12.dll dynamically. (#3696) [@Mattiwatti]
- Backends: Win32: Fix setting of io.DisplaySize to invalid/uninitialized data after hwnd has been closed. - Backends: Win32: Fix setting of io.DisplaySize to invalid/uninitialized data after hwnd has been closed.
- Backends: OSX: Fix keypad-enter key not working on MacOS. (#3554) [@rokups, @lfnoise] - Backends: OSX: Fix keypad-enter key not working on MacOS. (#3554) [@rokups, @lfnoise]
@ -136,8 +142,9 @@ Other Changes:
- Examples: Emscripten: Added 'make serve' helper to spawn a web-server on localhost. (#3705) [@Horki] - Examples: Emscripten: Added 'make serve' helper to spawn a web-server on localhost. (#3705) [@Horki]
- Examples: DirectX12: Move ImGui::Render() call above the first barrier to clarify its lack of effect on the graphics pipe. - Examples: DirectX12: Move ImGui::Render() call above the first barrier to clarify its lack of effect on the graphics pipe.
- CI: Fix testing for Windows DLL builds. (#3603, #3601) [@iboB] - CI: Fix testing for Windows DLL builds. (#3603, #3601) [@iboB]
- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md improved them. - Docs: Improved the wiki and added a https://github.com/ocornut/imgui/wiki/Useful-Widgets page. [@Xipiryon]
- Docs: Consistently renamed all occurences of "binding" and "back-end" to "backend" in comments and docs. - Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md, and improved them.
- Docs: Consistently renamed all occurrences of "binding" and "back-end" to "backend" in comments and docs.
----------------------------------------------------------------------- -----------------------------------------------------------------------

View File

@ -131,8 +131,7 @@ Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
### Upcoming Changes ### Upcoming Changes
Some of the goals for 2020 are: Some of the goals for 2021 are:
- Work on Tables (see [#2957](https://github.com/ocornut/imgui/issues/2957), now merged in master.
- Work on Docking (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch) - Work on Docking (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch)
- Work on Multi-Viewport / Multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback) - Work on Multi-Viewport / Multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
- Work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787)) - Work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))

View File

@ -59,8 +59,8 @@
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
//---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library. //---- Use stb_printf's faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
// Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf. // Requires 'stb_sprintf.h' to be available in the include path. Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
// #define IMGUI_USE_STB_SPRINTF // #define IMGUI_USE_STB_SPRINTF
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.

View File

@ -1,4 +1,4 @@
// dear imgui, v1.80 WIP // dear imgui, v1.80
// (main code and documentation) // (main code and documentation)
// Help: // Help:

43
imgui.h
View File

@ -1,4 +1,4 @@
// dear imgui, v1.80 WIP // dear imgui, v1.80
// (headers) // (headers)
// Help: // Help:
@ -58,8 +58,8 @@ Index of this file:
// Version // Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
#define IMGUI_VERSION "1.80 WIP" #define IMGUI_VERSION "1.80"
#define IMGUI_VERSION_NUM 17913 #define IMGUI_VERSION_NUM 18000
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
@ -662,11 +662,11 @@ namespace ImGui
// - See top of imgui_tables.cpp for general commentary. // - See top of imgui_tables.cpp for general commentary.
// - See ImGuiTableFlags_ and ImGuiTableColumnFlags_ enums for a description of available flags. // - See ImGuiTableFlags_ and ImGuiTableColumnFlags_ enums for a description of available flags.
// The typical call flow is: // The typical call flow is:
// - 1. Call BeginTable() // - 1. Call BeginTable().
// - 2. Optionally call TableSetupColumn() to submit column name/flags/defaults // - 2. Optionally call TableSetupColumn() to submit column name/flags/defaults.
// - 3. Optionally call TableSetupScrollFreeze() to request scroll freezing of columns/rows // - 3. Optionally call TableSetupScrollFreeze() to request scroll freezing of columns/rows.
// - 4. Optionally call TableHeadersRow() to submit a header row. Names will be pulled from data provided TableSetupColumn() calls) // - 4. Optionally call TableHeadersRow() to submit a header row. Names are pulled from TableSetupColumn() data.
// - 5. Populate contents // - 5. Populate contents:
// - In most situations you can use TableNextRow() + TableSetColumnIndex(N) to start appending into a column. // - In most situations you can use TableNextRow() + TableSetColumnIndex(N) to start appending into a column.
// - If you are using tables as a sort of grid, where every columns is holding the same type of contents, // - If you are using tables as a sort of grid, where every columns is holding the same type of contents,
// you may prefer using TableNextColumn() instead of TableNextRow() + TableSetColumnIndex(). // you may prefer using TableNextColumn() instead of TableNextRow() + TableSetColumnIndex().
@ -680,34 +680,37 @@ namespace ImGui
// TableNextRow() -> Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear! // TableNextRow() -> Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear!
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// - 5. Call EndTable() // - 5. Call EndTable()
IMGUI_API bool BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f); IMGUI_API bool BeginTable(const char* str_id, int column, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f);
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true! IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row. IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row.
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible. IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible.
IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible. IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible.
// Tables: Headers & Columns declaration // Tables: Headers & Columns declaration
// - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc. // - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc.
// Important: this will not display anything! The name passed to TableSetupColumn() is used by TableHeadersRow() and context-menus. // - Use TableHeadersRow() to create a header row and automatically submit a TableHeader() for each column.
// - Use TableHeadersRow() to create a row and automatically submit a TableHeader() for each column. // Headers are required to perform: reordering, sorting, and opening the context menu.
// Headers are required to perform: reordering, sorting, and opening the context menu (but context menu can also be available in columns body using ImGuiTableFlags_ContextMenuInBody). // The context menu can also be made available in columns body using ImGuiTableFlags_ContextMenuInBody.
// - You may manually submit headers using TableNextRow() + TableHeader() calls, but this is only useful in some advanced cases (e.g. adding custom widgets in header row). // - You may manually submit headers using TableNextRow() + TableHeader() calls, but this is only useful in
// - Use TableSetupScrollFreeze() to lock columns (from the right) or rows (from the top) so they stay visible when scrolled. // some advanced use cases (e.g. adding custom widgets in header row).
// - Use TableSetupScrollFreeze() to lock columns/rows so they stay visible when scrolled.
IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = 0.0f, ImU32 user_id = 0); IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = 0.0f, ImU32 user_id = 0);
IMGUI_API void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled. IMGUI_API void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled.
IMGUI_API void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu IMGUI_API void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu
IMGUI_API void TableHeader(const char* label); // submit one header cell manually (rarely used) IMGUI_API void TableHeader(const char* label); // submit one header cell manually (rarely used)
// Tables: Sorting
// - Call TableGetSortSpecs() to retrieve latest sort specs for the table. NULL when not sorting.
// - When 'SpecsDirty == true' you should sort your data. It will be true when sorting specs have changed
// since last call, or the first time. Make sure to set 'SpecsDirty = false' after sorting, else you may
// wastefully sort your data every frame!
// - Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable().
IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting).
// Tables: Miscellaneous functions // Tables: Miscellaneous functions
// - Most functions taking 'int column_n' treat the default value of -1 as the same as passing the current column index // - Functions args 'int column_n' treat the default value of -1 as the same as passing the current column index.
// - Sorting: call TableGetSortSpecs() to retrieve latest sort specs for the table. Return value will be NULL if no sorting.
// When 'SpecsDirty == true' you should sort your data. It will be true when sorting specs have changed since last call, or the first time.
// Make sure to set 'SpecsDirty = false' after sorting, else you may wastefully sort your data every frame!
// Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable().
IMGUI_API int TableGetColumnCount(); // return number of columns (value passed to BeginTable) IMGUI_API int TableGetColumnCount(); // return number of columns (value passed to BeginTable)
IMGUI_API int TableGetColumnIndex(); // return current column index. IMGUI_API int TableGetColumnIndex(); // return current column index.
IMGUI_API int TableGetRowIndex(); // return current row index. IMGUI_API int TableGetRowIndex(); // return current row index.
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column. IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column. IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column.
IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting).
IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n = -1); // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details. IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n = -1); // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details.
// Legacy Columns API (2020: prefer using Tables!) // Legacy Columns API (2020: prefer using Tables!)

View File

@ -1,4 +1,4 @@
// dear imgui, v1.80 WIP // dear imgui, v1.80
// (demo code) // (demo code)
// Help: // Help:
@ -3477,7 +3477,7 @@ static void ShowDemoWindowTables()
// [Method 1] Using TableNextRow() to create a new row, and TableSetColumnIndex() to select the column. // [Method 1] Using TableNextRow() to create a new row, and TableSetColumnIndex() to select the column.
// In many situations, this is the most flexible and easy to use pattern. // In many situations, this is the most flexible and easy to use pattern.
HelpMarker("Using TableNextRow() + calling TableSetColumnIndex() _before_ each cell, in a loop."); HelpMarker("Using TableNextRow() + calling TableSetColumnIndex() _before_ each cell, in a loop.");
if (ImGui::BeginTable("##table1", 3)) if (ImGui::BeginTable("table1", 3))
{ {
for (int row = 0; row < 4; row++) for (int row = 0; row < 4; row++)
{ {
@ -3494,7 +3494,7 @@ static void ShowDemoWindowTables()
// [Method 2] Using TableNextColumn() called multiple times, instead of using a for loop + TableSetColumnIndex(). // [Method 2] Using TableNextColumn() called multiple times, instead of using a for loop + TableSetColumnIndex().
// This is generally more convenient when you have code manually submitting the contents of each columns. // This is generally more convenient when you have code manually submitting the contents of each columns.
HelpMarker("Using TableNextRow() + calling TableNextColumn() _before_ each cell, manually."); HelpMarker("Using TableNextRow() + calling TableNextColumn() _before_ each cell, manually.");
if (ImGui::BeginTable("##table2", 3)) if (ImGui::BeginTable("table2", 3))
{ {
for (int row = 0; row < 4; row++) for (int row = 0; row < 4; row++)
{ {
@ -3515,7 +3515,7 @@ static void ShowDemoWindowTables()
HelpMarker( HelpMarker(
"Only using TableNextColumn(), which tends to be convenient for tables where every cells contains the same type of contents.\n" "Only using TableNextColumn(), which tends to be convenient for tables where every cells contains the same type of contents.\n"
"This is also more similar to the old NextColumn() function of the Columns API, and provided to facilitate the Columns->Tables API transition."); "This is also more similar to the old NextColumn() function of the Columns API, and provided to facilitate the Columns->Tables API transition.");
if (ImGui::BeginTable("##table3", 3)) if (ImGui::BeginTable("table3", 3))
{ {
for (int item = 0; item < 14; item++) for (int item = 0; item < 14; item++)
{ {
@ -3567,7 +3567,7 @@ static void ShowDemoWindowTables()
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers"); ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers");
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##table1", 3, flags)) if (ImGui::BeginTable("table1", 3, flags))
{ {
// Display headers so we can inspect their interaction with borders. // Display headers so we can inspect their interaction with borders.
// (Headers are not the main purpose of this section of the demo, so we are not elaborating on them too much. See other sections for details) // (Headers are not the main purpose of this section of the demo, so we are not elaborating on them too much. See other sections for details)
@ -3611,7 +3611,7 @@ static void ShowDemoWindowTables()
ImGui::SameLine(); HelpMarker("Using the _Resizable flag automatically enables the _BordersInnerV flag as well, this is why the resize borders are still showing when unchecking this."); ImGui::SameLine(); HelpMarker("Using the _Resizable flag automatically enables the _BordersInnerV flag as well, this is why the resize borders are still showing when unchecking this.");
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##table1", 3, flags)) if (ImGui::BeginTable("table1", 3, flags))
{ {
for (int row = 0; row < 5; row++) for (int row = 0; row < 5; row++)
{ {
@ -3641,12 +3641,10 @@ static void ShowDemoWindowTables()
"Double-click a column border to auto-fit the column to its contents."); "Double-click a column border to auto-fit the column to its contents.");
PushStyleCompact(); PushStyleCompact();
static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody; static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody;
static bool fixed_fill = true; ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
ImGui::Checkbox("fill", &fixed_fill);
PopStyleCompact(); PopStyleCompact();
ImVec2 outer_size(fixed_fill ? -FLT_MIN : 0.0f, 0.0f); if (ImGui::BeginTable("table1", 3, flags))
if (ImGui::BeginTable("##table1", 3, flags, outer_size))
{ {
for (int row = 0; row < 5; row++) for (int row = 0; row < 5; row++)
{ {
@ -3671,7 +3669,7 @@ static void ShowDemoWindowTables()
"When combining Fixed and Stretch columns, generally you only want one, maybe two trailing columns to use _WidthStretch."); "When combining Fixed and Stretch columns, generally you only want one, maybe two trailing columns to use _WidthStretch.");
static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
if (ImGui::BeginTable("##table1", 3, flags)) if (ImGui::BeginTable("table1", 3, flags))
{ {
ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed);
@ -3688,7 +3686,7 @@ static void ShowDemoWindowTables()
} }
ImGui::EndTable(); ImGui::EndTable();
} }
if (ImGui::BeginTable("##table2", 6, flags)) if (ImGui::BeginTable("table2", 6, flags))
{ {
ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed);
@ -3727,7 +3725,7 @@ static void ShowDemoWindowTables()
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)"); ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)");
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##table1", 3, flags)) if (ImGui::BeginTable("table1", 3, flags))
{ {
// Submit columns name with TableSetupColumn() and call TableHeadersRow() to create a row with a header in each column. // Submit columns name with TableSetupColumn() and call TableHeadersRow() to create a row with a header in each column.
// (Later we will show how TableSetupColumn() has other uses, optional flags, sizing weight etc.) // (Later we will show how TableSetupColumn() has other uses, optional flags, sizing weight etc.)
@ -3748,7 +3746,7 @@ static void ShowDemoWindowTables()
} }
// Use outer_size.x == 0.0f instead of default to make the table as tight as possible (only valid when no scrolling and no stretch column) // Use outer_size.x == 0.0f instead of default to make the table as tight as possible (only valid when no scrolling and no stretch column)
if (ImGui::BeginTable("##table2", 3, flags | ImGuiTableFlags_SizingFixedFit, ImVec2(0.0f, 0.0f))) if (ImGui::BeginTable("table2", 3, flags | ImGuiTableFlags_SizingFixedFit, ImVec2(0.0f, 0.0f)))
{ {
ImGui::TableSetupColumn("One"); ImGui::TableSetupColumn("One");
ImGui::TableSetupColumn("Two"); ImGui::TableSetupColumn("Two");
@ -3797,7 +3795,7 @@ static void ShowDemoWindowTables()
ImGui::Checkbox("show_headers", &show_headers); ImGui::Checkbox("show_headers", &show_headers);
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##table1", 3, flags1)) if (ImGui::BeginTable("table_padding", 3, flags1))
{ {
if (show_headers) if (show_headers)
{ {
@ -3850,7 +3848,7 @@ static void ShowDemoWindowTables()
PopStyleCompact(); PopStyleCompact();
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, cell_padding); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, cell_padding);
if (ImGui::BeginTable("##table2", 3, flags2)) if (ImGui::BeginTable("table_padding_2", 3, flags2))
{ {
static char text_bufs[3 * 5][16]; // Mini text storage for 3x5 cells static char text_bufs[3 * 5][16]; // Mini text storage for 3x5 cells
static bool init = true; static bool init = true;
@ -3880,18 +3878,12 @@ static void ShowDemoWindowTables()
ImGui::SetNextItemOpen(open_action != 0); ImGui::SetNextItemOpen(open_action != 0);
if (ImGui::TreeNode("Sizing policies")) if (ImGui::TreeNode("Sizing policies"))
{ {
static bool fixed_fill = true;
static ImGuiTableFlags flags1 = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_RowBg | ImGuiTableFlags_ContextMenuInBody; static ImGuiTableFlags flags1 = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_RowBg | ImGuiTableFlags_ContextMenuInBody;
PushStyleCompact(); PushStyleCompact();
ImGui::Checkbox("fill", &fixed_fill);
ImGui::SameLine(); HelpMarker(
"Value passed to outer_size only affects tables with _SizingFixedFit or _SizingFixedSame sizing policies.\n\n"
" - outer_size.x == 0: table fit to columns total contents.\n"
" - outer_size.x == -FLT_MIN: table fill until right-most edge.");
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable); ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable);
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags1, ImGuiTableFlags_NoHostExtendX);
PopStyleCompact(); PopStyleCompact();
ImVec2 outer_size = ImVec2(fixed_fill ? -FLT_MIN : 0.0f, 0.0f);
static ImGuiTableFlags sizing_policy_flags[4] = { ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingFixedSame, ImGuiTableFlags_SizingStretchProp, ImGuiTableFlags_SizingStretchSame }; static ImGuiTableFlags sizing_policy_flags[4] = { ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingFixedSame, ImGuiTableFlags_SizingStretchProp, ImGuiTableFlags_SizingStretchSame };
for (int table_n = 0; table_n < 4; table_n++) for (int table_n = 0; table_n < 4; table_n++)
{ {
@ -3901,7 +3893,7 @@ static void ShowDemoWindowTables()
// To make it easier to understand the different sizing policy, // To make it easier to understand the different sizing policy,
// For each policy: we display one table where the columns have equal contents width, and one where the columns have different contents width. // For each policy: we display one table where the columns have equal contents width, and one where the columns have different contents width.
if (ImGui::BeginTable("##table1", 3, sizing_policy_flags[table_n] | flags1, outer_size)) if (ImGui::BeginTable("table1", 3, sizing_policy_flags[table_n] | flags1))
{ {
for (int row = 0; row < 3; row++) for (int row = 0; row < 3; row++)
{ {
@ -3912,7 +3904,7 @@ static void ShowDemoWindowTables()
} }
ImGui::EndTable(); ImGui::EndTable();
} }
if (ImGui::BeginTable("##table2", 3, sizing_policy_flags[table_n] | flags1, outer_size)) if (ImGui::BeginTable("table2", 3, sizing_policy_flags[table_n] | flags1))
{ {
for (int row = 0; row < 3; row++) for (int row = 0; row < 3; row++)
{ {
@ -3957,8 +3949,7 @@ static void ShowDemoWindowTables()
ImGui::PopID(); ImGui::PopID();
PopStyleCompact(); PopStyleCompact();
outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 7); if (ImGui::BeginTable("table2", column_count, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 7)))
if (ImGui::BeginTable("##table2", column_count, flags, outer_size))
{ {
for (int cell = 0; cell < 10 * column_count; cell++) for (int cell = 0; cell < 10 * column_count; cell++)
{ {
@ -4000,7 +3991,7 @@ static void ShowDemoWindowTables()
// When using ScrollX or ScrollY we need to specify a size for our table container! // When using ScrollX or ScrollY we need to specify a size for our table container!
// Otherwise by default the table will fit all available space, like a BeginChild() call. // Otherwise by default the table will fit all available space, like a BeginChild() call.
ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8); ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8);
if (ImGui::BeginTable("##table1", 3, flags, outer_size)) if (ImGui::BeginTable("table_scrolly", 3, flags, outer_size))
{ {
ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible
ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_None); ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_None);
@ -4054,7 +4045,7 @@ static void ShowDemoWindowTables()
// When using ScrollX or ScrollY we need to specify a size for our table container! // When using ScrollX or ScrollY we need to specify a size for our table container!
// Otherwise by default the table will fit all available space, like a BeginChild() call. // Otherwise by default the table will fit all available space, like a BeginChild() call.
ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8); ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8);
if (ImGui::BeginTable("##table1", 7, flags, outer_size)) if (ImGui::BeginTable("table_scrollx", 7, flags, outer_size))
{ {
ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows); ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows);
ImGui::TableSetupColumn("Line #", ImGuiTableColumnFlags_NoHide); // Make the first column not hideable to match our use of TableSetupScrollFreeze() ImGui::TableSetupColumn("Line #", ImGuiTableColumnFlags_NoHide); // Make the first column not hideable to match our use of TableSetupScrollFreeze()
@ -4104,7 +4095,7 @@ static void ShowDemoWindowTables()
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::PopID(); ImGui::PopID();
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##table2", 7, flags2, outer_size, inner_width)) if (ImGui::BeginTable("table2", 7, flags2, outer_size, inner_width))
{ {
for (int cell = 0; cell < 20 * 7; cell++) for (int cell = 0; cell < 20 * 7; cell++)
{ {
@ -4126,7 +4117,7 @@ static void ShowDemoWindowTables()
static ImGuiTableColumnFlags column_flags[column_count] = { ImGuiTableColumnFlags_DefaultSort, ImGuiTableColumnFlags_None, ImGuiTableColumnFlags_DefaultHide }; static ImGuiTableColumnFlags column_flags[column_count] = { ImGuiTableColumnFlags_DefaultSort, ImGuiTableColumnFlags_None, ImGuiTableColumnFlags_DefaultHide };
static ImGuiTableColumnFlags column_flags_out[column_count] = { 0, 0, 0 }; // Output from TableGetColumnFlags() static ImGuiTableColumnFlags column_flags_out[column_count] = { 0, 0, 0 }; // Output from TableGetColumnFlags()
if (ImGui::BeginTable("##flags", column_count, ImGuiTableFlags_None)) if (ImGui::BeginTable("table_columns_flags_checkboxes", column_count, ImGuiTableFlags_None))
{ {
PushStyleCompact(); PushStyleCompact();
for (int column = 0; column < column_count; column++) for (int column = 0; column < column_count; column++)
@ -4155,7 +4146,7 @@ static void ShowDemoWindowTables()
| ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV
| ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable; | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable;
ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 9); ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 9);
if (ImGui::BeginTable("##table", column_count, flags, outer_size)) if (ImGui::BeginTable("table_columns_flags", column_count, flags, outer_size))
{ {
for (int column = 0; column < column_count; column++) for (int column = 0; column < column_count; column++)
ImGui::TableSetupColumn(column_names[column], column_flags[column]); ImGui::TableSetupColumn(column_names[column], column_flags[column]);
@ -4191,7 +4182,7 @@ static void ShowDemoWindowTables()
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable); ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable);
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags1, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags1, ImGuiTableFlags_NoBordersInBodyUntilResize);
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##table1", 3, flags1)) if (ImGui::BeginTable("table1", 3, flags1))
{ {
// We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed. // We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
ImGui::TableSetupColumn("one", ImGuiTableColumnFlags_WidthFixed, 100.0f); // Default to 100.0f ImGui::TableSetupColumn("one", ImGuiTableColumnFlags_WidthFixed, 100.0f); // Default to 100.0f
@ -4221,7 +4212,7 @@ static void ShowDemoWindowTables()
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags2, ImGuiTableFlags_BordersInnerV); ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags2, ImGuiTableFlags_BordersInnerV);
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags2, ImGuiTableFlags_BordersOuterV); ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags2, ImGuiTableFlags_BordersOuterV);
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##table2", 4, flags2)) if (ImGui::BeginTable("table2", 4, flags2))
{ {
// We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed. // We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f); ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f);
@ -4251,7 +4242,7 @@ static void ShowDemoWindowTables()
{ {
HelpMarker("This demonstrate embedding a table into another table cell."); HelpMarker("This demonstrate embedding a table into another table cell.");
if (ImGui::BeginTable("nested1", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) if (ImGui::BeginTable("table_nested1", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
{ {
ImGui::TableSetupColumn("A0"); ImGui::TableSetupColumn("A0");
ImGui::TableSetupColumn("A1"); ImGui::TableSetupColumn("A1");
@ -4261,7 +4252,7 @@ static void ShowDemoWindowTables()
ImGui::Text("A0 Cell 0"); ImGui::Text("A0 Cell 0");
{ {
float rows_height = TEXT_BASE_HEIGHT * 2; float rows_height = TEXT_BASE_HEIGHT * 2;
if (ImGui::BeginTable("nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) if (ImGui::BeginTable("table_nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
{ {
ImGui::TableSetupColumn("B0"); ImGui::TableSetupColumn("B0");
ImGui::TableSetupColumn("B1"); ImGui::TableSetupColumn("B1");
@ -4294,7 +4285,7 @@ static void ShowDemoWindowTables()
if (ImGui::TreeNode("Row height")) if (ImGui::TreeNode("Row height"))
{ {
HelpMarker("You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\nWe cannot honor a _maximum_ row height as that would requires a unique clipping rectangle per row."); HelpMarker("You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\nWe cannot honor a _maximum_ row height as that would requires a unique clipping rectangle per row.");
if (ImGui::BeginTable("##Table", 1, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerV)) if (ImGui::BeginTable("table_row_height", 1, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerV))
{ {
for (int row = 0; row < 10; row++) for (int row = 0; row < 10; row++)
{ {
@ -4324,7 +4315,7 @@ static void ShowDemoWindowTables()
PopStyleCompact(); PopStyleCompact();
ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 5.5f); ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 5.5f);
if (ImGui::BeginTable("##table3", 3, flags, outer_size)) if (ImGui::BeginTable("table1", 3, flags, outer_size))
{ {
for (int row = 0; row < 10; row++) for (int row = 0; row < 10; row++)
{ {
@ -4343,7 +4334,7 @@ static void ShowDemoWindowTables()
ImGui::Spacing(); ImGui::Spacing();
ImGui::Text("Using explicit size:"); ImGui::Text("Using explicit size:");
if (ImGui::BeginTable("##table1", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f))) if (ImGui::BeginTable("table2", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
{ {
for (int row = 0; row < 5; row++) for (int row = 0; row < 5; row++)
{ {
@ -4357,7 +4348,7 @@ static void ShowDemoWindowTables()
ImGui::EndTable(); ImGui::EndTable();
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::BeginTable("##table2", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f))) if (ImGui::BeginTable("table3", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
{ {
for (int row = 0; row < 3; row++) for (int row = 0; row < 3; row++)
{ {
@ -4395,7 +4386,7 @@ static void ShowDemoWindowTables()
IM_ASSERT(cell_bg_type >= 0 && cell_bg_type <= 1); IM_ASSERT(cell_bg_type >= 0 && cell_bg_type <= 1);
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##Table", 5, flags)) if (ImGui::BeginTable("table1", 5, flags))
{ {
for (int row = 0; row < 6; row++) for (int row = 0; row < 6; row++)
{ {
@ -4437,7 +4428,7 @@ static void ShowDemoWindowTables()
{ {
static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody; static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
if (ImGui::BeginTable("##3ways", 3, flags)) if (ImGui::BeginTable("3ways", 3, flags))
{ {
// The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On // The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoHide); ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoHide);
@ -4509,7 +4500,7 @@ static void ShowDemoWindowTables()
HelpMarker( HelpMarker(
"Showcase using PushItemWidth() and how it is preserved on a per-column basis.\n\n" "Showcase using PushItemWidth() and how it is preserved on a per-column basis.\n\n"
"Note that on auto-resizing non-resizable fixed columns, querying the content width for e.g. right-alignment doesn't make sense."); "Note that on auto-resizing non-resizable fixed columns, querying the content width for e.g. right-alignment doesn't make sense.");
if (ImGui::BeginTable("##table2", 3, ImGuiTableFlags_Borders)) if (ImGui::BeginTable("table_item_width", 3, ImGuiTableFlags_Borders))
{ {
ImGui::TableSetupColumn("small"); ImGui::TableSetupColumn("small");
ImGui::TableSetupColumn("half"); ImGui::TableSetupColumn("half");
@ -4552,7 +4543,7 @@ static void ShowDemoWindowTables()
if (ImGui::TreeNode("Custom headers")) if (ImGui::TreeNode("Custom headers"))
{ {
const int COLUMNS_COUNT = 3; const int COLUMNS_COUNT = 3;
if (ImGui::BeginTable("##table1", COLUMNS_COUNT, ImGuiTableFlags_Borders | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) if (ImGui::BeginTable("table_custom_headers", COLUMNS_COUNT, ImGuiTableFlags_Borders | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
{ {
ImGui::TableSetupColumn("Apricot"); ImGui::TableSetupColumn("Apricot");
ImGui::TableSetupColumn("Banana"); ImGui::TableSetupColumn("Banana");
@ -4609,7 +4600,7 @@ static void ShowDemoWindowTables()
// [1.1] Right-click on the TableHeadersRow() line to open the default table context menu. // [1.1] Right-click on the TableHeadersRow() line to open the default table context menu.
// [1.2] Right-click in columns also open the default table context menu (if ImGuiTableFlags_ContextMenuInBody is set) // [1.2] Right-click in columns also open the default table context menu (if ImGuiTableFlags_ContextMenuInBody is set)
const int COLUMNS_COUNT = 3; const int COLUMNS_COUNT = 3;
if (ImGui::BeginTable("##table1", COLUMNS_COUNT, flags1)) if (ImGui::BeginTable("table_context_menu", COLUMNS_COUNT, flags1))
{ {
ImGui::TableSetupColumn("One"); ImGui::TableSetupColumn("One");
ImGui::TableSetupColumn("Two"); ImGui::TableSetupColumn("Two");
@ -4637,7 +4628,7 @@ static void ShowDemoWindowTables()
// [2.3] Right-click in columns to open another custom popup // [2.3] Right-click in columns to open another custom popup
HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body)."); HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body).");
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders; ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
if (ImGui::BeginTable("##table2", COLUMNS_COUNT, flags2)) if (ImGui::BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2))
{ {
ImGui::TableSetupColumn("One"); ImGui::TableSetupColumn("One");
ImGui::TableSetupColumn("Two"); ImGui::TableSetupColumn("Two");
@ -4766,7 +4757,7 @@ static void ShowDemoWindowTables()
ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0)."); ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).");
PopStyleCompact(); PopStyleCompact();
if (ImGui::BeginTable("##table", 4, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 15), 0.0f)) if (ImGui::BeginTable("table_sorting", 4, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 15), 0.0f))
{ {
// Declare columns // Declare columns
// We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications.
@ -4979,7 +4970,7 @@ static void ShowDemoWindowTables()
const ImDrawList* table_draw_list = NULL; // " const ImDrawList* table_draw_list = NULL; // "
const float inner_width_to_use = (flags & ImGuiTableFlags_ScrollX) ? inner_width_with_scroll : 0.0f; const float inner_width_to_use = (flags & ImGuiTableFlags_ScrollX) ? inner_width_with_scroll : 0.0f;
if (ImGui::BeginTable("##table", 6, flags, outer_size_enabled ? outer_size_value : ImVec2(0, 0), inner_width_to_use)) if (ImGui::BeginTable("table_advanced", 6, flags, outer_size_enabled ? outer_size_value : ImVec2(0, 0), inner_width_to_use))
{ {
// Declare columns // Declare columns
// We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications.
@ -7035,7 +7026,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
{ {
if (ImGui::BeginTabItem("Primitives")) if (ImGui::BeginTabItem("Primitives"))
{ {
ImGui::PushItemWidth(-ImGui::GetFontSize() * 10); ImGui::PushItemWidth(-ImGui::GetFontSize() * 15);
ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImDrawList* draw_list = ImGui::GetWindowDrawList();
// Draw gradients // Draw gradients
@ -7129,7 +7120,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine) draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine)
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255)); draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255));
ImGui::Dummy(ImVec2((sz + spacing) * 8.8f, (sz + spacing) * 3.0f)); ImGui::Dummy(ImVec2((sz + spacing) * 10.2f, (sz + spacing) * 3.0f));
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::EndTabItem(); ImGui::EndTabItem();
} }

View File

@ -1,4 +1,4 @@
// dear imgui, v1.80 WIP // dear imgui, v1.80
// (drawing and font code) // (drawing and font code)
/* /*

View File

@ -1,4 +1,4 @@
// dear imgui, v1.80 WIP // dear imgui, v1.80
// (internal structures/api) // (internal structures/api)
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!

View File

@ -1,4 +1,4 @@
// dear imgui, v1.80 WIP // dear imgui, v1.80
// (tables and columns code) // (tables and columns code)
/* /*

View File

@ -1,4 +1,4 @@
// dear imgui, v1.80 WIP // dear imgui, v1.80
// (widgets code) // (widgets code)
/* /*