Skip to content

declarative::color_picker::SlidersRGB#

RGB sliders for editing a color.

Header:#include <AUI/View/AColorPicker.h>
CMake:aui_link(my_target PUBLIC aui::views)

Detailed Description#

SlidersRGB exposes three sliders, one for each channel (red, green, blue). The sliders are bound to a shared AColor contract and notify a callback when the color changes.

#include <AUI/Platform/Entry.h>
#include <AUI/Platform/AWindow.h>
#include <AUI/View/AColorPicker.h>

using namespace ass;
using namespace declarative;


class MainWindow : public AWindow {
public:
    MainWindow() : AWindow("Color picker", 600_dp, 300_dp) {
        auto color = _new<AProperty<AColor>>(AColor::RED);
        setContents(Vertical {
          GroupBox {
            Label { "View" },
            color_picker::ColorView { AUI_REACT(**color) } AUI_OVERRIDE_STYLE {
                  FixedSize(40_dp, 20_dp),
                  Border { 1_px, AColor::BLACK },
                  Padding { 2_px },
                },
          },
          GroupBox {
            Label { "Sliders RGB" },
            color_picker::SlidersRGB {
              .color = AUI_REACT(**color),
              .onColorChanged = [color](AColor c) { *color = c; },
            },
          },
        });
    }

};

AUI_ENTRY {
    _new<MainWindow>()->show();
    return 0;
}

Public fields and Signals#


Channel#

using Channel

Pointer to a color channel.


color#

contract::In<AColor> color

The color contract to edit.


onColorChanged#

std::function<void(AColor)> onColorChanged

Callback invoked when the color changes.


sliderFactory#

std::function<_<AView>(contract::In<AColor>color,std::function<void(AColor)>onColorChanged,Channelchannel)> sliderFactory

Factory used to create individual sliders.

Public Methods#

defaultSlider#


static _<AView> SlidersRGB::defaultSlider(contract::In<AColor> color, std::function<void(AColor)> onColorChanged, Channel channel)

Creates a slider for a single channel.

Arguments
color
The color contract.
onColorChanged
Callback when the color changes.
channel
Pointer to the channel member.
Returns
A view containing the slider.