diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-09-02 22:09:33 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-09-02 22:09:33 +0100 |
| commit | 8407612363705f757d3ab26d6e119171c217b00a (patch) | |
| tree | 96c5e07733656a8df6f0e660a828b1765110297f /src | |
| parent | e50e596448d17f32652a8215a01ae62a32c9afea (diff) | |
Seemingly rather long-winded way of making the JobManagerView in
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/dcpomatic_batch.cc | 17 | ||||
| -rw-r--r-- | src/wx/job_manager_view.cc | 12 | ||||
| -rw-r--r-- | src/wx/job_manager_view.h | 1 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 234bfea5c..de255e65e 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -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[] = { diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index df9c6f5f1..5146243b4 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_view.cc @@ -202,15 +202,25 @@ 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) { shared_ptr<Job> job = j.lock (); diff --git a/src/wx/job_manager_view.h b/src/wx/job_manager_view.h index c4bb1e218..83ce4ee5a 100644 --- a/src/wx/job_manager_view.h +++ b/src/wx/job_manager_view.h @@ -43,6 +43,7 @@ public: private: void job_added (boost::weak_ptr<Job>); void periodic (); + void sized (wxSizeEvent &); wxPanel* _panel; wxFlexGridSizer* _table; |
