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