void ColorDetailControl::Input(UIEvent *currentInput) { if ((UIEvent::BUTTON_1 == currentInput->tid) && (UIEvent::PHASE_MOVE != currentInput->phase)) { Vector2 touchPoint = currentInput->point - GetPosition(true); touchPoint.x = Min(touchPoint.x, GetRect().dx); touchPoint.y = Min(touchPoint.y, GetRect().dy - 1); if(0 <= touchPoint.y) { ColorSelected(touchPoint); } } }
void RGBColorChooserPanel::updateChooser(void) { Int32 Red,Green,Blue,Alpha; Color4f ColorSelected(getColorFromModel()); //Update the Red Bounded Range Red = osgClamp(0.0f, ColorSelected.red(), 1.0f) * 255; if(static_cast<Int32>(Red) != _RedModel->getValue()) { _RedModel->setValue(Red); } _RedSliderTrackBackground->editMFColors()->clear(); _RedSliderTrackBackground->editMFStops()->clear(); _RedSliderTrackBackground->editMFColors()->push_back(Color4f(0.0f, ColorSelected.green(), ColorSelected.blue(), ColorSelected.alpha())); _RedSliderTrackBackground->editMFStops()->push_back(0.0); _RedSliderTrackBackground->editMFColors()->push_back(Color4f(1.0f, ColorSelected.green(), ColorSelected.blue(), ColorSelected.alpha())); _RedSliderTrackBackground->editMFStops()->push_back(1.0); //Update the Green Bounded Range Green = osgClamp(0.0f, ColorSelected.green(), 1.0f) * 255; if(static_cast<Int32>(Green) != _GreenModel->getValue()) { _GreenModel->setValue(Green); } _GreenSliderTrackBackground->editMFColors()->clear(); _GreenSliderTrackBackground->editMFStops()->clear(); _GreenSliderTrackBackground->editMFColors()->push_back(Color4f(ColorSelected.red(), 0.0f, ColorSelected.blue(), ColorSelected.alpha())); _GreenSliderTrackBackground->editMFStops()->push_back(0.0); _GreenSliderTrackBackground->editMFColors()->push_back(Color4f(ColorSelected.red(), 1.0f, ColorSelected.blue(), ColorSelected.alpha())); _GreenSliderTrackBackground->editMFStops()->push_back(1.0); //Update the Blue Bounded Range Blue = osgClamp(0.0f, ColorSelected.blue(), 1.0f) * 255; if(static_cast<Int32>(Blue) != _BlueModel->getValue()) { _BlueModel->setValue(Blue); } _BlueSliderTrackBackground->editMFColors()->clear(); _BlueSliderTrackBackground->editMFStops()->clear(); _BlueSliderTrackBackground->editMFColors()->push_back(Color4f(ColorSelected.red(), ColorSelected.green(), 0.0f, ColorSelected.alpha())); _BlueSliderTrackBackground->editMFStops()->push_back(0.0); _BlueSliderTrackBackground->editMFColors()->push_back(Color4f(ColorSelected.red(), ColorSelected.green(), 1.0f, ColorSelected.alpha())); _BlueSliderTrackBackground->editMFStops()->push_back(1.0); //Update the Alpha Bounded Range Alpha = osgClamp(0.0f, ColorSelected.alpha(), 1.0f) * 255; if(static_cast<Int32>(Alpha) != _AlphaModel->getValue()) { _AlphaModel->setValue(Alpha); } if(getIncludeAlpha()) { _AlphaSliderTrackBackground->editMFColors()->clear(); _AlphaSliderTrackBackground->editMFStops()->clear(); _AlphaSliderTrackBackground->editMFColors()->push_back(Color4f(ColorSelected.red(), ColorSelected.green(), ColorSelected.blue(), 0.0f)); _AlphaSliderTrackBackground->editMFStops()->push_back(0.0); _AlphaSliderTrackBackground->editMFColors()->push_back(Color4f(ColorSelected.red(), ColorSelected.green(), ColorSelected.blue(), 1.0f)); _AlphaSliderTrackBackground->editMFStops()->push_back(1.0); } }