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