summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-10-20 21:10:49 +0200
committerCarl Hetherington <cth@carlh.net>2020-10-20 21:10:49 +0200
commit5da8d7521a600a5924fd10c52db21a367db72f97 (patch)
treed590a8f21864a2ec1f5574e7424efa8f6fb94fd5
parented94e34207c9d8dbd495ca4b0ef468b79126f26a (diff)
Try to improve splitter behaviour when shrinking and then enlarging
the main window (#1839).
-rw-r--r--src/wx/content_panel.cc19
-rw-r--r--src/wx/content_panel.h6
2 files changed, 24 insertions, 1 deletions
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index 8b6b02316..9ec44a9f2 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -803,11 +803,14 @@ ContentPanel::panels () const
LimitedSplitter::LimitedSplitter (wxWindow* parent)
: wxSplitterWindow (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_3DSASH | wxSP_LIVE_UPDATE)
+ , _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));
}
@@ -820,10 +823,24 @@ LimitedSplitter::first_shown (wxWindow* top, wxWindow* bottom)
/* 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);
+ 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);
}
}
+
+
+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 ();
+}
diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h
index 52a7e9f3c..df5c58ebd 100644
--- a/src/wx/content_panel.h
+++ b/src/wx/content_panel.h
@@ -54,6 +54,12 @@ public:
}
void first_shown (wxWindow* top, wxWindow* bottom);
+
+private:
+ void sized (wxSizeEvent& ev);
+
+ bool _first_shown;
+ int const _top_panel_minimum_size;
};