Seemingly rather long-winded way of making the JobManagerView in
authorCarl Hetherington <cth@carlh.net>
Tue, 2 Sep 2014 21:09:33 +0000 (22:09 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 2 Sep 2014 21:09:33 +0000 (22:09 +0100)
dcpomatic_batch shrink nicely (i.e. shrinking the gauge) when the
window is shrunk.  It seems surprising that we have to call back
to children to tell them to layout / fit-inside, but it does all
*seem* to be necessary.

ChangeLog
src/tools/dcpomatic_batch.cc
src/wx/job_manager_view.cc
src/wx/job_manager_view.h

index 9314e40660a131a4b42a830f872e8f00e734380d..54188c26a4f9f5da4f894bd9db761c4a761de959 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-09-02  Carl Hetherington  <cth@carlh.net>
+
+       * Improve behaviour of batch converter window when it is shrunk (#338).
+
 2014-09-01  Carl Hetherington  <cth@carlh.net>
 
        * Version 1.73.1 released.
index 234bfea5cda13905048caa8d4b01dc8757689a99..de255e65edaeab43959800f8639232f87b5272ea 100644 (file)
@@ -62,6 +62,7 @@ class Frame : public wxFrame
 public:
        Frame (wxString const & title)
                : wxFrame (NULL, -1, title)
+               , _sizer (new wxBoxSizer (wxVERTICAL))
        {
                wxMenuBar* bar = new wxMenuBar;
                setup_menu (bar);
@@ -76,24 +77,29 @@ public:
                s->Add (panel, 1, wxEXPAND);
                SetSizer (s);
 
-               wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
-
                JobManagerView* job_manager_view = new JobManagerView (panel, JobManagerView::PAUSE);
-               sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6);
+               _sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6);
 
                wxSizer* buttons = new wxBoxSizer (wxHORIZONTAL);
                wxButton* add = new wxButton (panel, wxID_ANY, _("Add Film..."));
                add->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&Frame::add_film, this));
                buttons->Add (add, 1, wxALL, 6);
 
-               sizer->Add (buttons, 0, wxALL, 6);
+               _sizer->Add (buttons, 0, wxALL, 6);
 
-               panel->SetSizer (sizer);
+               panel->SetSizer (_sizer);
 
                Bind (wxEVT_CLOSE_WINDOW, boost::bind (&Frame::close, this, _1));
+               Bind (wxEVT_SIZE, boost::bind (&Frame::sized, this, _1));
        }
 
 private:
+       void sized (wxSizeEvent& ev)
+       {
+               _sizer->Layout ();
+               ev.Skip ();
+       }
+       
        bool should_close ()
        {
                if (!JobManager::instance()->work_to_do ()) {
@@ -176,6 +182,7 @@ private:
        }
 
        boost::optional<boost::filesystem::path> _last_parent;
+       wxSizer* _sizer;
 };
 
 static const wxCmdLineEntryDesc command_line_description[] = {
index df9c6f5f1d996dfcbccff08753d71b5789c007c6..5146243b412b0ede27ed94a132475d1a7fbcbbc4 100644 (file)
@@ -202,14 +202,24 @@ JobManagerView::JobManagerView (wxWindow* parent, Buttons buttons)
        _panel->SetSizer (_table);
 
        SetScrollRate (0, 32);
+       EnableScrolling (false, true);
 
        Bind (wxEVT_TIMER, boost::bind (&JobManagerView::periodic, this));
        _timer.reset (new wxTimer (this));
        _timer->Start (1000);
-       
+
+       Bind (wxEVT_SIZE, boost::bind (&JobManagerView::sized, this, _1));
        JobManager::instance()->JobAdded.connect (bind (&JobManagerView::job_added, this, _1));
 }
 
+void
+JobManagerView::sized (wxSizeEvent& ev)
+{
+       _table->FitInside (_panel);
+       _table->Layout ();
+       ev.Skip ();
+}
+
 void
 JobManagerView::job_added (weak_ptr<Job> j)
 {
index c4bb1e2189b6e32850a0694c52e65121c957a316..83ce4ee5abb9d837eee80cd90df3800bb9892c80 100644 (file)
@@ -43,6 +43,7 @@ public:
 private:
        void job_added (boost::weak_ptr<Job>);
        void periodic ();
+       void sized (wxSizeEvent &);
 
        wxPanel* _panel;
        wxFlexGridSizer* _table;