00001 #include "bcdisplayinfo.h"
00002 #include "clip.h"
00003 #include "bchash.h"
00004 #include "edl.h"
00005 #include "edlsession.h"
00006 #include "guicast.h"
00007 #include "mainsession.h"
00008 #include "meterpanel.h"
00009 #include "mwindow.h"
00010 #include "mwindowgui.h"
00011 #include "auto.h"
00012
00013 MainSession::MainSession(MWindow *mwindow)
00014 {
00015 this->mwindow = mwindow;
00016 changes_made = 0;
00017 filename[0] = 0;
00018
00019
00020 track_highlighted = 0;
00021 plugin_highlighted = 0;
00022 pluginset_highlighted = 0;
00023 vcanvas_highlighted = 0;
00024 ccanvas_highlighted = 0;
00025 edit_highlighted = 0;
00026 current_operation = NO_OPERATION;
00027 drag_pluginservers = new ArrayList<PluginServer*>;
00028 drag_plugin = 0;
00029 drag_assets = new ArrayList<Asset*>;
00030 drag_auto_gang = new ArrayList<Auto*>;
00031 drag_clips = new ArrayList<EDL*>;
00032 drag_edits = new ArrayList<Edit*>;
00033 drag_edit = 0;
00034 clip_number = 1;
00035 brender_end = 0;
00036 cwindow_controls = 1;
00037 trim_edits = 0;
00038 gwindow_x = 0;
00039 gwindow_y = 0;
00040 show_gwindow = 0;
00041 current_tip = 0;
00042 cwindow_fullscreen = 0;
00043 rwindow_fullscreen = 0;
00044 vwindow_fullscreen = 0;
00045 }
00046
00047 MainSession::~MainSession()
00048 {
00049 delete drag_pluginservers;
00050 delete drag_assets;
00051 delete drag_auto_gang;
00052 delete drag_clips;
00053 delete drag_edits;
00054 }
00055
00056 void MainSession::boundaries()
00057 {
00058 lwindow_x = MAX(0, lwindow_x);
00059 lwindow_y = MAX(0, lwindow_y);
00060 mwindow_x = MAX(0, mwindow_x);
00061 mwindow_y = MAX(0, mwindow_y);
00062 cwindow_x = MAX(0, cwindow_x);
00063 cwindow_y = MAX(0, cwindow_y);
00064 vwindow_x = MAX(0, vwindow_x);
00065 vwindow_y = MAX(0, vwindow_y);
00066 awindow_x = MAX(0, awindow_x);
00067 awindow_y = MAX(0, awindow_y);
00068 gwindow_x = MAX(0, gwindow_x);
00069 gwindow_y = MAX(0, gwindow_y);
00070 rwindow_x = MAX(0, rwindow_x);
00071 rwindow_y = MAX(0, rwindow_y);
00072 rmonitor_x = MAX(0, rmonitor_x);
00073 rmonitor_y = MAX(0, rmonitor_y);
00074 cwindow_controls = CLIP(cwindow_controls, 0, 1);
00075 }
00076
00077 void MainSession::default_window_positions()
00078 {
00079
00080 BC_DisplayInfo display_info;
00081
00082 int root_x = 0;
00083 int root_y = 0;
00084 int root_w = display_info.get_root_w();
00085 int root_h = display_info.get_root_h();
00086 int border_left = 0;
00087 int border_right = 0;
00088 int border_top = 0;
00089 int border_bottom = 0;
00090
00091 border_left = display_info.get_left_border();
00092 border_top = display_info.get_top_border();
00093 border_right = display_info.get_right_border();
00094 border_bottom = display_info.get_bottom_border();
00095
00096
00097 if((float)root_w / root_h > 1.8) root_w /= 2;
00098
00099
00100
00101 vwindow_x = root_x;
00102 vwindow_y = root_y;
00103 vwindow_w = root_w / 2 - border_left - border_right;
00104 vwindow_h = root_h * 6 / 10 - border_top - border_bottom;
00105
00106 cwindow_x = root_x + root_w / 2;
00107 cwindow_y = root_y;
00108 cwindow_w = vwindow_w;
00109 cwindow_h = vwindow_h;
00110
00111 ctool_x = cwindow_x + cwindow_w / 2;
00112 ctool_y = cwindow_y + cwindow_h / 2;
00113
00114 mwindow_x = root_x;
00115 mwindow_y = vwindow_y + vwindow_h + border_top + border_bottom;
00116 mwindow_w = root_w * 2 / 3 - border_left - border_right;
00117 mwindow_h = root_h - mwindow_y - border_top - border_bottom;
00118
00119 awindow_x = mwindow_x + border_left + border_right + mwindow_w;
00120 awindow_y = mwindow_y;
00121 awindow_w = root_x + root_w - awindow_x - border_left - border_right;
00122 awindow_h = mwindow_h;
00123
00124 ewindow_w = 640;
00125 ewindow_h = 240;
00126
00127 if(mwindow->edl)
00128 lwindow_w = MeterPanel::get_meters_width(mwindow->edl->session->audio_channels, 1);
00129 else
00130 lwindow_w = 100;
00131
00132 lwindow_y = 0;
00133 lwindow_x = root_w - lwindow_w;
00134 lwindow_h = mwindow_y;
00135
00136 rwindow_x = 0;
00137 rwindow_y = 0;
00138 rwindow_h = 500;
00139 rwindow_w = 650;
00140
00141 rmonitor_x = rwindow_x + rwindow_w + 10;
00142 rmonitor_y = rwindow_y;
00143 rmonitor_w = root_w - rmonitor_x;
00144 rmonitor_h = rwindow_h;
00145
00146 batchrender_w = 540;
00147 batchrender_h = 340;
00148 batchrender_x = root_w / 2 - batchrender_w / 2;
00149 batchrender_y = root_h / 2 - batchrender_h / 2;
00150 }
00151
00152 int MainSession::load_defaults(BC_Hash *defaults)
00153 {
00154
00155 default_window_positions();
00156 vwindow_x = defaults->get("VWINDOW_X", vwindow_x);
00157 vwindow_y = defaults->get("VWINDOW_Y", vwindow_y);
00158 vwindow_w = defaults->get("VWINDOW_W", vwindow_w);
00159 vwindow_h = defaults->get("VWINDOW_H", vwindow_h);
00160
00161
00162 cwindow_x = defaults->get("CWINDOW_X", cwindow_x);
00163 cwindow_y = defaults->get("CWINDOW_Y", cwindow_y);
00164 cwindow_w = defaults->get("CWINDOW_W", cwindow_w);
00165 cwindow_h = defaults->get("CWINDOW_H", cwindow_h);
00166
00167 ctool_x = defaults->get("CTOOL_X", ctool_x);
00168 ctool_y = defaults->get("CTOOL_Y", ctool_y);
00169
00170 gwindow_x = defaults->get("GWINDOW_X", gwindow_x);
00171 gwindow_y = defaults->get("GWINDOW_Y", gwindow_y);
00172
00173 mwindow_x = defaults->get("MWINDOW_X", mwindow_x);
00174 mwindow_y = defaults->get("MWINDOW_Y", mwindow_y);
00175 mwindow_w = defaults->get("MWINDOW_W", mwindow_w);
00176 mwindow_h = defaults->get("MWINDOW_H", mwindow_h);
00177
00178 lwindow_x = defaults->get("LWINDOW_X", lwindow_x);
00179 lwindow_y = defaults->get("LWINDOW_Y", lwindow_y);
00180 lwindow_w = defaults->get("LWINDOW_W", lwindow_w);
00181 lwindow_h = defaults->get("LWINDOW_H", lwindow_h);
00182
00183
00184 awindow_x = defaults->get("AWINDOW_X", awindow_x);
00185 awindow_y = defaults->get("AWINDOW_Y", awindow_y);
00186 awindow_w = defaults->get("AWINDOW_W", awindow_w);
00187 awindow_h = defaults->get("AWINDOW_H", awindow_h);
00188
00189 ewindow_w = defaults->get("EWINDOW_W", ewindow_w);
00190 ewindow_h = defaults->get("EWINDOW_H", ewindow_h);
00191
00192
00193
00194
00195 afolders_w = defaults->get("ABINS_W", 100);
00196 rwindow_x = defaults->get("RWINDOW_X", rwindow_x);
00197 rwindow_y = defaults->get("RWINDOW_Y", rwindow_y);
00198 rwindow_w = defaults->get("RWINDOW_W", rwindow_w);
00199 rwindow_h = defaults->get("RWINDOW_H", rwindow_h);
00200
00201 rmonitor_x = defaults->get("RMONITOR_X", rmonitor_x);
00202 rmonitor_y = defaults->get("RMONITOR_Y", rmonitor_y);
00203 rmonitor_w = defaults->get("RMONITOR_W", rmonitor_w);
00204 rmonitor_h = defaults->get("RMONITOR_H", rmonitor_h);
00205
00206 batchrender_x = defaults->get("BATCHRENDER_X", batchrender_x);
00207 batchrender_y = defaults->get("BATCHRENDER_Y", batchrender_y);
00208 batchrender_w = defaults->get("BATCHRENDER_W", batchrender_w);
00209 batchrender_h = defaults->get("BATCHRENDER_H", batchrender_h);
00210
00211 show_vwindow = defaults->get("SHOW_VWINDOW", 1);
00212 show_awindow = defaults->get("SHOW_AWINDOW", 1);
00213 show_cwindow = defaults->get("SHOW_CWINDOW", 1);
00214 show_lwindow = defaults->get("SHOW_LWINDOW", 0);
00215 show_gwindow = defaults->get("SHOW_GWINDOW", 0);
00216
00217 cwindow_controls = defaults->get("CWINDOW_CONTROLS", cwindow_controls);
00218
00219 plugindialog_w = defaults->get("PLUGINDIALOG_W", 510);
00220 plugindialog_h = defaults->get("PLUGINDIALOG_H", 415);
00221 menueffect_w = defaults->get("MENUEFFECT_W", 580);
00222 menueffect_h = defaults->get("MENUEFFECT_H", 350);
00223
00224 current_tip = defaults->get("CURRENT_TIP", current_tip);
00225
00226 boundaries();
00227 return 0;
00228 }
00229
00230 int MainSession::save_defaults(BC_Hash *defaults)
00231 {
00232
00233
00234 defaults->update("MWINDOW_X", mwindow_x);
00235 defaults->update("MWINDOW_Y", mwindow_y);
00236 defaults->update("MWINDOW_W", mwindow_w);
00237 defaults->update("MWINDOW_H", mwindow_h);
00238
00239 defaults->update("LWINDOW_X", lwindow_x);
00240 defaults->update("LWINDOW_Y", lwindow_y);
00241 defaults->update("LWINDOW_W", lwindow_w);
00242 defaults->update("LWINDOW_H", lwindow_h);
00243
00244 defaults->update("VWINDOW_X", vwindow_x);
00245 defaults->update("VWINDOW_Y", vwindow_y);
00246 defaults->update("VWINDOW_W", vwindow_w);
00247 defaults->update("VWINDOW_H", vwindow_h);
00248
00249 defaults->update("CWINDOW_X", cwindow_x);
00250 defaults->update("CWINDOW_Y", cwindow_y);
00251 defaults->update("CWINDOW_W", cwindow_w);
00252 defaults->update("CWINDOW_H", cwindow_h);
00253
00254 defaults->update("CTOOL_X", ctool_x);
00255 defaults->update("CTOOL_Y", ctool_y);
00256
00257 defaults->update("GWINDOW_X", gwindow_x);
00258 defaults->update("GWINDOW_Y", gwindow_y);
00259
00260 defaults->update("AWINDOW_X", awindow_x);
00261 defaults->update("AWINDOW_Y", awindow_y);
00262 defaults->update("AWINDOW_W", awindow_w);
00263 defaults->update("AWINDOW_H", awindow_h);
00264
00265 defaults->update("EWINDOW_W", ewindow_w);
00266 defaults->update("EWINDOW_H", ewindow_h);
00267
00268 defaults->update("ABINS_W", afolders_w);
00269
00270 defaults->update("RMONITOR_X", rmonitor_x);
00271 defaults->update("RMONITOR_Y", rmonitor_y);
00272 defaults->update("RMONITOR_W", rmonitor_w);
00273 defaults->update("RMONITOR_H", rmonitor_h);
00274
00275 defaults->update("RWINDOW_X", rwindow_x);
00276 defaults->update("RWINDOW_Y", rwindow_y);
00277 defaults->update("RWINDOW_W", rwindow_w);
00278 defaults->update("RWINDOW_H", rwindow_h);
00279
00280 defaults->update("BATCHRENDER_X", batchrender_x);
00281 defaults->update("BATCHRENDER_Y", batchrender_y);
00282 defaults->update("BATCHRENDER_W", batchrender_w);
00283 defaults->update("BATCHRENDER_H", batchrender_h);
00284
00285 defaults->update("SHOW_VWINDOW", show_vwindow);
00286 defaults->update("SHOW_AWINDOW", show_awindow);
00287 defaults->update("SHOW_CWINDOW", show_cwindow);
00288 defaults->update("SHOW_LWINDOW", show_lwindow);
00289 defaults->update("SHOW_GWINDOW", show_gwindow);
00290
00291 defaults->update("CWINDOW_CONTROLS", cwindow_controls);
00292
00293 defaults->update("PLUGINDIALOG_W", plugindialog_w);
00294 defaults->update("PLUGINDIALOG_H", plugindialog_h);
00295
00296 defaults->update("MENUEFFECT_W", menueffect_w);
00297 defaults->update("MENUEFFECT_H", menueffect_h);
00298
00299 defaults->update("CURRENT_TIP", current_tip);
00300
00301
00302 return 0;
00303 }