WaveConfig::WaveConfig()
{
- reset();
+ reset(RESET_ALL);
}
-void WaveConfig::reset()
+void WaveConfig::reset(int clear)
{
- mode = SMEAR;
- reflective = 0;
- amplitude = 10;
- phase = 0;
- wavelength = 10;
+ switch(clear) {
+ case RESET_ALL :
+ mode = SMEAR;
+ reflective = 0;
+ amplitude = 0;
+ phase = 0;
+ wavelength = 0;
+ break;
+ case RESET_AMPLITUDE : amplitude = 0;
+ break;
+ case RESET_PHASE : phase = 0;
+ break;
+ case RESET_WAVELENGTH : wavelength = 0;
+ break;
+ case RESET_DEFAULT_SETTINGS :
+ default:
+ mode = SMEAR;
+ reflective = 0;
+ amplitude = 10;
+ phase = 0;
+ wavelength = 10;
+ break;
+ }
}
void WaveConfig::copy_from(WaveConfig &src)
: BC_FSlider(x,
y,
0,
- 200,
- 200,
+ xS(200),
+ yS(200),
(float)0,
(float)100,
plugin->config.amplitude)
: BC_FSlider(x,
y,
0,
- 200,
- 200,
+ xS(200),
+ yS(200),
(float)0,
(float)360,
plugin->config.phase)
: BC_FSlider(x,
y,
0,
- 200,
- 200,
+ xS(200),
+ yS(200),
(float)0,
(float)50,
plugin->config.wavelength)
}
int WaveReset::handle_event()
{
- plugin->config.reset();
- gui->update();
+ plugin->config.reset(RESET_ALL);
+ gui->update_gui(RESET_ALL);
plugin->send_configure_change();
return 1;
}
+WaveDefaultSettings::WaveDefaultSettings(WaveEffect *plugin, WaveWindow *gui, int x, int y, int w)
+ : BC_GenericButton(x, y, w, _("Default"))
+{
+ this->plugin = plugin;
+ this->gui = gui;
+}
+WaveDefaultSettings::~WaveDefaultSettings()
+{
+}
+int WaveDefaultSettings::handle_event()
+{
+ plugin->config.reset(RESET_DEFAULT_SETTINGS);
+ gui->update_gui(RESET_DEFAULT_SETTINGS);
+ plugin->send_configure_change();
+ return 1;
+}
-
+WaveSliderClr::WaveSliderClr(WaveEffect *plugin, WaveWindow *gui, int x, int y, int w, int clear)
+ : BC_Button(x, y, w, plugin->get_theme()->get_image_set("reset_button"))
+{
+ this->plugin = plugin;
+ this->gui = gui;
+ this->clear = clear;
+}
+WaveSliderClr::~WaveSliderClr()
+{
+}
+int WaveSliderClr::handle_event()
+{
+ // clear==1 ==> Amplitude slider
+ // clear==2 ==> Phase slider
+ // clear==3 ==> Steps slider
+ plugin->config.reset(clear);
+ gui->update_gui(clear);
+ plugin->send_configure_change();
+ return 1;
+}
WaveWindow::WaveWindow(WaveEffect *plugin)
- : PluginClientWindow(plugin, 335, 140, 335, 140, 0)
+ : PluginClientWindow(plugin, xS(385), yS(140), xS(385), yS(140), 0)
{
this->plugin = plugin;
}
void WaveWindow::create_objects()
{
- int x = 10, y = 10, x1 = 115;
+ int xs10 = xS(10), xs50 = xS(50), xs100 = xS(100), xs115 = xS(115);
+ int ys10 = yS(10), ys30 = yS(30), ys40 = yS(40);
+ int x = xs10, y = ys10, x1 = xs115;
+ int x2 = 0; int clrBtn_w = xs50;
+ int defaultBtn_w = xs100;
// add_subwindow(new BC_Title(x, y, _("Mode:")));
// add_subwindow(smear = new WaveSmear(plugin, this, x1, y));
-// y += 20;
+// y += ys20;
// add_subwindow(blacken = new WaveBlacken(plugin, this, x1, y));
-// y += 30;
+// y += ys30;
// add_subwindow(reflective = new WaveReflective(plugin, x1, y));
-// y += 30;
+// y += ys30;
add_subwindow(new BC_Title(x, y, _("Amplitude:")));
add_subwindow(amplitude = new WaveAmplitude(plugin, x1, y));
- y += 30;
+ x2 = x1 + amplitude->get_w() + xs10;
+ add_subwindow(amplitudeClr = new WaveSliderClr(plugin, this, x2, y, clrBtn_w, RESET_AMPLITUDE));
+
+ y += ys30;
add_subwindow(new BC_Title(x, y, _("Phase:")));
add_subwindow(phase = new WavePhase(plugin, x1, y));
- y += 30;
+ add_subwindow(phaseClr = new WaveSliderClr(plugin, this, x2, y, clrBtn_w, RESET_PHASE));
+
+ y += ys30;
add_subwindow(new BC_Title(x, y, _("Wavelength:")));
add_subwindow(wavelength = new WaveLength(plugin, x1, y));
- y += 40;
+ add_subwindow(wavelengthClr = new WaveSliderClr(plugin, this, x2, y, clrBtn_w, RESET_WAVELENGTH));
+
+ y += ys40;
add_subwindow(reset = new WaveReset(plugin, this, x, y));
+ add_subwindow(default_settings = new WaveDefaultSettings(plugin, this,
+ (xS(385) - xs10 - defaultBtn_w), y, defaultBtn_w));
show_window();
flush();
}
// for Reset button
-void WaveWindow::update()
+void WaveWindow::update_gui(int clear)
{
- amplitude->update(plugin->config.amplitude);
- phase->update(plugin->config.phase);
- wavelength->update(plugin->config.wavelength);
+ switch(clear) {
+ case RESET_AMPLITUDE : amplitude->update(plugin->config.amplitude);
+ break;
+ case RESET_PHASE : phase->update(plugin->config.phase);
+ break;
+ case RESET_WAVELENGTH : wavelength->update(plugin->config.wavelength);
+ break;
+ case RESET_ALL :
+ case RESET_DEFAULT_SETTINGS :
+ default:
+ amplitude->update(plugin->config.amplitude);
+ phase->update(plugin->config.phase);
+ wavelength->update(plugin->config.wavelength);
+ break;
+ }
}