Skip to content

Commit 7aed4b1

Browse files
committed
Tables: improve index, file structure tweaks.
1 parent 082f1d1 commit 7aed4b1

File tree

3 files changed

+60
-28
lines changed

3 files changed

+60
-28
lines changed

imgui_demo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Index of this file:
6868
#include "imgui.h"
6969
#ifndef IMGUI_DISABLE
7070

71+
// System includes
7172
#include <ctype.h> // toupper
7273
#include <limits.h> // INT_MIN, INT_MAX
7374
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf

imgui_tables.cpp

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
// (tables and columns code)
33

44
/*
5-
*
6-
* Index of this file:
7-
*
8-
* // [SECTION] Widgets: BeginTable, EndTable, etc.
9-
* // [SECTION] Widgets: Columns, BeginColumns, EndColumns, etc.
10-
*
11-
*/
5+
6+
Index of this file:
7+
8+
// [SECTION] Tables: BeginTable, EndTable, etc.
9+
// [SECTION] Tables: Headers
10+
// [SECTION] Tables: Context Menu
11+
// [SECTION] Tables: Settings (.ini data)
12+
// [SECTION] Tables: Garbage Collection
13+
// [SECTION] Tables: Debugging
14+
// [SECTION] Columns, BeginColumns, EndColumns, etc.
15+
16+
*/
1217

1318
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
1419
#define _CRT_SECURE_NO_WARNINGS
@@ -22,12 +27,17 @@
2227
#endif
2328
#include "imgui_internal.h"
2429

30+
// System includes
2531
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
2632
#include <stddef.h> // intptr_t
2733
#else
2834
#include <stdint.h> // intptr_t
2935
#endif
3036

37+
//-------------------------------------------------------------------------
38+
// Warnings
39+
//-------------------------------------------------------------------------
40+
3141
// Visual Studio warnings
3242
#ifdef _MSC_VER
3343
#pragma warning (disable: 4127) // condition expression is constant
@@ -45,21 +55,21 @@
4555
#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx'
4656
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse.
4757
#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok.
58+
#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
4859
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
4960
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0
5061
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
5162
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
5263
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
5364
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
5465
#elif defined(__GNUC__)
55-
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
56-
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
66+
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
67+
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
68+
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
5769
#endif
5870

5971
//-----------------------------------------------------------------------------
60-
// [SECTION] Widgets: BeginTable, EndTable, etc.
61-
//-----------------------------------------------------------------------------
62-
72+
// [SECTION] Tables: BeginTable, EndTable, etc.
6373
//-----------------------------------------------------------------------------
6474
// Typical call flow: (root level is public API):
6575
// - BeginTable() user begin into a table
@@ -1744,7 +1754,7 @@ void ImGui::TableNextRow(ImGuiTableRowFlags row_flags, float row_min_height)
17441754
table->InnerWindow->SkipItems = true;
17451755
}
17461756

1747-
// [Internal]
1757+
// [Internal] Called by TableNextRow()!
17481758
void ImGui::TableBeginRow(ImGuiTable* table)
17491759
{
17501760
ImGuiWindow* window = table->InnerWindow;
@@ -1777,7 +1787,7 @@ void ImGui::TableBeginRow(ImGuiTable* table)
17771787
}
17781788
}
17791789

1780-
// [Internal]
1790+
// [Internal] Called by TableNextRow()!
17811791
void ImGui::TableEndRow(ImGuiTable* table)
17821792
{
17831793
ImGuiContext& g = *GImGui;
@@ -2684,7 +2694,22 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
26842694
}
26852695

26862696
//-------------------------------------------------------------------------
2687-
// TABLE - .ini settings
2697+
// [SECTION] Tables: Settings (.ini data)
2698+
//-------------------------------------------------------------------------
2699+
// - TableSettingsInit() [Internal]
2700+
// - TableSettingsCalcChunkSize() [Internal]
2701+
// - TableSettingsCreate() [Internal]
2702+
// - TableSettingsFindByID() [Internal]
2703+
// - TableSettingsClearByID() [Internal]
2704+
// - TableGetBoundSettings() [Internal]
2705+
// - TableSaveSettings() [Internal]
2706+
// - TableLoadSettings() [Internal]
2707+
// - TableSettingsHandler_ClearAll() [Internal]
2708+
// - TableSettingsHandler_ApplyAll() [Internal]
2709+
// - TableSettingsHandler_ReadOpen() [Internal]
2710+
// - TableSettingsHandler_ReadLine() [Internal]
2711+
// - TableSettingsHandler_WriteAll() [Internal]
2712+
// - TableSettingsInstallHandler() [Internal]
26882713
//-------------------------------------------------------------------------
26892714
// [Init] 1: TableSettingsHandler_ReadXXXX() Load and parse .ini file into TableSettings.
26902715
// [Main] 2: TableLoadSettings() When table is created, bind Table to TableSettings, serialize TableSettings data into Table.
@@ -2693,7 +2718,7 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
26932718
//-------------------------------------------------------------------------
26942719

