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