summaryrefslogtreecommitdiff
path: root/src/wx/dcp_range_dialog.cc
blob: d1fef0e8b121c85cce2a029cc88f5fb753d6fa25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "dcp_range_dialog.h"
#include "lib/film.h"

DCPRangeDialog::DCPRangeDialog (Film* f)
	: _film (f)
	, _whole ("Whole film")
	, _first ("First")
	, _cut ("Cut remainder")
	, _black_out ("Black-out remainder")
{
	set_title ("DCP range");

	Gtk::Table* table = Gtk::manage (new Gtk::Table ());
	table->set_border_width (6);
	table->set_row_spacings (6);
	table->set_col_spacings (6);
	table->attach (_whole, 0, 4, 0, 1);
	table->attach (_first, 0, 1, 1, 2);
	table->attach (_n_frames, 1, 2, 1, 2);
	table->attach (*manage (new Gtk::Label ("frames")), 2, 3, 1, 2);
	table->attach (_cut, 1, 2, 2, 3);
	table->attach (_black_out, 1, 2, 3, 4);

	Gtk::RadioButtonGroup g = _whole.get_group ();
	_first.set_group (g);

	g = _black_out.get_group ();
	_cut.set_group (g);

	_n_frames.set_range (1, INT_MAX - 1);
	_n_frames.set_increments (24, 24 * 60);
	if (_film->dcp_frames() > 0) {
		_whole.set_active (false);
		_first.set_active (true);
		_n_frames.set_value (_film->dcp_frames ());
	} else {
		_whole.set_active (true);
		_first.set_active (false);
		_n_frames.set_value (24);
	}

	_black_out.set_active (_film->dcp_trim_action() == BLACK_OUT);
	_cut.set_active (_film->dcp_trim_action() == CUT);

	_whole.signal_toggled().connect (sigc::mem_fun (*this, &DCPRangeDialog::whole_toggled));
	_cut.signal_toggled().connect (sigc::mem_fun (*this, &DCPRangeDialog::cut_toggled));
	_n_frames.signal_value_changed().connect (sigc::mem_fun (*this, &DCPRangeDialog::n_frames_changed));

	get_vbox()->pack_start (*table);

	add_button ("Close", Gtk::RESPONSE_CLOSE);
	show_all_children ();

	set_sensitivity ();
}

void
DCPRangeDialog::whole_toggled ()
{
	set_sensitivity ();
	emit_changed ();
}

void
DCPRangeDialog::set_sensitivity ()
{
	_n_frames.set_sensitive (_first.get_active ());
	_black_out.set_sensitive (_first.get_active ());
	_cut.set_sensitive (_first.get_active ());
}

void
DCPRangeDialog::cut_toggled ()
{
	emit_changed ();
}

void
DCPRangeDialog::n_frames_changed ()
{
	emit_changed ();
}

void
DCPRangeDialog::emit_changed ()
{
	int frames = 0;
	if (!_whole.get_active ()) {
		frames = _n_frames.get_value_as_int ();
	}

	TrimAction action = CUT;
	if (_black_out.get_active ()) {
		action = BLACK_OUT;
	}

	Changed (frames, action);
}