Move contents of ContentPanel::first_shown into LimitedSplitter.
authorCarl Hetherington <cth@carlh.net>
Tue, 20 Oct 2020 14:52:04 +0000 (16:52 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 20 Oct 2020 14:52:04 +0000 (16:52 +0200)
src/wx/content_panel.cc
src/wx/content_panel.h

index 2c5fea79bee8596190813e00c707525fe313f09a..0fd21ff8696b8aeb4bc7b342b1454f56bc18f29e 100644 (file)
@@ -154,17 +154,7 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
 void
 ContentPanel::first_shown ()
 {
-       int const sn = wxDisplay::GetFromWindow(_splitter);
-       if (sn >= 0) {
-               wxRect const screen = wxDisplay(sn).GetClientArea();
-               /* 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.
-                  */
-               _splitter->SplitHorizontally (_top_panel, _notebook, screen.height > 800 ? -600 : -150);
-       } else {
-               /* Fallback for when GetFromWindow fails for reasons that aren't clear */
-               _splitter->SplitHorizontally (_top_panel, _notebook, -600);
-       }
+       _splitter->first_shown (_top_panel, _notebook);
 }
 
 
@@ -809,3 +799,21 @@ ContentPanel::panels () const
        p.push_back (_timing_panel);
        return p;
 }
+
+
+void
+LimitedSplitter::first_shown (wxWindow* top, wxWindow* bottom)
+{
+       int const sn = wxDisplay::GetFromWindow(this);
+       if (sn >= 0) {
+               wxRect const screen = wxDisplay(sn).GetClientArea();
+               /* 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.
+                  */
+               SplitHorizontally (top, bottom, screen.height > 800 ? -600 : -150);
+       } else {
+               /* Fallback for when GetFromWindow fails for reasons that aren't clear */
+               SplitHorizontally (top, bottom, -600);
+       }
+
+}
index 7b3217605064a94a9c460e51bb66ff0e66e1649b..ab11a894b95f3dd1e09b7da22239f91154f2646d 100644 (file)
@@ -59,6 +59,8 @@ public:
                /* Try to stop the top bit of the splitter getting so small that buttons disappear */
                return new_position > 220;
        }
+
+       void first_shown (wxWindow* top, wxWindow* bottom);
 };
 
 
@@ -123,7 +125,7 @@ private:
        void add_files (std::list<boost::filesystem::path>);
        std::list<ContentSubPanel *> panels () const;
 
-       wxSplitterWindow* _splitter;
+       LimitedSplitter* _splitter;
        wxPanel* _top_panel;
        wxNotebook* _notebook;
        wxListCtrl* _content;