4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
24 #include "filesystem.h"
25 #include "gainwindow.h"
37 GainWindow::GainWindow(GainMain *plugin)
38 : PluginClientWindow(plugin,
45 this->plugin = plugin;
48 GainWindow::~GainWindow()
52 void GainWindow::create_objects()
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
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));
73 void GainWindow::update()
75 float level = plugin->config.level;
76 level_text->update(level);
77 level_slider->update(level);
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)
86 this->window = window;
87 this->plugin = plugin;
90 GainLevelText::~GainLevelText()
93 int GainLevelText::handle_event()
95 float min = INFINITYGAIN, max = GAINLEVEL_MAX;
96 float output = atof(get_text());
98 if(output > max) output = max;
99 else if(output < min) output = min;
100 plugin->config.level = output;
102 plugin->send_configure_change();
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)
111 this->window = window;
112 this->plugin = plugin;
113 enable_show_value(0); // Hide caption
115 GainLevelSlider::~GainLevelSlider()
118 int GainLevelSlider::handle_event()
120 plugin->config.level = get_value();
121 window->level_text->update((float)plugin->config.level);
122 plugin->send_configure_change();
128 GainLevelClr::GainLevelClr(GainWindow *window, GainMain *plugin, int x, int y)
129 : BC_Button(x, y, plugin->get_theme()->get_image_set("reset_button"))
131 this->window = window;
132 this->plugin = plugin;
134 GainLevelClr::~GainLevelClr()
137 int GainLevelClr::handle_event()
139 plugin->config.reset();
141 plugin->send_configure_change();