1 #include "bcdisplayinfo.h"
5 #include "edlsession.h"
7 #include "mainsession.h"
8 #include "meterpanel.h"
10 #include "mwindowgui.h"
13 MainSession::MainSession(MWindow *mwindow)
15 this->mwindow = mwindow;
18 // playback_cursor_visible = 0;
19 // is_playing_back = 0;
20 track_highlighted = 0;
21 plugin_highlighted = 0;
22 pluginset_highlighted = 0;
23 vcanvas_highlighted = 0;
24 ccanvas_highlighted = 0;
26 current_operation = NO_OPERATION;
27 drag_pluginservers = new ArrayList<PluginServer*>;
29 drag_assets = new ArrayList<Asset*>;
30 drag_auto_gang = new ArrayList<Auto*>;
31 drag_clips = new ArrayList<EDL*>;
32 drag_edits = new ArrayList<Edit*>;
44 MainSession::~MainSession()
46 delete drag_pluginservers;
48 delete drag_auto_gang;
53 void MainSession::boundaries()
55 lwindow_x = MAX(0, lwindow_x);
56 lwindow_y = MAX(0, lwindow_y);
57 mwindow_x = MAX(0, mwindow_x);
58 mwindow_y = MAX(0, mwindow_y);
59 cwindow_x = MAX(0, cwindow_x);
60 cwindow_y = MAX(0, cwindow_y);
61 vwindow_x = MAX(0, vwindow_x);
62 vwindow_y = MAX(0, vwindow_y);
63 awindow_x = MAX(0, awindow_x);
64 awindow_y = MAX(0, awindow_y);
65 gwindow_x = MAX(0, gwindow_x);
66 gwindow_y = MAX(0, gwindow_y);
67 rwindow_x = MAX(0, rwindow_x);
68 rwindow_y = MAX(0, rwindow_y);
69 rmonitor_x = MAX(0, rmonitor_x);
70 rmonitor_y = MAX(0, rmonitor_y);
71 cwindow_controls = CLIP(cwindow_controls, 0, 1);
74 void MainSession::default_window_positions()
76 // Get defaults based on root window size
77 BC_DisplayInfo display_info;
81 int root_w = display_info.get_root_w();
82 int root_h = display_info.get_root_h();
86 int border_bottom = 0;
88 border_left = display_info.get_left_border();
89 border_top = display_info.get_top_border();
90 border_right = display_info.get_right_border();
91 border_bottom = display_info.get_bottom_border();
93 // Wider than 16:9, narrower than dual head
94 if((float)root_w / root_h > 1.8) root_w /= 2;
100 vwindow_w = root_w / 2 - border_left - border_right;
101 vwindow_h = root_h * 6 / 10 - border_top - border_bottom;
103 cwindow_x = root_x + root_w / 2;
105 cwindow_w = vwindow_w;
106 cwindow_h = vwindow_h;
108 ctool_x = cwindow_x + cwindow_w / 2;
109 ctool_y = cwindow_y + cwindow_h / 2;
112 mwindow_y = vwindow_y + vwindow_h + border_top + border_bottom;
113 mwindow_w = root_w * 2 / 3 - border_left - border_right;
114 mwindow_h = root_h - mwindow_y - border_top - border_bottom;
116 awindow_x = mwindow_x + border_left + border_right + mwindow_w;
117 awindow_y = mwindow_y;
118 awindow_w = root_x + root_w - awindow_x - border_left - border_right;
119 awindow_h = mwindow_h;
122 lwindow_w = MeterPanel::get_meters_width(mwindow->edl->session->audio_channels, 1);
127 lwindow_x = root_w - lwindow_w;
128 lwindow_h = mwindow_y;
135 rmonitor_x = rwindow_x + rwindow_w + 10;
136 rmonitor_y = rwindow_y;
137 rmonitor_w = root_w - rmonitor_x;
138 rmonitor_h = rwindow_h;
142 batchrender_x = root_w / 2 - batchrender_w / 2;
143 batchrender_y = root_h / 2 - batchrender_h / 2;
146 int MainSession::load_defaults(Defaults *defaults)
148 // Setup main windows
149 default_window_positions();
150 vwindow_x = defaults->get("VWINDOW_X", vwindow_x);
151 vwindow_y = defaults->get("VWINDOW_Y", vwindow_y);
152 vwindow_w = defaults->get("VWINDOW_W", vwindow_w);
153 vwindow_h = defaults->get("VWINDOW_H", vwindow_h);
156 cwindow_x = defaults->get("CWINDOW_X", cwindow_x);
157 cwindow_y = defaults->get("CWINDOW_Y", cwindow_y);
158 cwindow_w = defaults->get("CWINDOW_W", cwindow_w);
159 cwindow_h = defaults->get("CWINDOW_H", cwindow_h);
161 ctool_x = defaults->get("CTOOL_X", ctool_x);
162 ctool_y = defaults->get("CTOOL_Y", ctool_y);
164 gwindow_x = defaults->get("GWINDOW_X", gwindow_x);
165 gwindow_y = defaults->get("GWINDOW_Y", gwindow_y);
167 mwindow_x = defaults->get("MWINDOW_X", mwindow_x);
168 mwindow_y = defaults->get("MWINDOW_Y", mwindow_y);
169 mwindow_w = defaults->get("MWINDOW_W", mwindow_w);
170 mwindow_h = defaults->get("MWINDOW_H", mwindow_h);
172 lwindow_x = defaults->get("LWINDOW_X", lwindow_x);
173 lwindow_y = defaults->get("LWINDOW_Y", lwindow_y);
174 lwindow_w = defaults->get("LWINDOW_W", lwindow_w);
175 lwindow_h = defaults->get("LWINDOW_H", lwindow_h);
178 awindow_x = defaults->get("AWINDOW_X", awindow_x);
179 awindow_y = defaults->get("AWINDOW_Y", awindow_y);
180 awindow_w = defaults->get("AWINDOW_W", awindow_w);
181 awindow_h = defaults->get("AWINDOW_H", awindow_h);
183 //printf("MainSession::load_defaults 1\n");
186 afolders_w = defaults->get("ABINS_W", 100);
187 rwindow_x = defaults->get("RWINDOW_X", rwindow_x);
188 rwindow_y = defaults->get("RWINDOW_Y", rwindow_y);
189 rwindow_w = defaults->get("RWINDOW_W", rwindow_w);
190 rwindow_h = defaults->get("RWINDOW_H", rwindow_h);
192 rmonitor_x = defaults->get("RMONITOR_X", rmonitor_x);
193 rmonitor_y = defaults->get("RMONITOR_Y", rmonitor_y);
194 rmonitor_w = defaults->get("RMONITOR_W", rmonitor_w);
195 rmonitor_h = defaults->get("RMONITOR_H", rmonitor_h);
197 batchrender_x = defaults->get("BATCHRENDER_X", batchrender_x);
198 batchrender_y = defaults->get("BATCHRENDER_Y", batchrender_y);
199 batchrender_w = defaults->get("BATCHRENDER_W", batchrender_w);
200 batchrender_h = defaults->get("BATCHRENDER_H", batchrender_h);
202 show_vwindow = defaults->get("SHOW_VWINDOW", 1);
203 show_awindow = defaults->get("SHOW_AWINDOW", 1);
204 show_cwindow = defaults->get("SHOW_CWINDOW", 1);
205 show_lwindow = defaults->get("SHOW_LWINDOW", 0);
206 show_gwindow = defaults->get("SHOW_GWINDOW", 0);
208 cwindow_controls = defaults->get("CWINDOW_CONTROLS", cwindow_controls);
210 plugindialog_w = defaults->get("PLUGINDIALOG_W", 510);
211 plugindialog_h = defaults->get("PLUGINDIALOG_H", 415);
212 menueffect_w = defaults->get("MENUEFFECT_W", 580);
213 menueffect_h = defaults->get("MENUEFFECT_H", 350);
215 current_tip = defaults->get("CURRENT_TIP", current_tip);
221 int MainSession::save_defaults(Defaults *defaults)
225 defaults->update("MWINDOW_X", mwindow_x);
226 defaults->update("MWINDOW_Y", mwindow_y);
227 defaults->update("MWINDOW_W", mwindow_w);
228 defaults->update("MWINDOW_H", mwindow_h);
230 defaults->update("LWINDOW_X", lwindow_x);
231 defaults->update("LWINDOW_Y", lwindow_y);
232 defaults->update("LWINDOW_W", lwindow_w);
233 defaults->update("LWINDOW_H", lwindow_h);
235 defaults->update("VWINDOW_X", vwindow_x);
236 defaults->update("VWINDOW_Y", vwindow_y);
237 defaults->update("VWINDOW_W", vwindow_w);
238 defaults->update("VWINDOW_H", vwindow_h);
240 defaults->update("CWINDOW_X", cwindow_x);
241 defaults->update("CWINDOW_Y", cwindow_y);
242 defaults->update("CWINDOW_W", cwindow_w);
243 defaults->update("CWINDOW_H", cwindow_h);
245 defaults->update("CTOOL_X", ctool_x);
246 defaults->update("CTOOL_Y", ctool_y);
248 defaults->update("GWINDOW_X", gwindow_x);
249 defaults->update("GWINDOW_Y", gwindow_y);
251 defaults->update("AWINDOW_X", awindow_x);
252 defaults->update("AWINDOW_Y", awindow_y);
253 defaults->update("AWINDOW_W", awindow_w);
254 defaults->update("AWINDOW_H", awindow_h);
256 defaults->update("ABINS_W", afolders_w);
258 defaults->update("RMONITOR_X", rmonitor_x);
259 defaults->update("RMONITOR_Y", rmonitor_y);
260 defaults->update("RMONITOR_W", rmonitor_w);
261 defaults->update("RMONITOR_H", rmonitor_h);
263 defaults->update("RWINDOW_X", rwindow_x);
264 defaults->update("RWINDOW_Y", rwindow_y);
265 defaults->update("RWINDOW_W", rwindow_w);
266 defaults->update("RWINDOW_H", rwindow_h);
268 defaults->update("BATCHRENDER_X", batchrender_x);
269 defaults->update("BATCHRENDER_Y", batchrender_y);
270 defaults->update("BATCHRENDER_W", batchrender_w);
271 defaults->update("BATCHRENDER_H", batchrender_h);
273 defaults->update("SHOW_VWINDOW", show_vwindow);
274 defaults->update("SHOW_AWINDOW", show_awindow);
275 defaults->update("SHOW_CWINDOW", show_cwindow);
276 defaults->update("SHOW_LWINDOW", show_lwindow);
277 defaults->update("SHOW_GWINDOW", show_gwindow);
279 defaults->update("CWINDOW_CONTROLS", cwindow_controls);
281 defaults->update("PLUGINDIALOG_W", plugindialog_w);
282 defaults->update("PLUGINDIALOG_H", plugindialog_h);
284 defaults->update("MENUEFFECT_W", menueffect_w);
285 defaults->update("MENUEFFECT_H", menueffect_h);
287 defaults->update("CURRENT_TIP", current_tip);