5862b9432f7dfd27b5e7a2a09ea46cca9c959933
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mainsession.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "auto.h"
23 #include "bcdisplayinfo.h"
24 #include "clip.h"
25 #include "bchash.h"
26 #include "edit.h"
27 #include "edits.h"
28 #include "edl.h"
29 #include "edlsession.h"
30 #include "guicast.h"
31 #include "indexable.h"
32 #include "language.h"
33 #include "localsession.h"
34 #include "mainsession.h"
35 #include "meterpanel.h"
36 #include "mwindow.h"
37 #include "mwindowgui.h"
38 #include "plugin.h"
39
40 MainSession::MainSession(MWindow *mwindow)
41 {
42         this->mwindow = mwindow;
43         changes_made = 0;
44         filename[0] = 0;
45 //      playback_cursor_visible = 0;
46 //      is_playing_back = 0;
47         track_highlighted = 0;
48         plugin_highlighted = 0;
49         pluginset_highlighted = 0;
50         edit_highlighted = 0;
51         current_operation = NO_OPERATION;
52         drag_pluginservers = new ArrayList<PluginServer*>;
53         drag_plugin = 0;
54         drag_assets = new ArrayList<Indexable*>;
55         drag_auto_gang = new ArrayList<Auto*>;
56         drag_clips = new ArrayList<EDL*>;
57         drag_edits = new ArrayList<Edit*>;
58         drag_edit = 0;
59         drag_group = 0;
60         drag_group_edit = 0;
61         drag_group_position = 0;
62         drag_group_first_track = 0;
63         group_number = 1;
64         clip_number = 1;
65         brender_end = 0;
66         cwindow_controls = 1;
67         trim_edits = 0;
68         current_tip = -1;
69         selected_zwindow = -1;
70         actual_frame_rate = 0;
71         title_bar_alpha = 0;
72         window_config = 0;
73         a_x11_host[0] = 0;
74         b_x11_host[0] = 0;
75         record_scope = 0;
76
77         drag_auto = 0;
78         drag_button = 0;
79         drag_handle = 0;
80         drag_position = 0;
81         drag_start = 0;
82         drag_origin_x = drag_origin_y = 0;
83         drag_start_percentage = 0;
84         drag_start_position = 0;
85         cwindow_output_x = cwindow_output_y = 0;
86         batchrender_x = batchrender_y = batchrender_w = batchrender_h = 0;
87         lwindow_x = lwindow_y = lwindow_w = lwindow_h = 0;
88         mwindow_x = mwindow_y = mwindow_w = mwindow_h = 0;
89         vwindow_x = vwindow_y = vwindow_w = vwindow_h = 0;
90         cwindow_x = cwindow_y = cwindow_w = cwindow_h = 0;
91         ctool_x = ctool_y = 0;
92         awindow_x = awindow_y = awindow_w = awindow_h = 0;
93         bwindow_w = bwindow_h = 0;
94         rmonitor_x = rmonitor_y = rmonitor_w = rmonitor_h = 0;
95         rwindow_x = rwindow_y = rwindow_w = rwindow_h = 0;
96         gwindow_x = gwindow_y = 0;
97         cswindow_x = cswindow_y = cswindow_w = cswindow_h = 0;
98         swindow_x = swindow_y = swindow_w = swindow_h = 0;
99         ewindow_w = ewindow_h = 0;
100         channels_x = channels_y = 0;
101         picture_x = picture_y = 0;
102         scope_x = scope_y = scope_w = scope_h = 0;
103         histogram_x = histogram_y = histogram_w = histogram_h = 0;
104         use_hist = 0;
105         use_wave = 0;
106         use_vector = 0;
107         use_hist_parade = 0;
108         use_wave_parade = 0;
109         afolders_w = 0;
110         show_vwindow = show_awindow = show_cwindow = show_gwindow = show_lwindow = 0;
111         plugindialog_w = plugindialog_h = 0;
112 //      presetdialog_w = presetdialog_h = 0;
113         keyframedialog_w = keyframedialog_h = 0;
114         keyframedialog_column1 = 0;
115         keyframedialog_column2 = 0;
116         keyframedialog_all = 0;
117         menueffect_w = menueffect_h = 0;
118         transitiondialog_w = transitiondialog_h = 0;
119 }
120
121 MainSession::~MainSession()
122 {
123         delete drag_pluginservers;
124         delete drag_assets;
125         delete drag_auto_gang;
126         delete drag_clips;
127         delete drag_edits;
128         if( drag_group )
129                 drag_group->remove_user();
130 }
131
132 void MainSession::boundaries()
133 {
134         lwindow_x = MAX(0, lwindow_x);
135         lwindow_y = MAX(0, lwindow_y);
136         mwindow_x = MAX(0, mwindow_x);
137         mwindow_y = MAX(0, mwindow_y);
138         cwindow_x = MAX(0, cwindow_x);
139         cwindow_y = MAX(0, cwindow_y);
140         vwindow_x = MAX(0, vwindow_x);
141         vwindow_y = MAX(0, vwindow_y);
142         awindow_x = MAX(0, awindow_x);
143         awindow_y = MAX(0, awindow_y);
144         gwindow_x = MAX(0, gwindow_x);
145         gwindow_y = MAX(0, gwindow_y);
146         rwindow_x = MAX(0, rwindow_x);
147         rwindow_y = MAX(0, rwindow_y);
148         rmonitor_x = MAX(0, rmonitor_x);
149         rmonitor_y = MAX(0, rmonitor_y);
150         CLAMP(cwindow_controls, 0, 1);
151 }
152
153 void MainSession::save_x11_host(int play_config, const char *x11_host)
154 {
155         strcpy(!play_config ? a_x11_host : b_x11_host, x11_host);
156 }
157
158 // set default x11 host, window_config, return screens
159 int MainSession::set_default_x11_host(int win_config)
160 {
161         if( win_config < 0 ) win_config = window_config;
162         const char *x11_host = win_config!=1 ? a_x11_host : b_x11_host;
163         BC_DisplayInfo display_info(x11_host,0);
164         int screen = display_info.get_screen();
165         if( screen < 0 && strcmp(a_x11_host, b_x11_host) ) {
166                 win_config = win_config==1 ? 0 : 1;
167                 x11_host = win_config!=1 ? a_x11_host : b_x11_host;
168                 display_info.init_window(x11_host,0);
169                 screen = display_info.get_screen();
170         }
171         if( screen < 0 ) {
172                 x11_host = "";
173                 display_info.init_window(x11_host,1);
174         }
175         int screens = 1;
176         if( display_info.get_screen_count() > 1 )
177                 screens = strcmp(a_x11_host, b_x11_host) != 0 ? 2 : 1;
178         window_config = win_config;
179         BC_Window::set_default_x11_host(x11_host);
180         return screens;
181 }
182
183 void MainSession::default_window_positions(int window_config)
184 {
185 // 0 - all windows on a, playback_config a
186 // 1 - all windows on b, playback_config b
187 // 2 - all windows on a, except composer on b, playback_config b
188         int screens = set_default_x11_host(window_config);
189         mwindow->set_screens(screens);
190
191         BC_DisplayInfo display_info(BC_Window::get_default_x11_host());
192 // Get defaults based on root window size
193         int root_x = 0;
194         int root_y = 0;
195         int root_w = display_info.get_root_w();
196         int root_h = display_info.get_root_h();
197
198         int border_left = display_info.get_left_border();
199         int border_right = display_info.get_right_border();
200         int border_top = display_info.get_top_border();
201         int border_bottom = display_info.get_bottom_border();
202
203         int dual_head = screens > 1 ? 1 : 0;
204         int left_w = 0, left_h = 0, right_w = 0;
205         int xin_screens = display_info.get_xinerama_screens();
206         if( xin_screens > 1 ) {
207                 dual_head = 1;
208                 int x, y, w, h;
209                 for( int s=0; s<xin_screens; ++s ) {
210                         if( display_info.xinerama_geometry(s, x, y, w, h) )
211                                 continue;
212                         if( !y && !x ) {
213                                 left_w = w;  left_h = h;
214                                 break;
215                         }
216                 }
217                 if( left_w > 0 ) {
218                         for( int s=0; s<xin_screens; ++s ) {
219                                 if( display_info.xinerama_geometry(s, x, y, w, h) )
220                                         continue;
221                                 if( !y && x == left_w ) {
222                                         right_w = w;
223                                         screens = 2;
224                                         break;
225                                 }
226                         }
227                         if( window_config == 1 ) {
228                                 root_x = left_w;
229                                 root_w = right_w;
230                         }
231                         else {
232                                 root_w = left_w;
233                                 root_h = left_h;
234                         }
235                 }
236         }
237 // Wider than 16:9, narrower than dual head
238         else if( screens < 2 && (float)root_w / root_h > 1.8 ) {
239                 dual_head = 1;
240                 switch( root_h ) {
241                 case 600:  right_w = 800;   break;
242                 case 720:  right_w = 1280;  break;
243                 case 1024: right_w = 1280;  break;
244                 case 1200: right_w = 1600;  break;
245                 case 1080: right_w = 1920;  break;
246                 default:   right_w = root_w/2;  break;
247                 }
248                 if( window_config == 1 ) {
249                         root_x = root_w - right_w;
250                         root_w = right_w;
251                 }
252                 else {
253                         // use same aspect ratio to compute left height
254                         root_w -= right_w;
255                         root_h = (root_w*root_h) / right_w;
256                 }
257         }
258
259         vwindow_x = root_x;
260         vwindow_y = root_y;
261         vwindow_w = root_w / 2 - border_left - border_right;
262         vwindow_h = root_h * 6 / 10 - border_top - border_bottom;
263
264         int b_root_w = root_w;
265         int b_root_h = root_h;
266         if( !dual_head || window_config != 2 ) {
267                 cwindow_x = root_x + root_w / 2;
268                 cwindow_y = root_y;
269                 cwindow_w = vwindow_w;
270                 cwindow_h = vwindow_h;
271         }
272         else {
273 // Get defaults based on root window size
274                 BC_DisplayInfo b_display_info(b_x11_host);
275                 b_root_w = b_display_info.get_root_w();
276                 b_root_h = b_display_info.get_root_h();
277                 cwindow_x = xS(50);
278                 cwindow_y = yS(50);
279                 cwindow_w = b_root_w-xS(100);
280                 cwindow_h = b_root_h-yS(100);
281         }
282
283         ctool_x = cwindow_x + cwindow_w / 2;
284         ctool_y = cwindow_y + cwindow_h / 2;
285
286         mwindow_x = root_x;
287         mwindow_y = vwindow_y + vwindow_h + border_top + border_bottom;
288         mwindow_w = root_w * 2 / 3 - border_left - border_right;
289         mwindow_h = root_h - mwindow_y - border_top - border_bottom;
290
291         awindow_x = mwindow_x + border_left + border_right + mwindow_w;
292         awindow_y = mwindow_y;
293         awindow_w = root_x + root_w - awindow_x - border_left - border_right;
294         awindow_h = mwindow_h;
295
296         bwindow_w = xS(600);
297         bwindow_h = yS(360);
298
299         ewindow_w = xS(640);
300         ewindow_h = yS(240);
301
302         channels_x = 0;
303         channels_y = 0;
304         picture_x = 0;
305         picture_y = 0;
306         scope_x = 0;
307         scope_y = 0;
308         scope_w = xS(640);
309         scope_h = yS(320);
310         histogram_x = 0;
311         histogram_y = 0;
312         histogram_w = xS(320);
313         histogram_h = yS(480);
314         record_scope = 0;
315         use_hist = 1;
316         use_wave = 1;
317         use_vector = 1;
318         use_hist_parade = 1;
319         use_wave_parade = 1;
320
321         if(mwindow->edl)
322                 lwindow_w = MeterPanel::get_meters_width(mwindow->theme,
323                         mwindow->edl->session->audio_channels,
324                         1);
325         else
326                 lwindow_w = xS(100);
327
328         lwindow_y = 0;
329         lwindow_x = root_w - lwindow_w;
330         lwindow_h = mwindow_y;
331
332         rwindow_x = root_x;
333         rwindow_y = root_y;
334         rwindow_h = yS(500);
335         rwindow_w = xS(650);
336
337         cswindow_x = root_x;
338         cswindow_y = root_y;
339         cswindow_w = xS(1280);
340         cswindow_h = yS(600);
341
342         if( !dual_head || window_config != 2 ) {
343                 rmonitor_x = rwindow_x + rwindow_w + xS(10);
344                 rmonitor_y = rwindow_y;
345                 rmonitor_w = root_x + root_w - rmonitor_x;
346                 rmonitor_h = rwindow_h;
347         }
348         else {
349                 rmonitor_x = cswindow_x = xS(50);
350                 rmonitor_y = cswindow_y = yS(50);
351                 rmonitor_w = b_root_w-xS(100);
352                 rmonitor_h = b_root_h-yS(100);
353                 if( cswindow_w < rmonitor_w ) cswindow_w = rmonitor_w;
354                 if( cswindow_h < rmonitor_h ) cswindow_h = rmonitor_h;
355         }
356
357         swindow_x = root_x;
358         swindow_y = root_y;
359         swindow_w = xS(600);
360         swindow_h = yS(400);
361
362         batchrender_w = xS(750);
363         batchrender_h = yS(400);
364         batchrender_x = root_w / 2 - batchrender_w / 2;
365         batchrender_y = root_h / 2 - batchrender_h / 2;
366 }
367
368 int MainSession::load_defaults(BC_Hash *defaults)
369 {
370 // Setup main windows
371         char *a_host = defaults->get("A_X11_HOST", a_x11_host);
372         if( a_host != a_x11_host )
373                 strcpy(a_x11_host, defaults->get("A_X11_HOST", a_x11_host));
374         char *b_host = defaults->get("B_X11_HOST", b_x11_host);
375         if( b_host != b_x11_host )
376                 strcpy(b_x11_host, defaults->get("B_X11_HOST", b_x11_host));
377         window_config = defaults->get("WINDOW_CONFIG", window_config);
378         default_window_positions(window_config);
379
380         vwindow_x = defaults->get("VWINDOW_X", vwindow_x);
381         vwindow_y = defaults->get("VWINDOW_Y", vwindow_y);
382         vwindow_w = defaults->get("VWINDOW_W", vwindow_w);
383         vwindow_h = defaults->get("VWINDOW_H", vwindow_h);
384
385
386         cwindow_x = defaults->get("CWINDOW_X", cwindow_x);
387         cwindow_y = defaults->get("CWINDOW_Y", cwindow_y);
388         cwindow_w = defaults->get("CWINDOW_W", cwindow_w);
389         cwindow_h = defaults->get("CWINDOW_H", cwindow_h);
390
391         ctool_x = defaults->get("CTOOL_X", ctool_x);
392         ctool_y = defaults->get("CTOOL_Y", ctool_y);
393
394         gwindow_x = defaults->get("GWINDOW_X", gwindow_x);
395         gwindow_y = defaults->get("GWINDOW_Y", gwindow_y);
396
397         mwindow_x = defaults->get("MWINDOW_X", mwindow_x);
398         mwindow_y = defaults->get("MWINDOW_Y", mwindow_y);
399         mwindow_w = defaults->get("MWINDOW_W", mwindow_w);
400         mwindow_h = defaults->get("MWINDOW_H", mwindow_h);
401
402         lwindow_x = defaults->get("LWINDOW_X", lwindow_x);
403         lwindow_y = defaults->get("LWINDOW_Y", lwindow_y);
404         lwindow_w = defaults->get("LWINDOW_W", lwindow_w);
405         lwindow_h = defaults->get("LWINDOW_H", lwindow_h);
406
407
408         awindow_x = defaults->get("AWINDOW_X", awindow_x);
409         awindow_y = defaults->get("AWINDOW_Y", awindow_y);
410         awindow_w = defaults->get("AWINDOW_W", awindow_w);
411         awindow_h = defaults->get("AWINDOW_H", awindow_h);
412
413         ewindow_w = defaults->get("EWINDOW_W", ewindow_w);
414         ewindow_h = defaults->get("EWINDOW_H", ewindow_h);
415
416         channels_x = defaults->get("CHANNELS_X", channels_x);
417         channels_y = defaults->get("CHANNELS_Y", channels_y);
418         picture_x = defaults->get("PICTURE_X", picture_x);
419         picture_y = defaults->get("PICTURE_Y", picture_y);
420         scope_x = defaults->get("SCOPE_X", scope_x);
421         scope_y = defaults->get("SCOPE_Y", scope_y);
422         scope_w = defaults->get("SCOPE_W", scope_w);
423         scope_h = defaults->get("SCOPE_H", scope_h);
424         histogram_x = defaults->get("HISTOGRAM_X", histogram_x);
425         histogram_y = defaults->get("HISTOGRAM_Y", histogram_y);
426         histogram_w = defaults->get("HISTOGRAM_W", histogram_w);
427         histogram_h = defaults->get("HISTOGRAM_H", histogram_h);
428         record_scope = defaults->get("RECORD_SCOPE", record_scope);
429         use_hist = defaults->get("USE_HIST", use_hist);
430         use_wave = defaults->get("USE_WAVE", use_wave);
431         use_vector = defaults->get("USE_VECTOR", use_vector);
432         use_hist_parade = defaults->get("USE_HIST_PARADE", use_hist_parade);
433         use_wave_parade = defaults->get("USE_WAVE_PARADE", use_wave_parade);
434
435 //printf("MainSession::load_defaults 1\n");
436
437 // Other windows
438         afolders_w = defaults->get("ABINS_W", xS(200));
439
440         bwindow_w = defaults->get("BWINDOW_W", bwindow_w);
441         bwindow_h = defaults->get("BWINDOW_H", bwindow_h);
442
443         rwindow_x = defaults->get("RWINDOW_X", rwindow_x);
444         rwindow_y = defaults->get("RWINDOW_Y", rwindow_y);
445         rwindow_w = defaults->get("RWINDOW_W", rwindow_w);
446         rwindow_h = defaults->get("RWINDOW_H", rwindow_h);
447
448         cswindow_x = defaults->get("CSWINDOW_X", cswindow_x);
449         cswindow_y = defaults->get("CSWINDOW_Y", cswindow_y);
450         cswindow_w = defaults->get("CSWINDOW_W", cswindow_w);
451         cswindow_h = defaults->get("CSWINDOW_H", cswindow_h);
452
453         swindow_x = defaults->get("SWINDOW_X", swindow_x);
454         swindow_y = defaults->get("SWINDOW_Y", swindow_y);
455         swindow_w = defaults->get("SWINDOW_W", swindow_w);
456         swindow_h = defaults->get("SWINDOW_H", swindow_h);
457
458         rmonitor_x = defaults->get("RMONITOR_X", rmonitor_x);
459         rmonitor_y = defaults->get("RMONITOR_Y", rmonitor_y);
460         rmonitor_w = defaults->get("RMONITOR_W", rmonitor_w);
461         rmonitor_h = defaults->get("RMONITOR_H", rmonitor_h);
462
463         batchrender_x = defaults->get("BATCHRENDER_X", batchrender_x);
464         batchrender_y = defaults->get("BATCHRENDER_Y", batchrender_y);
465         batchrender_w = defaults->get("BATCHRENDER_W", batchrender_w);
466         batchrender_h = defaults->get("BATCHRENDER_H", batchrender_h);
467
468         show_vwindow = defaults->get("SHOW_VWINDOW", 1);
469         show_awindow = defaults->get("SHOW_AWINDOW", 1);
470         show_cwindow = defaults->get("SHOW_CWINDOW", 1);
471         show_lwindow = defaults->get("SHOW_LWINDOW", 0);
472         show_gwindow = defaults->get("SHOW_GWINDOW", 0);
473
474         cwindow_controls = defaults->get("CWINDOW_CONTROLS", cwindow_controls);
475
476         plugindialog_w = defaults->get("PLUGINDIALOG_W", xS(510));
477         plugindialog_h = defaults->get("PLUGINDIALOG_H", yS(415));
478 //      presetdialog_w = defaults->get("PRESETDIALOG_W", xS(510));
479 //      presetdialog_h = defaults->get("PRESETDIALOG_H", yS(415));
480         keyframedialog_w = defaults->get("KEYFRAMEDIALOG_W", xS(320));
481         keyframedialog_h = defaults->get("KEYFRAMEDIALOG_H", yS(415));
482         keyframedialog_column1 = defaults->get("KEYFRAMEDIALOG_COLUMN1", xS(150));
483         keyframedialog_column2 = defaults->get("KEYFRAMEDIALOG_COLUMN2", xS(100));
484         keyframedialog_all = defaults->get("KEYFRAMEDIALOG_ALL", 0);
485         menueffect_w = defaults->get("MENUEFFECT_W", xS(580));
486         menueffect_h = defaults->get("MENUEFFECT_H", yS(350));
487         transitiondialog_w = defaults->get("TRANSITIONDIALOG_W", xS(320));
488         transitiondialog_h = defaults->get("TRANSITIONDIALOG_H", yS(512));
489
490         current_tip = defaults->get("CURRENT_TIP", current_tip);
491         actual_frame_rate = defaults->get("ACTUAL_FRAME_RATE", (float)-1);
492         title_bar_alpha = defaults->get("TITLE_BAR_ALPHA", (float)1);
493
494         boundaries();
495         return 0;
496 }
497
498 int MainSession::save_defaults(BC_Hash *defaults)
499 {
500         defaults->update("A_X11_HOST", a_x11_host);
501         defaults->update("B_X11_HOST", b_x11_host);
502         defaults->update("WINDOW_CONFIG", window_config);
503 // Window positions
504         defaults->update("MWINDOW_X", mwindow_x);
505         defaults->update("MWINDOW_Y", mwindow_y);
506         defaults->update("MWINDOW_W", mwindow_w);
507         defaults->update("MWINDOW_H", mwindow_h);
508
509         defaults->update("LWINDOW_X", lwindow_x);
510         defaults->update("LWINDOW_Y", lwindow_y);
511         defaults->update("LWINDOW_W", lwindow_w);
512         defaults->update("LWINDOW_H", lwindow_h);
513
514         defaults->update("VWINDOW_X", vwindow_x);
515         defaults->update("VWINDOW_Y", vwindow_y);
516         defaults->update("VWINDOW_W", vwindow_w);
517         defaults->update("VWINDOW_H", vwindow_h);
518
519         defaults->update("CWINDOW_X", cwindow_x);
520         defaults->update("CWINDOW_Y", cwindow_y);
521         defaults->update("CWINDOW_W", cwindow_w);
522         defaults->update("CWINDOW_H", cwindow_h);
523
524         defaults->update("CTOOL_X", ctool_x);
525         defaults->update("CTOOL_Y", ctool_y);
526
527         defaults->update("GWINDOW_X", gwindow_x);
528         defaults->update("GWINDOW_Y", gwindow_y);
529
530         defaults->update("AWINDOW_X", awindow_x);
531         defaults->update("AWINDOW_Y", awindow_y);
532         defaults->update("AWINDOW_W", awindow_w);
533         defaults->update("AWINDOW_H", awindow_h);
534
535         defaults->update("BWINDOW_W", bwindow_w);
536         defaults->update("BWINDOW_H", bwindow_h);
537
538         defaults->update("EWINDOW_W", ewindow_w);
539         defaults->update("EWINDOW_H", ewindow_h);
540
541         defaults->update("CHANNELS_X", channels_x);
542         defaults->update("CHANNELS_Y", channels_y);
543         defaults->update("PICTURE_X", picture_x);
544         defaults->update("PICTURE_Y", picture_y);
545         defaults->update("SCOPE_X", scope_x);
546         defaults->update("SCOPE_Y", scope_y);
547         defaults->update("SCOPE_W", scope_w);
548         defaults->update("SCOPE_H", scope_h);
549         defaults->update("HISTOGRAM_X", histogram_x);
550         defaults->update("HISTOGRAM_Y", histogram_y);
551         defaults->update("HISTOGRAM_W", histogram_w);
552         defaults->update("HISTOGRAM_H", histogram_h);
553         defaults->update("RECORD_SCOPE", record_scope);
554         defaults->update("USE_HIST", use_hist);
555         defaults->update("USE_WAVE", use_wave);
556         defaults->update("USE_VECTOR", use_vector);
557         defaults->update("USE_HIST_PARADE", use_hist_parade);
558         defaults->update("USE_WAVE_PARADE", use_wave_parade);
559
560         defaults->update("ABINS_W", afolders_w);
561
562         defaults->update("RMONITOR_X", rmonitor_x);
563         defaults->update("RMONITOR_Y", rmonitor_y);
564         defaults->update("RMONITOR_W", rmonitor_w);
565         defaults->update("RMONITOR_H", rmonitor_h);
566
567         defaults->update("RWINDOW_X", rwindow_x);
568         defaults->update("RWINDOW_Y", rwindow_y);
569         defaults->update("RWINDOW_W", rwindow_w);
570         defaults->update("RWINDOW_H", rwindow_h);
571
572         defaults->update("CSWINDOW_X", cswindow_x);
573         defaults->update("CSWINDOW_Y", cswindow_y);
574         defaults->update("CSWINDOW_W", cswindow_w);
575         defaults->update("CSWINDOW_H", cswindow_h);
576
577         defaults->update("SWINDOW_X", swindow_x);
578         defaults->update("SWINDOW_Y", swindow_y);
579         defaults->update("SWINDOW_W", swindow_w);
580         defaults->update("SWINDOW_H", swindow_h);
581
582         defaults->update("BATCHRENDER_X", batchrender_x);
583         defaults->update("BATCHRENDER_Y", batchrender_y);
584         defaults->update("BATCHRENDER_W", batchrender_w);
585         defaults->update("BATCHRENDER_H", batchrender_h);
586
587         defaults->update("SHOW_VWINDOW", show_vwindow);
588         defaults->update("SHOW_AWINDOW", show_awindow);
589         defaults->update("SHOW_CWINDOW", show_cwindow);
590         defaults->update("SHOW_LWINDOW", show_lwindow);
591         defaults->update("SHOW_GWINDOW", show_gwindow);
592
593         defaults->update("CWINDOW_CONTROLS", cwindow_controls);
594
595         defaults->update("PLUGINDIALOG_W", plugindialog_w);
596         defaults->update("PLUGINDIALOG_H", plugindialog_h);
597 //      defaults->update("PRESETDIALOG_W", presetdialog_w);
598 //      defaults->update("PRESETDIALOG_H", presetdialog_h);
599         defaults->update("KEYFRAMEDIALOG_W", keyframedialog_w);
600         defaults->update("KEYFRAMEDIALOG_H", keyframedialog_h);
601         defaults->update("KEYFRAMEDIALOG_COLUMN1", keyframedialog_column1);
602         defaults->update("KEYFRAMEDIALOG_COLUMN2", keyframedialog_column2);
603         defaults->update("KEYFRAMEDIALOG_ALL", keyframedialog_all);
604
605         defaults->update("MENUEFFECT_W", menueffect_w);
606         defaults->update("MENUEFFECT_H", menueffect_h);
607
608         defaults->update("TRANSITIONDIALOG_W", transitiondialog_w);
609         defaults->update("TRANSITIONDIALOG_H", transitiondialog_h);
610
611         defaults->update("ACTUAL_FRAME_RATE", actual_frame_rate);
612         defaults->update("TITLE_BAR_ALPHA", title_bar_alpha);
613         defaults->update("CURRENT_TIP", current_tip);
614
615
616         return 0;
617 }
618
619 Track *MainSession::drag_handle_track()
620 {
621         Track *track = 0;
622         switch( current_operation ) {
623         case DRAG_EDITHANDLE1:
624         case DRAG_EDITHANDLE2:
625                 track = drag_edit->edits->track;
626                 break;
627         case DRAG_PLUGINHANDLE1:
628         case DRAG_PLUGINHANDLE2:
629                 track = drag_plugin->edits->track;
630                 break;
631         }
632         return track;
633 }
634
635 void MainSession::update_clip_number()
636 {
637         int clip_no = 0;
638         for( int i=mwindow->edl->clips.size(); --i>=0; ) {
639                 EDL *clip_edl = mwindow->edl->clips[i];
640                 int no = 0;
641                 if( sscanf(clip_edl->local_session->clip_title,_("Clip %d"),&no) == 1 )
642                         if( no > clip_no ) clip_no = no;
643         }
644         clip_number = clip_no+1;
645 }
646
647 int MainSession::load_file(const char *path)
648 {
649         int ret = 1;
650         FILE *fp = fopen(path,"r");
651         if( fp ) {
652                 BC_Hash defaults;
653                 defaults.load_file(fp);
654                 load_defaults(&defaults);
655                 fclose(fp);
656                 ret = 0;
657         }
658         return ret;
659 }
660
661 int MainSession::save_file(const char *path)
662 {
663         int ret = 1;
664         FILE *fp = fopen(path,"w");
665         if( fp ) {
666                 BC_Hash defaults;
667                 save_defaults(&defaults);
668                 defaults.save_file(fp);
669                 fclose(fp);
670                 ret = 0;
671         }
672         return ret;
673 }
674