Remove old dvd test code.
[dcpomatic.git] / hacks / pretty-c++ / src / film_view.cc
1 FilmView::FilmView ()
2         : _film (0)
3         , _content_file_radio (_content_group)
4         , _content_file_chooser ("Content", Gtk::FILE_CHOOSER_ACTION_OPEN)
5         , _content_file_button (_content_file_chooser)
6         , _content_folder_radio (_content_group)
7         , _content_folder_chooser ("Content", Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)
8         , _content_folder_button (_content_folder_chooser)
9         , _dvd ("DVD")
10         , _deinterlace ("Deinterlace")
11 {
12         _table = manage (new Gtk::Table);
13         table->set_row_spacings (4);
14         table->set_col_spacings (12);
15         main_vbox->pack_start (*table, false, false);
16
17         int n = 0;
18
19         table->attach (*left_aligned_label ("Content"), 0, 1, n, n + 1);
20         _content_file_chooser.add_button ("Select", Gtk::RESPONSE_OK);
21         _content_folder_chooser.add_button ("Select", Gtk::RESPONSE_OK);
22         Gtk::HBox* b = Gtk::manage (new Gtk::HBox);
23         b->set_spacing (12);
24         _content_file_radio.set_label ("File");
25         b->pack_start (_content_file_radio, false, false);
26         b->pack_start (_content_file_button, true, true);
27         _content_folder_radio.set_label ("Folder");
28         b->pack_start (_content_folder_radio, false, false);
29         b->pack_start (_content_folder_button, true, true);
30         table->attach (*b, 1, 2, n, n + 1);
31         ++n;
32
33         table->attach (*left_aligned_label ("Name"), 0, 1, n, n + 1);
34         table->attach (_name, 1, 2, n, n + 1);
35         ++n;
36
37         table->attach (*left_aligned_label ("Ratio"), 0, 1, n, n + 1);
38         _ratio.append_text ("1.33:1 (4:3)");
39         _ratio.append_text ("1.78:1 (16:9)");
40         _ratio.append_text ("1.85:1 (Flat)");
41         _ratio.append_text ("2.39:1 (Scope)");
42         table->attach (_ratio, 1, 2, n, n + 1);
43         _ratio.set_active_text ("1.85:1 (Flat)");
44         ++n;
45
46         table->attach (_dvd, 0, 2, n, n + 1);
47         ++n;
48
49         table->attach (*left_aligned_label ("DVD title"), 0, 1, n, n + 1);
50         _dvd_title.set_range (1, 64);
51         _dvd_title.set_increments (1, 4);
52         _dvd_title.set_value (1);
53         table->attach (_dvd_title, 1, 2, n, n + 1);
54         ++n;
55
56         table->attach (_deinterlace, 0, 2, n, n + 1);
57         ++n;
58
59         table->attach (*left_aligned_label ("Left Crop"), 0, 1, n, n + 1);
60         _left_crop.set_range (0, 1024);
61         _left_crop.set_increments (1, 64);
62         _left_crop.set_value (0);
63         table->attach (_left_crop, 1, 2, n, n + 1);
64         ++n;
65
66         table->attach (*left_aligned_label ("Right Crop"), 0, 1, n, n + 1);
67         _right_crop.set_range (0, 1024);
68         _right_crop.set_increments (1, 64);
69         _right_crop.set_value (0);
70         table->attach (_right_crop, 1, 2, n, n + 1);
71         ++n;
72
73         table->attach (*left_aligned_label ("Top Crop"), 0, 1, n, n + 1);
74         _top_crop.set_range (0, 1024);
75         _top_crop.set_increments (1, 64);
76         _top_crop.set_value (0);
77         table->attach (_top_crop, 1, 2, n, n + 1);
78         ++n;
79
80         table->attach (*left_aligned_label ("Bottom Crop"), 0, 1, n, n + 1);
81         _bottom_crop.set_range (0, 1024);
82         _bottom_crop.set_increments (1, 64);
83         _bottom_crop.set_value (0);
84         table->attach (_bottom_crop, 1, 2, n, n + 1);
85         ++n;
86
87         table->attach (*left_aligned_label ("Size"), 0, 1, n, n + 1);
88         table->attach (_size, 1, 2, n, n + 1);
89         ++n;
90
91         table->attach (*left_aligned_label ("Length"), 0, 1, n, n + 1);
92         table->attach (_length, 1, 2, n, n + 1);
93         ++n;
94         
95         /* We only need to connect to one of the radios in the group */
96         _content_file_radio.signal_toggled().connect (sigc::mem_fun (*this, &FilmView::content_radio_toggled));
97         _content_file_button.signal_file_set().connect (sigc::mem_fun (*this, &FilmView::content_changed));
98         _content_folder_button.signal_file_set().connect (sigc::mem_fun (*this, &FilmView::content_changed));
99         _dvd.signal_toggled().connect (sigc::mem_fun (*this, &FilmView::update_dvd_title_sensitivity));
100
101         update_content_radio_sensitivity ();
102         update_dvd_title_sensitivity ();
103         show_all ();
104 }
105
106 Gtk::Label *
107 FilmView::left_aligned_label (string const & t) const
108 {
109         Gtk::Label* l = Gtk::manage (new Gtk::Label (t));
110         l->set_alignment (0, 0.5);
111         return l;
112 }
113
114 void
115 FilmView::content_radio_toggled ()
116 {
117         update_content_radio_sensitivity ();
118         content_changed ();
119 }
120
121 void
122 FilmView::update_content_radio_sensitivity ()
123 {
124         _content_file_button.set_sensitive (_content_file_radio.get_active ());
125         _content_folder_button.set_sensitive (_content_folder_radio.get_active ());
126 }
127
128 void
129 FilmView::update_dvd_title_sensitivity ()
130 {
131         _dvd_title.set_sensitive (_dvd.get_active ());
132 }
133
134 void
135 FilmView::content_changed ()
136 {
137         cout << "Content changed.\n";
138 }
139
140 void
141 FilmView::set_film (Film* f)
142 {
143         _film = f;
144         update ();
145 }