imgui-platform-kit 2.0.0
Cross-platform Dear ImGui application framework
Loading...
Searching...
No Matches
log_window.h
Go to the documentation of this file.
1
2#pragma once
3
9#include <vector>
10#include <string>
11#include <cstdarg>
12#include "imgui.h"
13#include "colour_palette.h"
15
16namespace imgui_kit
17{
19 struct LogEntry
20 {
21 std::string message;
22 ImVec4 color;
23 };
24
35 class LogWindow final : public UserInterfaceWindow
36 {
37 private:
38 inline static std::vector<LogEntry> logs;
39 inline static ImGuiTextFilter filter;
40 inline static bool autoScroll = true;
41 inline static bool isWindowActive = false;
42
43 public:
51 static void addLog(const ImVec4& color, const char* fmt, ...) IM_FMTARGS(2);
53 void render() override { draw(); }
55 static bool isActive() { return isWindowActive; }
57 static size_t getLogCount() { return logs.size(); }
59 static void clearLogs() { logs.clear(); }
67 static void renderContent();
68 ~LogWindow() override = default;
69 private:
70 static void clean() { logs.clear(); }
71 static void draw();
72 };
73}
Built-in window that displays colour-coded log messages.
Definition log_window.h:36
static size_t getLogCount()
Returns the number of stored log entries.
Definition log_window.h:57
static void renderContent()
Renders the log contents (toolbar, filter and entries) into the current ImGui window.
void render() override
Renders the log window. Called once per frame by the UserInterface.
Definition log_window.h:53
~LogWindow() override=default
static void addLog(const ImVec4 &color, const char *fmt,...)
Appends a printf-style formatted message to the log.
static void clearLogs()
Removes all stored log entries.
Definition log_window.h:59
static bool isActive()
Returns true while the log window is open and being rendered.
Definition log_window.h:55
Abstract base class for all windows rendered by the kit.
Definition user_interface_window.h:83
Named colour constants for use with ImGui (e.g.
Definition colour_palette.h:11
A single log line: message text and its display colour.
Definition log_window.h:20
ImVec4 color
Colour used to render the line (see imgui_kit::colours).
Definition log_window.h:22
std::string message
Text of the log line.
Definition log_window.h:21
Abstract base class for user-defined windows and global window flags.