r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / mainsession.C
blob2367355f6e4550de73ce9d97bfc150949902767e
1 #include "bcdisplayinfo.h"
2 #include "clip.h"
3 #include "bchash.h"
4 #include "edl.h"
5 #include "edlsession.h"
6 #include "guicast.h"
7 #include "mainsession.h"
8 #include "meterpanel.h"
9 #include "mwindow.h"
10 #include "mwindowgui.h"
11 #include "auto.h"
13 MainSession::MainSession(MWindow *mwindow)
15         this->mwindow = mwindow;
16         changes_made = 0;
17         filename[0] = 0;
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;
25         edit_highlighted = 0;
26         current_operation = NO_OPERATION;
27         drag_pluginservers = new ArrayList<PluginServer*>;
28         drag_plugin = 0;
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*>;
33         drag_edit = 0;
34         clip_number = 1;
35         brender_end = 0;
36         cwindow_controls = 1;
37         trim_edits = 0;
38         gwindow_x = 0;
39         gwindow_y = 0;
40         show_gwindow = 0;
41         current_tip = 0;
42         cwindow_fullscreen = 0;
43         rwindow_fullscreen = 0;
44         vwindow_fullscreen = 0;
47 MainSession::~MainSession()
49         delete drag_pluginservers;
50         delete drag_assets;
51         delete drag_auto_gang;
52         delete drag_clips;
53         delete drag_edits;
56 void MainSession::boundaries()
58         lwindow_x = MAX(0, lwindow_x);
59         lwindow_y = MAX(0, lwindow_y);
60         mwindow_x = MAX(0, mwindow_x);
61         mwindow_y = MAX(0, mwindow_y);
62         cwindow_x = MAX(0, cwindow_x);
63         cwindow_y = MAX(0, cwindow_y);
64         vwindow_x = MAX(0, vwindow_x);
65         vwindow_y = MAX(0, vwindow_y);
66         awindow_x = MAX(0, awindow_x);
67         awindow_y = MAX(0, awindow_y);
68         gwindow_x = MAX(0, gwindow_x);
69         gwindow_y = MAX(0, gwindow_y);
70         rwindow_x = MAX(0, rwindow_x);
71         rwindow_y = MAX(0, rwindow_y);
72         rmonitor_x = MAX(0, rmonitor_x);
73         rmonitor_y = MAX(0, rmonitor_y);
74         cwindow_controls = CLIP(cwindow_controls, 0, 1);
77 void MainSession::default_window_positions()
79 // Get defaults based on root window size
80         BC_DisplayInfo display_info;
82         int root_x = 0;
83         int root_y = 0;
84         int root_w = display_info.get_root_w();
85         int root_h = display_info.get_root_h();
86         int border_left = 0;
87         int border_right = 0;
88         int border_top = 0;
89         int border_bottom = 0;
91         border_left = display_info.get_left_border();
92         border_top = display_info.get_top_border();
93         border_right = display_info.get_right_border();
94         border_bottom = display_info.get_bottom_border();
96 // Wider than 16:9, narrower than dual head
97         if((float)root_w / root_h > 1.8) root_w /= 2;
101         vwindow_x = root_x;
102         vwindow_y = root_y;
103         vwindow_w = root_w / 2 - border_left - border_right;
104         vwindow_h = root_h * 6 / 10 - border_top - border_bottom;
106         cwindow_x = root_x + root_w / 2;
107         cwindow_y = root_y;
108         cwindow_w = vwindow_w;
109         cwindow_h = vwindow_h;
111         ctool_x = cwindow_x + cwindow_w / 2;
112         ctool_y = cwindow_y + cwindow_h / 2;
114         mwindow_x = root_x;
115         mwindow_y = vwindow_y + vwindow_h + border_top + border_bottom;
116         mwindow_w = root_w * 2 / 3 - border_left - border_right;
117         mwindow_h = root_h - mwindow_y - border_top - border_bottom;
119         awindow_x = mwindow_x + border_left + border_right + mwindow_w;
120         awindow_y = mwindow_y;
121         awindow_w = root_x + root_w - awindow_x - border_left - border_right;
122         awindow_h = mwindow_h;
124         ewindow_w = 640;
125         ewindow_h = 240;
127         if(mwindow->edl)
128                 lwindow_w = MeterPanel::get_meters_width(mwindow->edl->session->audio_channels, 1);
129         else
130                 lwindow_w = 100;
132         lwindow_y = 0;
133         lwindow_x = root_w - lwindow_w;
134         lwindow_h = mwindow_y;
136         rwindow_x = 0;
137         rwindow_y = 0;
138         rwindow_h = 500;
139         rwindow_w = 650;
141         rmonitor_x = rwindow_x + rwindow_w + 10;
142         rmonitor_y = rwindow_y;
143         rmonitor_w = root_w - rmonitor_x;
144         rmonitor_h = rwindow_h;
146         batchrender_w = 540;
147         batchrender_h = 340;
148         batchrender_x = root_w / 2 - batchrender_w / 2;
149         batchrender_y = root_h / 2 - batchrender_h / 2;
152 int MainSession::load_defaults(BC_Hash *defaults)
154 // Setup main windows
155         default_window_positions();
156         vwindow_x = defaults->get("VWINDOW_X", vwindow_x);
157         vwindow_y = defaults->get("VWINDOW_Y", vwindow_y);
158         vwindow_w = defaults->get("VWINDOW_W", vwindow_w);
159         vwindow_h = defaults->get("VWINDOW_H", vwindow_h);
162         cwindow_x = defaults->get("CWINDOW_X", cwindow_x);
163         cwindow_y = defaults->get("CWINDOW_Y", cwindow_y);
164         cwindow_w = defaults->get("CWINDOW_W", cwindow_w);
165         cwindow_h = defaults->get("CWINDOW_H", cwindow_h);
167         ctool_x = defaults->get("CTOOL_X", ctool_x);
168         ctool_y = defaults->get("CTOOL_Y", ctool_y);
170         gwindow_x = defaults->get("GWINDOW_X", gwindow_x);
171         gwindow_y = defaults->get("GWINDOW_Y", gwindow_y);
173         mwindow_x = defaults->get("MWINDOW_X", mwindow_x);
174         mwindow_y = defaults->get("MWINDOW_Y", mwindow_y);
175         mwindow_w = defaults->get("MWINDOW_W", mwindow_w);
176         mwindow_h = defaults->get("MWINDOW_H", mwindow_h);
178         lwindow_x = defaults->get("LWINDOW_X", lwindow_x);
179         lwindow_y = defaults->get("LWINDOW_Y", lwindow_y);
180         lwindow_w = defaults->get("LWINDOW_W", lwindow_w);
181         lwindow_h = defaults->get("LWINDOW_H", lwindow_h);
184         awindow_x = defaults->get("AWINDOW_X", awindow_x);
185         awindow_y = defaults->get("AWINDOW_Y", awindow_y);
186         awindow_w = defaults->get("AWINDOW_W", awindow_w);
187         awindow_h = defaults->get("AWINDOW_H", awindow_h);
189         ewindow_w = defaults->get("EWINDOW_W", ewindow_w);
190         ewindow_h = defaults->get("EWINDOW_H", ewindow_h);
192 //printf("MainSession::load_defaults 1\n");
194 // Other windows
195         afolders_w = defaults->get("ABINS_W", 100);
196         rwindow_x = defaults->get("RWINDOW_X", rwindow_x);
197         rwindow_y = defaults->get("RWINDOW_Y", rwindow_y);
198         rwindow_w = defaults->get("RWINDOW_W", rwindow_w);
199         rwindow_h = defaults->get("RWINDOW_H", rwindow_h);
201         rmonitor_x = defaults->get("RMONITOR_X", rmonitor_x);
202         rmonitor_y = defaults->get("RMONITOR_Y", rmonitor_y);
203         rmonitor_w = defaults->get("RMONITOR_W", rmonitor_w);
204         rmonitor_h = defaults->get("RMONITOR_H", rmonitor_h);
206         batchrender_x = defaults->get("BATCHRENDER_X", batchrender_x);
207         batchrender_y = defaults->get("BATCHRENDER_Y", batchrender_y);
208         batchrender_w = defaults->get("BATCHRENDER_W", batchrender_w);
209         batchrender_h = defaults->get("BATCHRENDER_H", batchrender_h);
211         show_vwindow = defaults->get("SHOW_VWINDOW", 1);
212         show_awindow = defaults->get("SHOW_AWINDOW", 1);
213         show_cwindow = defaults->get("SHOW_CWINDOW", 1);
214         show_lwindow = defaults->get("SHOW_LWINDOW", 0);
215         show_gwindow = defaults->get("SHOW_GWINDOW", 0);
217         cwindow_controls = defaults->get("CWINDOW_CONTROLS", cwindow_controls);
219         plugindialog_w = defaults->get("PLUGINDIALOG_W", 510);
220         plugindialog_h = defaults->get("PLUGINDIALOG_H", 415);
221         menueffect_w = defaults->get("MENUEFFECT_W", 580);
222         menueffect_h = defaults->get("MENUEFFECT_H", 350);
224         current_tip = defaults->get("CURRENT_TIP", current_tip);
226         boundaries();
227         return 0;
230 int MainSession::save_defaults(BC_Hash *defaults)
233 // Window positions
234         defaults->update("MWINDOW_X", mwindow_x);
235         defaults->update("MWINDOW_Y", mwindow_y);
236         defaults->update("MWINDOW_W", mwindow_w);
237         defaults->update("MWINDOW_H", mwindow_h);
239         defaults->update("LWINDOW_X", lwindow_x);
240         defaults->update("LWINDOW_Y", lwindow_y);
241         defaults->update("LWINDOW_W", lwindow_w);
242         defaults->update("LWINDOW_H", lwindow_h);
244         defaults->update("VWINDOW_X", vwindow_x);
245         defaults->update("VWINDOW_Y", vwindow_y);
246         defaults->update("VWINDOW_W", vwindow_w);
247         defaults->update("VWINDOW_H", vwindow_h);
249         defaults->update("CWINDOW_X", cwindow_x);
250         defaults->update("CWINDOW_Y", cwindow_y);
251         defaults->update("CWINDOW_W", cwindow_w);
252         defaults->update("CWINDOW_H", cwindow_h);
254         defaults->update("CTOOL_X", ctool_x);
255         defaults->update("CTOOL_Y", ctool_y);
257         defaults->update("GWINDOW_X", gwindow_x);
258         defaults->update("GWINDOW_Y", gwindow_y);
260         defaults->update("AWINDOW_X", awindow_x);
261         defaults->update("AWINDOW_Y", awindow_y);
262         defaults->update("AWINDOW_W", awindow_w);
263         defaults->update("AWINDOW_H", awindow_h);
265         defaults->update("EWINDOW_W", ewindow_w);
266         defaults->update("EWINDOW_H", ewindow_h);
268         defaults->update("ABINS_W", afolders_w);
270         defaults->update("RMONITOR_X", rmonitor_x);
271         defaults->update("RMONITOR_Y", rmonitor_y);
272         defaults->update("RMONITOR_W", rmonitor_w);
273         defaults->update("RMONITOR_H", rmonitor_h);
275         defaults->update("RWINDOW_X", rwindow_x);
276         defaults->update("RWINDOW_Y", rwindow_y);
277         defaults->update("RWINDOW_W", rwindow_w);
278         defaults->update("RWINDOW_H", rwindow_h);
280         defaults->update("BATCHRENDER_X", batchrender_x);
281         defaults->update("BATCHRENDER_Y", batchrender_y);
282         defaults->update("BATCHRENDER_W", batchrender_w);
283         defaults->update("BATCHRENDER_H", batchrender_h);
285         defaults->update("SHOW_VWINDOW", show_vwindow);
286         defaults->update("SHOW_AWINDOW", show_awindow);
287         defaults->update("SHOW_CWINDOW", show_cwindow);
288         defaults->update("SHOW_LWINDOW", show_lwindow);
289         defaults->update("SHOW_GWINDOW", show_gwindow);
291         defaults->update("CWINDOW_CONTROLS", cwindow_controls);
293         defaults->update("PLUGINDIALOG_W", plugindialog_w);
294         defaults->update("PLUGINDIALOG_H", plugindialog_h);
296         defaults->update("MENUEFFECT_W", menueffect_w);
297         defaults->update("MENUEFFECT_H", menueffect_h);
299         defaults->update("CURRENT_TIP", current_tip);
302         return 0;