diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-05-18 11:41:44 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-05-18 11:59:54 +0200 |
| commit | d8fc4fd042a3ae62ab1b258dbfa032bc7a933dc2 (patch) | |
| tree | 1bc928ffd7f87a82fd15e511fcaf9dc59fc8863f /src | |
| parent | 1aa976b08e0cb7430adeb6c243e1cb9c7b330365 (diff) | |
Remember position and size of caption list view.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/text_panel.cc | 2 | ||||
| -rw-r--r-- | src/wx/text_view.cc | 32 | ||||
| -rw-r--r-- | src/wx/text_view.h | 10 | ||||
| -rw-r--r-- | src/wx/window_metrics.cc | 45 | ||||
| -rw-r--r-- | src/wx/window_metrics.h | 39 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
6 files changed, 126 insertions, 3 deletions
diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc index c3a5706b0..4b6e900db 100644 --- a/src/wx/text_panel.cc +++ b/src/wx/text_panel.cc @@ -712,7 +712,7 @@ TextPanel::text_view_clicked () if (decoder) { _text_view.reset(this, _parent->film(), c.front(), c.front()->text_of_original_type(_original_type), decoder, _parent->film_viewer()); - _text_view->Show (); + _text_view->show(); } } diff --git a/src/wx/text_view.cc b/src/wx/text_view.cc index 7e5267886..7f60e79f0 100644 --- a/src/wx/text_view.cc +++ b/src/wx/text_view.cc @@ -42,14 +42,17 @@ using namespace boost::placeholders; #endif +WindowMetrics TextView::_metrics; + + TextView::TextView ( wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<TextContent> text, shared_ptr<Decoder> decoder, FilmViewer& viewer ) - : wxDialog (parent, wxID_ANY, _("Captions"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) + : wxDialog(parent, wxID_ANY, _("Captions"), _metrics.position, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , _content (content) , _film_viewer (viewer) { - _list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); + _list = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, _metrics.size, wxLC_REPORT | wxLC_SINGLE_SEL); { wxListItem ip; @@ -104,10 +107,35 @@ TextView::TextView ( } while (!decoder->pass ()) {} SetSizerAndFit (sizer); + + _list->Bind(wxEVT_SIZE, boost::bind(&TextView::list_sized, this, _1)); + Bind(wxEVT_MOVE, boost::bind(&TextView::moved, this, _1)); } void +TextView::list_sized(wxSizeEvent& ev) +{ + _metrics.size = ev.GetSize(); + ev.Skip(); +} + + +void +TextView::moved(wxMoveEvent& ev) +{ + _metrics.position = ClientToScreen({0, 0}); + ev.Skip(); +} + + +void +TextView::show() +{ + _metrics.show(this); +} + +void TextView::data_start (ContentStringText cts) { for (auto const& i: cts.subs) { diff --git a/src/wx/text_view.h b/src/wx/text_view.h index 8cf3c78bb..d1271ef26 100644 --- a/src/wx/text_view.h +++ b/src/wx/text_view.h @@ -18,6 +18,8 @@ */ + +#include "window_metrics.h" #include "lib/content_text.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -25,10 +27,12 @@ LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS + class Decoder; class FilmViewer; class Film; + class TextView : public wxDialog { public: @@ -41,10 +45,14 @@ public: FilmViewer& viewer ); + void show(); + private: void data_start (ContentStringText cts); void data_stop (dcpomatic::ContentTime time); void subtitle_selected (wxListEvent &); + void moved(wxMoveEvent& ev); + void list_sized(wxSizeEvent& ev); wxListCtrl* _list; int _subs; @@ -53,4 +61,6 @@ private: std::vector<dcpomatic::ContentTime> _start_times; std::weak_ptr<Content> _content; FilmViewer& _film_viewer; + + static WindowMetrics _metrics; }; diff --git a/src/wx/window_metrics.cc b/src/wx/window_metrics.cc new file mode 100644 index 000000000..4b0c6ce66 --- /dev/null +++ b/src/wx/window_metrics.cc @@ -0,0 +1,45 @@ +/* + Copyright (C) 2024 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "window_metrics.h" +#include <dcp/warnings.h> +LIBDCP_DISABLE_WARNINGS +#include <wx/app.h> +#include <wx/wx.h> +LIBDCP_ENABLE_WARNINGS + + +void +WindowMetrics::show(wxWindow* window) const +{ +#ifdef DCPOMATIC_LINUX + auto const position_before = position; +#endif + + window->Show(); + +#ifdef DCPOMATIC_LINUX + wxTheApp->CallAfter([window, position_before] { + window->SetPosition(position_before); + }); +#endif +} + diff --git a/src/wx/window_metrics.h b/src/wx/window_metrics.h new file mode 100644 index 000000000..30a921134 --- /dev/null +++ b/src/wx/window_metrics.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2024 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include <dcp/warnings.h> +LIBDCP_DISABLE_WARNINGS +#include <wx/gdicmn.h> +LIBDCP_ENABLE_WARNINGS + + +class wxWindow; + + +class WindowMetrics +{ +public: + void show(wxWindow* window) const; + + wxPoint position = wxDefaultPosition; + wxSize size = wxDefaultSize; +}; + diff --git a/src/wx/wscript b/src/wx/wscript index bdae9708e..0255149ed 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -186,6 +186,7 @@ sources = """ video_view.cc video_waveform_dialog.cc video_waveform_plot.cc + window_metrics.cc wx_signal_manager.cc wx_util.cc wx_variant.cc |
