Work around strange build error on Ubuntu 18.04
[dcpomatic.git] / src / wx / content_panel.h
1 /*
2     Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "content_menu.h"
23 #include "lib/film.h"
24 #include "lib/types.h"
25 #include <dcp/warnings.h>
26 LIBDCP_DISABLE_WARNINGS
27 #include <wx/splitter.h>
28 LIBDCP_ENABLE_WARNINGS
29 #include <list>
30
31
32 class AudioPanel;
33 class ContentSubPanel;
34 class Film;
35 class FilmEditor;
36 class FilmViewer;
37 class TextPanel;
38 class TimelineDialog;
39 class TimingPanel;
40 class VideoPanel;
41 class wxListCtrl;
42 class wxListEvent;
43 class wxNotebook;
44 class wxPanel;
45 class wxSizer;
46 class wxSplitterWindow;
47
48
49 class LimitedSplitter : public wxSplitterWindow
50 {
51 public:
52         LimitedSplitter (wxWindow* parent);
53
54         bool OnSashPositionChange (int new_position) override
55         {
56                 /* Try to stop the top bit of the splitter getting so small that buttons disappear */
57                 return new_position > 220;
58         }
59
60         void first_shown (wxWindow* top, wxWindow* bottom);
61
62 private:
63         void sized (wxSizeEvent& ev);
64
65         bool _first_shown;
66         int const _top_panel_minimum_size;
67 };
68
69
70 class ContentPanel
71 {
72 public:
73         ContentPanel (wxNotebook *, std::shared_ptr<Film>, std::weak_ptr<FilmViewer> viewer);
74
75         ContentPanel (ContentPanel const&) = delete;
76         ContentPanel& operator= (ContentPanel const&) = delete;
77
78         std::shared_ptr<Film> film () const {
79                 return _film;
80         }
81
82         void set_film (std::shared_ptr<Film>);
83         void set_general_sensitivity (bool s);
84         void set_selection (std::weak_ptr<Content>);
85         void set_selection (ContentList cl);
86         void select_all ();
87
88         void film_changed (Film::Property p);
89         void film_content_changed (int p);
90
91         void first_shown ();
92
93         wxWindow* window () const {
94                 return _splitter;
95         }
96
97         wxNotebook* notebook () const {
98                 return _notebook;
99         }
100
101         ContentList selected ();
102         ContentList selected_video ();
103         ContentList selected_audio ();
104         ContentList selected_text ();
105         FFmpegContentList selected_ffmpeg ();
106
107         void add_file_clicked ();
108         bool remove_clicked (bool hotkey);
109         void timeline_clicked ();
110
111         std::weak_ptr<FilmViewer> film_viewer () const {
112                 return _film_viewer;
113         }
114
115         boost::signals2::signal<void (void)> SelectionChanged;
116
117 private:
118         void item_selected ();
119         void item_deselected ();
120         void item_deselected_idle ();
121         void check_selection ();
122         void add_folder_clicked ();
123         void add_dcp_clicked ();
124         void earlier_clicked ();
125         void later_clicked ();
126         void right_click (wxListEvent &);
127         void files_dropped (wxDropFilesEvent &);
128
129         void setup ();
130         void setup_sensitivity ();
131         void set_selected_state(int item, bool state);
132
133         void add_files (std::vector<boost::filesystem::path>);
134         std::list<ContentSubPanel *> panels () const;
135
136         LimitedSplitter* _splitter;
137         wxPanel* _top_panel;
138         wxNotebook* _notebook;
139         wxListCtrl* _content;
140         wxButton* _add_file;
141         wxButton* _add_folder;
142         wxButton* _add_dcp;
143         wxButton* _remove;
144         wxButton* _earlier;
145         wxButton* _later;
146         wxButton* _timeline;
147         VideoPanel* _video_panel = nullptr;
148         AudioPanel* _audio_panel = nullptr;
149         TextPanel* _text_panel[static_cast<int>(TextType::COUNT)];
150         TimingPanel* _timing_panel;
151         ContentMenu* _menu;
152         TimelineDialog* _timeline_dialog = nullptr;
153         wxNotebook* _parent;
154         wxWindow* _last_selected_tab = nullptr;
155
156         std::shared_ptr<Film> _film;
157         std::weak_ptr<FilmViewer> _film_viewer;
158         bool _generally_sensitive;
159         bool _ignore_deselect;
160         bool _no_check_selection;
161 };