mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Merge branch 'master' into docking
# Conflicts: # imgui.cpp
This commit is contained in:
		| @@ -99,6 +99,7 @@ Other changes: | |||||||
|  |  | ||||||
| Other Changes: | Other Changes: | ||||||
|  |  | ||||||
|  | - Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigation to the menu layer. | ||||||
| - InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when | - InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when | ||||||
|   style.FramePadding.x is abnormally larger than style.FramePadding.y. Since the buttons are |   style.FramePadding.x is abnormally larger than style.FramePadding.y. Since the buttons are | ||||||
|   meant to be square (to align with e.g. color button) we always use FramePadding.y. (#2367) |   meant to be square (to align with e.g. color button) we always use FramePadding.y. (#2367) | ||||||
| @@ -107,6 +108,11 @@ Other Changes: | |||||||
| - TabBar: Fixed a crash when using BeginTabBar() recursively (didn't affect docking). (#2371) | - TabBar: Fixed a crash when using BeginTabBar() recursively (didn't affect docking). (#2371) | ||||||
| - TabBar: Added extra mis-usage error recovery. Past the assert, common mis-usage don't lead to | - TabBar: Added extra mis-usage error recovery. Past the assert, common mis-usage don't lead to | ||||||
|   hard crashes any more, facilitating integration with scripting languages. (#1651) |   hard crashes any more, facilitating integration with scripting languages. (#1651) | ||||||
|  | - Log/Capture: Fixed extraneous leading carriage return. | ||||||
|  | - Log/Capture: Fixed an issue when empty string on a new line would not emit a carriage return. | ||||||
|  | - Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute | ||||||
|  |   tree depth instead of a relative one. | ||||||
|  | - Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##". | ||||||
| - Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN | - Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN | ||||||
|   even if the OpenGL headers/loader happens to define the value. (#2366, #2186) |   even if the OpenGL headers/loader happens to define the value. (#2366, #2186) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -241,10 +241,11 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i | |||||||
|  - style: gradients fill (#1223) ~ 2 bg colors for each fill? tricky with rounded shapes and using textures for corners. |  - style: gradients fill (#1223) ~ 2 bg colors for each fill? tricky with rounded shapes and using textures for corners. | ||||||
|  - style editor: color child window height expressed in multiple of line height. |  - style editor: color child window height expressed in multiple of line height. | ||||||
|  |  | ||||||
|  - log: LogButtons() options for specifying depth and/or hiding depth slider |  | ||||||
|  - log: have more control over the log scope (e.g. stop logging when leaving current tree node scope) |  - log: have more control over the log scope (e.g. stop logging when leaving current tree node scope) | ||||||
|  - log: be able to log anything (e.g. right-click on a window/tree-node, shows context menu? log into tty/file/clipboard) |  - log: be able to log anything (e.g. right-click on a window/tree-node, shows context menu? log into tty/file/clipboard) | ||||||
|  - log: let user copy any window content to clipboard easily (CTRL+C on windows? while moving it? context menu?). code is commented because it fails with multiple Begin/End pairs. |  - log: let user copy any window content to clipboard easily (CTRL+C on windows? while moving it? context menu?). code is commented because it fails with multiple Begin/End pairs. | ||||||
|  |  - log: obsolete LogButtons() all together. | ||||||
|  |  - log: LogButtons() options for specifying depth and/or hiding depth slider | ||||||
|   |   | ||||||
|  - filters: set a current filter that tree node can automatically query to hide themselves |  - filters: set a current filter that tree node can automatically query to hide themselves | ||||||
|  - filters: handle wild-cards (with implicit leading/trailing *), reg-exprs |  - filters: handle wild-cards (with implicit leading/trailing *), reg-exprs | ||||||
|   | |||||||
							
								
								
									
										160
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										160
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -3819,7 +3819,7 @@ void ImGui::Shutdown(ImGuiContext* context) | |||||||
|         fclose(g.LogFile); |         fclose(g.LogFile); | ||||||
|         g.LogFile = NULL; |         g.LogFile = NULL; | ||||||
|     } |     } | ||||||
|     g.LogClipboard.clear(); |     g.LogBuffer.clear(); | ||||||
|  |  | ||||||
|     g.Initialized = false; |     g.Initialized = false; | ||||||
| } | } | ||||||
| @@ -5800,7 +5800,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|         window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext; |         window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext; | ||||||
|         window->DC.NavLayerActiveMaskNext = 0x00; |         window->DC.NavLayerActiveMaskNext = 0x00; | ||||||
|         window->DC.MenuBarAppending = false; |         window->DC.MenuBarAppending = false; | ||||||
|         window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f; |  | ||||||
|         window->DC.ChildWindows.resize(0); |         window->DC.ChildWindows.resize(0); | ||||||
|         window->DC.LayoutType = ImGuiLayoutType_Vertical; |         window->DC.LayoutType = ImGuiLayoutType_Vertical; | ||||||
|         window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical; |         window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical; | ||||||
| @@ -7153,7 +7152,6 @@ void ImGui::BeginGroup() | |||||||
|     group_data.BackupGroupOffset = window->DC.GroupOffset; |     group_data.BackupGroupOffset = window->DC.GroupOffset; | ||||||
|     group_data.BackupCurrentLineSize = window->DC.CurrentLineSize; |     group_data.BackupCurrentLineSize = window->DC.CurrentLineSize; | ||||||
|     group_data.BackupCurrentLineTextBaseOffset = window->DC.CurrentLineTextBaseOffset; |     group_data.BackupCurrentLineTextBaseOffset = window->DC.CurrentLineTextBaseOffset; | ||||||
|     group_data.BackupLogLinePosY = window->DC.LogLinePosY; |  | ||||||
|     group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive; |     group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive; | ||||||
|     group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive; |     group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive; | ||||||
|     group_data.AdvanceCursor = true; |     group_data.AdvanceCursor = true; | ||||||
| @@ -7162,14 +7160,15 @@ void ImGui::BeginGroup() | |||||||
|     window->DC.Indent = window->DC.GroupOffset; |     window->DC.Indent = window->DC.GroupOffset; | ||||||
|     window->DC.CursorMaxPos = window->DC.CursorPos; |     window->DC.CursorMaxPos = window->DC.CursorPos; | ||||||
|     window->DC.CurrentLineSize = ImVec2(0.0f, 0.0f); |     window->DC.CurrentLineSize = ImVec2(0.0f, 0.0f); | ||||||
|     window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f; // To enforce Log carriage return |     if (g.LogEnabled) | ||||||
|  |         g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return | ||||||
| } | } | ||||||
|  |  | ||||||
| void ImGui::EndGroup() | void ImGui::EndGroup() | ||||||
| { | { | ||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
|     ImGuiWindow* window = GetCurrentWindow(); |     ImGuiWindow* window = GetCurrentWindow(); | ||||||
|     IM_ASSERT(!window->DC.GroupStack.empty());    // Mismatched BeginGroup()/EndGroup() calls |     IM_ASSERT(!window->DC.GroupStack.empty());  // Mismatched BeginGroup()/EndGroup() calls | ||||||
|  |  | ||||||
|     ImGuiGroupData& group_data = window->DC.GroupStack.back(); |     ImGuiGroupData& group_data = window->DC.GroupStack.back(); | ||||||
|  |  | ||||||
| @@ -7182,7 +7181,8 @@ void ImGui::EndGroup() | |||||||
|     window->DC.GroupOffset = group_data.BackupGroupOffset; |     window->DC.GroupOffset = group_data.BackupGroupOffset; | ||||||
|     window->DC.CurrentLineSize = group_data.BackupCurrentLineSize; |     window->DC.CurrentLineSize = group_data.BackupCurrentLineSize; | ||||||
|     window->DC.CurrentLineTextBaseOffset = group_data.BackupCurrentLineTextBaseOffset; |     window->DC.CurrentLineTextBaseOffset = group_data.BackupCurrentLineTextBaseOffset; | ||||||
|     window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f; // To enforce Log carriage return |     if (g.LogEnabled) | ||||||
|  |         g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return | ||||||
|  |  | ||||||
|     if (group_data.AdvanceCursor) |     if (group_data.AdvanceCursor) | ||||||
|     { |     { | ||||||
| @@ -8913,9 +8913,12 @@ static void ImGui::NavUpdate() | |||||||
|         NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_); |         NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_); | ||||||
|         NAV_MAP_KEY(ImGuiKey_UpArrow,   ImGuiNavInput_KeyUp_   ); |         NAV_MAP_KEY(ImGuiKey_UpArrow,   ImGuiNavInput_KeyUp_   ); | ||||||
|         NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ ); |         NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ ); | ||||||
|         if (g.IO.KeyCtrl)   g.IO.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f; |         if (g.IO.KeyCtrl) | ||||||
|         if (g.IO.KeyShift)  g.IO.NavInputs[ImGuiNavInput_TweakFast] = 1.0f; |             g.IO.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f; | ||||||
|         if (g.IO.KeyAlt)    g.IO.NavInputs[ImGuiNavInput_KeyMenu_]  = 1.0f; |         if (g.IO.KeyShift) | ||||||
|  |             g.IO.NavInputs[ImGuiNavInput_TweakFast] = 1.0f; | ||||||
|  |         if (g.IO.KeyAlt && !g.IO.KeyCtrl) // AltGR is Alt+Ctrl, also even on keyboards without AltGR we don't want Alt+Ctrl to open menu. | ||||||
|  |             g.IO.NavInputs[ImGuiNavInput_KeyMenu_]  = 1.0f; | ||||||
|         #undef NAV_MAP_KEY |         #undef NAV_MAP_KEY | ||||||
|     } |     } | ||||||
|     memcpy(g.IO.NavInputsDownDurationPrev, g.IO.NavInputsDownDuration, sizeof(g.IO.NavInputsDownDuration)); |     memcpy(g.IO.NavInputsDownDurationPrev, g.IO.NavInputsDownDuration, sizeof(g.IO.NavInputsDownDuration)); | ||||||
| @@ -13210,7 +13213,7 @@ void ImGui::LogText(const char* fmt, ...) | |||||||
|     if (g.LogFile) |     if (g.LogFile) | ||||||
|         vfprintf(g.LogFile, fmt, args); |         vfprintf(g.LogFile, fmt, args); | ||||||
|     else |     else | ||||||
|         g.LogClipboard.appendfv(fmt, args); |         g.LogBuffer.appendfv(fmt, args); | ||||||
|     va_end(args); |     va_end(args); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -13224,17 +13227,20 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* | |||||||
|     if (!text_end) |     if (!text_end) | ||||||
|         text_end = FindRenderedTextEnd(text, text_end); |         text_end = FindRenderedTextEnd(text, text_end); | ||||||
|  |  | ||||||
|     const bool log_new_line = ref_pos && (ref_pos->y > window->DC.LogLinePosY + 1); |     const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + 1); | ||||||
|     if (ref_pos) |     if (ref_pos) | ||||||
|         window->DC.LogLinePosY = ref_pos->y; |         g.LogLinePosY = ref_pos->y; | ||||||
|  |     if (log_new_line) | ||||||
|  |         g.LogLineFirstItem = true; | ||||||
|  |  | ||||||
|     const char* text_remaining = text; |     const char* text_remaining = text; | ||||||
|     if (g.LogStartDepth > window->DC.TreeDepth)  // Re-adjust padding if we have popped out of our starting depth |     if (g.LogDepthRef > window->DC.TreeDepth)  // Re-adjust padding if we have popped out of our starting depth | ||||||
|         g.LogStartDepth = window->DC.TreeDepth; |         g.LogDepthRef = window->DC.TreeDepth; | ||||||
|     const int tree_depth = (window->DC.TreeDepth - g.LogStartDepth); |     const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef); | ||||||
|     for (;;) |     for (;;) | ||||||
|     { |     { | ||||||
|         // Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry. |         // Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry. | ||||||
|  |         // We don't add a trailing \n to allow a subsequent item on the same line to be captured. | ||||||
|         const char* line_start = text_remaining; |         const char* line_start = text_remaining; | ||||||
|         const char* line_end = ImStreolRange(line_start, text_end); |         const char* line_end = ImStreolRange(line_start, text_end); | ||||||
|         const bool is_first_line = (line_start == text); |         const bool is_first_line = (line_start == text); | ||||||
| @@ -13243,9 +13249,18 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* | |||||||
|         { |         { | ||||||
|             const int char_count = (int)(line_end - line_start); |             const int char_count = (int)(line_end - line_start); | ||||||
|             if (log_new_line || !is_first_line) |             if (log_new_line || !is_first_line) | ||||||
|                 LogText(IM_NEWLINE "%*s%.*s", tree_depth*4, "", char_count, line_start); |                 LogText(IM_NEWLINE "%*s%.*s", tree_depth * 4, "", char_count, line_start); | ||||||
|  |             else if (g.LogLineFirstItem) | ||||||
|  |                 LogText("%*s%.*s", tree_depth * 4, "", char_count, line_start); | ||||||
|             else  |             else  | ||||||
|                 LogText(" %.*s", char_count, line_start); |                 LogText(" %.*s", char_count, line_start); | ||||||
|  |             g.LogLineFirstItem = false; | ||||||
|  |         } | ||||||
|  |         else if (log_new_line) | ||||||
|  |         { | ||||||
|  |             // An empty "" string at a different Y position should output a carriage return. | ||||||
|  |             LogText(IM_NEWLINE); | ||||||
|  |             break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (is_last_line) |         if (is_last_line) | ||||||
| @@ -13254,64 +13269,71 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| // Start logging ImGui output to TTY | // Start logging/capturing text output | ||||||
| void ImGui::LogToTTY(int max_depth) | void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth) | ||||||
| { | { | ||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
|     if (g.LogEnabled) |  | ||||||
|         return; |  | ||||||
|     ImGuiWindow* window = g.CurrentWindow; |     ImGuiWindow* window = g.CurrentWindow; | ||||||
|  |     IM_ASSERT(g.LogEnabled == false); | ||||||
|     IM_ASSERT(g.LogFile == NULL); |     IM_ASSERT(g.LogFile == NULL); | ||||||
|     g.LogFile = stdout; |     IM_ASSERT(g.LogBuffer.empty()); | ||||||
|     g.LogEnabled = true; |     g.LogEnabled = true; | ||||||
|     g.LogStartDepth = window->DC.TreeDepth; |     g.LogType = type; | ||||||
|     if (max_depth >= 0) |     g.LogDepthRef = window->DC.TreeDepth; | ||||||
|         g.LogAutoExpandMaxDepth = max_depth; |     g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault); | ||||||
|  |     g.LogLinePosY = FLT_MAX; | ||||||
|  |     g.LogLineFirstItem = true; | ||||||
| } | } | ||||||
|  |  | ||||||
| // Start logging ImGui output to given file | void ImGui::LogToTTY(int auto_open_depth) | ||||||
| void ImGui::LogToFile(int max_depth, const char* filename) |  | ||||||
| { | { | ||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
|     if (g.LogEnabled) |     if (g.LogEnabled) | ||||||
|         return; |         return; | ||||||
|     ImGuiWindow* window = g.CurrentWindow; |     LogBegin(ImGuiLogType_TTY, auto_open_depth); | ||||||
|  |     g.LogFile = stdout; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Start logging/capturing text output to given file | ||||||
|  | void ImGui::LogToFile(int auto_open_depth, const char* filename) | ||||||
|  | { | ||||||
|  |     ImGuiContext& g = *GImGui; | ||||||
|  |     if (g.LogEnabled) | ||||||
|  |         return; | ||||||
|  |  | ||||||
|  |     // FIXME: We could probably open the file in text mode "at", however note that clipboard/buffer logging will still  | ||||||
|  |     // be subject to outputting OS-incompatible carriage return if within strings the user doesn't use IM_NEWLINE. | ||||||
|  |     // By opening the file in binary mode "ab" we have consistent output everywhere. | ||||||
|     if (!filename) |     if (!filename) | ||||||
|     { |  | ||||||
|         filename = g.IO.LogFilename; |         filename = g.IO.LogFilename; | ||||||
|         if (!filename) |     if (!filename || !filename[0]) | ||||||
|             return; |         return; | ||||||
|     } |     FILE* f = ImFileOpen(filename, "ab"); | ||||||
|  |     if (f == NULL) | ||||||
|     IM_ASSERT(g.LogFile == NULL); |  | ||||||
|     g.LogFile = ImFileOpen(filename, "ab"); |  | ||||||
|     if (g.LogFile == NULL) |  | ||||||
|     { |     { | ||||||
|         IM_ASSERT(0); |         IM_ASSERT(0); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     g.LogEnabled = true; |  | ||||||
|     g.LogStartDepth = window->DC.TreeDepth; |     LogBegin(ImGuiLogType_File, auto_open_depth); | ||||||
|     if (max_depth >= 0) |     g.LogFile = f; | ||||||
|         g.LogAutoExpandMaxDepth = max_depth; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| // Start logging ImGui output to clipboard | // Start logging/capturing text output to clipboard | ||||||
| void ImGui::LogToClipboard(int max_depth) | void ImGui::LogToClipboard(int auto_open_depth) | ||||||
| { | { | ||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
|     if (g.LogEnabled) |     if (g.LogEnabled) | ||||||
|         return; |         return; | ||||||
|     ImGuiWindow* window = g.CurrentWindow; |     LogBegin(ImGuiLogType_Clipboard, auto_open_depth); | ||||||
|  | } | ||||||
|  |  | ||||||
|     IM_ASSERT(g.LogFile == NULL); | void ImGui::LogToBuffer(int auto_open_depth) | ||||||
|     g.LogFile = NULL; | { | ||||||
|     g.LogEnabled = true; |     ImGuiContext& g = *GImGui; | ||||||
|     g.LogStartDepth = window->DC.TreeDepth; |     if (g.LogEnabled) | ||||||
|     if (max_depth >= 0) |         return; | ||||||
|         g.LogAutoExpandMaxDepth = max_depth; |     LogBegin(ImGuiLogType_Buffer, auto_open_depth); | ||||||
| } | } | ||||||
|  |  | ||||||
| void ImGui::LogFinish() | void ImGui::LogFinish() | ||||||
| @@ -13321,23 +13343,33 @@ void ImGui::LogFinish() | |||||||
|         return; |         return; | ||||||
|  |  | ||||||
|     LogText(IM_NEWLINE); |     LogText(IM_NEWLINE); | ||||||
|     if (g.LogFile != NULL) |     switch (g.LogType) | ||||||
|     { |     { | ||||||
|         if (g.LogFile == stdout) |     case ImGuiLogType_TTY: | ||||||
|             fflush(g.LogFile); |         fflush(g.LogFile); | ||||||
|         else |         break; | ||||||
|             fclose(g.LogFile); |     case ImGuiLogType_File: | ||||||
|         g.LogFile = NULL; |         fclose(g.LogFile); | ||||||
|     } |         break; | ||||||
|     if (g.LogClipboard.size() > 1) |     case ImGuiLogType_Buffer: | ||||||
|     { |         break; | ||||||
|         SetClipboardText(g.LogClipboard.begin()); |     case ImGuiLogType_Clipboard: | ||||||
|         g.LogClipboard.clear(); |         if (!g.LogBuffer.empty()) | ||||||
|  |             SetClipboardText(g.LogBuffer.begin()); | ||||||
|  |         break; | ||||||
|  |     case ImGuiLogType_None: | ||||||
|  |         IM_ASSERT(0); | ||||||
|  |         break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     g.LogEnabled = false; |     g.LogEnabled = false; | ||||||
|  |     g.LogType = ImGuiLogType_None; | ||||||
|  |     g.LogFile = NULL; | ||||||
|  |     g.LogBuffer.clear(); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Helper to display logging buttons | // Helper to display logging buttons | ||||||
|  | // FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!) | ||||||
| void ImGui::LogButtons() | void ImGui::LogButtons() | ||||||
| { | { | ||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
| @@ -13348,18 +13380,18 @@ void ImGui::LogButtons() | |||||||
|     const bool log_to_clipboard = Button("Log To Clipboard"); SameLine(); |     const bool log_to_clipboard = Button("Log To Clipboard"); SameLine(); | ||||||
|     PushItemWidth(80.0f); |     PushItemWidth(80.0f); | ||||||
|     PushAllowKeyboardFocus(false); |     PushAllowKeyboardFocus(false); | ||||||
|     SliderInt("Depth", &g.LogAutoExpandMaxDepth, 0, 9, NULL); |     SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL); | ||||||
|     PopAllowKeyboardFocus(); |     PopAllowKeyboardFocus(); | ||||||
|     PopItemWidth(); |     PopItemWidth(); | ||||||
|     PopID(); |     PopID(); | ||||||
|  |  | ||||||
|     // Start logging at the end of the function so that the buttons don't appear in the log |     // Start logging at the end of the function so that the buttons don't appear in the log | ||||||
|     if (log_to_tty) |     if (log_to_tty) | ||||||
|         LogToTTY(g.LogAutoExpandMaxDepth); |         LogToTTY(); | ||||||
|     if (log_to_file) |     if (log_to_file) | ||||||
|         LogToFile(g.LogAutoExpandMaxDepth, g.IO.LogFilename); |         LogToFile(); | ||||||
|     if (log_to_clipboard) |     if (log_to_clipboard) | ||||||
|         LogToClipboard(g.LogAutoExpandMaxDepth); |         LogToClipboard(); | ||||||
| } | } | ||||||
|  |  | ||||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								imgui.h
									
									
									
									
									
								
							| @@ -597,9 +597,9 @@ namespace ImGui | |||||||
|  |  | ||||||
|     // Logging/Capture |     // Logging/Capture | ||||||
|     // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging. |     // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging. | ||||||
|     IMGUI_API void          LogToTTY(int max_depth = -1);                                       // start logging to tty (stdout) |     IMGUI_API void          LogToTTY(int auto_open_depth = -1);                                 // start logging to tty (stdout) | ||||||
|     IMGUI_API void          LogToFile(int max_depth = -1, const char* filename = NULL);         // start logging to file |     IMGUI_API void          LogToFile(int auto_open_depth = -1, const char* filename = NULL);   // start logging to file | ||||||
|     IMGUI_API void          LogToClipboard(int max_depth = -1);                                 // start logging to OS clipboard |     IMGUI_API void          LogToClipboard(int auto_open_depth = -1);                           // start logging to OS clipboard | ||||||
|     IMGUI_API void          LogFinish();                                                        // stop logging (close file, etc.) |     IMGUI_API void          LogFinish();                                                        // stop logging (close file, etc.) | ||||||
|     IMGUI_API void          LogButtons();                                                       // helper to display buttons for logging to tty/file/clipboard |     IMGUI_API void          LogButtons();                                                       // helper to display buttons for logging to tty/file/clipboard | ||||||
|     IMGUI_API void          LogText(const char* fmt, ...) IM_FMTARGS(1);                        // pass text data straight to log (without being displayed) |     IMGUI_API void          LogText(const char* fmt, ...) IM_FMTARGS(1);                        // pass text data straight to log (without being displayed) | ||||||
|   | |||||||
| @@ -413,7 +413,7 @@ ImDrawList* ImDrawList::CloneOutput() const | |||||||
|  |  | ||||||
| // Using macros because C++ is a terrible language, we want guaranteed inline, no code in header, and no overhead in Debug builds | // Using macros because C++ is a terrible language, we want guaranteed inline, no code in header, and no overhead in Debug builds | ||||||
| #define GetCurrentClipRect()    (_ClipRectStack.Size ? _ClipRectStack.Data[_ClipRectStack.Size-1]  : _Data->ClipRectFullscreen) | #define GetCurrentClipRect()    (_ClipRectStack.Size ? _ClipRectStack.Data[_ClipRectStack.Size-1]  : _Data->ClipRectFullscreen) | ||||||
| #define GetCurrentTextureId()   (_TextureIdStack.Size ? _TextureIdStack.Data[_TextureIdStack.Size-1] : NULL) | #define GetCurrentTextureId()   (_TextureIdStack.Size ? _TextureIdStack.Data[_TextureIdStack.Size-1] : (ImTextureID)NULL) | ||||||
|  |  | ||||||
| void ImDrawList::AddDrawCmd() | void ImDrawList::AddDrawCmd() | ||||||
| { | { | ||||||
|   | |||||||
| @@ -392,6 +392,15 @@ enum ImGuiLayoutType_ | |||||||
|     ImGuiLayoutType_Vertical = 1 |     ImGuiLayoutType_Vertical = 1 | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | enum ImGuiLogType | ||||||
|  | { | ||||||
|  |     ImGuiLogType_None = 0, | ||||||
|  |     ImGuiLogType_TTY, | ||||||
|  |     ImGuiLogType_File, | ||||||
|  |     ImGuiLogType_Buffer, | ||||||
|  |     ImGuiLogType_Clipboard | ||||||
|  | }; | ||||||
|  |  | ||||||
| // X/Y enums are fixed to 0/1 so they may be used to index ImVec2 | // X/Y enums are fixed to 0/1 so they may be used to index ImVec2 | ||||||
| enum ImGuiAxis | enum ImGuiAxis | ||||||
| { | { | ||||||
| @@ -553,7 +562,6 @@ struct ImGuiGroupData | |||||||
|     ImVec1      BackupGroupOffset; |     ImVec1      BackupGroupOffset; | ||||||
|     ImVec2      BackupCurrentLineSize; |     ImVec2      BackupCurrentLineSize; | ||||||
|     float       BackupCurrentLineTextBaseOffset; |     float       BackupCurrentLineTextBaseOffset; | ||||||
|     float       BackupLogLinePosY; |  | ||||||
|     ImGuiID     BackupActiveIdIsAlive; |     ImGuiID     BackupActiveIdIsAlive; | ||||||
|     bool        BackupActiveIdPreviousFrameIsAlive; |     bool        BackupActiveIdPreviousFrameIsAlive; | ||||||
|     bool        AdvanceCursor; |     bool        AdvanceCursor; | ||||||
| @@ -1067,10 +1075,14 @@ struct ImGuiContext | |||||||
|  |  | ||||||
|     // Logging |     // Logging | ||||||
|     bool                    LogEnabled; |     bool                    LogEnabled; | ||||||
|  |     ImGuiLogType            LogType; | ||||||
|     FILE*                   LogFile;                            // If != NULL log to stdout/ file |     FILE*                   LogFile;                            // If != NULL log to stdout/ file | ||||||
|     ImGuiTextBuffer         LogClipboard;                       // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators. |     ImGuiTextBuffer         LogBuffer;                          // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators. | ||||||
|     int                     LogStartDepth; |     float                   LogLinePosY; | ||||||
|     int                     LogAutoExpandMaxDepth; |     bool                    LogLineFirstItem; | ||||||
|  |     int                     LogDepthRef; | ||||||
|  |     int                     LogDepthToExpand; | ||||||
|  |     int                     LogDepthToExpandDefault;            // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call. | ||||||
|  |  | ||||||
|     // Misc |     // Misc | ||||||
|     float                   FramerateSecPerFrame[120];          // Calculate estimate of framerate for user over the last 2 seconds. |     float                   FramerateSecPerFrame[120];          // Calculate estimate of framerate for user over the last 2 seconds. | ||||||
| @@ -1169,6 +1181,8 @@ struct ImGuiContext | |||||||
|         DragDropAcceptFrameCount = -1; |         DragDropAcceptFrameCount = -1; | ||||||
|         memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal)); |         memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal)); | ||||||
|  |  | ||||||
|  |         CurrentTabBar = NULL; | ||||||
|  |  | ||||||
|         ScalarAsInputTextId = 0; |         ScalarAsInputTextId = 0; | ||||||
|         ColorEditOptions = ImGuiColorEditFlags__OptionsDefault; |         ColorEditOptions = ImGuiColorEditFlags__OptionsDefault; | ||||||
|         DragCurrentAccumDirty = false; |         DragCurrentAccumDirty = false; | ||||||
| @@ -1188,9 +1202,12 @@ struct ImGuiContext | |||||||
|         SettingsDirtyTimer = 0.0f; |         SettingsDirtyTimer = 0.0f; | ||||||
|  |  | ||||||
|         LogEnabled = false; |         LogEnabled = false; | ||||||
|  |         LogType = ImGuiLogType_None; | ||||||
|         LogFile = NULL; |         LogFile = NULL; | ||||||
|         LogStartDepth = 0; |         LogLinePosY = FLT_MAX; | ||||||
|         LogAutoExpandMaxDepth = 2; |         LogLineFirstItem = false; | ||||||
|  |         LogDepthRef = 0; | ||||||
|  |         LogDepthToExpand = LogDepthToExpandDefault = 2; | ||||||
|  |  | ||||||
|         memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); |         memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); | ||||||
|         FramerateSecPerFrameIdx = 0; |         FramerateSecPerFrameIdx = 0; | ||||||
| @@ -1216,7 +1233,6 @@ struct IMGUI_API ImGuiWindowTempData | |||||||
|     float                   CurrentLineTextBaseOffset; |     float                   CurrentLineTextBaseOffset; | ||||||
|     ImVec2                  PrevLineSize; |     ImVec2                  PrevLineSize; | ||||||
|     float                   PrevLineTextBaseOffset; |     float                   PrevLineTextBaseOffset; | ||||||
|     float                   LogLinePosY; |  | ||||||
|     int                     TreeDepth; |     int                     TreeDepth; | ||||||
|     ImU32                   TreeDepthMayJumpToParentOnPop; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31 |     ImU32                   TreeDepthMayJumpToParentOnPop; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31 | ||||||
|     ImGuiID                 LastItemId; |     ImGuiID                 LastItemId; | ||||||
| @@ -1256,7 +1272,6 @@ struct IMGUI_API ImGuiWindowTempData | |||||||
|         CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f); |         CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f); | ||||||
|         CurrentLineSize = PrevLineSize = ImVec2(0.0f, 0.0f); |         CurrentLineSize = PrevLineSize = ImVec2(0.0f, 0.0f); | ||||||
|         CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f; |         CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f; | ||||||
|         LogLinePosY = -1.0f; |  | ||||||
|         TreeDepth = 0; |         TreeDepth = 0; | ||||||
|         TreeDepthMayJumpToParentOnPop = 0x00; |         TreeDepthMayJumpToParentOnPop = 0x00; | ||||||
|         LastItemId = 0; |         LastItemId = 0; | ||||||
| @@ -1575,6 +1590,10 @@ namespace ImGui | |||||||
|     IMGUI_API void          PushItemFlag(ImGuiItemFlags option, bool enabled); |     IMGUI_API void          PushItemFlag(ImGuiItemFlags option, bool enabled); | ||||||
|     IMGUI_API void          PopItemFlag(); |     IMGUI_API void          PopItemFlag(); | ||||||
|  |  | ||||||
|  |     // Logging/Capture | ||||||
|  |     IMGUI_API void          LogBegin(ImGuiLogType type, int auto_open_depth);   // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name. | ||||||
|  |     IMGUI_API void          LogToBuffer(int auto_open_depth = -1);              // Start logging/capturing to internal buffer | ||||||
|  |  | ||||||
|     // Popups, Modals, Tooltips |     // Popups, Modals, Tooltips | ||||||
|     IMGUI_API void          OpenPopupEx(ImGuiID id); |     IMGUI_API void          OpenPopupEx(ImGuiID id); | ||||||
|     IMGUI_API void          ClosePopupToLevel(int remaining, bool apply_focus_to_window_under); |     IMGUI_API void          ClosePopupToLevel(int remaining, bool apply_focus_to_window_under); | ||||||
|   | |||||||
| @@ -3678,7 +3678,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2 | |||||||
|     const int buf_display_max_length = 2 * 1024 * 1024; |     const int buf_display_max_length = 2 * 1024 * 1024; | ||||||
|  |  | ||||||
|     // Select which buffer we are going to display. We set buf to NULL to prevent accidental usage from now on. |     // Select which buffer we are going to display. We set buf to NULL to prevent accidental usage from now on. | ||||||
|     const char* buf_display = (state != NULL && !is_readonly) ? state->TextA.Data : buf; |     const char* buf_display = (g.ActiveId == id && state && !is_readonly) ? state->TextA.Data : buf; | ||||||
|     IM_ASSERT(buf_display); |     IM_ASSERT(buf_display); | ||||||
|     buf = NULL; |     buf = NULL; | ||||||
|  |  | ||||||
| @@ -4829,7 +4829,7 @@ bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) | |||||||
|  |  | ||||||
|     // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior). |     // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior). | ||||||
|     // NB- If we are above max depth we still allow manually opened nodes to be logged. |     // NB- If we are above max depth we still allow manually opened nodes to be logged. | ||||||
|     if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && window->DC.TreeDepth < g.LogAutoExpandMaxDepth) |     if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && (window->DC.TreeDepth - g.LogDepthRef) < g.LogDepthToExpand) | ||||||
|         is_open = true; |         is_open = true; | ||||||
|  |  | ||||||
|     return is_open; |     return is_open; | ||||||
| @@ -4956,7 +4956,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l | |||||||
|             const char log_suffix[] = "##"; |             const char log_suffix[] = "##"; | ||||||
|             LogRenderedText(&text_pos, log_prefix, log_prefix+3); |             LogRenderedText(&text_pos, log_prefix, log_prefix+3); | ||||||
|             RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); |             RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); | ||||||
|             LogRenderedText(&text_pos, log_suffix+1, log_suffix+3); |             LogRenderedText(&text_pos, log_suffix, log_suffix+2); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user