Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / gain / gainwindow.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 "bcdisplayinfo.h"
23 #include "bchash.h"
24 #include "filesystem.h"
25 #include "gainwindow.h"
26 #include "theme.h"
27 #include "language.h"
28
29 #include <string.h>
30
31
32
33
34
35
36
37 GainWindow::GainWindow(GainMain *plugin)
38  : PluginClientWindow(plugin,
39         xS(420),
40         yS(60),
41         xS(420),
42         yS(60),
43         0)
44 {
45         this->plugin = plugin;
46 }
47
48 GainWindow::~GainWindow()
49 {
50 }
51
52 void GainWindow::create_objects()
53 {
54         int xs10 = xS(10);
55         int ys10 = yS(10);
56         int x = xs10, y = ys10;
57         int x2 = xS(80), x3 = xS(180);
58         int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22
59
60         y += ys10;
61         add_tool(new BC_Title(x, y, _("Level:")));
62         level_text = new GainLevelText(this, plugin, (x + x2), y);
63         level_text->create_objects();
64         add_tool(level_slider = new GainLevelSlider(this, plugin, x3, y));
65         clr_x = x3 + level_slider->get_w() + x;
66         add_subwindow(level_clr = new GainLevelClr(this, plugin, clr_x, y));
67         show_window();
68         flush();
69 }
70
71
72
73 void GainWindow::update()
74 {
75         float level = plugin->config.level;
76         level_text->update(level);
77         level_slider->update(level);
78 }
79
80
81
82 GainLevelText::GainLevelText(GainWindow *window, GainMain *plugin, int x, int y)
83  : BC_TumbleTextBox(window, plugin->config.level,
84         (float)INFINITYGAIN, (float)GAINLEVEL_MAX, x, y, xS(60), 2)
85 {
86         this->window = window;
87         this->plugin = plugin;
88         set_increment(0.1);
89 }
90 GainLevelText::~GainLevelText()
91 {
92 }
93 int GainLevelText::handle_event()
94 {
95         float min = INFINITYGAIN, max = GAINLEVEL_MAX;
96         float output = atof(get_text());
97
98         if(output > max) output = max;
99         else if(output < min) output = min;
100         plugin->config.level = output;
101         window->update();
102         plugin->send_configure_change();
103         return 1;
104 }
105
106
107
108 GainLevelSlider::GainLevelSlider(GainWindow *window, GainMain *plugin, int x, int y)
109  : BC_FSlider(x, y, 0, xS(200), yS(200), INFINITYGAIN, GAINLEVEL_MAX, plugin->config.level)
110 {
111         this->window = window;
112         this->plugin = plugin;
113         enable_show_value(0); // Hide caption
114 }
115 GainLevelSlider::~GainLevelSlider()
116 {
117 }
118 int GainLevelSlider::handle_event()
119 {
120         plugin->config.level = get_value();
121         window->level_text->update((float)plugin->config.level);
122         plugin->send_configure_change();
123         return 1;
124 }
125
126
127
128 GainLevelClr::GainLevelClr(GainWindow *window, GainMain *plugin, int x, int y)
129  : BC_Button(x, y, plugin->get_theme()->get_image_set("reset_button"))
130 {
131         this->window = window;
132         this->plugin = plugin;
133 }
134 GainLevelClr::~GainLevelClr()
135 {
136 }
137 int GainLevelClr::handle_event()
138 {
139         plugin->config.reset();
140         window->update();
141         plugin->send_configure_change();
142         return 1;
143 }