2 Copyright (C) 2010 Paul Davis
3 Author: Robin Gareus <robin@gareus.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifdef WITH_VIDEOTIMELINE
25 #include <sigc++/bind.h>
27 #include "pbd/file_utils.h"
28 #include "pbd/error.h"
29 #include "pbd/convert.h"
30 #include "gtkmm2ext/utils.h"
31 #include "ardour/profile.h"
32 #include "ardour/template_utils.h"
33 #include "ardour/session.h"
34 #include "ardour_ui.h"
37 #include "add_video_dialog.h"
38 #include "video_monitor.h"
44 using namespace ARDOUR;
46 OpenVideoMonitorDialog::OpenVideoMonitorDialog (Session* s)
47 : ArdourDialog (_("Open Video Monitor"))
49 , showagain_checkbox (_("Don't show this dialog again. (Reset in Edit->Preferences)."))
50 , win_checkbox (_("Restore last window size and position."))
51 , att_checkbox (_("Restore Window Attributes (fullscreen, on-top)."))
52 , osd_checkbox (_("Restore On-Screen-Display settings."))
53 , off_checkbox (_("Restore Time Offset."))
62 , debug_checkbox (_("Enable Debug Mode: Dump Communication to stdout."))
67 set_name ("OpenVideoMonitorDialog");
68 set_position (Gtk::WIN_POS_MOUSE);
70 set_skip_taskbar_hint (true);
71 set_resizable (false);
74 VBox* vbox = manage (new VBox);
75 VBox* options_box = manage (new VBox);
77 l = manage (new Label (_("<b>Video Monitor Window</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
79 vbox->pack_start (*l, false, true);
80 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));
81 l->set_size_request(550,-1);
83 vbox->pack_start (*l, false, true,4);
85 l = manage (new Label (_("<b>Open Video file:</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
87 vbox->pack_start (*l, false, true, 4);
88 vbox->pack_start (filename_label, false, false);
90 l = manage (new Label (_("<b>Session Options</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
92 options_box->pack_start (*l, false, true, 4);
94 options_box->pack_start (win_checkbox, false, true, 2);
95 options_box->pack_start (label_winpos, false, false, 2);
96 options_box->pack_start (label_winsize, false, false, 2);
97 options_box->pack_start (label_letterbox, false, false, 2);
99 options_box->pack_start (att_checkbox, false, true, 2);
100 options_box->pack_start (label_fullscreen, false, false, 2);
101 options_box->pack_start (label_ontop, false, false, 2);
103 options_box->pack_start (osd_checkbox, false, true, 2);
104 options_box->pack_start (label_osd, false, false, 2);
106 options_box->pack_start (off_checkbox, false, true, 2);
107 options_box->pack_start (label_offset, false, false, 2);
109 options_box->pack_start (*(manage (new HSeparator())), true, true, 2);
110 options_box->pack_start (showagain_checkbox, false, true, 2);
113 options_box->pack_start (debug_checkbox, false, true, 2);
114 debug_checkbox.set_active(false);
117 vbox->pack_start (*options_box, false, true);
119 get_vbox()->set_spacing (4);
120 get_vbox()->pack_start (*vbox, false, false);
122 showagain_checkbox.set_active(false);
123 show_all_children ();
124 add_button (Stock::CANCEL, RESPONSE_CANCEL);
125 add_button (Stock::OPEN, RESPONSE_ACCEPT);
128 OpenVideoMonitorDialog::~OpenVideoMonitorDialog ()
133 OpenVideoMonitorDialog::on_show ()
135 label_offset.set_text(string_compose(_("Offset: %1 Video frame(s)"), "-"));
136 label_osd.set_text(string_compose(_("On-Screen-Display: %1"), "-"));
137 label_letterbox.set_text(string_compose(_("Letterbox: %1"), "-"));
138 label_winsize.set_text(string_compose(_("Size: %1"), "-"));
139 label_winpos.set_text(string_compose(_("Position: %1"), "-"));
140 label_fullscreen.set_text(string_compose(_("Fullscreen: %1"), "-"));
141 label_ontop.set_text(string_compose(_("Window on Top: %1"), "-"));
143 #define L_YESNO(v) (atoi(v)?_("Yes"):_("No"))
144 #define L_OSDMODE(i) ( std::string((i)? "":_("(Off)")) \
145 +std::string((i&1)?_("Frame Number "):"") \
146 +std::string((i&2)?_("SMPTE "):"") \
147 +std::string((i&4)?_("Text "):"") \
148 +std::string((i&8)?_("Box "):"") )
150 XMLNode* node = _session->extra_xml (X_("XJSettings"));
152 XMLNodeList nlist = node->children();
153 XMLNodeConstIterator niter;
154 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
155 std::string k = (*niter)->property(X_("k"))->value();
156 std::string v = (*niter)->property(X_("v"))->value();
157 if (k == "osd mode") { label_osd.set_text(string_compose(_("On-Screen-Display: %1"), L_OSDMODE(atoi(v)))); }
158 if (k == "window letterbox") { label_letterbox.set_text(string_compose(_("Letterbox: %1"), L_YESNO(v))); }
159 if (k == "window xy") { label_winpos.set_text(string_compose(_("Position: %1"), v)); }
160 if (k == "window ontop") { label_ontop.set_text(string_compose(_("Window On Top: %1"), L_YESNO(v))); }
161 if (k == "window zoom") { label_fullscreen.set_text(string_compose(_("Fullscreen: %1"), L_YESNO(v))); }
162 if (k == "window size") { label_winsize.set_text(string_compose(_("Size: %1"), v)); }
163 if (k == "set offset") { label_offset.set_text(string_compose(_("Offset: %1 video-frame(s)"), v)); }
171 OpenVideoMonitorDialog::xj_settings_mask ()
174 if (!win_checkbox.get_active()) { rv |= XJ_WINDOW_SIZE | XJ_WINDOW_POS | XJ_LETTERBOX; }
175 if (!att_checkbox.get_active()) { rv |= XJ_WINDOW_ONTOP | XJ_FULLSCREEN; }
176 if (!osd_checkbox.get_active()) { rv |= XJ_OSD; }
177 if (!off_checkbox.get_active()) { rv |= XJ_OFFSET; }
182 OpenVideoMonitorDialog::set_filename (const std::string fn)
184 filename_label.set_text(fn);
188 OpenVideoMonitorDialog::setup_settings_mask (const int f)
190 win_checkbox.set_active((f&XJ_WINDOW_SIZE) == 0);
191 att_checkbox.set_active((f&XJ_WINDOW_ONTOP) == 0);
192 osd_checkbox.set_active((f&XJ_OSD) == 0);
193 off_checkbox.set_active((f&XJ_OFFSET) == 0);
196 #endif /* WITH_VIDEOTIMELINE */