Basic auto-scroll of job view (#129).
authorCarl Hetherington <cth@carlh.net>
Tue, 7 May 2013 22:22:56 +0000 (23:22 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 7 May 2013 22:22:56 +0000 (23:22 +0100)
src/wx/job_manager_view.cc
src/wx/job_manager_view.h

index a7788ddd01334cd0a8d2dba94afb3f3b8e489321..c339d26bbf2a0b60da3167004e37bf41901c001e 100644 (file)
@@ -79,6 +79,7 @@ JobManagerView::update ()
                        
                        JobRecord r;
                        r.finalised = false;
+                       r.scroll_nudged = false;
                        r.gauge = new wxGauge (_panel, wxID_ANY, 100);
                        _table->Insert (index + 1, r.gauge, 1, wxEXPAND | wxLEFT | wxRIGHT);
                        
@@ -95,6 +96,7 @@ JobManagerView::update ()
                        _table->Insert (index + 4, r.details, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6);
                        
                        _job_records[*i] = r;
+
                }
 
                string const st = (*i)->status ();
@@ -108,8 +110,25 @@ JobManagerView::update ()
                                checked_set (_job_records[*i].message, wx_to_std (_("Running")));
                                _job_records[*i].gauge->Pulse ();
                        }
+
                }
 
+               if (!_job_records[*i].scroll_nudged && ((*i)->running () || (*i)->finished())) {
+                       int x, y;
+                       _job_records[*i].gauge->GetPosition (&x, &y);
+                       int px, py;
+                       GetScrollPixelsPerUnit (&px, &py);
+                       int vx, vy;
+                       GetViewStart (&vx, &vy);
+                       int sx, sy;
+                       GetClientSize (&sx, &sy);
+
+                       if (y > (vy * py + sy / 2)) {
+                               Scroll (-1, y / py);
+                               _job_records[*i].scroll_nudged = true;
+                       }
+               }
+                       
                if ((*i)->finished() && !_job_records[*i].finalised) {
                        checked_set (_job_records[*i].message, st);
                        if (!(*i)->finished_cancelled()) {
index 72ac85c02640423ee4c2f23b1756c8680adf645b..6343d78af070471b898ffa4feb37e56b67ebd3bc 100644 (file)
@@ -51,6 +51,7 @@ private:
                wxButton* cancel;
                wxButton* details;
                bool finalised;
+               bool scroll_nudged;
        };
                
        std::map<boost::shared_ptr<Job>, JobRecord> _job_records;