ab11a894b95f3dd1e09b7da22239f91154f2646d
[dcpomatic.git] / src / wx / content_panel.h
1 /*
2     Copyright (C) 2012-2019 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 #include "content_menu.h"
22 #include "lib/types.h"
23 #include "lib/film.h"
24 #include <wx/splitter.h>
25 #include <boost/shared_ptr.hpp>
26 #include <list>
27
28 class wxNotebook;
29 class wxPanel;
30 class wxSizer;
31 class wxListCtrl;
32 class wxListEvent;
33 class wxSplitterWindow;
34 class TimelineDialog;
35 class FilmEditor;
36 class ContentSubPanel;
37 class TextPanel;
38 class VideoPanel;
39 class AudioPanel;
40 class TimingPanel;
41 class Film;
42 class FilmViewer;
43
44
45 class LimitedSplitter : public wxSplitterWindow
46 {
47 public:
48         LimitedSplitter (wxWindow* parent)
49                 : wxSplitterWindow (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_3DSASH | wxSP_LIVE_UPDATE)
50         {
51                 /* This value doesn't really mean much but we just want to stop double-click on the
52                    divider from shrinking the bottom panel (#1601).
53                 */
54                 SetMinimumPaneSize (64);
55         }
56
57         bool OnSashPositionChange (int new_position)
58         {
59                 /* Try to stop the top bit of the splitter getting so small that buttons disappear */
60                 return new_position > 220;
61         }
62
63         void first_shown (wxWindow* top, wxWindow* bottom);
64 };
65
66
67 class ContentPanel : public boost::noncopyable
68 {
69 public:
70         ContentPanel (wxNotebook *, boost::shared_ptr<Film>, boost::weak_ptr<FilmViewer> viewer);
71
72         boost::shared_ptr<Film> film () const {
73                 return _film;
74         }
75
76         void set_film (boost::shared_ptr<Film>);
77         void set_general_sensitivity (bool s);
78         void set_selection (boost::weak_ptr<Content>);
79         void set_selection (ContentList cl);
80
81         void film_changed (Film::Property p);
82         void film_content_changed (int p);
83
84         void first_shown ();
85
86         wxWindow* window () const {
87                 return _splitter;
88         }
89
90         wxNotebook* notebook () const {
91                 return _notebook;
92         }
93
94         ContentList selected ();
95         ContentList selected_video ();
96         ContentList selected_audio ();
97         ContentList selected_text ();
98         FFmpegContentList selected_ffmpeg ();
99
100         void add_file_clicked ();
101         bool remove_clicked (bool hotkey);
102         void timeline_clicked ();
103
104         boost::weak_ptr<FilmViewer> film_viewer () const {
105                 return _film_viewer;
106         }
107
108         boost::signals2::signal<void (void)> SelectionChanged;
109
110 private:
111         void item_selected ();
112         void item_deselected ();
113         void item_deselected_idle ();
114         void check_selection ();
115         void add_folder_clicked ();
116         void add_dcp_clicked ();
117         void earlier_clicked ();
118         void later_clicked ();
119         void right_click (wxListEvent &);
120         void files_dropped (wxDropFilesEvent &);
121
122         void setup ();
123         void setup_sensitivity ();
124
125         void add_files (std::list<boost::filesystem::path>);
126         std::list<ContentSubPanel *> panels () const;
127
128         LimitedSplitter* _splitter;
129         wxPanel* _top_panel;
130         wxNotebook* _notebook;
131         wxListCtrl* _content;
132         wxButton* _add_file;
133         wxButton* _add_folder;
134         wxButton* _add_dcp;
135         wxButton* _remove;
136         wxButton* _earlier;
137         wxButton* _later;
138         wxButton* _timeline;
139         VideoPanel* _video_panel;
140         AudioPanel* _audio_panel;
141         TextPanel* _text_panel[TEXT_COUNT];
142         TimingPanel* _timing_panel;
143         ContentMenu* _menu;
144         TimelineDialog* _timeline_dialog;
145         wxNotebook* _parent;
146         wxWindow* _last_selected_tab;
147
148         boost::shared_ptr<Film> _film;
149         boost::weak_ptr<FilmViewer> _film_viewer;
150         bool _generally_sensitive;
151         bool _ignore_deselect;
152         bool _no_check_selection;
153 };