3 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "mainsession.h"
27 #include "preferences.h"
28 #include "recordmonitor.h"
29 #include "recordscopes.h"
31 RecordScopeThread::RecordScopeThread(MWindow *mwindow, RecordMonitor *record_monitor)
34 this->mwindow = mwindow;
35 this->record_monitor = record_monitor;
37 gui_lock = new Mutex("RecordScopeThread::gui_lock");
40 RecordScopeThread::~RecordScopeThread()
46 void RecordScopeThread::handle_done_event(int result)
48 gui_lock->lock("RecordScopeThread::handle_done_event");
52 record_monitor->window->lock_window("RecordScopeThread::handle_done_event");
53 record_monitor->window->scope_toggle->update(0);
54 record_monitor->window->unlock_window();
57 BC_Window* RecordScopeThread::new_gui()
59 RecordScopeGUI *gui = new RecordScopeGUI(mwindow, record_monitor);
60 gui->create_objects();
65 void RecordScopeThread::process(VFrame *output_frame)
67 if(record_monitor->scope_thread)
69 record_monitor->scope_thread->gui_lock->lock("RecordScopeThread::process");
70 if(record_monitor->scope_thread->scope_gui)
72 RecordScopeGUI *gui = record_monitor->scope_thread->scope_gui;
73 gui->process(output_frame);
78 record_monitor->scope_thread->gui_lock->unlock();
90 RecordScopeGUI::RecordScopeGUI(MWindow *mwindow,
91 RecordMonitor *record_monitor)
92 : ScopeGUI(mwindow->theme,
93 mwindow->session->scope_x,
94 mwindow->session->scope_y,
95 mwindow->session->scope_w,
96 mwindow->session->scope_h,
97 mwindow->preferences->processors)
99 this->mwindow = mwindow;
100 this->record_monitor = record_monitor;
103 RecordScopeGUI::~RecordScopeGUI()
107 void RecordScopeGUI::create_objects()
109 use_hist = mwindow->session->use_hist;
110 use_wave = mwindow->session->use_wave;
111 use_vector = mwindow->session->use_vector;
112 use_hist_parade = mwindow->session->use_hist_parade;
113 use_wave_parade = mwindow->session->use_wave_parade;
114 ScopeGUI::create_objects();
118 void RecordScopeGUI::toggle_event()
120 mwindow->session->use_hist = use_hist;
121 mwindow->session->use_wave = use_wave;
122 mwindow->session->use_vector = use_vector;
123 mwindow->session->use_hist_parade = use_hist_parade;
124 mwindow->session->use_wave_parade = use_wave_parade;
127 int RecordScopeGUI::translation_event()
129 ScopeGUI::translation_event();
130 mwindow->session->scope_x = get_x();
131 mwindow->session->scope_y = get_y();
135 int RecordScopeGUI::resize_event(int w, int h)
137 ScopeGUI::resize_event(w, h);
138 mwindow->session->scope_w = w;
139 mwindow->session->scope_h = h;
147 ScopeEnable::ScopeEnable(MWindow *mwindow, RecordMonitor *record_monitor, int x, int y)
150 mwindow->theme ? mwindow->theme->get_image_set("scope_toggle") : 0,
151 mwindow->session->record_scope)
153 this->record_monitor = record_monitor;
154 this->mwindow = mwindow;
155 set_tooltip(_("View scope"));
158 ScopeEnable::~ScopeEnable()
163 int ScopeEnable::handle_event()
166 mwindow->session->record_scope = get_value();
168 if(mwindow->session->record_scope)
170 record_monitor->scope_thread->start();
174 record_monitor->scope_thread->close_window();
177 lock_window("ScopeEnable::handle_event");