浏览代码

imgui.h: Comments

omar 6 年之前
父节点
当前提交
1fa2cb8748
共有 1 个文件被更改,包括 61 次插入11 次删除
  1. 61 11
      imgui.h

+ 61 - 11
imgui.h

@@ -6,9 +6,26 @@
 // Read 'Programmer guide' in imgui.cpp for notes on how to setup ImGui in your codebase.
 // Read 'Programmer guide' in imgui.cpp for notes on how to setup ImGui in your codebase.
 // Get latest version at https://github.com/ocornut/imgui
 // Get latest version at https://github.com/ocornut/imgui
 
 
+/*
+
+Index of this file:
+// Header mess
+// Forward declarations and basic types
+// ImGui API (Dear ImGui end-user API)
+// Flags & Enumerations
+// ImGuiStyle
+// ImGuiIO
+// Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload)
+// Obsolete functions
+// Helpers (ImVector, ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor)
+// Draw List API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListFlags, ImDrawList, ImDrawData)
+// Font API (ImFontConfig, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFont)
+
+*/
+
 #pragma once
 #pragma once
 
 
-// Configuration file (edit imconfig.h or define IMGUI_USER_CONFIG to set your own filename)
+// Configuration file (edit imconfig.h or define IMGUI_USER_CONFIG to your own filename)
 #ifdef IMGUI_USER_CONFIG
 #ifdef IMGUI_USER_CONFIG
 #include IMGUI_USER_CONFIG
 #include IMGUI_USER_CONFIG
 #endif
 #endif
@@ -16,6 +33,10 @@
 #include "imconfig.h"
 #include "imconfig.h"
 #endif
 #endif
 
 
+//-----------------------------------------------------------------------------
+// Header mess
+//-----------------------------------------------------------------------------
+
 #include <float.h>                  // FLT_MAX
 #include <float.h>                  // FLT_MAX
 #include <stdarg.h>                 // va_list
 #include <stdarg.h>                 // va_list
 #include <stddef.h>                 // ptrdiff_t, NULL
 #include <stddef.h>                 // ptrdiff_t, NULL
@@ -36,7 +57,7 @@
 #define IMGUI_IMPL_API              IMGUI_API
 #define IMGUI_IMPL_API              IMGUI_API
 #endif
 #endif
 
 
-// Helpers
+// Helper Macros
 #ifndef IM_ASSERT
 #ifndef IM_ASSERT
 #include <assert.h>
 #include <assert.h>
 #define IM_ASSERT(_EXPR)            assert(_EXPR)                               // You can override the default assert handler by editing imconfig.h
 #define IM_ASSERT(_EXPR)            assert(_EXPR)                               // You can override the default assert handler by editing imconfig.h
@@ -51,6 +72,7 @@
 #define IM_ARRAYSIZE(_ARR)          ((int)(sizeof(_ARR)/sizeof(*_ARR)))         // Size of a static C-style array. Don't use on pointers!
 #define IM_ARRAYSIZE(_ARR)          ((int)(sizeof(_ARR)/sizeof(*_ARR)))         // Size of a static C-style array. Don't use on pointers!
 #define IM_OFFSETOF(_TYPE,_MEMBER)  ((size_t)&(((_TYPE*)0)->_MEMBER))           // Offset of _MEMBER within _TYPE. Standardized as offsetof() in modern C++.
 #define IM_OFFSETOF(_TYPE,_MEMBER)  ((size_t)&(((_TYPE*)0)->_MEMBER))           // Offset of _MEMBER within _TYPE. Standardized as offsetof() in modern C++.
 
 
+// Warnings
 #if defined(__clang__)
 #if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wold-style-cast"
 #pragma clang diagnostic ignored "-Wold-style-cast"
@@ -59,7 +81,10 @@
 #pragma GCC diagnostic ignored "-Wclass-memaccess"
 #pragma GCC diagnostic ignored "-Wclass-memaccess"
 #endif
 #endif
 
 
-// Forward declarations
+//-----------------------------------------------------------------------------
+// Forward declarations and basic types
+//-----------------------------------------------------------------------------
+
 struct ImDrawChannel;               // Temporary storage for outputting drawing commands out of order, used by ImDrawList::ChannelsSplit()
 struct ImDrawChannel;               // Temporary storage for outputting drawing commands out of order, used by ImDrawList::ChannelsSplit()
 struct ImDrawCmd;                   // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call)
 struct ImDrawCmd;                   // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call)
 struct ImDrawData;                  // All draw command lists required to render the frame
 struct ImDrawData;                  // All draw command lists required to render the frame
