void GwenParameterInterface::registerSliderFloatParameter(SliderParams& params) { Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(m_gwenInternalData->m_demoPage->GetPage()); m_paramInternalData->m_textLabels.push_back(label); //m_data->m_myControls.push_back(label); label->SetText( params.m_name); label->SetPos( 10, 10 + 25 ); label->SetWidth(110); label->SetPos(10,m_gwenInternalData->m_curYposition); m_gwenInternalData->m_curYposition+=22; Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( m_gwenInternalData->m_demoPage->GetPage()); m_paramInternalData->m_sliders.push_back(pSlider); //m_data->m_myControls.push_back(pSlider); pSlider->SetPos( 10, m_gwenInternalData->m_curYposition ); pSlider->SetSize( 100, 20 ); pSlider->SetRange( params.m_minVal, params.m_maxVal); pSlider->SetNotchCount(20);//float(params.m_maxVal-params.m_minVal)/100.f); pSlider->SetClampToNotches( params.m_clampToNotches ); pSlider->SetValue( *params.m_paramValuePointer);//dimensions[i] ); char labelName[1024]; sprintf(labelName,"%s",params.m_name);//axisNames[0]); MySliderEventHandler<btScalar>* handler = new MySliderEventHandler<btScalar>(labelName,label,pSlider,params.m_paramValuePointer); m_paramInternalData->m_sliderEventHandlers.push_back(handler); pSlider->onValueChanged.Add( handler, &MySliderEventHandler<btScalar>::SliderMoved ); handler->SliderMoved(pSlider); float v = pSlider->GetValue(); m_gwenInternalData->m_curYposition+=22; }
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; }
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 ); } }
MyWindow ( Gwen::Controls::Base* pParent) : Gwen::Controls::WindowControl( pParent ) { SetTitle( L"FEM Settings" ); SetSize( 200, 300 ); this->Dock( Gwen::Pos::Left ); m_TextOutput = new Gwen::Controls::ListBox( this ); m_TextOutput->Dock( Gwen::Pos::Bottom ); m_TextOutput->SetHeight( 100 ); { Gwen::Controls::GroupBox* pGroup = new Gwen::Controls::GroupBox( this ); pGroup->SetPos(5, 5); pGroup->SetSize(170, 45); // pGroup->Dock( Gwen::Pos::Fill ); pGroup->SetText( "Young modulus" ); Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( pGroup ); pSlider->SetPos( 5, 10 ); pSlider->SetSize( 130, 20 ); pSlider->SetRange( 0, 100 ); pSlider->SetValue( 25 ); pSlider->onValueChanged.Add( this, &MyWindow::SliderMoved); } Gwen::Controls::CheckBoxWithLabel* labeled = new Gwen::Controls::CheckBoxWithLabel( this ); labeled->SetPos( 10, 55); labeled->Checkbox()->SetChecked(true); labeled->Label()->SetText( "Stifness warping" ); // labeled->Checkbox()->onChecked.Add( handler, &MyHander::OnCheckedStiffnessWarping ); // labeled->Checkbox()->onUnChecked.Add( handler, &MyHander::OnUncheckedStiffnessWarping ); labeled->Checkbox()->onCheckChanged.Add( this, &MyWindow::OnCheckChangedStiffnessWarping ); // Gwen::Align::PlaceBelow( labeled, check, 10 ); if (0) { Gwen::Controls::GroupBox* pGroup = new Gwen::Controls::GroupBox( this ); pGroup->SetPos(5, 55); pGroup->SetSize(170, 45); // pGroup->Dock( Gwen::Pos::Fill ); pGroup->SetText( "Gravity" ); Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( pGroup); pSlider->SetPos( 5, 10 ); pSlider->SetSize( 130, 20 ); pSlider->SetRange( 0, 100 ); pSlider->SetValue( 25 ); pSlider->SetNotchCount( 10 ); pSlider->SetClampToNotches( true ); // pSlider->onValueChanged.Add( this, &Slider::SliderMoved ); } Gwen::Controls::Button* pButton = new Gwen::Controls::Button( this ); pButton->onPress.Add(this, &MyWindow::onButtonA); pButton->SetBounds( 5, 110, 170, 45); pButton->SetText( "Toggle simulation" ); }