Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute tree depth instead of a relative one. Fixed CollapsingHeader trailing ascii representation being "#" instead of "##". Minor tidying up the of code.

docking
omar 6 years ago
parent 2cd7de5666
commit cd67d4d3c1

@ -44,6 +44,9 @@ 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 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)

@ -217,10 +217,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

@ -8805,9 +8805,9 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char*
window->DC.LogLinePosY = ref_pos->y; window->DC.LogLinePosY = ref_pos->y;
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.
@ -8831,7 +8831,7 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char*
} }
// Start logging/capturing text output to TTY // Start logging/capturing text output to TTY
void ImGui::LogToTTY(int max_depth) void ImGui::LogToTTY(int auto_open_depth)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.LogEnabled) if (g.LogEnabled)
@ -8842,13 +8842,12 @@ void ImGui::LogToTTY(int max_depth)
g.LogFile = stdout; g.LogFile = stdout;
g.LogEnabled = true; g.LogEnabled = true;
g.LogType = ImGuiLogType_TTY; g.LogType = ImGuiLogType_TTY;
g.LogStartDepth = window->DC.TreeDepth; g.LogDepthRef = window->DC.TreeDepth;
if (max_depth >= 0) g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
g.LogAutoExpandMaxDepth = max_depth;
} }
// Start logging/capturing text output to given file // Start logging/capturing text output to given file
void ImGui::LogToFile(int max_depth, const char* filename) void ImGui::LogToFile(int auto_open_depth, const char* filename)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.LogEnabled) if (g.LogEnabled)
@ -8869,13 +8868,12 @@ void ImGui::LogToFile(int max_depth, const char* filename)
} }
g.LogEnabled = true; g.LogEnabled = true;
g.LogType = ImGuiLogType_File; g.LogType = ImGuiLogType_File;
g.LogStartDepth = window->DC.TreeDepth; g.LogDepthRef = window->DC.TreeDepth;
if (max_depth >= 0) g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
g.LogAutoExpandMaxDepth = max_depth;
} }
// Start logging/capturing text 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)
@ -8887,12 +8885,11 @@ void ImGui::LogToClipboard(int max_depth)
g.LogEnabled = true; g.LogEnabled = true;
g.LogType = ImGuiLogType_Clipboard; g.LogType = ImGuiLogType_Clipboard;
g.LogFile = NULL; g.LogFile = NULL;
g.LogStartDepth = window->DC.TreeDepth; g.LogDepthRef = window->DC.TreeDepth;
if (max_depth >= 0) g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
g.LogAutoExpandMaxDepth = max_depth;
} }
void ImGui::LogToBuffer(int max_depth) void ImGui::LogToBuffer(int auto_open_depth)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.LogEnabled) if (g.LogEnabled)
@ -8904,9 +8901,8 @@ void ImGui::LogToBuffer(int max_depth)
g.LogEnabled = true; g.LogEnabled = true;
g.LogType = ImGuiLogType_Clipboard; g.LogType = ImGuiLogType_Clipboard;
g.LogFile = NULL; g.LogFile = NULL;
g.LogStartDepth = window->DC.TreeDepth; g.LogDepthRef = window->DC.TreeDepth;
if (max_depth >= 0) g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
g.LogAutoExpandMaxDepth = max_depth;
} }
void ImGui::LogFinish() void ImGui::LogFinish()
@ -8950,18 +8946,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();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

@ -572,9 +572,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)

@ -940,8 +940,9 @@ struct ImGuiContext
ImGuiLogType LogType; ImGuiLogType LogType;
FILE* LogFile; // If != NULL log to stdout/ file FILE* LogFile; // If != NULL log to stdout/ file
ImGuiTextBuffer LogBuffer; // 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; int LogDepthRef;
int LogAutoExpandMaxDepth; 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.
@ -1053,8 +1054,8 @@ struct ImGuiContext
LogEnabled = false; LogEnabled = false;
LogType = ImGuiLogType_None; LogType = ImGuiLogType_None;
LogFile = NULL; LogFile = NULL;
LogStartDepth = 0; LogDepthRef = 0;
LogAutoExpandMaxDepth = 2; LogDepthToExpand = LogDepthToExpandDefault = 2;
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
FramerateSecPerFrameIdx = 0; FramerateSecPerFrameIdx = 0;
@ -1408,7 +1409,7 @@ namespace ImGui
IMGUI_API void PopItemFlag(); IMGUI_API void PopItemFlag();
// Logging/Capture // Logging/Capture
IMGUI_API void LogToBuffer(int max_depth = -1); // Start logging to internal buffer IMGUI_API void LogToBuffer(int auto_open_depth = -1); // Start logging to internal buffer
// Popups, Modals, Tooltips // Popups, Modals, Tooltips
IMGUI_API void OpenPopupEx(ImGuiID id); IMGUI_API void OpenPopupEx(ImGuiID id);

@ -4795,7 +4795,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;
@ -4922,7 +4922,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
{ {

Loading…
Cancel
Save