0dd2aa0db8340f62b82cdf7243070e66bfd9f565
[goodguy/history.git] / cinelerra-5.0 / cinelerra / levelwindowgui.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2011 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 "edl.h"
23 #include "edlsession.h"
24 #include "levelwindow.h"
25 #include "levelwindowgui.h"
26 #include "mainmenu.h"
27 #include "mainsession.h"
28 #include "meterpanel.h"
29 #include "mwindow.h"
30 #include "mwindowgui.h"
31 #include "preferences.h"
32 #include "theme.h"
33
34 LevelWindowGUI::LevelWindowGUI(MWindow *mwindow, LevelWindow *thread)
35  : BC_Window(PROGRAM_NAME ": Levels", 
36         mwindow->session->lwindow_x, 
37         mwindow->session->lwindow_y, 
38         mwindow->session->lwindow_w, 
39         mwindow->session->lwindow_h, 
40         10,
41         10,
42         1,
43         0, 
44         1)
45 {
46         this->thread = thread;
47         this->mwindow = mwindow;
48 }
49
50 LevelWindowGUI::~LevelWindowGUI()
51 {
52         delete panel;
53 }
54
55 void LevelWindowGUI::create_objects()
56 {
57         int border = mwindow->theme->widget_border;
58         lock_window("LevelWindowGUI::create_objects");
59         mwindow->theme->draw_lwindow_bg(this);
60         panel = new MeterPanel(mwindow, 
61                 this, 
62                 border, 
63                 border,
64                 get_w() - border * 2, 
65                 get_h() - border * 2, 
66                 mwindow->edl->session->audio_channels,
67                 1,
68                 0,
69                 1);
70         panel->create_objects();
71         unlock_window();
72 }
73
74
75 int LevelWindowGUI::resize_event(int w, int h)
76 {
77         int border = mwindow->theme->widget_border;
78         mwindow->session->lwindow_x = get_x();
79         mwindow->session->lwindow_y = get_y();
80         mwindow->session->lwindow_w = w;
81         mwindow->session->lwindow_h = h;
82
83         mwindow->theme->draw_lwindow_bg(this);
84
85         panel->reposition_window(panel->x,
86                 panel->y,
87                 w - border * 2,
88                 h - border * 2);
89
90         BC_WindowBase::resize_event(w, h);
91         return 1;
92 }
93
94 int LevelWindowGUI::translation_event()
95 {
96         mwindow->session->lwindow_x = get_x();
97         mwindow->session->lwindow_y = get_y();
98         return 0;
99 }
100
101 int LevelWindowGUI::close_event()
102 {
103         hide_window();
104         mwindow->session->show_lwindow = 0;
105         mwindow->gui->lock_window();
106         mwindow->gui->mainmenu->show_lwindow->set_checked(0);
107         mwindow->gui->unlock_window();
108         mwindow->save_defaults();
109         return 1;
110 }
111
112 int LevelWindowGUI::keypress_event()
113 {
114         if(get_keypress() == 'w' || get_keypress() == 'W')
115         {
116                 close_event();
117                 return 1;
118         }
119         return 0;
120 }
121
122
123 int LevelWindowGUI::reset_over()
124 {
125         return 0;
126 }
127