Use EnumIndexedVector in ContentPanel.
[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/enum_indexed_vector.h"
24 #include "lib/film.h"
25 #include "lib/types.h"
26 #include <dcp/warnings.h>
27 LIBDCP_DISABLE_WARNINGS
28 #include <wx/splitter.h>
29 LIBDCP_ENABLE_WARNINGS
30 #include <list>
31
32
33 class AudioPanel;
34 class ContentSubPanel;
35 class Film;
36 class FilmEditor;
37 class FilmViewer;
38 class TextPanel;
39 class TimelineDialog;
40 class TimingPanel;
41 class VideoPanel;
42 class wxListCtrl;
43 class wxListEvent;
44 class wxNotebook;
45 class wxPanel;
46 class wxSizer;
47 class wxSplitterWindow;
48
49
50 class LimitedSplitter : public wxSplitterWindow
51 {
52 public:
53         LimitedSplitter (wxWindow* parent);
54
55         bool OnSashPositionChange (int new_position) override
56         {
57                 /* Try to stop the top bit of the splitter getting so small that buttons disappear */
58                 return new_position > 220;
59         }
60
61         void first_shown (wxWindow* top, wxWindow* bottom);
62
63 private:
64         void sized (wxSizeEvent& ev);
65
66         bool _first_shown;
67         int const _top_panel_minimum_size;
68 };
69
70
71 class ContentPanel
72 {
73 public:
74         ContentPanel (wxNotebook *, std::shared_ptr<Film>, std::weak_ptr<FilmViewer> viewer);
75
76         ContentPanel (ContentPanel const&) = delete;
77         ContentPanel& operator= (ContentPanel const&) = delete;
78
79         std::shared_ptr<Film> film () const {
80                 return _film;
81         }
82
83         void set_film (std::shared_ptr<Film>);
84         void set_general_sensitivity (bool s);
85         void set_selection (std::weak_ptr<Content>);
86         void set_selection (ContentList cl);
87         void select_all ();
88
89         void film_changed (Film::Property p);
90         void film_content_changed (int p);
91
92         void first_shown ();
93
94         wxWindow* window () const {
95                 return _splitter;
96         }
97
98         wxNotebook* notebook () const {
99                 return _notebook;
100         }
101
102         ContentList selected ();
103         ContentList selected_video ();
104         ContentList selected_audio ();
105         ContentList selected_text ();
106         FFmpegContentList selected_ffmpeg ();
107
108         void add_file_clicked ();
109         bool remove_clicked (bool hotkey);
110         void timeline_clicked ();
111
112         std::weak_ptr<FilmViewer> film_viewer () const {
113                 return _film_viewer;
114         }
115
116         boost::signals2::signal<void (void)> SelectionChanged;
117
118 private:
119         void item_selected ();
120         void item_deselected ();
121         void item_deselected_idle ();
122         void check_selection ();
123         void add_folder_clicked ();
124         void add_dcp_clicked ();
125         void earlier_clicked ();
126         void later_clicked ();
127         void right_click (wxListEvent &);
128         void files_dropped (wxDropFilesEvent &);
129
130         void setup ();
131         void setup_sensitivity ();
132         void set_selected_state(int item, bool state);
133
134         void add_files (std::vector<boost::filesystem::path>);
135         std::list<ContentSubPanel *> panels () const;
136
137         LimitedSplitter* _splitter;
138         wxPanel* _top_panel;
139         wxNotebook* _notebook;
140         wxListCtrl* _content;
141         wxButton* _add_file;
142         wxButton* _add_folder;
143         wxButton* _add_dcp;
144         wxButton* _remove;
145         wxButton* _earlier;
146         wxButton* _later;
147         wxButton* _timeline;
148         VideoPanel* _video_panel = nullptr;
149         AudioPanel* _audio_panel = nullptr;
150         EnumIndexedVector<TextPanel*, TextType> _text_panel;
151         TimingPanel* _timing_panel;
152         ContentMenu* _menu;
153         TimelineDialog* _timeline_dialog = nullptr;
154         wxNotebook* _parent;
155         wxWindow* _last_selected_tab = nullptr;
156
157         std::shared_ptr<Film> _film;
158         std::weak_ptr<FilmViewer> _film_viewer;
159         bool _generally_sensitive;
160         bool _ignore_deselect;
161         bool _no_check_selection;
162 };