#include "bchash.h"
#include "filesystem.h"
#include "gainwindow.h"
+#include "theme.h"
#include "language.h"
#include <string.h>
-GainWindow::GainWindow(Gain *gain)
- : PluginClientWindow(gain,
- 230,
- 60,
- 230,
- 60,
+GainWindow::GainWindow(GainMain *plugin)
+ : PluginClientWindow(plugin,
+ xS(420),
+ yS(60),
+ xS(420),
+ yS(60),
0)
{
- this->gain = gain;
+ this->plugin = plugin;
}
GainWindow::~GainWindow()
void GainWindow::create_objects()
{
- int x = 10, y = 10;
- add_tool(new BC_Title(5, y, _("Level:")));
- y += 20;
- add_tool(level = new GainLevel(gain, x, y));
+ int xs10 = xS(10);
+ int ys10 = yS(10);
+ int x = xs10, y = ys10;
+ int x2 = xS(80), x3 = xS(180);
+ int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22
+
+ y += ys10;
+ add_tool(new BC_Title(x, y, _("Level:")));
+ level_text = new GainLevelText(this, plugin, (x + x2), y);
+ level_text->create_objects();
+ add_tool(level_slider = new GainLevelSlider(this, plugin, x3, y));
+ clr_x = x3 + level_slider->get_w() + x;
+ add_subwindow(level_clr = new GainLevelClr(this, plugin, clr_x, y));
show_window();
flush();
}
+void GainWindow::update()
+{
+ float level = plugin->config.level;
+ level_text->update(level);
+ level_slider->update(level);
+}
+
+
+
+GainLevelText::GainLevelText(GainWindow *window, GainMain *plugin, int x, int y)
+ : BC_TumbleTextBox(window, plugin->config.level,
+ (float)INFINITYGAIN, (float)GAINLEVEL_MAX, x, y, xS(60), 2)
+{
+ this->window = window;
+ this->plugin = plugin;
+ set_increment(0.1);
+}
+GainLevelText::~GainLevelText()
+{
+}
+int GainLevelText::handle_event()
+{
+ float min = INFINITYGAIN, max = GAINLEVEL_MAX;
+ float output = atof(get_text());
+
+ if(output > max) output = max;
+ else if(output < min) output = min;
+ plugin->config.level = output;
+ window->update();
+ plugin->send_configure_change();
+ return 1;
+}
+GainLevelSlider::GainLevelSlider(GainWindow *window, GainMain *plugin, int x, int y)
+ : BC_FSlider(x, y, 0, xS(200), yS(200), INFINITYGAIN, GAINLEVEL_MAX, plugin->config.level)
+{
+ this->window = window;
+ this->plugin = plugin;
+ enable_show_value(0); // Hide caption
+}
+GainLevelSlider::~GainLevelSlider()
+{
+}
+int GainLevelSlider::handle_event()
+{
+ plugin->config.level = get_value();
+ window->level_text->update((float)plugin->config.level);
+ plugin->send_configure_change();
+ return 1;
+}
+
-GainLevel::GainLevel(Gain *gain, int x, int y)
- : BC_FSlider(x,
- y,
- 0,
- 200,
- 200,
- INFINITYGAIN,
- 40,
- gain->config.level)
+GainLevelClr::GainLevelClr(GainWindow *window, GainMain *plugin, int x, int y)
+ : BC_Button(x, y, plugin->get_theme()->get_image_set("reset_button"))
+{
+ this->window = window;
+ this->plugin = plugin;
+}
+GainLevelClr::~GainLevelClr()
{
- this->gain = gain;
}
-int GainLevel::handle_event()
+int GainLevelClr::handle_event()
{
- gain->config.level = get_value();
- gain->send_configure_change();
+ plugin->config.reset();
+ window->update();
+ plugin->send_configure_change();
return 1;
}