SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
LogWindow.h
Go to the documentation of this file.
1 #ifndef LOGWINDOW_H
2 #define LOGWINDOW_H
3 
4 #include <Utils.h>
5 #include <CustomLog.h>
6 #include <imgui.h>
7 
8 class LogWindow : public Utils::CustomLog
9 {
10 public:
11  LogWindow(int screenWidth, int screenHeight, ImFont* fontHeading, ImFont* fontText);
12 
13  void post(const std::string& message) override;
14 
15  void clear();
16  void draw(const char* title, bool* p_open = NULL);
17 
18 private:
19  void addLog(const char* fmt, ...) IM_FMTARGS(2);
20 
21  ImGuiTextBuffer _buf;
22  ImGuiTextFilter _filter;
23  ImVector<int> _lineOffsets; // Index to lines offset. We maintain this with AddLog() calls, allowing us to have a random access on lines
24  bool _autoScroll = true; // Keep scrolling if already at the bottom
25 
26  int _screenW = 0;
27  int _screenH = 0;
28 
29  ImFont* _fontText = nullptr;
30  ImFont* _fontHeading = nullptr;
31 };
32 
33 #endif
ImVector< int > _lineOffsets
Definition: LogWindow.h:23
void clear()
Definition: LogWindow.cpp:14
ImFont * _fontHeading
Definition: LogWindow.h:30
ImGuiTextBuffer _buf
Definition: LogWindow.h:21
ImFont * _fontText
Definition: LogWindow.h:29
void addLog(const char *fmt,...) IM_FMTARGS(2)
Definition: LogWindow.cpp:126
LogWindow(int screenWidth, int screenHeight, ImFont *fontHeading, ImFont *fontText)
Definition: LogWindow.cpp:4
int _screenH
Definition: LogWindow.h:27
int _screenW
Definition: LogWindow.h:26
void draw(const char *title, bool *p_open=NULL)
Definition: LogWindow.cpp:26
void post(const std::string &message) override
Definition: LogWindow.cpp:21
bool _autoScroll
Definition: LogWindow.h:24
ImGuiTextFilter _filter
Definition: LogWindow.h:22
Logger interface.
Definition: CustomLog.h:21