summaryrefslogtreecommitdiff
path: root/gtk2_ardour/open_video_monitor_dialog.cc
blob: 3d4091ff8b2c2f14174c8738770170d8d50b9354 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
    Copyright (C) 2010 Paul Davis
    Author: Robin Gareus <robin@gareus.org>

    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.

*/
#ifdef WITH_VIDEOTIMELINE

#include <cstdio>
#include <cmath>

#include <sigc++/bind.h>

#include "pbd/file_utils.h"
#include "pbd/error.h"
#include "pbd/convert.h"
#include "gtkmm2ext/utils.h"
#include "ardour/profile.h"
#include "ardour/template_utils.h"
#include "ardour/session.h"
#include "ardour_ui.h"

#include "utils.h"
#include "add_video_dialog.h"
#include "video_monitor.h"
#include "i18n.h"

using namespace Gtk;
using namespace std;
using namespace PBD;
using namespace ARDOUR;

OpenVideoMonitorDialog::OpenVideoMonitorDialog (Session* s)
	: ArdourDialog (_("Open Video Monitor"))
	, filename_label ()
	, showagain_checkbox (_("Don't show this dialog again. (Reset in Edit->Preferences)."))
	, win_checkbox (_("Restore last window size and position."))
	, att_checkbox (_("Restore Window Attributes (fullscreen, on-top)."))
	, osd_checkbox (_("Restore On-Screen-Display settings."))
	, off_checkbox (_("Restore Time Offset."))
	, label_winsize ()
	, label_winpos ()
	, label_letterbox ()
	, label_ontop ()
	, label_fullscreen ()
	, label_osd ()
	, label_offset ()
#if 1
	, debug_checkbox (_("Enable Debug Mode: Dump Communication to stdout."))
