Example #1
0
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 );
}
Example #2
0
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 ) );
}
Example #3
0
void ColorPicker::SlidersMoved( Gwen::Controls::Base* control )
{

	HorizontalSlider* slider = control->DynamicCastHorizontalSlider();
	if (slider)
		SetColorByName( GetColorFromName( slider->GetName() ), slider->GetValue() );

	UpdateControls();
	//SetColor( Gwen::Color( redSlider->GetValue(), greenSlider->GetValue(), blueSlider->GetValue(), alphaSlider->GetValue() ) );
}
Example #4
0
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 ) );
}
Example #5
0
void ColorPicker::SlidersMoved( Gwen::Controls::Base* control )
{
	/*
	HorizontalSlider* redSlider		= gwen_cast<HorizontalSlider>(	FindChildByName( "RedSlider",   true ) );
	HorizontalSlider* greenSlider	= gwen_cast<HorizontalSlider>(	FindChildByName( "GreenSlider", true ) );
	HorizontalSlider* blueSlider	= gwen_cast<HorizontalSlider>(	FindChildByName( "BlueSlider",  true ) );
	HorizontalSlider* alphaSlider	= gwen_cast<HorizontalSlider>(	FindChildByName( "AlphaSlider", true ) );
	*/

	HorizontalSlider* slider = gwen_cast<HorizontalSlider>( control );
	if (slider)
		SetColorByName( GetColorFromName( slider->GetName() ), slider->GetValue() );

	UpdateControls();
	//SetColor( Gwen::Color( redSlider->GetValue(), greenSlider->GetValue(), blueSlider->GetValue(), alphaSlider->GetValue() ) );
}