Make logs button red when there are unread log entries
This commit is contained in:
parent
df3ee3366f
commit
21badd1db4
|
@ -27,7 +27,7 @@ static inline void settings_window(Config& config, float* config_write_timer, bo
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void logs_window(bool* show_logs_window) {
|
static inline void logs_window(bool* latest_log_entries_read, bool* show_logs_window) {
|
||||||
if (!ImGui::Begin("LogMeow Logs", show_logs_window)) {
|
if (!ImGui::Begin("LogMeow Logs", show_logs_window)) {
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
|
@ -46,6 +46,7 @@ static inline void logs_window(bool* show_logs_window) {
|
||||||
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar)) {
|
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar)) {
|
||||||
ImGui::TextUnformatted(log_entries.data(), &log_entries[log_entries.size()]);
|
ImGui::TextUnformatted(log_entries.data(), &log_entries[log_entries.size()]);
|
||||||
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
|
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
|
||||||
|
*latest_log_entries_read = true;
|
||||||
ImGui::SetScrollHereY(1.0f);
|
ImGui::SetScrollHereY(1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,18 +54,29 @@ static inline void logs_window(bool* show_logs_window) {
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void main_window(bool* show_settings_window, bool* show_logs_window, bool* run_event_loop) {
|
static inline void main_window(bool latest_log_entries_read, bool* show_settings_window, bool* show_logs_window, bool* run_event_loop) {
|
||||||
if (!ImGui::Begin("LogMeow", run_event_loop)) {
|
if (!ImGui::Begin("LogMeow", run_event_loop)) {
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Button("Settings")) {
|
if (ImGui::Button("Settings")) {
|
||||||
*show_settings_window = true;
|
*show_settings_window = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
if (!latest_log_entries_read) {
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(0.0f, 0.6f, 0.6f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(0.0f, 0.7f, 0.7f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(0.0f, 0.8f, 0.8f));
|
||||||
|
}
|
||||||
if (ImGui::Button("Logs")) {
|
if (ImGui::Button("Logs")) {
|
||||||
*show_logs_window = true;
|
*show_logs_window = true;
|
||||||
}
|
}
|
||||||
|
if (!latest_log_entries_read) {
|
||||||
|
ImGui::PopStyleColor(3);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +122,7 @@ static inline void debug_window() {
|
||||||
void event_loop(Config& config, float* config_write_timer, bool* run_event_loop) {
|
void event_loop(Config& config, float* config_write_timer, bool* run_event_loop) {
|
||||||
static bool show_settings_window = false;
|
static bool show_settings_window = false;
|
||||||
static bool show_logs_window = false;
|
static bool show_logs_window = false;
|
||||||
|
static size_t log_entries_read = 0;
|
||||||
|
|
||||||
debug_window();
|
debug_window();
|
||||||
|
|
||||||
|
@ -124,8 +137,13 @@ void event_loop(Config& config, float* config_write_timer, bool* run_event_loop)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_logs_window) {
|
if (show_logs_window) {
|
||||||
logs_window(&show_logs_window);
|
bool latest_log_entries_read = false;
|
||||||
|
logs_window(&latest_log_entries_read, &show_logs_window);
|
||||||
|
if (latest_log_entries_read) {
|
||||||
|
log_entries_read = log_entries.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_window(&show_settings_window, &show_logs_window, run_event_loop);
|
// log_entries must not be mutated until the show logs button
|
||||||
|
main_window(log_entries_read == log_entries.size(), &show_settings_window, &show_logs_window, run_event_loop);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue