mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Tables: (Breaking) Add TableSetupScrollFreeze() api, remove ImGuiTableFlags_ScrollFreezeXXX flags, tweak comments, move columns block.
Avoid awkwardly named ScrollFreeze flags, raise limit over 3, and will allow for future api maybe freezing bottom/right side.
This commit is contained in:
		
							
								
								
									
										98
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										98
									
								
								imgui.h
									
									
									
									
									
								
							| @@ -652,11 +652,55 @@ namespace ImGui | ||||
|     //  - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId + ImGuiPopupFlags_AnyPopupLevel: return true if any popup is open. | ||||
|     IMGUI_API bool          IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0);                         // return true if the popup is open. | ||||
|  | ||||
|     // Columns | ||||
|     // Tables | ||||
|     // [ALPHA API] API will evolve! (see: FIXME-TABLE) | ||||
|     // - Full-featured replacement for old Columns API | ||||
|     // - See Demo->Tables for details. | ||||
|     // - See ImGuiTableFlags_ and ImGuiTableColumnsFlags_ enums for a description of available flags. | ||||
|     // The typical call flow is: | ||||
|     // - 1. Call BeginTable() | ||||
|     // - 2. Optionally call TableSetupColumn() to submit column name/flags/defaults | ||||
|     // - 3. Optionally call TableSetupScrollFreeze() to request scroll freezing of columns/rows | ||||
|     // - 4. Optionally call TableAutoHeaders() to submit a header row (names will be pulled from data submitted to TableSetupColumns) | ||||
|     // - 4. Populate contents | ||||
|     //     - In most situations you can use TableNextRow() + TableSetColumnIndex() 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, | ||||
|     //       you may prefer using TableNextCell() instead of TableNextRow() + TableSetColumnIndex(). | ||||
|     //     - Submit your content with regular ImGui function. | ||||
|     // - 5. Call EndTable() | ||||
|     #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! | ||||
|     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          TableNextCell();                            // append into the next column (next column, or next row if currently in last column). Return true if column is visible. | ||||
|     IMGUI_API bool          TableSetColumnIndex(int column_n);          // append into the specified column. Return true if column is visible. | ||||
|     IMGUI_API int           TableGetColumnIndex();                      // return current column index. | ||||
|     // Tables: Headers & Columns declaration | ||||
|     // - Use TableSetupScrollFreeze() to lock columns (from the right) or rows (from the top) so they stay visible when scrolled. | ||||
|     // - Use TableSetupColumn() to specify label, resizing policy, default width, id, various other flags etc. | ||||
|     //   Important: this will not display anything! The name passed to TableSetupColumn() is used by TableAutoHeaders() and context-menus. | ||||
|     // - Use TableAutoHeaders() to create a row and automatically submit a TableHeader() for each column. | ||||
|     //   Headers are required to perform some interactions: reordering, sorting, context menu (FIXME-TABLE: context menu should work without!) | ||||
|     // - 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). | ||||
|     IMGUI_API void          TableSetupScrollFreeze(int columns, int rows); | ||||
|     IMGUI_API void          TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = -1.0f, ImU32 user_id = 0); | ||||
|     IMGUI_API void          TableAutoHeaders();                         // 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) | ||||
|     // Tables: Miscellaneous functions | ||||
|     // - Most functions taking '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 const char*   TableGetColumnName(int column_n = -1);      // return NULL if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column. | ||||
|     IMGUI_API bool          TableGetColumnIsVisible(int column_n = -1); // return true if column is visible. Same value is also returned by TableNextCell() and TableSetColumnIndex(). Pass -1 to use current column. | ||||
|     IMGUI_API bool          TableGetColumnIsSorted(int column_n = -1);  // return true if column is included in the sort specs. Rarely used, can be useful to tell if a data change should trigger resort. Equivalent to test ImGuiTableSortSpecs's ->ColumnsMask & (1 << column_n). Pass -1 to use current column. | ||||
|     IMGUI_API int           TableGetHoveredColumn();                    // 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 ImGuiTableSortSpecs* TableGetSortSpecs();                 // get latest sort specs for the table (NULL if not sorting). | ||||
|     IMGUI_API void          TableSetBgColor(ImGuiTableBgTarget bg_target, ImU32 color, int column_n = -1);  // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details. | ||||
|  | ||||
|     // Columns (Legacy API, prefer using Tables) | ||||
|     // - You can also use SameLine(pos_x) to mimic simplified columns. | ||||
|     // - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!) | ||||
|     // - There is a maximum of 64 columns. | ||||
|     // - Currently working on new 'Tables' api which will replace columns around Q2 2020 (see GitHub #2957). | ||||
|     IMGUI_API void          Columns(int count = 1, const char* id = NULL, bool border = true); | ||||
|     IMGUI_API void          NextColumn();                                                       // next column, defaults to current row or next row if the current row is finished | ||||
|     IMGUI_API int           GetColumnIndex();                                                   // get current column index | ||||
| @@ -666,42 +710,6 @@ namespace ImGui | ||||
|     IMGUI_API void          SetColumnOffset(int column_index, float offset_x);                  // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column | ||||
|     IMGUI_API int           GetColumnsCount(); | ||||
|  | ||||
|     // Tables | ||||
|     // [ALPHA API] API will evolve! (FIXME-TABLE) | ||||
|     // - Full-featured replacement for old Columns API | ||||
|     // - In most situations you can use TableNextRow() + TableSetColumnIndex() to populate a table. | ||||
|     // - 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_ and ImGuiTableColumnsFlags_ 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! | ||||
|     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          TableNextCell();                            // append into the next column (next column, or next row if currently in last column). Return true if column is visible. | ||||
|     IMGUI_API bool          TableSetColumnIndex(int column_n);          // append into the specified column. Return true if column is visible. | ||||
|     IMGUI_API int           TableGetColumnIndex();                      // return current column index. | ||||
|     IMGUI_API const char*   TableGetColumnName(int column_n = -1);      // return NULL if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column. | ||||
|     IMGUI_API bool          TableGetColumnIsVisible(int column_n = -1); // return true if column is visible. Same value is also returned by TableNextCell() and TableSetColumnIndex(). Pass -1 to use current column. | ||||
|     IMGUI_API bool          TableGetColumnIsSorted(int column_n = -1);  // return true if column is included in the sort specs. Rarely used, can be useful to tell if a data change should trigger resort. Equivalent to test ImGuiTableSortSpecs's ->ColumnsMask & (1 << column_n). Pass -1 to use current column. | ||||
|     IMGUI_API int           TableGetHoveredColumn();                    // 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 void          TableSetBgColor(ImGuiTableBgTarget bg_target, ImU32 color, int column_n = -1);  // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details. | ||||
|     // Tables: Headers & Columns declaration | ||||
|     // - Use TableSetupColumn() to specify label, resizing policy, default width, id, various other flags etc. | ||||
|     //   Important: this will not display anything! The name passed to TableSetupColumn() is used by TableAutoHeaders() and context-menus. | ||||
|     // - Use TableAutoHeaders() to create a row and automatically submit a TableHeader() for each column. | ||||
|     //   Headers are required to perform some interactions: reordering, sorting, context menu (FIXME-TABLE: context menu should work without!) | ||||
|     // - 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). | ||||
|     IMGUI_API void          TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = -1.0f, ImU32 user_id = 0); | ||||
|     IMGUI_API void          TableAutoHeaders();                         // 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) | ||||
|     // Tables: Sorting | ||||
|     // - Call TableGetSortSpecs() to retrieve latest sort specs for the table. Return value will be NULL if no sorting. | ||||
|     // - When 'SpecsDirty == true' you can sort your data. It will be true with 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). | ||||
|  | ||||
|     // Tab Bars, Tabs | ||||
|     IMGUI_API bool          BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0);        // create and append into a TabBar | ||||
|     IMGUI_API void          EndTabBar();                                                        // only call EndTabBar() if BeginTabBar() returns true! | ||||
| @@ -1062,19 +1070,9 @@ enum ImGuiTableFlags_ | ||||
|     ImGuiTableFlags_ScrollX                         = 1 << 20,  // Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Because this create a child window, ScrollY is currently generally recommended when using ScrollX. | ||||
|     ImGuiTableFlags_ScrollY                         = 1 << 21,  // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. | ||||
|     ImGuiTableFlags_Scroll                          = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY, | ||||
|     ImGuiTableFlags_ScrollFreezeTopRow              = 1 << 22,  // We can lock 1 to 3 rows (starting from the top). Use with ScrollY enabled. | ||||
|     ImGuiTableFlags_ScrollFreeze2Rows               = 2 << 22, | ||||
|     ImGuiTableFlags_ScrollFreeze3Rows               = 3 << 22, | ||||
|     ImGuiTableFlags_ScrollFreezeLeftColumn          = 1 << 24,  // We can lock 1 to 3 columns (starting from the left). Use with ScrollX enabled. | ||||
|     ImGuiTableFlags_ScrollFreeze2Columns            = 2 << 24, | ||||
|     ImGuiTableFlags_ScrollFreeze3Columns            = 3 << 24, | ||||
|  | ||||
|     // [Internal] Combinations and masks | ||||
|     ImGuiTableFlags_SizingPolicyMaskX_              = ImGuiTableFlags_SizingPolicyStretchX | ImGuiTableFlags_SizingPolicyFixedX, | ||||
|     ImGuiTableFlags_ScrollFreezeRowsShift_          = 22, | ||||
|     ImGuiTableFlags_ScrollFreezeColumnsShift_       = 24, | ||||
|     ImGuiTableFlags_ScrollFreezeRowsMask_           = 0x03 << ImGuiTableFlags_ScrollFreezeRowsShift_, | ||||
|     ImGuiTableFlags_ScrollFreezeColumnsMask_        = 0x03 << ImGuiTableFlags_ScrollFreezeColumnsShift_ | ||||
| }; | ||||
|  | ||||
| // Flags for ImGui::TableSetupColumn() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user