Remove nasty border from wxSplitterWindow.
[dcpomatic.git] / src / wx / content_panel.cc
index 4587b8cc30aff4c0854636d567d1f306f41bdfe4..a164ee977bf25686bce9170d594ab475e459926a 100644 (file)
@@ -62,6 +62,22 @@ using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
 
+class LimitedSplitter : public wxSplitterWindow
+{
+public:
+       LimitedSplitter (wxWindow* parent)
+               : wxSplitterWindow (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_3DSASH | wxSP_LIVE_UPDATE)
+       {
+
+       }
+
+       bool OnSashPositionChange (int new_position)
+       {
+               /* Try to stop the top bit of the splitter getting so small that buttons disappear */
+               return new_position > 220;
+       }
+};
+
 ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer)
        : _video_panel (0)
        , _audio_panel (0)
@@ -77,7 +93,9 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
                _text_panel[i] = 0;
        }
 
-       _splitter = new wxSplitterWindow (n);
+       _splitter = new LimitedSplitter (n);
+       wxDisplay display (wxDisplay::GetFromWindow(_splitter));
+       wxRect screen = display.GetClientArea();
        wxPanel* top = new wxPanel (_splitter);
 
        _menu = new ContentMenu (_splitter);
@@ -132,8 +150,6 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
        /* This is a hack to try and make the content notebook a sensible size; large on big displays but small
           enough on small displays to leave space for the content area.
        */
-       wxDisplay display (wxDisplay::GetFromWindow(_splitter));
-       wxRect screen = display.GetClientArea();
        _splitter->SplitHorizontally (top, _notebook, screen.height > 800 ? -600 : -150);
 
        _timing_panel = new TimingPanel (this, _film_viewer);
@@ -589,7 +605,11 @@ ContentPanel::set_film (shared_ptr<Film> film)
 
        film_changed (Film::CONTENT);
        film_changed (Film::AUDIO_CHANNELS);
-       check_selection ();
+
+       if (_film) {
+               check_selection ();
+       }
+
        setup_sensitivity ();
 }
 
@@ -667,6 +687,12 @@ ContentPanel::film_content_changed (int property)
 void
 ContentPanel::setup ()
 {
+       if (!_film) {
+               _content->DeleteAllItems ();
+               setup_sensitivity ();
+               return;
+       }
+
        ContentList content = _film->content ();
 
        Content* selected_content = 0;
@@ -685,11 +711,6 @@ ContentPanel::setup ()
                int const t = _content->GetItemCount ();
                bool const valid = i->paths_valid ();
 
-               /* Temporary debugging for Igor */
-               BOOST_FOREACH (boost::filesystem::path j, i->paths()) {
-                       LOG_GENERAL ("Check %1 %2 answer %3", j.string(), boost::filesystem::exists(j) ? "yes" : "no", valid ? "yes" : "no");
-               }
-
                shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (i);
                bool const needs_kdm = dcp && dcp->needs_kdm ();
                bool const needs_assets = dcp && dcp->needs_assets ();