#endif
{
	set_session (s);

	set_name ("OpenVideoMonitorDialog");
	set_position (Gtk::WIN_POS_MOUSE);
	set_modal (true);
	set_skip_taskbar_hint (true);
	set_resizable (false);

	Gtk::Label* l;
	VBox* vbox = manage (new VBox);
	VBox* options_box = manage (new VBox);

	l = manage (new Label (_("<b>Video Monitor Window</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
	l->set_use_markup ();
	vbox->pack_start (*l, false, true);
	l = manage (new Label (_("The video monitor state can restored to the last known settings for this session. To modify the settings, interact with the monitor itself: Move its window or focus it and use keyboard shortcuts (or the OSX menu bar). Consult the xjadeo documentation for available keyboard shortcuts."), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
	l->set_size_request(550,-1);
	l->set_line_wrap();
	vbox->pack_start (*l, false, true,4);

	l = manage (new Label (_("<b>Open Video file:</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
	l->set_use_markup ();
	vbox->pack_start (*l, false, true, 4);
	vbox->pack_start (filename_label, false, false);

	l = manage (new Label (_("<b>Session Options</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
	l->set_use_markup ();
	options_box->pack_start (*l, false, true, 4);

	options_box->pack_start (win_checkbox, false, true, 2);
	options_box->pack_start (label_winpos, false, false, 2);
	options_box->pack_start (label_winsize, false, false, 2);
	options_box->pack_start (label_letterbox, false, false, 2);

	options_box->pack_start (att_checkbox, false, true, 2);
	options_box->pack_start (label_fullscreen, false, false, 2);
	options_box->pack_start (label_ontop, false, false, 2);

	options_box->pack_start (osd_checkbox, false, true, 2);
	options_box->pack_start (label_osd, false, false, 2);

	options_box->pack_start (off_checkbox, false, true, 2);
	options_box->pack_start (label_offset, false, false, 2);

	options_box->pack_start (*(manage (new  HSeparator())), true, true, 2);
	options_box->pack_start (showagain_checkbox, false, true, 2);

#if 1
	options_box->pack_start (debug_checkbox, false, true, 2);
	debug_checkbox.set_active(false);
#endif

	vbox->pack_start (*options_box, false, true);

	get_vbox()->set_spacing (4);
	get_vbox()->pack_start (*vbox, false, false);

	showagain_checkbox.set_active(false);
	show_all_children ();
	add_button (Stock::CANCEL, RESPONSE_CANCEL);
	add_button (Stock::OPEN, RESPONSE_ACCEPT);
}

OpenVideoMonitorDialog::~OpenVideoMonitorDialog ()
{
}

void
OpenVideoMonitorDialog::on_show ()
{
	label_offset.set_text(string_compose(_("Offset: %1 Video frame(s)"), "-"));
	label_osd.set_text(string_compose(_("On-Screen-Display: %1"), "-"));
	label_letterbox.set_text(string_compose(_("Letterbox: %1"), "-"));
	label_winsize.set_text(string_compose(_("Size: %1"), "-"));
	label_winpos.set_text(string_compose(_("Position: %1"), "-"));
	label_fullscreen.set_text(string_compose(_("Fullscreen: %1"), "-"));
	label_ontop.set_text(string_compose(_("Window on Top: %1"), "-"));

#define L_YESNO(v) (atoi(v)?_("Yes"):_("No"))
#define L_OSDMODE(i) ( std::string((i)? "":_("(Off)")) \
		                  +std::string((i&1)?_("Frame Number "):"") \
                      +std::string((i&2)?_("SMPTE "):"") \
                      +std::string((i&4)?_("Text "):"") \
                      +std::string((i&8)?_("Box "):"") )

	XMLNode* node = _session->extra_xml (X_("XJSettings"));
	if (node) {
		XMLNodeList nlist = node->children();
		XMLNodeConstIterator niter;
		for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
			std::string k = (*niter)->property(X_("k"))->value();
			std::string v = (*niter)->property(X_("v"))->value();
			if (k == "osd mode") { label_osd.set_text(string_compose(_("On-Screen-Display: %1"), L_OSDMODE(atoi(v)))); }
			if (k == "window letterbox") { label_letterbox.set_text(string_compose(_("Letterbox: %1"), L_YESNO(v))); }
			if (k == "window xy") { label_winpos.set_text(string_compose(_("Position: %1"), v)); }
			if (k == "window ontop") { label_ontop.set_text(string_compose(_("Window On Top: %1"), L_YESNO(v))); }
			if (k == "window zoom") { label_fullscreen.set_text(string_compose(_("Fullscreen: %1"), L_YESNO(v))); }
			if (k == "window size") { label_winsize.set_text(string_compose(_("Size: %1"), v)); }
			if (k == "set offset") { label_offset.set_text(string_compose(_("Offset: %1 video-frame(s)"), v)); }
		}
	}

	Dialog::on_show ();
}

int
OpenVideoMonitorDialog::xj_settings_mask ()
{
	int rv =0;
	if (!win_checkbox.get_active()) { rv |= XJ_WINDOW_SIZE | XJ_WINDOW_POS | XJ_LETTERBOX; }
	if (!att_checkbox.get_active()) { rv |= XJ_WINDOW_ONTOP | XJ_FULLSCREEN; }
	if (!osd_checkbox.get_active()) { rv |= XJ_OSD; }
	if (!off_checkbox.get_active()) { rv |= XJ_OFFSET; }
	return rv;
}

void
OpenVideoMonitorDialog::set_filename (const std::string fn)
{
  filename_label.set_text(fn);
}

void
OpenVideoMonitorDialog::setup_settings_mask (const int f)
{
	win_checkbox.set_active((f&XJ_WINDOW_SIZE) == 0);
	att_checkbox.set_active((f&XJ_WINDOW_ONTOP) == 0);
	osd_checkbox.set_active((f&XJ_OSD) == 0);
	off_checkbox.set_active((f&XJ_OFFSET) == 0);
}

#endif /* WITH_VIDEOTIMELINE */