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