+
+class LimitedFrameSplitter : public wxSplitterWindow
+{
+public:
+ LimitedFrameSplitter(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 left panel.
+ */
+ SetMinimumPaneSize(64);
+
+ Bind(wxEVT_SIZE, boost::bind(&LimitedFrameSplitter::sized, this, _1));
+ }
+
+ bool OnSashPositionChange(int new_position) override
+ {
+ /* Try to stop the left bit of the splitter getting too small */
+ auto const ok = new_position > _left_panel_minimum_size;
+ if (ok) {
+ Config::instance()->set_main_divider_sash_position(new_position);
+ }
+ return ok;
+ }
+
+private:
+ void sized(wxSizeEvent& ev)
+ {
+ if (GetSize().GetWidth() > _left_panel_minimum_size && GetSashPosition() < _left_panel_minimum_size) {
+ /* The window is now fairly big but the left panel is small; this happens when the DCP-o-matic window
+ * is shrunk and then made larger again. Try to set a sensible left panel size in this case.
+ */
+ SetSashPosition(Config::instance()->main_divider_sash_position().get_value_or(_left_panel_minimum_size));
+ }
+
+ ev.Skip();
+ }
+
+ int const _left_panel_minimum_size = 200;
+};
+
+