void Label_SetHorizontalAlignment(Gwen::Controls::Label& label, const int32 value) { int32 alignment = label.GetAlignment(); alignment &= ~Gwen::Pos::Left; alignment &= ~Gwen::Pos::CenterH; alignment &= ~Gwen::Pos::Right; alignment |= value; label.SetAlignment(alignment); }
void Label_SetVerticalAlignment(Gwen::Controls::Label& label, const int32 value) { int32 alignment = label.GetAlignment(); alignment &= ~Gwen::Pos::Top; alignment &= ~Gwen::Pos::CenterV; alignment &= ~Gwen::Pos::Bottom; alignment |= value; label.SetAlignment(alignment); }
Gwen::Controls::Base* SettingsPanel::addProperty( Gwen::Controls::Base* pControl , Rectf bounds, string name, int val){ Gwen::Controls::Base* cont = new Gwen::Controls::Base( pControl ); Gwen::Controls::Label* pLabelName = new Gwen::Controls::Label( cont ); Gwen::Controls::Label* pLabelValue = new Gwen::Controls::Label( cont ); cont->Dock( Gwen::Pos::Top ); cont->SetMargin( Gwen::Margin(5,7,5,7) ); cont->SetHeight( 20 ); pLabelName->SetText( name ); pLabelName->SetAlignment(Gwen::Pos::Left ); pLabelName->Dock( Gwen::Pos::Left ); pLabelName->SizeToContents(); pLabelValue->Dock( Gwen::Pos::Right ); pLabelValue->SetWidth( 300 ); pLabelValue->SetText( toString(val) ); pLabelValue->SetAlignment( Gwen::Pos::Right ); pLabelValue->SetName( name ); mLabelsValueMap[name] = pLabelValue; return pLabelName; }
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; }