Commit 3b3af165 authored by twanvl's avatar twanvl

blink console panel icon to indicate new errors/warnings/infos

parent bfbbe02b
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <gui/set/console_panel.hpp> #include <gui/set/console_panel.hpp>
#include <gui/set/window.hpp>
#include <gui/control/text_ctrl.hpp> #include <gui/control/text_ctrl.hpp>
#include <gui/util.hpp> #include <gui/util.hpp>
#include <util/window_id.hpp> #include <util/window_id.hpp>
...@@ -268,6 +269,9 @@ END_EVENT_TABLE() ...@@ -268,6 +269,9 @@ END_EVENT_TABLE()
ConsolePanel::ConsolePanel(Window* parent, int id) ConsolePanel::ConsolePanel(Window* parent, int id)
: SetWindowPanel(parent, id) : SetWindowPanel(parent, id)
, is_active_window(false)
, blinker_state(0)
, blinker_timer(this)
{ {
// init controls // init controls
splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
...@@ -301,11 +305,18 @@ void ConsolePanel::initUI(wxToolBar* tb, wxMenuBar* mb) { ...@@ -301,11 +305,18 @@ void ConsolePanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
// Menus // Menus
// focus on entry // focus on entry
entry->SetFocus(); entry->SetFocus();
// stop blinker
is_active_window = true;
stop_blinker();
} }
void ConsolePanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) { void ConsolePanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar // Toolbar
// Menus // Menus
// we are no longer active, allow blinker
is_active_window = false;
} }
void ConsolePanel::onUpdateUI(wxUpdateUIEvent& ev) { void ConsolePanel::onUpdateUI(wxUpdateUIEvent& ev) {
...@@ -334,9 +345,12 @@ void ConsolePanel::get_pending_errors() { ...@@ -334,9 +345,12 @@ void ConsolePanel::get_pending_errors() {
String msg; String msg;
while (get_queued_message(type,msg)) { while (get_queued_message(type,msg)) {
messages->add_message(type,msg); messages->add_message(type,msg);
// If this panel doesn't have the focus, then highlight it somehow
if (!is_active_window) {
new_errors_since_last_view = max(new_errors_since_last_view,type);
start_blinker();
}
} }
// If this panel doesn't have the focus, then highlight it somehow
} }
void ConsolePanel::exec(String const& command) { void ConsolePanel::exec(String const& command) {
...@@ -388,6 +402,7 @@ void ConsolePanel::exec(String const& command) { ...@@ -388,6 +402,7 @@ void ConsolePanel::exec(String const& command) {
BEGIN_EVENT_TABLE(ConsolePanel, wxPanel) BEGIN_EVENT_TABLE(ConsolePanel, wxPanel)
EVT_TEXT_ENTER(wxID_ANY,ConsolePanel::onEnter) EVT_TEXT_ENTER(wxID_ANY,ConsolePanel::onEnter)
EVT_IDLE(ConsolePanel::onIdle) EVT_IDLE(ConsolePanel::onIdle)
EVT_TIMER(wxID_ANY,ConsolePanel::onTimer)
END_EVENT_TABLE () END_EVENT_TABLE ()
// ----------------------------------------------------------------------------- : Clipboard // ----------------------------------------------------------------------------- : Clipboard
...@@ -399,3 +414,38 @@ void ConsolePanel::doCut() { entry->doCut(); } ...@@ -399,3 +414,38 @@ void ConsolePanel::doCut() { entry->doCut(); }
void ConsolePanel::doCopy() { entry->doCopy(); } void ConsolePanel::doCopy() { entry->doCopy(); }
void ConsolePanel::doPaste() { entry->doPaste(); } void ConsolePanel::doPaste() { entry->doPaste(); }
*/ */
// ----------------------------------------------------------------------------- : Annoying blinking icon thing
void ConsolePanel::start_blinker() {
if (new_errors_since_last_view) {
blinker_state = 0;
blinker_timer.Start(BLINK_TIME);
update_blinker();
}
}
void ConsolePanel::stop_blinker() {
blinker_state = 0;
new_errors_since_last_view = static_cast<MessageType>(0);
blinker_timer.Stop();
update_blinker();
}
void ConsolePanel::onTimer(wxTimerEvent&) {
blinker_state++;
if (blinker_state > MAX_BLINKS) {
blinker_timer.Stop();
}
update_blinker();
}
void ConsolePanel::update_blinker() {
SetWindow* parent = static_cast<SetWindow*>(GetParent());
if (blinker_state % 2 == 1 || !new_errors_since_last_view) {
parent->setPanelIcon(this, load_resource_image(_("tool/window_console")));
} else if (new_errors_since_last_view == MESSAGE_INFO) {
parent->setPanelIcon(this, load_resource_image(_("message_information")));
} else if (new_errors_since_last_view == MESSAGE_WARNING) {
parent->setPanelIcon(this, load_resource_image(_("message_warning")));
} else {
parent->setPanelIcon(this, load_resource_image(_("message_error")));
}
}
...@@ -55,6 +55,19 @@ class ConsolePanel : public SetWindowPanel { ...@@ -55,6 +55,19 @@ class ConsolePanel : public SetWindowPanel {
void get_pending_errors(); void get_pending_errors();
void exec(String const& code); void exec(String const& code);
// notification of new messages
bool is_active_window;
MessageType new_errors_since_last_view;
int blinker_state;
wxTimer blinker_timer;
static const int MAX_BLINKS = 5;
static const int BLINK_TIME = 1000;
void stop_blinker();
void start_blinker();
void update_blinker();
void onTimer(wxTimerEvent&);
}; };
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
......
...@@ -250,6 +250,16 @@ void SetWindow::selectPanel(int id) { ...@@ -250,6 +250,16 @@ void SetWindow::selectPanel(int id) {
current_panel->SetFocus(); current_panel->SetFocus();
} }
void SetWindow::setPanelIcon(SetWindowPanel* panel, wxBitmap const& icon) {
for (size_t i = 0 ; i < panels.size() ; ++i) {
if (panels[i] == panel) {
wxToolBar* tabBar = (wxToolBar*)FindWindow(ID_TAB_BAR);
tabBar->SetToolNormalBitmap(ID_WINDOW_MIN+i, icon);
return;
}
}
}
// ----------------------------------------------------------------------------- : Window managment // ----------------------------------------------------------------------------- : Window managment
vector<SetWindow*> SetWindow::set_windows; vector<SetWindow*> SetWindow::set_windows;
......
...@@ -30,6 +30,9 @@ class SetWindow : public wxFrame, public SetView { ...@@ -30,6 +30,9 @@ class SetWindow : public wxFrame, public SetView {
SetWindow(Window* parent, const SetP& set); SetWindow(Window* parent, const SetP& set);
~SetWindow(); ~SetWindow();
/// Set the icon of one of the panels
void setPanelIcon(SetWindowPanel* panel, wxBitmap const& icon);
// --------------------------------------------------- : Set actions // --------------------------------------------------- : Set actions
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment