private Button _button(string text, int delta) { Button button = new Button(text); button.area.widthExpandable = false; button.area.heightExpandable = false; button.area.width = 25; button.area.height = 25; button.font.style = FontStyle.Bold; button.onClick = ((b, m) => { _value = _value + delta; updateValue(); }); return button; }
public AxisController(string name, bool fullCircle) { _fullCircle = fullCircle; Layout mainLayout = Layout.makeHorizontal(); var nameLabel = new Label(name); nameLabel.area.width = 50; nameLabel.font.normal = Color.white; nameLabel.font.style = FontStyle.Bold; mainLayout.views.add(nameLabel); Layout digitalLayout = Layout.makeHorizontal(); digitalLayout.views.add(new Space()); digitalLayout.views.add(_button("<<<", -15)); digitalLayout.views.add(_button("<<", -5)); digitalLayout.views.add(_button("<", -1)); _info = new Label("0"); _info.area.width = 30; _info.font.alignment = Alignment.Center; _info.font.style = FontStyle.Bold; digitalLayout.views.add(_info); digitalLayout.views.add(_button(">", 1)); digitalLayout.views.add(_button(">>", 5)); digitalLayout.views.add(_button(">>>", 15)); digitalLayout.views.add(new Space()); Layout analogLayout = Layout.makeHorizontal(); _slider = new Slider(-90, 90, 0); _slider.onUpdate = (s => { updateSliderValue(s.value); }); analogLayout.views.add(_slider); Layout controlLayout = Layout.makeVertical(); controlLayout.views.add(digitalLayout); controlLayout.views.add(analogLayout); mainLayout.views.add(controlLayout); Layout switchLayout = Layout.makeVertical(); switchLayout.views.add(new Space(10)); _sideSwitch = new Button("+"); _sideSwitch.area.width = 30; _sideSwitch.area.height = 30; _sideSwitch.onClick = ((b, m) => { onFrontSide = !onFrontSide; if(onFrontSide) b.text = "+"; else b.text = "-"; }); if(_fullCircle) switchLayout.views.add(_sideSwitch); else { Layout placeholder = Layout.makeHorizontal(); placeholder.views.add(new Space(34)); switchLayout.views.add(placeholder); } switchLayout.views.add(new Space()); mainLayout.views.add(new Space(10)); mainLayout.views.add(switchLayout); _view = mainLayout; }