summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-12-22 17:02:43 +0100
committerCarl Hetherington <cth@carlh.net>2024-01-28 02:01:58 +0100
commit1889bd28b5e5fcef7607b26f184ceba3f3076b2c (patch)
treef659b81b5eac00138c035fb2f8621ac7aa882b2c /src/wx
parente9285246f543248eec88627ce61a3ccafd6f3ac2 (diff)
Remember whether Content or DCP is selected in a new ui.xml state file.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/film_editor.cc33
-rw-r--r--src/wx/film_editor.h4
2 files changed, 31 insertions, 6 deletions
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index 9f54db58e..fae02787a 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -54,13 +54,15 @@ FilmEditor::FilmEditor(wxWindow* parent, FilmViewer& viewer)
{
auto s = new wxBoxSizer (wxVERTICAL);
- auto notebook = new wxNotebook(this, wxID_ANY);
- s->Add(notebook, 1, wxEXPAND);
+ _notebook = new wxNotebook(this, wxID_ANY);
+ s->Add(_notebook, 1, wxEXPAND);
- _content_panel = new ContentPanel(notebook, _film, viewer);
- notebook->AddPage(_content_panel->window(), _("Content"), true);
- _dcp_panel = new DCPPanel(notebook, _film, viewer);
- notebook->AddPage(_dcp_panel->panel (), _("DCP"), false);
+ _content_panel = new ContentPanel(_notebook, _film, viewer);
+ _notebook->AddPage(_content_panel->window(), _("Content"), true);
+ _dcp_panel = new DCPPanel(_notebook, _film, viewer);
+ _notebook->AddPage(_dcp_panel->panel (), _("DCP"), false);
+
+ _notebook->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, boost::bind(&FilmEditor::page_changed, this, _1));
JobManager::instance()->ActiveJobsChanged.connect (
bind(&FilmEditor::active_jobs_changed, this, _2)
@@ -71,6 +73,18 @@ FilmEditor::FilmEditor(wxWindow* parent, FilmViewer& viewer)
}
+void
+FilmEditor::page_changed(wxBookCtrlEvent& ev)
+{
+ /* One of these events arrives early on with GetOldSelection() being a non-existent tab,
+ * and we want to ignore that.
+ */
+ if (_film && ev.GetOldSelection() < 2) {
+ _film->set_ui_state("FilmEditorTab", ev.GetSelection() == 0 ? "content" : "dcp");
+ }
+}
+
+
/** Called when the metadata stored in the Film object has changed;
* so that we can update the GUI.
* @param p Property of the Film that has changed.
@@ -144,6 +158,13 @@ FilmEditor::set_film (shared_ptr<Film> film)
if (!_film->content().empty()) {
_content_panel->set_selection (_film->content().front());
}
+
+ auto tab = _film->ui_state("FilmEditorTab").get_value_or("content");
+ if (tab == "content") {
+ _notebook->SetSelection(0);
+ } else if (tab == "dcp") {
+ _notebook->SetSelection(1);
+ }
}
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index 75a09ba02..54d639ef5 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -36,6 +36,7 @@ class ContentPanel;
class DCPPanel;
class Film;
class FilmViewer;
+class wxBookCtrlEvent;
class wxNotebook;
@@ -71,6 +72,9 @@ private:
void set_general_sensitivity (bool);
void active_jobs_changed (boost::optional<std::string>);
+ void page_changed(wxBookCtrlEvent& ev);
+
+ wxNotebook* _notebook;
ContentPanel* _content_panel;
DCPPanel* _dcp_panel;