mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 23:31:08 +01:00
Log/Capture: renaming ImGuiLogType to ImGuiLogFlags
This commit is contained in:
parent
9a0dff1bc5
commit
a4fcc93f4a
33
imgui.cpp
33
imgui.cpp
@ -4007,7 +4007,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
|||||||
memset(LocalizationTable, 0, sizeof(LocalizationTable));
|
memset(LocalizationTable, 0, sizeof(LocalizationTable));
|
||||||
|
|
||||||
LogEnabled = false;
|
LogEnabled = false;
|
||||||
LogType = ImGuiLogType_None;
|
LogFlags = ImGuiLogFlags_None;
|
||||||
LogNextPrefix = LogNextSuffix = NULL;
|
LogNextPrefix = LogNextSuffix = NULL;
|
||||||
LogFile = NULL;
|
LogFile = NULL;
|
||||||
LogLinePosY = FLT_MAX;
|
LogLinePosY = FLT_MAX;
|
||||||
@ -14324,15 +14324,16 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start logging/capturing text output
|
// Start logging/capturing text output
|
||||||
void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth)
|
void ImGui::LogBegin(ImGuiLogFlags flags, int auto_open_depth)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
IM_ASSERT(g.LogEnabled == false);
|
IM_ASSERT(g.LogEnabled == false);
|
||||||
IM_ASSERT(g.LogFile == NULL);
|
IM_ASSERT(g.LogFile == NULL && g.LogBuffer.empty());
|
||||||
IM_ASSERT(g.LogBuffer.empty());
|
IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiLogFlags_OutputMask_)); // Check that only 1 type flag is used
|
||||||
|
|
||||||
g.LogEnabled = g.ItemUnclipByLog = true;
|
g.LogEnabled = g.ItemUnclipByLog = true;
|
||||||
g.LogType = type;
|
g.LogFlags = flags;
|
||||||
g.LogNextPrefix = g.LogNextSuffix = NULL;
|
g.LogNextPrefix = g.LogNextSuffix = NULL;
|
||||||
g.LogDepthRef = window->DC.TreeDepth;
|
g.LogDepthRef = window->DC.TreeDepth;
|
||||||
g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
|
g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
|
||||||
@ -14355,7 +14356,7 @@ void ImGui::LogToTTY(int auto_open_depth)
|
|||||||
return;
|
return;
|
||||||
IM_UNUSED(auto_open_depth);
|
IM_UNUSED(auto_open_depth);
|
||||||
#ifndef IMGUI_DISABLE_TTY_FUNCTIONS
|
#ifndef IMGUI_DISABLE_TTY_FUNCTIONS
|
||||||
LogBegin(ImGuiLogType_TTY, auto_open_depth);
|
LogBegin(ImGuiLogFlags_OutputTTY, auto_open_depth);
|
||||||
g.LogFile = stdout;
|
g.LogFile = stdout;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -14381,7 +14382,7 @@ void ImGui::LogToFile(int auto_open_depth, const char* filename)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogBegin(ImGuiLogType_File, auto_open_depth);
|
LogBegin(ImGuiLogFlags_OutputFile, auto_open_depth);
|
||||||
g.LogFile = f;
|
g.LogFile = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14391,7 +14392,7 @@ void ImGui::LogToClipboard(int auto_open_depth)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
return;
|
return;
|
||||||
LogBegin(ImGuiLogType_Clipboard, auto_open_depth);
|
LogBegin(ImGuiLogFlags_OutputClipboard, auto_open_depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::LogToBuffer(int auto_open_depth)
|
void ImGui::LogToBuffer(int auto_open_depth)
|
||||||
@ -14399,7 +14400,7 @@ void ImGui::LogToBuffer(int auto_open_depth)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
return;
|
return;
|
||||||
LogBegin(ImGuiLogType_Buffer, auto_open_depth);
|
LogBegin(ImGuiLogFlags_OutputBuffer, auto_open_depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::LogFinish()
|
void ImGui::LogFinish()
|
||||||
@ -14409,29 +14410,29 @@ void ImGui::LogFinish()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
LogText(IM_NEWLINE);
|
LogText(IM_NEWLINE);
|
||||||
switch (g.LogType)
|
switch (g.LogFlags & ImGuiLogFlags_OutputMask_)
|
||||||
{
|
{
|
||||||
case ImGuiLogType_TTY:
|
case ImGuiLogFlags_OutputTTY:
|
||||||
#ifndef IMGUI_DISABLE_TTY_FUNCTIONS
|
#ifndef IMGUI_DISABLE_TTY_FUNCTIONS
|
||||||
fflush(g.LogFile);
|
fflush(g.LogFile);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case ImGuiLogType_File:
|
case ImGuiLogFlags_OutputFile:
|
||||||
ImFileClose(g.LogFile);
|
ImFileClose(g.LogFile);
|
||||||
break;
|
break;
|
||||||
case ImGuiLogType_Buffer:
|
case ImGuiLogFlags_OutputBuffer:
|
||||||
break;
|
break;
|
||||||
case ImGuiLogType_Clipboard:
|
case ImGuiLogFlags_OutputClipboard:
|
||||||
if (!g.LogBuffer.empty())
|
if (!g.LogBuffer.empty())
|
||||||
SetClipboardText(g.LogBuffer.begin());
|
SetClipboardText(g.LogBuffer.begin());
|
||||||
break;
|
break;
|
||||||
case ImGuiLogType_None:
|
default:
|
||||||
IM_ASSERT(0);
|
IM_ASSERT(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g.LogEnabled = g.ItemUnclipByLog = false;
|
g.LogEnabled = g.ItemUnclipByLog = false;
|
||||||
g.LogType = ImGuiLogType_None;
|
g.LogFlags = ImGuiLogFlags_None;
|
||||||
g.LogFile = NULL;
|
g.LogFile = NULL;
|
||||||
g.LogBuffer.clear();
|
g.LogBuffer.clear();
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,7 @@ typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // F
|
|||||||
typedef int ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow()
|
typedef int ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow()
|
||||||
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for g.LastItemData.StatusFlags
|
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for g.LastItemData.StatusFlags
|
||||||
typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns()
|
typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns()
|
||||||
|
typedef int ImGuiLogFlags; // -> enum ImGuiLogFlags_ // Flags: for LogBegin() text capturing function
|
||||||
typedef int ImGuiNavRenderCursorFlags; // -> enum ImGuiNavRenderCursorFlags_//Flags: for RenderNavCursor()
|
typedef int ImGuiNavRenderCursorFlags; // -> enum ImGuiNavRenderCursorFlags_//Flags: for RenderNavCursor()
|
||||||
typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests
|
typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests
|
||||||
typedef int ImGuiNextItemDataFlags; // -> enum ImGuiNextItemDataFlags_ // Flags: for SetNextItemXXX() functions
|
typedef int ImGuiNextItemDataFlags; // -> enum ImGuiNextItemDataFlags_ // Flags: for SetNextItemXXX() functions
|
||||||
@ -989,13 +990,16 @@ enum ImGuiLayoutType_
|
|||||||
ImGuiLayoutType_Vertical = 1
|
ImGuiLayoutType_Vertical = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiLogType
|
// Flags for LogBegin() text capturing function
|
||||||
|
enum ImGuiLogFlags_
|
||||||
{
|
{
|
||||||
ImGuiLogType_None = 0,
|
ImGuiLogFlags_None = 0,
|
||||||
ImGuiLogType_TTY,
|
|
||||||
ImGuiLogType_File,
|
ImGuiLogFlags_OutputTTY = 1 << 0,
|
||||||
ImGuiLogType_Buffer,
|
ImGuiLogFlags_OutputFile = 1 << 1,
|
||||||
ImGuiLogType_Clipboard,
|
ImGuiLogFlags_OutputBuffer = 1 << 2,
|
||||||
|
ImGuiLogFlags_OutputClipboard = 1 << 3,
|
||||||
|
ImGuiLogFlags_OutputMask_ = ImGuiLogFlags_OutputTTY | ImGuiLogFlags_OutputFile | ImGuiLogFlags_OutputBuffer | ImGuiLogFlags_OutputClipboard,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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
|
||||||
@ -2316,7 +2320,7 @@ struct ImGuiContext
|
|||||||
|
|
||||||
// Capture/Logging
|
// Capture/Logging
|
||||||
bool LogEnabled; // Currently capturing
|
bool LogEnabled; // Currently capturing
|
||||||
ImGuiLogType LogType; // Capture target
|
ImGuiLogFlags LogFlags; // Capture flags/type
|
||||||
ImFileHandle LogFile; // If != NULL log to stdout/ file
|
ImFileHandle 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.
|
||||||
const char* LogNextPrefix;
|
const char* LogNextPrefix;
|
||||||
@ -3067,7 +3071,7 @@ namespace ImGui
|
|||||||
IMGUI_API void EndDisabledOverrideReenable();
|
IMGUI_API void EndDisabledOverrideReenable();
|
||||||
|
|
||||||
// Logging/Capture
|
// 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 LogBegin(ImGuiLogFlags flags, 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
|
IMGUI_API void LogToBuffer(int auto_open_depth = -1); // Start logging/capturing to internal buffer
|
||||||
IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
|
IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
|
||||||
IMGUI_API void LogSetNextTextDecoration(const char* prefix, const char* suffix);
|
IMGUI_API void LogSetNextTextDecoration(const char* prefix, const char* suffix);
|
||||||
|
Loading…
Reference in New Issue
Block a user