| 21 | } |
| 22 | |
| 23 | void ColorPage::init() |
| 24 | { |
| 25 | stylesheet = FlexJsonStringify({"flexGrow" : 1.0}); |
| 26 | |
| 27 | _checkBox = std::make_shared<ui::Checkbox>(); |
| 28 | _checkBox->state = ui::TriState::On; |
| 29 | _checkBox->state.onChange() += [this](auto) { updateColor(); }; |
| 30 | |
| 31 | addChildView(makeRow("Enable color", _checkBox)); |
| 32 | |
| 33 | for (auto &slider : _rgbSlider) { |
| 34 | slider->stylesheet = FlexJsonStringify({"minimumSize" : {"width" : 100}}); |
| 35 | slider->value.onChange() += [this](auto) { updateColor(); }; |
| 36 | } |
| 37 | |
| 38 | addChildView(makeRow("Red", _rgbSlider[0])); |
| 39 | addChildView(makeRow("Green", _rgbSlider[1])); |
| 40 | addChildView(makeRow("Blue", _rgbSlider[2])); |
| 41 | addChildView(makeRow("Alpha", _rgbSlider[3])); |
| 42 | |
| 43 | auto colorLabel = std::make_shared<Label>(); |
| 44 | colorLabel->text.bind(colorText); |
| 45 | addChildView(makeRow("Color", colorLabel)); |
| 46 | |
| 47 | _colorBox = std::make_shared<ContainerView>(); |
| 48 | _colorBox->stylesheet = FlexJsonStringify({"minimumSize" : {"width" : 200, "height" : 100}}); |
| 49 | |
| 50 | addChildView(_colorBox); |
| 51 | |
| 52 | _rgbSlider[0]->value = 0.0; |
| 53 | _rgbSlider[1]->value = 0.5; |
| 54 | _rgbSlider[2]->value = 1.0; |
| 55 | _rgbSlider[3]->value = 1.0; |
| 56 | } |
| 57 | } |