Various fixes.
authorCarl Hetherington <cth@carlh.net>
Wed, 25 Jul 2012 19:24:20 +0000 (20:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 25 Jul 2012 19:24:20 +0000 (20:24 +0100)
src/wx/film_viewer.cc
src/wx/job_manager_view.cc
src/wx/job_manager_view.h

index b1af469a87eb0d3c794cc7fda05c16efc6972f75..0a077265e89de43a06a8972a1c3e39b967e3523b 100644 (file)
@@ -64,15 +64,19 @@ public:
                        return;
                }
 
-               resize ();
+               setup ();
        }
 
-       void resize ()
+       void setup ()
        {
+               if (!_film || !_image) {
+                       return;
+               }
+               
                int vw, vh;
                GetSize (&vw, &vh);
 
-               float const target = _film->format()->ratio_as_float ();
+               float const target = _film->format() ? _film->format()->ratio_as_float () : 1.78;
 
                _cropped_image = _image->GetSubImage (
                        wxRect (_left_crop, _top_crop, _image->GetWidth() - (_left_crop + _right_crop), _image->GetHeight() - (_top_crop + _bottom_crop))
@@ -96,7 +100,7 @@ public:
        {
                delete _image;
                _image = new wxImage (wxString (f.c_str(), wxConvUTF8));
-               resize ();
+               setup ();
        }
 
        void set_crop (int l, int r, int t, int b)
@@ -105,7 +109,17 @@ public:
                _right_crop = r;
                _top_crop = t;
                _bottom_crop = b;
-               resize ();
+               setup ();
+       }
+
+       void set_film (Film* f)
+       {
+               _film = f;
+               if (!_film) {
+                       clear ();
+               } else {
+                       setup ();
+               }
        }
 
        void clear ()
@@ -204,15 +218,15 @@ void
 FilmViewer::set_film (Film* f)
 {
        _film = f;
+       _thumb_panel->set_film (_film);
 
        if (!_film) {
-               _thumb_panel->clear ();
                return;
        }
 
        _film->Changed.connect (sigc::mem_fun (*this, &FilmViewer::film_changed));
-
        film_changed (Film::THUMBS);
+       reload_current_thumbnail ();
 }
 
 void
index 9938d3a88bbd7e78cc509993f53d3a740c094d58..16a3e4afe5e88e12c5297c9ac567330d45a53dee 100644 (file)
@@ -35,19 +35,10 @@ using namespace boost;
 JobManagerView::JobManagerView (wxWindow* parent)
        : wxPanel (parent)
 {
-       _sizer = new wxFlexGridSizer (2, 6, 6);
+       _sizer = new wxFlexGridSizer (3, 6, 6);
+       _sizer->AddGrowableCol (1, 1);
        SetSizer (_sizer);
 
-#if 0  
-       add_label_to_sizer (_sizer, this, "Hello world");
-       wxGauge* g = new wxGauge (this, wxID_ANY, 100);
-       _sizer->Add (g, 1, wxEXPAND | wxALL);
-
-       add_label_to_sizer (_sizer, this, "Shit");
-       g = new wxGauge (this, wxID_ANY, 100);
-       _sizer->Add (g, 1, wxEXPAND | wxALL);
-#endif 
-       
        Connect (wxID_ANY, wxEVT_TIMER, wxTimerEventHandler (JobManagerView::periodic), 0, this);
        _timer.reset (new wxTimer (this));
        _timer->Start (1000);
@@ -76,23 +67,23 @@ JobManagerView::update ()
 
                        JobRecord r;
                        r.gauge = new wxGauge (this, wxID_ANY, 100);
+                       _sizer->Add (r.gauge, 1, wxEXPAND);
                        r.informed_of_finish = false;
+                       r.message = add_label_to_sizer (_sizer, this, "");
                        
-                       _sizer->Add (r.gauge, 1, wxEXPAND);
                        _job_records[*i] = r;
                        _sizer->Layout ();
                }
 
-               bool inform_of_finish = false;
                string const st = (*i)->status ();
 
                if (!(*i)->finished ()) {
                        float const p = (*i)->overall_progress ();
                        if (p >= 0) {
-//                             r[_columns.text] = st;
+                               _job_records[*i].message->SetLabel (std_to_wx (st));
                                _job_records[*i].gauge->SetValue (p * 100);
                        } else {
-//                             r[_columns.text] = "Running";
+                               _job_records[*i].message->SetLabel (wxT ("Running"));
                                _job_records[*i].gauge->Pulse ();
                        }
                }
@@ -102,21 +93,10 @@ JobManagerView::update ()
                   from here (the GUI thread).
                */
                
-               if ((*i)->finished_ok ()) {
-                       if (!_job_records[*i].informed_of_finish) {
-                               _job_records[*i].gauge->SetValue (100);
-//                             r[_columns.text] = st;
-                               inform_of_finish = true;
-                       }
-               } else if ((*i)->finished_in_error ()) {
-                       if (!_job_records[*i].informed_of_finish) {
-                               _job_records[*i].gauge->SetValue (100);
-//                             r[_columns.text] = st;
-                               inform_of_finish = true;
-                       }
-               }
+               if ((*i)->finished () && !_job_records[*i].informed_of_finish) {
+                       _job_records[*i].gauge->SetValue (100);
+                       _job_records[*i].message->SetLabel (std_to_wx (st));
 
-               if (inform_of_finish) {
                        try {
                                (*i)->emit_finished ();
                        } catch (OpenFileError& e) {
@@ -124,6 +104,7 @@ JobManagerView::update ()
                                s << "Error: " << e.what();
                                error_dialog (this, s.str ());
                        }
+                       
                        _job_records[*i].informed_of_finish = true;
                }
        }
index ef74b3cf86600bd66825deeee63bd416dafa3388..16fd7a3dc039921214bd09243536637eaa77d42e 100644 (file)
@@ -44,6 +44,7 @@ private:
        wxFlexGridSizer* _sizer;
        struct JobRecord {
                wxGauge* gauge;
+               wxStaticText* message;
                bool informed_of_finish;
        };