GWEN_CONTROL_INLINE( Slider, GUnit ) { { Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( this ); pSlider->SetPos( 10, 10 ); pSlider->SetSize( 150, 20 ); pSlider->SetRange( 0, 100 ); pSlider->SetFloatValue( 25 ); pSlider->onValueChanged.Add( this, &Slider::SliderMoved ); } { Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( this ); pSlider->SetPos( 10, 40 ); pSlider->SetSize( 150, 20 ); pSlider->SetRange( 0, 100 ); pSlider->SetFloatValue( 20 ); pSlider->SetNotchCount( 10 ); pSlider->SetClampToNotches( true ); pSlider->onValueChanged.Add( this, &Slider::SliderMoved ); } { Gwen::Controls::VerticalSlider* pSlider = new Gwen::Controls::VerticalSlider( this ); pSlider->SetPos( 160, 10 ); pSlider->SetSize( 20, 200 ); pSlider->SetRange( 0, 100 ); pSlider->SetFloatValue( 25 ); pSlider->onValueChanged.Add( this, &Slider::SliderMoved ); } { Gwen::Controls::VerticalSlider* pSlider = new Gwen::Controls::VerticalSlider( this ); pSlider->SetPos( 190, 10 ); pSlider->SetSize( 20, 200 ); pSlider->SetRange( 0, 100 ); pSlider->SetFloatValue( 20 ); pSlider->SetNotchCount( 10 ); pSlider->SetClampToNotches( true ); pSlider->onValueChanged.Add( this, &Slider::SliderMoved ); } }
Gwen::Controls::Base* SettingsPanel::addSlider( Gwen::Controls::Base* pControl , Rectf bounds, string name, float value, float valueMin, float valueMax){ Gwen::Controls::Base* cont = new Gwen::Controls::Base( pControl ); cont->Dock( Gwen::Pos::Top ); cont->SetMargin( Gwen::Margin(5,7,5,7) ); cont->SetHeight( 38 ); int px = 0;//bounds.getX1(); int py = 0;//bounds.getY1(); int w = bounds.getWidth(); Gwen::Controls::Base* lbls = new Gwen::Controls::Base( cont ); lbls->Dock( Gwen::Pos::Top ); lbls->SetHeight( 20 ); Gwen::Controls::Label* label = new Gwen::Controls::Label( lbls ); label->Dock( Gwen::Pos::Left ); label->SetText( name ); label->SizeToContents(); // label->SetPos( px, py ); Gwen::Controls::Label* labelValue = new Gwen::Controls::Label( lbls ); // labelValue->SizeToContents(); labelValue->Dock( Gwen::Pos::Right ); labelValue->SetWidth(w); labelValue->SetAlignment(Gwen::Pos::Right); // labelValue->SetPos( px, py ); labelValue->SetText( toString(value) ); Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( cont ); labelValue->Dock( Gwen::Pos::Top ); pSlider->SetPos( px, py + 17 ); pSlider->SetSize( w, 20 ); pSlider->SetClampToNotches(false); pSlider->SetNotchCount( (valueMax-valueMin)/10 ); pSlider->SetRange( valueMin, valueMax ); pSlider->SetFloatValue( value ); pSlider->SetName(name); pSlider->onValueChanged.Add( this, &SettingsPanel::onSliderLaserOutput ); mLabelsMap[pSlider] = labelValue; mSliderValueMap[name] = pSlider; return pSlider; }