void ColorPicker::CreateColorControl( Gwen::String name, int y ) { int colorSize = 12; GroupBox* colorGroup = new GroupBox( this ); colorGroup->SetPos( 10, y ); colorGroup->SetText( name ); colorGroup->SetSize( 160, 35 ); colorGroup->SetName( name + "groupbox" ); ColorDisplay* disp = new ColorDisplay( colorGroup ); disp->SetName(name); disp->SetBounds( 0 , 10, colorSize, colorSize ); TextBoxNumeric* numeric = new TextBoxNumeric( colorGroup ); numeric->SetName( name + "Box" ); numeric->SetPos( 105, 7 ); numeric->SetSize( 26, 16 ); numeric->SetSelectAllOnFocus( true ); numeric->onTextChanged.Add( this, &ColorPicker::NumericTyped ); HorizontalSlider* slider = new HorizontalSlider( colorGroup ); slider->SetPos( colorSize + 5 , 10 ); slider->SetRange( 0, 255 ); slider->SetSize( 80, colorSize ); slider->SetName( name + "Slider"); slider->onValueChanged.Add( this, &ColorPicker::SlidersMoved ); }
void ColorPicker::UpdateColorControls( Gwen::String name, Gwen::Color col, int sliderVal ) { ColorDisplay* disp = gwen_cast<ColorDisplay> ( FindChildByName( name, true ) ); disp->SetColor( col ); HorizontalSlider* slider = gwen_cast<HorizontalSlider> ( FindChildByName( name + "Slider", true ) ); slider->SetFloatValue( sliderVal ); TextBoxNumeric* box = gwen_cast<TextBoxNumeric> ( FindChildByName( name + "Box", true ) ); box->SetText( Gwen::Utility::ToString( sliderVal ) ); }
void ColorPicker::UpdateColorControls( Gwen::String name, Gwen::Color col, int sliderVal ) { Base* el = FindChildByName( name, true ); ColorDisplay* disp = el ? el->DynamicCastColorDisplay() : 0; disp->SetColor( col ); HorizontalSlider* slider = FindChildByName( name + "Slider", true )->DynamicCastHorizontalSlider(); slider->SetValue( sliderVal ); TextBoxNumeric* box = FindChildByName( name + "Box", true )->DynamicCastTextBoxNumeric(); box->SetText( Gwen::Utility::ToString( sliderVal ) ); }
void ColorPicker::NumericTyped( Gwen::Controls::Base* control ) { TextBoxNumeric* box = gwen_cast<TextBoxNumeric>(control); if (!box) return; if ( box->GetText() == L"") return; int textValue = atoi( Utility::UnicodeToString( box->GetText()).c_str() ); if ( textValue < 0) textValue = 0; if ( textValue > 255) textValue = 255; if ( box->GetName().find("Red") != Gwen::String::npos ) SetRed( textValue ); if ( box->GetName().find("Green") != Gwen::String::npos ) SetGreen( textValue ); if ( box->GetName().find("Blue") != Gwen::String::npos ) SetBlue( textValue ); if ( box->GetName().find("Alpha") != Gwen::String::npos ) SetAlpha( textValue ); UpdateControls(); }
void ColorPicker::NumericTyped( gwen::Controls::Base* control ) { TextBoxNumeric* box = gwen_cast<TextBoxNumeric> ( control ); if ( !box ) { return; } if ( box->GetText() == L"" ) { return; } int textValue = atoi( box->GetText().c_str() ); if ( textValue < 0 ) { textValue = 0; } if ( textValue > 255 ) { textValue = 255; } if ( box->GetName().find( "Red" ) != gwen::String::npos ) { SetRed( textValue ); } if ( box->GetName().find( "Green" ) != gwen::String::npos ) { SetGreen( textValue ); } if ( box->GetName().find( "Blue" ) != gwen::String::npos ) { SetBlue( textValue ); } if ( box->GetName().find( "Alpha" ) != gwen::String::npos ) { SetAlpha( textValue ); } UpdateControls(); }
void HSVColorPicker::NumericTyped( Gwen::Controls::Base* control ) { TextBoxNumeric* box = gwen_cast<TextBoxNumeric> ( control ); if ( !box ) { return; } if ( box->GetText() == U"" ) { return; } int textValue = atoi( box->GetText().c_str() ); if ( textValue < 0 ) { textValue = 0; } if ( textValue > 255 ) { textValue = 255; } Gwen::Color newColor = GetColor(); if ( box->GetName().find( "Red" ) != Gwen::String::npos ) { newColor.r = textValue; } else if ( box->GetName().find( "Green" ) != Gwen::String::npos ) { newColor.g = textValue; } else if ( box->GetName().find( "Blue" ) != Gwen::String::npos ) { newColor.b = textValue; } else if ( box->GetName().find( "Alpha" ) != Gwen::String::npos ) { newColor.a = textValue; } SetColor( newColor ); }
void HSVColorPicker::UpdateControls( Gwen::Color color ) { // What in the F**K TextBoxNumeric* redBox = gwen_cast<TextBoxNumeric> ( FindChildByName( "RedBox", false ) ); if ( redBox ) { redBox->SetText( Gwen::Utility::ToString( ( int ) color.r ), false ); } TextBoxNumeric* greenBox = gwen_cast<TextBoxNumeric> ( FindChildByName( "GreenBox", false ) ); if ( greenBox ) { greenBox->SetText( Gwen::Utility::ToString( ( int ) color.g ), false ); } TextBoxNumeric* blueBox = gwen_cast<TextBoxNumeric> ( FindChildByName( "BlueBox", false ) ); if ( blueBox ) { blueBox->SetText( Gwen::Utility::ToString( ( int ) color.b ), false ); } m_After->SetColor( color ); }