1 #include "bcdisplayinfo.h"
5 #include "edlsession.h"
7 #include "mainsession.h"
8 #include "meterpanel.h"
10 #include "mwindowgui.h"
12 MainSession::MainSession(MWindow *mwindow)
14 this->mwindow = mwindow;
17 // playback_cursor_visible = 0;
18 // is_playing_back = 0;
19 track_highlighted = 0;
20 plugin_highlighted = 0;
21 pluginset_highlighted = 0;
22 vcanvas_highlighted = 0;
23 ccanvas_highlighted = 0;
25 current_operation = NO_OPERATION;
26 drag_pluginservers = new ArrayList<PluginServer*>;
28 drag_assets = new ArrayList<Asset*>;
29 drag_clips = new ArrayList<EDL*>;
30 drag_edits = new ArrayList<Edit*>;
36 MainSession::~MainSession()
38 delete drag_pluginservers;
44 void MainSession::boundaries()
46 lwindow_x = MAX(0, lwindow_x);
47 lwindow_y = MAX(0, lwindow_y);
48 mwindow_x = MAX(0, mwindow_x);
49 mwindow_y = MAX(0, mwindow_y);
50 cwindow_x = MAX(0, cwindow_x);
51 cwindow_y = MAX(0, cwindow_y);
52 vwindow_x = MAX(0, vwindow_x);
53 vwindow_y = MAX(0, vwindow_y);
54 awindow_x = MAX(0, awindow_x);
55 awindow_y = MAX(0, awindow_y);
56 rwindow_x = MAX(0, rwindow_x);
57 rwindow_y = MAX(0, rwindow_y);
58 rmonitor_x = MAX(0, rmonitor_x);
59 rmonitor_y = MAX(0, rmonitor_y);
62 void MainSession::default_window_positions()
64 // Get defaults based on root window size
65 BC_DisplayInfo display_info;
69 int root_w = display_info.get_root_w();
70 int root_h = display_info.get_root_h();
74 int border_bottom = 0;
76 border_left = display_info.get_left_border();
77 border_top = display_info.get_top_border();
78 border_right = display_info.get_right_border();
79 border_bottom = display_info.get_bottom_border();
81 // Wider than 16:9, narrower than dual head
82 if((float)root_w / root_h > 1.8) root_w /= 2;
88 vwindow_w = root_w / 2 - border_left - border_right;
89 vwindow_h = root_h * 6 / 10 - border_top - border_bottom;
91 cwindow_x = root_x + root_w / 2;
93 cwindow_w = vwindow_w;
94 cwindow_h = vwindow_h;
96 ctool_x = cwindow_x + cwindow_w / 2;
97 ctool_y = cwindow_y + cwindow_h / 2;
100 mwindow_y = vwindow_y + vwindow_h + border_top + border_bottom;
101 mwindow_w = root_w * 2 / 3 - border_left - border_right;
102 mwindow_h = root_h - mwindow_y - border_top - border_bottom;
104 awindow_x = mwindow_x + border_left + border_right + mwindow_w;
105 awindow_y = mwindow_y;
106 awindow_w = root_x + root_w - awindow_x - border_left - border_right;
107 awindow_h = mwindow_h;
110 lwindow_w = MeterPanel::get_meters_width(mwindow->edl->session->audio_channels, 1);
115 lwindow_x = root_w - lwindow_w;
116 lwindow_h = mwindow_y;
123 rmonitor_x = rwindow_x + rwindow_w + 10;
124 rmonitor_y = rwindow_y;
125 rmonitor_w = root_w - rmonitor_x;
126 rmonitor_h = rwindow_h;
129 int MainSession::load_defaults(Defaults *defaults)
131 char string[BCTEXTLEN];
137 // Setup main windows
138 default_window_positions();
139 vwindow_x = defaults->get("VWINDOW_X", vwindow_x);
140 vwindow_y = defaults->get("VWINDOW_Y", vwindow_y);
141 vwindow_w = defaults->get("VWINDOW_W", vwindow_w);
142 vwindow_h = defaults->get("VWINDOW_H", vwindow_h);
143 cwindow_x = defaults->get("CWINDOW_X", cwindow_x);
144 cwindow_y = defaults->get("CWINDOW_Y", cwindow_y);
145 cwindow_w = defaults->get("CWINDOW_W", cwindow_w);
146 cwindow_h = defaults->get("CWINDOW_H", cwindow_h);
147 ctool_x = defaults->get("CTOOL_X", ctool_x);
148 ctool_y = defaults->get("CTOOL_Y", ctool_y);
149 mwindow_x = defaults->get("MWINDOW_X", mwindow_x);
150 mwindow_y = defaults->get("MWINDOW_Y", mwindow_y);
151 mwindow_w = defaults->get("MWINDOW_W", mwindow_w);
152 mwindow_h = defaults->get("MWINDOW_H", mwindow_h);
153 lwindow_x = defaults->get("LWINDOW_X", lwindow_x);
154 lwindow_y = defaults->get("LWINDOW_Y", lwindow_y);
155 lwindow_w = defaults->get("LWINDOW_W", lwindow_w);
156 lwindow_h = defaults->get("LWINDOW_H", lwindow_h);
157 awindow_x = defaults->get("AWINDOW_X", awindow_x);
158 awindow_y = defaults->get("AWINDOW_Y", awindow_y);
159 awindow_w = defaults->get("AWINDOW_W", awindow_w);
160 awindow_h = defaults->get("AWINDOW_H", awindow_h);
162 //printf("MainSession::load_defaults 1\n");
165 afolders_w = defaults->get("ABINS_W", 100);
166 rwindow_x = defaults->get("RWINDOW_X", rwindow_x);
167 rwindow_y = defaults->get("RWINDOW_Y", rwindow_y);
168 rwindow_w = defaults->get("RWINDOW_W", rwindow_w);
169 rwindow_h = defaults->get("RWINDOW_H", rwindow_h);
170 rmonitor_x = defaults->get("RMONITOR_X", rmonitor_x);
171 rmonitor_y = defaults->get("RMONITOR_Y", rmonitor_y);
172 rmonitor_w = defaults->get("RMONITOR_W", rmonitor_w);
173 rmonitor_h = defaults->get("RMONITOR_H", rmonitor_h);
175 show_vwindow = defaults->get("SHOW_VWINDOW", 1);
176 show_awindow = defaults->get("SHOW_AWINDOW", 1);
177 show_cwindow = defaults->get("SHOW_CWINDOW", 1);
178 show_lwindow = defaults->get("SHOW_LWINDOW", 0);
181 plugindialog_w = defaults->get("PLUGINDIALOG_W", 510);
182 plugindialog_h = defaults->get("PLUGINDIALOG_H", 415);
183 menueffect_w = defaults->get("MENUEFFECT_W", 580);
184 menueffect_h = defaults->get("MENUEFFECT_H", 350);
190 int MainSession::save_defaults(Defaults *defaults)
194 defaults->update("MWINDOW_X", mwindow_x);
195 defaults->update("MWINDOW_Y", mwindow_y);
196 defaults->update("MWINDOW_W", mwindow_w);
197 defaults->update("MWINDOW_H", mwindow_h);
198 defaults->update("LWINDOW_X", lwindow_x);
199 defaults->update("LWINDOW_Y", lwindow_y);
200 defaults->update("LWINDOW_W", lwindow_w);
201 defaults->update("LWINDOW_H", lwindow_h);
202 defaults->update("VWINDOW_X", vwindow_x);
203 defaults->update("VWINDOW_Y", vwindow_y);
204 defaults->update("VWINDOW_W", vwindow_w);
205 defaults->update("VWINDOW_H", vwindow_h);
206 defaults->update("CWINDOW_X", cwindow_x);
207 defaults->update("CWINDOW_Y", cwindow_y);
208 defaults->update("CWINDOW_W", cwindow_w);
209 defaults->update("CWINDOW_H", cwindow_h);
210 defaults->update("CTOOL_X", ctool_x);
211 defaults->update("CTOOL_Y", ctool_y);
212 defaults->update("AWINDOW_X", awindow_x);
213 defaults->update("AWINDOW_Y", awindow_y);
214 defaults->update("AWINDOW_W", awindow_w);
215 defaults->update("AWINDOW_H", awindow_h);
217 defaults->update("ABINS_W", afolders_w);
218 defaults->update("RMONITOR_X", rmonitor_x);
219 defaults->update("RMONITOR_Y", rmonitor_y);
220 defaults->update("RMONITOR_W", rmonitor_w);
221 defaults->update("RMONITOR_H", rmonitor_h);
222 defaults->update("RWINDOW_X", rwindow_x);
223 defaults->update("RWINDOW_Y", rwindow_y);
224 defaults->update("RWINDOW_W", rwindow_w);
225 defaults->update("RWINDOW_H", rwindow_h);
227 defaults->update("SHOW_VWINDOW", show_vwindow);
228 defaults->update("SHOW_AWINDOW", show_awindow);
229 defaults->update("SHOW_CWINDOW", show_cwindow);
230 defaults->update("SHOW_LWINDOW", show_lwindow);
233 defaults->update("PLUGINDIALOG_W", plugindialog_w);
234 defaults->update("PLUGINDIALOG_H", plugindialog_h);
236 defaults->update("MENUEFFECT_W", menueffect_w);
237 defaults->update("MENUEFFECT_H", menueffect_h);