+PaletteLum::PaletteLum(ColorWindow *window, int x, int y)
+ : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->yuv.y, 0)
+{
+ this->window = window;
+ set_precision(0.01);
+}
+PaletteLum::~PaletteLum()
+{
+}
+
+int PaletteLum::handle_event()
+{
+ window->yuv.y = get_value();
+ window->update_yuv();
+ window->handle_event();
+ return 1;
+}
+
+PaletteCr::PaletteCr(ColorWindow *window, int x, int y)
+ : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->yuv.u, 0)
+{
+ this->window = window;
+ set_precision(0.01);
+}
+PaletteCr::~PaletteCr()
+{
+}
+
+int PaletteCr::handle_event()
+{
+ window->yuv.u = get_value();
+ window->update_yuv();
+ window->handle_event();
+ return 1;
+}
+
+PaletteCb::PaletteCb(ColorWindow *window, int x, int y)
+ : BC_FSlider(x, y, 0, 150, 200, 0, 1, window->yuv.v, 0)
+{
+ this->window = window;
+ set_precision(0.01);
+}
+PaletteCb::~PaletteCb()
+{
+}
+
+int PaletteCb::handle_event()
+{
+ window->yuv.v = get_value();
+ window->update_yuv();
+ window->handle_event();
+ return 1;
+}
+
+void ColorWindow::update_rgb(float r, float g, float b)
+{
+ { float y, u, v;
+ YUV::rgb_to_yuv_f(r, g, b, y, u, v);
+ u += 0.5f; v += 0.5f;
+ bclamp(y, 0, 1); yuv.y = y;
+ bclamp(u, 0, 1); yuv.u = u;
+ bclamp(v, 0, 1); yuv.v = v; }
+ { float h, s, v;
+ HSV::rgb_to_hsv(r,g,b, h,s,v);
+ bclamp(h, 0, 360); hsv.h = h;
+ bclamp(s, 0, 1); hsv.s = s;
+ bclamp(v, 0, 1); hsv.v = v; }
+}
+
+void ColorWindow::update_yuv(float y, float u, float v)
+{
+ u -= 0.5f; v -= 0.5f;
+ { float r, g, b;
+ YUV::yuv_to_rgb_f(r, g, b, y, u, v);
+ bclamp(r, 0, 1); rgb.r = r;
+ bclamp(g, 0, 1); rgb.g = g;
+ bclamp(b, 0, 1); rgb.b = b;
+ float h, s, v;
+ HSV::rgb_to_hsv(r,g,b, h, s, v);
+ bclamp(h, 0, 360); hsv.h = h;
+ bclamp(s, 0, 1); hsv.s = s;
+ bclamp(v, 0, 1); hsv.v = v; }
+}
+
+void ColorWindow::update_hsv(float h, float s, float v)
+{
+ { float r, g, b;
+ HSV::hsv_to_rgb(r,g,b, h,s,v);
+ bclamp(r, 0, 1); rgb.r = r;
+ bclamp(g, 0, 1); rgb.g = g;
+ bclamp(b, 0, 1); rgb.b = b;
+ float y, u, v;
+ YUV::rgb_to_yuv_f(r, g, b, y, u, v);
+ u += 0.5f; v += 0.5f;
+ bclamp(y, 0, 1); yuv.y = y;
+ bclamp(u, 0, 1); yuv.u = u;
+ bclamp(v, 0, 1); yuv.v = v; }
+}
+
+PalletteNum::PalletteNum(ColorWindow *window, int x, int y,
+ float &output, float min, float max)
+ : BC_TumbleTextBox(window, output, min, max, x, y, 64)
+{
+ this->window = window;
+ this->output = &output;
+ set_increment(0.01);
+}
+
+PalletteNum::~PalletteNum()
+{
+}
+
+
+int PalletteHSV::handle_event()
+{
+ update_output();
+ window->update_hsv();
+ window->update_display();
+ window->handle_event();
+ return 1;
+}
+
+int PalletteRGB::handle_event()
+{
+ update_output();
+ window->update_rgb();
+ window->update_display();
+ window->handle_event();
+ return 1;
+}
+
+int PalletteYUV::handle_event()
+{
+ update_output();
+ window->update_yuv();
+ window->update_display();
+ window->handle_event();
+ return 1;
+}
+
+int PalletteAPH::handle_event()
+{
+ update_output();
+ window->update_display();
+ window->handle_event();
+ return 1;
+}