2 #include "edlsession.h"
3 #include "meterpanel.h"
5 #include "preferences.h"
10 #define _(String) gettext(String)
11 #define gettext_noop(String) String
12 #define N_(String) gettext_noop (String)
15 MeterPanel::MeterPanel(MWindow *mwindow,
16 BC_WindowBase *subwindow,
23 this->subwindow = subwindow;
24 this->mwindow = mwindow;
28 this->meter_count = meter_count;
29 this->use_meters = use_meters;
33 MeterPanel::~MeterPanel()
35 meters.remove_all_objects();
38 int MeterPanel::get_meters_width(int meter_count, int use_meters)
40 //printf("MeterPanel::get_meters_width %d %d\n", BC_Meter::get_title_w(), BC_Meter::get_meter_w());
42 (BC_Meter::get_title_w() + BC_Meter::get_meter_w() * meter_count) :
46 void MeterPanel::reposition_window(int x, int y, int h)
52 // reset->reposition_window(get_reset_x(), get_reset_y());
54 //printf("MeterPanel::reposition_window 0 %d\n", meter_count);
56 for(int i = 0; i < meter_count; i++)
58 //printf("MeterPanel::reposition_window 1 %d\n", x);
59 meters.values[i]->reposition_window(x, y, get_meter_h());
64 int MeterPanel::change_status_event()
66 //printf("MeterPanel::change_status_event\n");
70 int MeterPanel::get_reset_x()
73 get_meters_width(meter_count, use_meters) -
74 mwindow->theme->over_button[0]->get_w();
77 int MeterPanel::get_reset_y()
79 return y + h - mwindow->theme->over_button[0]->get_h();
82 int MeterPanel::get_meter_w(int number)
84 return (number == 0) ? BC_Meter::get_title_w() + BC_Meter::get_meter_w() : BC_Meter::get_meter_w();
87 int MeterPanel::get_meter_h()
89 return /* reset->get_y() - this->y - */ this->h - 5;
92 void MeterPanel::update(double *levels)
94 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, float min)
164 for(int i = 0; i < meters.total; i++)
166 meters.values[i]->change_format(mode, min);
178 MeterReset::MeterReset(MWindow *mwindow, MeterPanel *panel, int x, int y)
179 : BC_Button(x, y, mwindow->theme->over_button)
181 this->mwindow = mwindow;
185 MeterReset::~MeterReset()
189 int MeterReset::handle_event()
191 for(int i = 0; i < panel->meters.total; i++)
192 panel->meters.values[i]->reset_over();
200 MeterMeter::MeterMeter(MWindow *mwindow,
210 mwindow->edl->session->min_meter_db,
211 mwindow->edl->session->meter_format,
214 this->mwindow = mwindow;
218 MeterMeter::~MeterMeter()
223 int MeterMeter::button_press_event()
225 if(is_event_win() && BC_WindowBase::cursor_inside())
227 panel->reset_meters();
228 mwindow->reset_meters();
239 MeterShow::MeterShow(MWindow *mwindow, MeterPanel *panel, int x, int y)
242 mwindow->theme->show_meters,
245 this->mwindow = mwindow;
247 set_tooltip(_("Show meters"));
251 MeterShow::~MeterShow()
256 int MeterShow::handle_event()
258 //printf("MeterShow::MeterShow 1 %d\n",panel->use_meters );
259 panel->use_meters = get_value();
260 panel->change_status_event();