From 68b2c7e0e7ef06d37cd3f47dafe0b66f25a59f95 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 23 Mar 2018 20:19:41 -0400 Subject: [PATCH] Show status errors in red --- src/gui/Window.cc | 19 +++++++++++++++---- src/gui/Window.h | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/gui/Window.cc b/src/gui/Window.cc index 03e851e..43cae4a 100644 --- a/src/gui/Window.cc +++ b/src/gui/Window.cc @@ -495,7 +495,17 @@ void Window::draw_status_message() { int x = 0; uint64_t current_time = Jtk_UsTime(); - float alpha; + float alpha, g, b; + if (m_status_error) + { + g = 0.0; + b = 0.0; + } + else + { + g = 1.0; + b = 1.0; + } if (((current_time - m_status_message_basetime) / 1000) < (STATUS_TIME / 2)) { alpha = 1.0; @@ -510,7 +520,7 @@ void Window::draw_status_message() } for (size_t i = 0u, length = m_status_message.size(); i < length; i++) { - m_gl->draw_character(x, 0, m_status_message[i], *m_font, 1.0, 1.0, 1.0, alpha); + m_gl->draw_character(x, 0, m_status_message[i], *m_font, 1.0, g, b, alpha); x += m_font->get_advance(); } } @@ -567,9 +577,10 @@ static bool is_number(const EncodedString & s) return true; } -void Window::set_status(const std::string & status) +void Window::set_status(const std::string & status, bool error) { clear_status(); + m_status_error = error; m_status_message = status; m_status_message_basetime = Jtk_UsTime(); m_status_message_timer = Jtk_AddTimer(STATUS_TIME / 2, 50u, nullptr, nullptr); @@ -644,7 +655,7 @@ void Window::command_write_file(const CommandParser & cp) } else { - set_status("Error writing file"); + set_status("Error writing file", true); } } m_redraw_requested = true; diff --git a/src/gui/Window.h b/src/gui/Window.h index f739564..25a3399 100644 --- a/src/gui/Window.h +++ b/src/gui/Window.h @@ -58,7 +58,7 @@ protected: void command_write_file(const CommandParser & cp); void command_quit(const CommandParser & cp); - void set_status(const std::string & status); + void set_status(const std::string & status, bool error = false); void clear_status(); void * m_window; @@ -81,6 +81,7 @@ protected: std::string m_status_message; size_t m_status_message_timer; uint64_t m_status_message_basetime; + bool m_status_error; bool m_command_invalid; };