@@ -153,8 +178,11 @@ struct ImVec4
 #endif
 #endif
 };
 };
 
 
-// Dear ImGui end-user API
-// (In a namespace so you can add extra functions in your own separate file. Please don't modify imgui.cpp/.h!)
+//-----------------------------------------------------------------------------
+// ImGui: Dear ImGui end-user API
+// (Inside a namespace so you can add extra functions in your own separate file. Please don't modify imgui.cpp/.h!)
+//-----------------------------------------------------------------------------
+
 namespace ImGui
 namespace ImGui
 {
 {
     // Context creation and access
     // Context creation and access
@@ -609,6 +637,10 @@ namespace ImGui
 
 
 } // namespace ImGui
 } // namespace ImGui
 
 
+//-----------------------------------------------------------------------------
+// Flags & Enumerations
+//-----------------------------------------------------------------------------
+
 // Flags for ImGui::Begin()
 // Flags for ImGui::Begin()
 enum ImGuiWindowFlags_
 enum ImGuiWindowFlags_
 {
 {
@@ -1031,7 +1063,8 @@ enum ImGuiMouseCursor_
 #endif
 #endif
 };
 };
 
 
-// Enumateration representation a Condition for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
+// Enumateration for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
+// Represent a condition.
 // Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
 // Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
 enum ImGuiCond_
 enum ImGuiCond_
 {
 {
@@ -1046,8 +1079,13 @@ enum ImGuiCond_
 #endif
 #endif
 };
 };
 
 
+//-----------------------------------------------------------------------------
+// ImGuiStyle
 // You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame().
 // You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame().
-// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values, and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors.
+// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values, 
+// and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors.
+//-----------------------------------------------------------------------------
+
 struct ImGuiStyle
 struct ImGuiStyle
 {
 {
     float       Alpha;                      // Global alpha applies to everything in ImGui.
     float       Alpha;                      // Global alpha applies to everything in ImGui.
@@ -1085,8 +1123,12 @@ struct ImGuiStyle
     IMGUI_API void ScaleAllSizes(float scale_factor);
     IMGUI_API void ScaleAllSizes(float scale_factor);
 };
 };
 
 
-// This is where your app communicate with Dear ImGui. Access via ImGui::GetIO().
-// Read 'Programmer guide' section in .cpp file for general usage.
+//-----------------------------------------------------------------------------
+// ImGuiIO
+// Communicate most settings and inputs/outputs to Dear ImGui using this structure. 
+// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage.
+//-----------------------------------------------------------------------------
+
 struct ImGuiIO
 struct ImGuiIO
 {
 {
     //------------------------------------------------------------------
     //------------------------------------------------------------------
@@ -1209,6 +1251,10 @@ struct ImGuiIO
     IMGUI_API   ImGuiIO();
     IMGUI_API   ImGuiIO();
 };
 };
 
 
+//-----------------------------------------------------------------------------
+// Misc data structures
+//-----------------------------------------------------------------------------
+
 // Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used.
 // Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used.
 // The callback function should return 0 by default.
 // The callback function should return 0 by default.
 // Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details)
 // Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details)
@@ -1254,7 +1300,7 @@ struct ImGuiSizeCallbackData
     ImVec2  DesiredSize;    // Read-write.  Desired size, based on user's mouse position. Write to this field to restrain resizing.
     ImVec2  DesiredSize;    // Read-write.  Desired size, based on user's mouse position. Write to this field to restrain resizing.
 };
 };
 
 
-// Data payload for Drag and Drop operations
+// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
 struct ImGuiPayload
 struct ImGuiPayload
 {
 {
     // Members
     // Members
@@ -1578,7 +1624,7 @@ struct ImColor
 };
 };
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-// Draw List
+// Draw List API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListFlags, ImDrawList, ImDrawData)
 // Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList.
 // Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList.
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
@@ -1764,6 +1810,10 @@ struct ImDrawData
     IMGUI_API void  ScaleClipRects(const ImVec2& sc);   // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
     IMGUI_API void  ScaleClipRects(const ImVec2& sc);   // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
 };
 };
 
 
+//-----------------------------------------------------------------------------
+// Font API (ImFontConfig, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFont)
+//-----------------------------------------------------------------------------
+
 struct ImFontConfig
 struct ImFontConfig
 {
 {
     void*           FontData;               //          // TTF/OTF data
     void*           FontData;               //          // TTF/OTF data