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()
45 void RecordScopeThread::handle_done_event(int result)
47 gui_lock->lock("RecordScopeThread::handle_done_event");
51 record_monitor->window->lock_window("RecordScopeThread::handle_done_event");
52 record_monitor->window->scope_toggle->update(0);
53 record_monitor->window->unlock_window();
56 BC_Window* RecordScopeThread::new_gui()
58 RecordScopeGUI *gui = new RecordScopeGUI(mwindow, record_monitor);
59 gui->create_objects();
64 void RecordScopeThread::process(VFrame *output_frame)
66 if(record_monitor->scope_thread)
68 record_monitor->scope_thread->gui_lock->lock("RecordScopeThread::process");
69 if(record_monitor->scope_thread->scope_gui)
71 RecordScopeGUI *gui = record_monitor->scope_thread->scope_gui;
72 gui->process(output_frame);
77 record_monitor->scope_thread->gui_lock->unlock();
89 RecordScopeGUI::RecordScopeGUI(MWindow *mwindow,
90 RecordMonitor *record_monitor)
91 : ScopeGUI(mwindow->theme,
92 mwindow->session->scope_x,
93 mwindow->session->scope_y,
94 mwindow->session->scope_w,
95 mwindow->session->scope_h,
96 mwindow->preferences->processors)
98 this->mwindow = mwindow;
99 this->record_monitor = record_monitor;
102 RecordScopeGUI::~RecordScopeGUI()
106 void RecordScopeGUI::create_objects()
108 use_hist = mwindow->session->use_hist;
109 use_wave = mwindow->session->use_wave;
110 use_vector = mwindow->session->use_vector;
111 use_hist_parade = mwindow->session->use_hist_parade;
112 use_wave_parade = mwindow->session->use_wave_parade;
113 ScopeGUI::create_objects();
117 void RecordScopeGUI::toggle_event()
119 mwindow->session->use_hist = use_hist;
120 mwindow->session->use_wave = use_wave;
121 mwindow->session->use_vector = use_vector;
122 mwindow->session->use_hist_parade = use_hist_parade;
123 mwindow->session->use_wave_parade = use_wave_parade;
126 int RecordScopeGUI::translation_event()
128 ScopeGUI::translation_event();
129 mwindow->session->scope_x = get_x();
130 mwindow->session->scope_y = get_y();
134 int RecordScopeGUI::resize_event(int w, int h)
136 ScopeGUI::resize_event(w, h);
137 mwindow->session->scope_w = w;
138 mwindow->session->scope_h = h;
146 ScopeEnable::ScopeEnable(MWindow *mwindow, RecordMonitor *record_monitor, int x, int y)
149 mwindow->theme ? mwindow->theme->get_image_set("scope_toggle") : 0,
150 mwindow->session->record_scope)
152 this->record_monitor = record_monitor;
153 this->mwindow = mwindow;
154 set_tooltip(_("View scope"));
157 ScopeEnable::~ScopeEnable()
162 int ScopeEnable::handle_event()
165 mwindow->session->record_scope = get_value();
167 if(mwindow->session->record_scope)
169 record_monitor->scope_thread->start();
173 record_monitor->scope_thread->close_window();
176 lock_window("ScopeEnable::handle_event");