8#include <imgui_internal.h>
9#include <IconsForkAwesome.h>
21 void PrintColouredText(
const string& text,
const ImVec4& colour)
23 ImGui::PushStyleColor( ImGuiCol_Text, colour );
24 ImGui::TextUnformatted( text.c_str(), text.c_str() + text.length() );
25 ImGui::PopStyleColor();
71 static bool infoFlag =
true;
72 static bool warningFlag =
true;
73 static bool errorFlag =
true;
75 ImGui::PushStyleColor( ImGuiCol_ChildBg, ImVec4( 0.3f, 0.3f, 0.3f, 1.0f ) );
78 ImGui::Text( ICON_FK_SEARCH ); tooltip = tooltip || ImGui::IsItemHovered();
80 ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
81 _filter.Draw(
"##Filter", 180 ); tooltip = tooltip || ImGui::IsItemHovered();
84 ImGui::SetTooltip(
"Search/Filter (\"incl,-excl\") (\"error\")" );
86 ImGui::SameLine(0.f, 30.f);
87 ImGui::Text(
"Max log entries: ");
89 ImGui::SetNextItemWidth( 100 );
91 if (ImGui::InputScalar(
"##MaxLogEntries", ImGuiDataType_U16, &logSize,
nullptr,
nullptr,
nullptr, ImGuiInputTextFlags_EnterReturnsTrue ))
99 if ( ImGui::Checkbox(
"Info", &infoFlag ) )
104 if ( ImGui::Checkbox(
"Warning", &warningFlag ) )
109 if ( ImGui::Checkbox(
"Error", &errorFlag ) )
114 ImGui::PopStyleVar();
115 ImGuiWindow* window = ImGui::GetCurrentWindow();
116 ImGui::SameLine( window->SizeFull.x - 200 );
117 if ( ImGui::SmallButton(
"Clear" ) )
122 const bool copy_to_clipboard = ImGui::SmallButton(
"Copy" );
125 ImGui::BeginChild(
"ScrollingRegion", ImVec2( 0, -ImGui::GetFrameHeightWithSpacing() ),
false, ImGuiWindowFlags_HorizontalScrollbar );
126 if ( ImGui::BeginPopupContextWindow() )
128 if ( ImGui::Selectable(
"Clear" ) )
135 static ImVec4 colours[] = {
136 ImVec4( 1.0f, 1.0f, 1.0f, 1.0f ),
137 ImVec4( 1.0f, 1.0f, 0.0f, 1.0f ),
138 ImVec4( 1.0f, 0.4f, 0.4f, 1.0f ),
139 ImVec4( 0.0f, 0.0f, 1.0f, 1.0f )
142 size_t readIndex = 0u;
154 ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 4, 1 ) );
156 if ( copy_to_clipboard )
158 ImGui::LogToClipboard();
165 static string output=
"";
172 const char* msgBegin = message.
_text.c_str();
173 const char* msgEnd = message.
_text.c_str() + message.
_text.length();
175 if ( !
_filter.PassFilter( msgBegin, msgEnd ) ) [[unlikely]]
179 switch (message.
_type)
210 if ( previousType != message.
_type )
212 if ( !output.empty() )
214 PrintColouredText(output, colours[
to_U8( previousType )]);
217 previousType = message.
_type;
220 output.append( message.
_text );
221 output.append(
"\n" );
224 if ( !output.empty() )
226 PrintColouredText( output, colours[
to_U8( previousType )] );
237 if ( copy_to_clipboard )
242 ImGui::PopStyleVar();
246 ImGui::Text(
"Input:" ); ImGui::SameLine();
247 if ( ImGui::InputText(
"##Input:",
250 ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory,
251 []( ImGuiInputTextCallbackData* data )
noexcept
259 while ( input_end >
_inputBuf && input_end[-1] ==
' ' )
272 bool tooltip =
false;
273 ImGui::SameLine( window->SizeFull.x - 125 );
274 ImGui::Text( ICON_FK_ARROW_CIRCLE_DOWN ); tooltip = tooltip || ImGui::IsItemHovered();
276 ImGui::PushID( ICON_FK_ARROW_CIRCLE_DOWN
"_ID" );
277 ImGui::Checkbox(
"", &
_scrollToBottom ); tooltip = tooltip || ImGui::IsItemHovered();
281 ImGui::SetTooltip(
"Auto-scroll to bottom" );
285 if ( ImGui::IsItemHovered() ||
286 (ImGui::IsWindowFocused( ImGuiFocusedFlags_RootAndChildWindows ) && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked( 0 )) )
288 ImGui::SetKeyboardFocusHere( -1 );
290 ImGui::PopStyleColor();
311 switch ( data->EventFlag )
313 case ImGuiInputTextFlags_CallbackCompletion:
314 case ImGuiInputTextFlags_CallbackHistory:
#define PROFILE_SCOPE_AUTO(CATEGORY)
#define PROFILE_SCOPE(NAME, CATEGORY)
OutputWindow(Editor &parent, const Descriptor &descriptor)
void executeCommand(const char *command_line)
bool _scrollToButtomReset
static void PrintText(const Console::OutputEntry &entry)
static I32 TextEditCallback(const ImGuiInputTextCallbackData *data) noexcept
void drawInternal() override
size_t _consoleCallbackIndex
#define IM_ARRAYSIZE(_ARR)
constexpr Optick::Category::Type GUI
Str StringFormat(const char *fmt, Args &&...args)
Handle console commands that start with a forward slash.
eastl::vector< Type > vector
constexpr U8 to_U8(const T value)
constexpr U16 g_maxLogEntries
static std::atomic_size_t g_writeIndex
Project const SceneEntry & entry
static vector< Console::OutputEntry > g_log
void SetScrollHereY(float center_y_ratio)
static bool UnbindConsoleOutput(size_t &index)
static size_t BindConsoleOutput(const ConsolePrintCallback &guiConsoleCallback)