Class ColorPicker

Inheritance Relationships

Base Type

Derived Type

Class Documentation

class ColorPicker : public nanogui::PopupButton

Push button with a popup to tweak a color value. This widget was contributed by Christian Schueller.

Subclassed by nanogui::detail::FormWidget< Color, std::true_type >

Public Functions

ColorPicker(Widget *parent, const Color &color = Color(1.0f, , , ))

Attaches a ColorPicker to the specified parent.

Parameters

std::function<void(const Color&)> callback() const

The callback executed when the ColorWheel changes.

void setCallback(const std::function<void(const Color&)> &callback)

Sets the callback is executed as the ColorWheel itself is changed. Set this callback if you need to receive updates for the ColorWheel changing before the user clicks nanogui::ColorPicker::mPickButton or nanogui::ColorPicker::mPickButton.

std::function<void(const Color&)> finalCallback() const

The callback to execute when a new Color is selected on the ColorWheel and the user clicks the nanogui::ColorPicker::mPickButton or nanogui::ColorPicker::mResetButton.

void setFinalCallback(const std::function<void(const Color&)> &callback)

The callback to execute when a new Color is selected on the ColorWheel and the user clicks the nanogui::ColorPicker::mPickButton or nanogui::ColorPicker::mResetButton.

Color color() const

Get the current Color selected for this ColorPicker.

void setColor(const Color &color)

Set the current Color selected for this ColorPicker.

const std::string &pickButtonCaption()

The current caption of the nanogui::ColorPicker::mPickButton.

void setPickButtonCaption(const std::string &caption)

Sets the current caption of the nanogui::ColorPicker::mPickButton.

const std::string &resetButtonCaption()

The current caption of the nanogui::ColorPicker::mResetButton.

void setResetButtonCaption(const std::string &caption)

Sets the current caption of the nanogui::ColorPicker::mResetButton.

Protected Attributes

std::function<void(const Color&)> mCallback

The “fast” callback executed when the ColorWheel has changed.

std::function<void(const Color&)> mFinalCallback

The callback to execute when a new Color is selected on the ColorWheel and the user clicks the nanogui::ColorPicker::mPickButton or nanogui::ColorPicker::mResetButton.

ColorWheel *mColorWheel

The ColorWheel for this ColorPicker (the actual widget allowing selection).

Button *mPickButton

The Button used to signal that the current value on the ColorWheel is the desired color to be chosen. The default value for the caption of this Button is "Pick". You can change it using nanogui::ColorPicker::setPickButtonCaption if you need.

The color of this Button will not affect nanogui::ColorPicker::color until the user has actively selected by clicking this pick button. Similarly, the nanogui::ColorPicker::mCallback function is only called when a user selects a new Color using by clicking this Button.

Button *mResetButton

Remains the Color of the active color selection, until the user picks a new Color on the ColorWheel and selects the nanogui::ColorPicker::mPickButton. The default value for the caption of this Button is "Reset". You can change it using nanogui::ColorPicker::setResetButtonCaption if you need.