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