2 #include "edlsession.h"
4 #include "meterpanel.h"
6 #include "preferences.h"
12 MeterPanel::MeterPanel(MWindow *mwindow,
13 BC_WindowBase *subwindow,
21 this->subwindow = subwindow;
22 this->mwindow = mwindow;
26 this->meter_count = meter_count;
27 this->use_meters = use_meters;
28 this->use_recording = use_recording;
32 MeterPanel::~MeterPanel()
34 meters.remove_all_objects();
37 int MeterPanel::get_meters_width(int meter_count, int use_meters)
39 //printf("MeterPanel::get_meters_width %d %d\n", BC_Meter::get_title_w(), BC_Meter::get_meter_w());
41 (BC_Meter::get_title_w() + BC_Meter::get_meter_w() * meter_count) :
45 void MeterPanel::reposition_window(int x, int y, int h)
51 // reset->reposition_window(get_reset_x(), get_reset_y());
53 //printf("MeterPanel::reposition_window 0 %d\n", meter_count);
55 for(int i = 0; i < meter_count; i++)
57 //printf("MeterPanel::reposition_window 1 %d\n", x);
58 meters.values[i]->reposition_window(x, y, get_meter_h());
63 int MeterPanel::change_status_event()
65 //printf("MeterPanel::change_status_event\n");
69 int MeterPanel::get_reset_x()
72 get_meters_width(meter_count, use_meters) -
73 mwindow->theme->over_button[0]->get_w();
76 int MeterPanel::get_reset_y()
78 return y + h - mwindow->theme->over_button[0]->get_h();
81 int MeterPanel::get_meter_w(int number)
83 return (number == 0) ? BC_Meter::get_title_w() + BC_Meter::get_meter_w() : BC_Meter::get_meter_w();
86 int MeterPanel::get_meter_h()
88 return /* reset->get_y() - this->y - */ this->h - 5;
91 void MeterPanel::update(double *levels)
93 if(subwindow->get_hidden()) return;
100 meters.values[i]->update(levels[i], levels[i] > 1);
104 void MeterPanel::stop_meters()
110 meters.values[i]->reset();
115 int MeterPanel::create_objects()
117 set_meters(meter_count, use_meters);
121 int MeterPanel::set_meters(int meter_count, int use_meters)
123 if(meter_count != meters.total || use_meters != this->use_meters)
126 meters.remove_all_objects();
128 this->meter_count = meter_count;
129 this->use_meters = use_meters;
130 // if(!use_meters) this->meter_count = 0;
136 int h = get_meter_h();
137 for(int i = 0; i < meter_count; i++)
139 MeterMeter *new_meter;
140 subwindow->add_subwindow(new_meter = new MeterMeter(mwindow,
146 meters.append(new_meter);
155 void MeterPanel::reset_meters()
157 for(int i = 0; i < meters.total; i++)
158 meters.values[i]->reset_over();
162 void MeterPanel::change_format(int mode, int min, int max)
164 for(int i = 0; i < meters.total; i++)
167 meters.values[i]->change_format(mode, min, 0);
169 meters.values[i]->change_format(mode, min, max);
181 MeterReset::MeterReset(MWindow *mwindow, MeterPanel *panel, int x, int y)
182 : BC_Button(x, y, mwindow->theme->over_button)
184 this->mwindow = mwindow;
188 MeterReset::~MeterReset()
192 int MeterReset::handle_event()
194 for(int i = 0; i < panel->meters.total; i++)
195 panel->meters.values[i]->reset_over();
203 MeterMeter::MeterMeter(MWindow *mwindow,
213 mwindow->edl->session->min_meter_db,
214 panel->use_recording ? 0 : mwindow->edl->session->max_meter_db,
215 mwindow->edl->session->meter_format,
220 this->mwindow = mwindow;
224 MeterMeter::~MeterMeter()
229 int MeterMeter::button_press_event()
231 if(is_event_win() && BC_WindowBase::cursor_inside())
233 panel->reset_meters();
234 mwindow->reset_meters();
245 MeterShow::MeterShow(MWindow *mwindow, MeterPanel *panel, int x, int y)
248 mwindow->theme->get_image_set("meters"),
251 this->mwindow = mwindow;
253 set_tooltip(_("Show meters"));
257 MeterShow::~MeterShow()
262 int MeterShow::handle_event()
264 //printf("MeterShow::MeterShow 1 %d\n",panel->use_meters );
265 panel->use_meters = get_value();
266 panel->change_status_event();