Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

meterpanel.C

Go to the documentation of this file.
00001 #include "edl.h"
00002 #include "edlsession.h"
00003 #include "language.h"
00004 #include "meterpanel.h"
00005 #include "mwindow.h"
00006 #include "preferences.h"
00007 #include "theme.h"
00008 #include "vframe.h"
00009 
00010 
00011 
00012 MeterPanel::MeterPanel(MWindow *mwindow, 
00013         BC_WindowBase *subwindow, 
00014         int x, 
00015         int y,
00016         int h,
00017         int meter_count,
00018         int use_meters,
00019         int use_recording)
00020 {
00021         this->subwindow = subwindow;
00022         this->mwindow = mwindow;
00023         this->x = x;
00024         this->y = y;
00025         this->h = h;
00026         this->meter_count = meter_count;
00027         this->use_meters = use_meters;
00028         this->use_recording = use_recording;
00029 }
00030 
00031 
00032 MeterPanel::~MeterPanel()
00033 {
00034         meters.remove_all_objects();
00035 }
00036 
00037 int MeterPanel::get_meters_width(int meter_count, int use_meters)
00038 {
00039 //printf("MeterPanel::get_meters_width %d %d\n", BC_Meter::get_title_w(), BC_Meter::get_meter_w());
00040         return use_meters ? 
00041                 (BC_Meter::get_title_w() + BC_Meter::get_meter_w() * meter_count) : 
00042                 0;
00043 }
00044 
00045 void MeterPanel::reposition_window(int x, int y, int h)
00046 {
00047         this->x = x;
00048         this->y = y;
00049         this->h = h;
00050 
00051 //      reset->reposition_window(get_reset_x(), get_reset_y());
00052 
00053 //printf("MeterPanel::reposition_window 0 %d\n", meter_count);
00054 
00055         for(int i = 0; i < meter_count; i++)
00056         {
00057 //printf("MeterPanel::reposition_window 1 %d\n", x);
00058                 meters.values[i]->reposition_window(x, y, get_meter_h());
00059                 x += get_meter_w(i);
00060         }
00061 }
00062 
00063 int MeterPanel::change_status_event()
00064 {
00065 //printf("MeterPanel::change_status_event\n");
00066         return 1;
00067 }
00068 
00069 int MeterPanel::get_reset_x()
00070 {
00071         return x + 
00072                 get_meters_width(meter_count, use_meters) - 
00073                 mwindow->theme->over_button[0]->get_w();
00074 }
00075 
00076 int MeterPanel::get_reset_y()
00077 {
00078         return y + h - mwindow->theme->over_button[0]->get_h();
00079 }
00080 
00081 int MeterPanel::get_meter_w(int number)
00082 {
00083         return (number == 0) ? BC_Meter::get_title_w() + BC_Meter::get_meter_w() : BC_Meter::get_meter_w();
00084 }
00085 
00086 int MeterPanel::get_meter_h()
00087 {
00088         return /* reset->get_y() - this->y - */ this->h - 5;
00089 }
00090 
00091 void MeterPanel::update(double *levels)
00092 {
00093         if(subwindow->get_hidden()) return;
00094 
00095         for(int i = 0; 
00096                 i < meter_count; 
00097                 i++)
00098         {
00099                 meters.values[i]->update(levels[i], levels[i] > 1);
00100         }
00101 }
00102 
00103 void MeterPanel::stop_meters()
00104 {
00105         for(int i = 0; 
00106                 i < meter_count; 
00107                 i++)
00108         {
00109                 meters.values[i]->reset();
00110         }
00111 }
00112 
00113 
00114 int MeterPanel::create_objects()
00115 {
00116         set_meters(meter_count, use_meters);
00117         return 0;
00118 }
00119 
00120 int MeterPanel::set_meters(int meter_count, int use_meters)
00121 {
00122         if(meter_count != meters.total || use_meters != this->use_meters)
00123         {
00124 // Delete old meters
00125                 meters.remove_all_objects();
00126 
00127                 this->meter_count = meter_count;
00128                 this->use_meters = use_meters;
00129 //              if(!use_meters) this->meter_count = 0;
00130 
00131                 if(meter_count)
00132                 {
00133                         int x = this->x;
00134                         int y = this->y;
00135                         int h = get_meter_h();
00136                         for(int i = 0; i < meter_count; i++)
00137                         {
00138                                 MeterMeter *new_meter;
00139                                 subwindow->add_subwindow(new_meter = new MeterMeter(mwindow,
00140                                                 this,
00141                                                 x, 
00142                                                 y, 
00143                                                 h, 
00144                                                 (i == 0)));
00145                                 meters.append(new_meter);
00146                         x += get_meter_w(i);
00147                         }
00148                 }
00149         }
00150 
00151         return 0;
00152 }
00153 
00154 void MeterPanel::reset_meters()
00155 {
00156         for(int i = 0; i < meters.total; i++)
00157                 meters.values[i]->reset_over();
00158 }
00159 
00160 
00161 void MeterPanel::change_format(int mode, int min, int max)
00162 {
00163         for(int i = 0; i < meters.total; i++)
00164         {
00165                 if(use_recording)
00166                         meters.values[i]->change_format(mode, min, 0);
00167                 else
00168                         meters.values[i]->change_format(mode, min, max);
00169         }
00170 }
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 MeterReset::MeterReset(MWindow *mwindow, MeterPanel *panel, int x, int y)
00181  : BC_Button(x, y, mwindow->theme->over_button)
00182 {
00183         this->mwindow = mwindow;
00184         this->panel = panel;
00185 }
00186 
00187 MeterReset::~MeterReset()
00188 {
00189 }
00190         
00191 int MeterReset::handle_event()
00192 {
00193         for(int i = 0; i < panel->meters.total; i++)
00194                 panel->meters.values[i]->reset_over();
00195         return 1;
00196 }
00197 
00198 
00199 
00200 
00201 
00202 MeterMeter::MeterMeter(MWindow *mwindow, 
00203         MeterPanel *panel, 
00204         int x, 
00205         int y, 
00206         int h, 
00207         int titles)
00208  : BC_Meter(x,
00209         y,
00210         METER_VERT,
00211         h,
00212         mwindow->edl->session->min_meter_db, 
00213         panel->use_recording ? 0 : mwindow->edl->session->max_meter_db, 
00214         mwindow->edl->session->meter_format,
00215         titles,
00216         TRACKING_RATE * 10,
00217         TRACKING_RATE)
00218 {
00219         this->mwindow = mwindow;
00220         this->panel = panel;
00221 }
00222 
00223 MeterMeter::~MeterMeter()
00224 {
00225 }
00226 
00227 
00228 int MeterMeter::button_press_event()
00229 {
00230         if(is_event_win() && BC_WindowBase::cursor_inside())
00231         {
00232                 panel->reset_meters();
00233                 mwindow->reset_meters();
00234                 return 1;
00235         }
00236 
00237         return 0;
00238 }
00239 
00240 
00241 
00242 
00243 
00244 MeterShow::MeterShow(MWindow *mwindow, MeterPanel *panel, int x, int y)
00245  : BC_Toggle(x, 
00246                 y, 
00247                 mwindow->theme->get_image_set("meters"), 
00248                 panel->use_meters)
00249 {
00250         this->mwindow = mwindow;
00251         this->panel = panel;
00252         set_tooltip(_("Show meters"));
00253 }
00254 
00255 
00256 MeterShow::~MeterShow()
00257 {
00258 }
00259 
00260 
00261 int MeterShow::handle_event()
00262 {
00263 //printf("MeterShow::MeterShow 1 %d\n",panel->use_meters );
00264         panel->use_meters = get_value();
00265         panel->change_status_event();
00266         return 1;
00267 }

Generated on Sun Jan 8 13:38:57 2006 for Cinelerra-svn by  doxygen 1.4.4