26952720
// Clear and initialize empty settings instance
2696-
static void InitTableSettings(ImGuiTableSettings* settings, ImGuiID id, int columns_count, int columns_count_max)
2721+
static void TableSettingsInit(ImGuiTableSettings* settings, ImGuiID id, int columns_count, int columns_count_max)
26972722
{
26982723
IM_PLACEMENT_NEW(settings) ImGuiTableSettings();
26992724
ImGuiTableColumnSettings* settings_column = settings->GetColumnSettings();
@@ -2714,7 +2739,7 @@ ImGuiTableSettings* ImGui::TableSettingsCreate(ImGuiID id, int columns_count)
27142739
{
27152740
ImGuiContext& g = *GImGui;
27162741
ImGuiTableSettings* settings = g.SettingsTables.alloc_chunk(TableSettingsCalcChunkSize(columns_count));
2717-
InitTableSettings(settings, id, columns_count, columns_count);
2742+
TableSettingsInit(settings, id, columns_count, columns_count);
27182743
return settings;
27192744
}
27202745

@@ -2893,7 +2918,7 @@ static void* TableSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*,
28932918
{
28942919
if (settings->ColumnsCountMax >= columns_count)
28952920
{
2896-
InitTableSettings(settings, id, columns_count, settings->ColumnsCountMax); // Recycle
2921+
TableSettingsInit(settings, id, columns_count, settings->ColumnsCountMax); // Recycle
28972922
return settings;
28982923
}
28992924
settings->ID = 0; // Invalidate storage, we won't fit because of a count change
@@ -2980,7 +3005,11 @@ void ImGui::TableSettingsInstallHandler(ImGuiContext* context)
29803005
}
29813006

29823007
//-------------------------------------------------------------------------
2983-
// TABLE - Garbage Collection
3008+
// [SECTION] Tables: Garbage Collection
3009+
//-------------------------------------------------------------------------
3010+
// - TableRemove() [Internal]
3011+
// - TableGcCompactTransientBuffers() [Internal]
3012+
// - TableGcCompactSettings() [Internal]
29843013
//-------------------------------------------------------------------------
29853014

29863015
// Remove Table (currently only used by TestEngine)
@@ -3030,8 +3059,9 @@ void ImGui::TableGcCompactSettings()
30303059
g.SettingsTables.swap(new_chunk_stream);
30313060
}
30323061

3062+
30333063
//-------------------------------------------------------------------------
3034-
// TABLE - Debugging
3064+
// [SECTION] Tables: Debugging
30353065
//-------------------------------------------------------------------------
30363066
// - DebugNodeTable() [Internal]
30373067
//-------------------------------------------------------------------------
@@ -3112,13 +3142,9 @@ void ImGui::DebugNodeTableSettings(ImGuiTableSettings* settings)
31123142

31133143
#endif // #ifndef IMGUI_DISABLE_METRICS_WINDOW
31143144

3115-
//-------------------------------------------------------------------------
3116-
3117-
3118-
31193145

31203146
//-------------------------------------------------------------------------
3121-
// [SECTION] Widgets: Columns, BeginColumns, EndColumns, etc.
3147+
// [SECTION] Columns, BeginColumns, EndColumns, etc.
31223148
// (This is a legacy API, prefer using BeginTable/EndTable!)
31233149
//-------------------------------------------------------------------------
31243150
// - SetWindowClipRectBeforeSetChannel() [Internal]

imgui_widgets.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,18 @@ Index of this file:
4040
#endif
4141
#include "imgui_internal.h"
4242

43+
// System includes
4344
#include <ctype.h> // toupper
4445
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
4546
#include <stddef.h> // intptr_t
4647
#else
4748
#include <stdint.h> // intptr_t
4849
#endif
4950

51+
//-------------------------------------------------------------------------
52+
// Warnings
53+
//-------------------------------------------------------------------------
54+
5055
// Visual Studio warnings
5156
#ifdef _MSC_VER
5257
#pragma warning (disable: 4127) // condition expression is constant
@@ -72,9 +77,9 @@ Index of this file:
7277
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
7378
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
7479
#elif defined(__GNUC__)
75-
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
76-
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
77-
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
80+
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
81+
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
82+
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
7883
#endif
7984

8085
//-------------------------------------------------------------------------

0 commit comments

Comments
 (0)