Cleanup: move LimitedSplitter out of the header.
authorCarl Hetherington <cth@carlh.net>
Wed, 12 Oct 2022 20:14:57 +0000 (22:14 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 14 Oct 2022 09:41:18 +0000 (11:41 +0200)
src/wx/content_panel.cc
src/wx/content_panel.h

index 637de9f0f5972d478838d14b30ed98cb390cd794..643efa78764beef9878a3bcceabef8f99ebb61f6 100644 (file)
@@ -73,6 +73,60 @@ using namespace boost::placeholders;
 #endif
 
 
+class LimitedSplitter : public wxSplitterWindow
+{
+public:
+       LimitedSplitter(wxWindow* parent)
+               : wxSplitterWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_3DSASH | wxSP_LIVE_UPDATE)
+       {
+               /* This value doesn't really mean much but we just want to stop double-click on the
+                  divider from shrinking the bottom panel (#1601).
+                  */
+               SetMinimumPaneSize(64);
+
+               Bind(wxEVT_SIZE, boost::bind(&LimitedSplitter::sized, this, _1));
+       }
+
+       bool OnSashPositionChange(int new_position) override
+       {
+               /* 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)
+       {
+               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 : -_top_panel_minimum_size);
+               } else {
+                       /* Fallback for when GetFromWindow fails for reasons that aren't clear */
+                       SplitHorizontally(top, bottom, -600);
+               }
+               _first_shown = true;
+       }
+
+private:
+       void sized(wxSizeEvent& ev)
+       {
+               if (_first_shown && GetSize().GetHeight() > _top_panel_minimum_size && GetSashPosition() < _top_panel_minimum_size) {
+                       /* The window is now fairly big but the top panel is small; this happens when the DCP-o-matic window
+                        * is shrunk and then made larger again.  Try to set a sensible top panel size in this case (#1839).
+                        */
+                       SetSashPosition(_top_panel_minimum_size);
+               }
+
+               ev.Skip ();
+       }
+
+       bool _first_shown = false;
+       int const _top_panel_minimum_size = 350;
+};
+
+
 class ContentDropTarget : public wxFileDropTarget
 {
 public:
@@ -921,47 +975,8 @@ ContentPanel::set_selected_state(int item, bool state)
 }
 
 
-LimitedSplitter::LimitedSplitter (wxWindow* parent)
-       : wxSplitterWindow (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_3DSASH | wxSP_LIVE_UPDATE)
-       , _first_shown (false)
-       , _top_panel_minimum_size (350)
-{
-       /* This value doesn't really mean much but we just want to stop double-click on the
-          divider from shrinking the bottom panel (#1601).
-       */
-       SetMinimumPaneSize (64);
-
-       Bind (wxEVT_SIZE, boost::bind(&LimitedSplitter::sized, this, _1));
-}
-
-
-void
-LimitedSplitter::first_shown (wxWindow* top, wxWindow* bottom)
+wxWindow*
+ContentPanel::window() const
 {
-       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 : -_top_panel_minimum_size);
-       } else {
-               /* Fallback for when GetFromWindow fails for reasons that aren't clear */
-               SplitHorizontally (top, bottom, -600);
-       }
-       _first_shown = true;
-}
-
-
-void
-LimitedSplitter::sized (wxSizeEvent& ev)
-{
-       if (_first_shown && GetSize().GetHeight() > _top_panel_minimum_size && GetSashPosition() < _top_panel_minimum_size) {
-               /* The window is now fairly big but the top panel is small; this happens when the DCP-o-matic window
-                * is shrunk and then made larger again.  Try to set a sensible top panel size in this case (#1839).
-                */
-               SetSashPosition (_top_panel_minimum_size);
-       }
-
-       ev.Skip ();
+       return _splitter;
 }
index 3aeb9db17328475984f04bab805cbee9e62b6dbb..1d303718031e6e1082bb4e8b76772d553b31504d 100644 (file)
@@ -35,6 +35,7 @@ class ContentSubPanel;
 class Film;
 class FilmEditor;
 class FilmViewer;
+class LimitedSplitter;
 class TextPanel;
 class TimelineDialog;
 class TimingPanel;
@@ -47,27 +48,6 @@ class wxSizer;
 class wxSplitterWindow;
 
 
-class LimitedSplitter : public wxSplitterWindow
-{
-public:
-       LimitedSplitter (wxWindow* parent);
-
-       bool OnSashPositionChange (int new_position) override
-       {
-               /* 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);
-
-private:
-       void sized (wxSizeEvent& ev);
-
-       bool _first_shown;
-       int const _top_panel_minimum_size;
-};
-
-
 class ContentPanel
 {
 public:
@@ -91,9 +71,7 @@ public:
 
        void first_shown ();
 
-       wxWindow* window () const {
-               return _splitter;
-       }
+       wxWindow* window () const;
 
        wxNotebook* notebook () const {
                return _notebook;