Added timer to progress dialog so it updates even when no idle events would normally be fired. Also (unsuccessfully) attempted to reduce the flicker.
Originally committed to SVN as r734.
This commit is contained in:
parent
b3ac7e40cb
commit
4e463a098a
2 changed files with 17 additions and 0 deletions
|
@ -312,6 +312,7 @@ namespace Automation4 {
|
|||
, has_inited(false)
|
||||
, script_finished(false)
|
||||
, debug_visible(false)
|
||||
, data_updated(false)
|
||||
{
|
||||
// make the controls
|
||||
progress_display = new wxGauge(this, -1, 1000, wxDefaultPosition, wxSize(300, 20));
|
||||
|
@ -336,6 +337,12 @@ namespace Automation4 {
|
|||
title_font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
title_display->SetFont(title_font);
|
||||
|
||||
// Set up a timer to regularly update the status
|
||||
// It doesn't need an event handler attached, as just a the timer in itself
|
||||
// will ensure that the idle event is fired
|
||||
update_timer = new wxTimer();
|
||||
update_timer->Start(50, false);
|
||||
|
||||
sizer->SetSizeHints(this);
|
||||
SetSizer(sizer);
|
||||
Center();
|
||||
|
@ -343,6 +350,7 @@ namespace Automation4 {
|
|||
|
||||
ProgressSink::~ProgressSink()
|
||||
{
|
||||
delete update_timer;
|
||||
}
|
||||
|
||||
void ProgressSink::OnIdle(wxIdleEvent &evt)
|
||||
|
@ -368,6 +376,7 @@ namespace Automation4 {
|
|||
// there might actually be some debug output but the debug_visible flag won't
|
||||
// be set before the dialog closes itself.
|
||||
wxMutexLocker lock(data_mutex);
|
||||
if (!data_updated) return;
|
||||
if (!pending_debug_output.IsEmpty()) {
|
||||
if (!debug_visible) {
|
||||
sizer->Show(debug_output, true);
|
||||
|
@ -386,30 +395,35 @@ namespace Automation4 {
|
|||
progress_display->SetValue((int)(progress*10));
|
||||
task_display->SetLabel(task);
|
||||
title_display->SetLabel(title);
|
||||
data_updated = false;
|
||||
}
|
||||
|
||||
void ProgressSink::SetProgress(float _progress)
|
||||
{
|
||||
wxMutexLocker lock(data_mutex);
|
||||
progress = _progress;
|
||||
data_updated = true;
|
||||
}
|
||||
|
||||
void ProgressSink::SetTask(const wxString &_task)
|
||||
{
|
||||
wxMutexLocker lock(data_mutex);
|
||||
task = _task;
|
||||
data_updated = true;
|
||||
}
|
||||
|
||||
void ProgressSink::SetTitle(const wxString &_title)
|
||||
{
|
||||
wxMutexLocker lock(data_mutex);
|
||||
title = _title;
|
||||
data_updated = true;
|
||||
}
|
||||
|
||||
void ProgressSink::AddDebugOutput(const wxString &msg)
|
||||
{
|
||||
wxMutexLocker lock(data_mutex);
|
||||
pending_debug_output << msg;
|
||||
data_updated = true;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(ProgressSink, wxWindow)
|
||||
|
|
|
@ -216,6 +216,7 @@ namespace Automation4 {
|
|||
wxTextCtrl *debug_output;
|
||||
|
||||
bool debug_visible;
|
||||
bool data_updated;
|
||||
|
||||
float progress;
|
||||
wxString task;
|
||||
|
@ -223,6 +224,8 @@ namespace Automation4 {
|
|||
wxString pending_debug_output;
|
||||
wxMutex data_mutex;
|
||||
|
||||
wxTimer *update_timer;
|
||||
|
||||
void OnCancel(wxCommandEvent &evt);
|
||||
void OnInit(wxInitDialogEvent &evt);
|
||||
void OnIdle(wxIdleEvent &evt);
|
||||
|
|
Loading…
Reference in a new issue