Added to ColorEditor rpl value of current colors.

This commit is contained in:
23rd 2023-01-24 20:28:57 +03:00 committed by John Preston
parent dff738f3c6
commit 5c3067d1f8
2 changed files with 9 additions and 0 deletions

View File

@ -948,6 +948,10 @@ QColor ColorEditor::color() const {
return _new.toRgb(); return _new.toRgb();
} }
rpl::producer<QColor> ColorEditor::colorValue() const {
return _newChanges.events_starting_with_copy(_new);
}
rpl::producer<> ColorEditor::submitRequests() const { rpl::producer<> ColorEditor::submitRequests() const {
return _submitRequests.events(); return _submitRequests.events();
} }
@ -1147,6 +1151,7 @@ QColor ColorEditor::applyLimits(QColor color) const {
void ColorEditor::updateFromColor(QColor color) { void ColorEditor::updateFromColor(QColor color) {
_new = applyLimits(color); _new = applyLimits(color);
_newChanges.fire_copy(_new);
updateControlsFromColor(); updateControlsFromColor();
updateRGBFields(); updateRGBFields();
updateHSBFields(); updateHSBFields();
@ -1252,6 +1257,7 @@ void ColorEditor::setHSB(HSB hsb, int alpha) {
} else { } else {
_new.setHsl(hsb.hue, hsb.saturation, hsb.brightness, alpha); _new.setHsl(hsb.hue, hsb.saturation, hsb.brightness, alpha);
} }
_newChanges.fire_copy(_new);
updateRGBFields(); updateRGBFields();
updateResultField(); updateResultField();
update(); update();
@ -1259,6 +1265,7 @@ void ColorEditor::setHSB(HSB hsb, int alpha) {
void ColorEditor::setRGB(int red, int green, int blue, int alpha) { void ColorEditor::setRGB(int red, int green, int blue, int alpha) {
_new = applyLimits(QColor(red, green, blue, alpha)); _new = applyLimits(QColor(red, green, blue, alpha));
_newChanges.fire_copy(_new);
updateControlsFromColor(); updateControlsFromColor();
updateHSBFields(); updateHSBFields();
update(); update();

View File

@ -24,6 +24,7 @@ public:
void setLightnessLimits(int min, int max); void setLightnessLimits(int min, int max);
[[nodiscard]] QColor color() const; [[nodiscard]] QColor color() const;
[[nodiscard]] rpl::producer<QColor> colorValue() const;
[[nodiscard]] rpl::producer<> submitRequests() const; [[nodiscard]] rpl::producer<> submitRequests() const;
void showColor(QColor color) { void showColor(QColor color) {
@ -101,5 +102,6 @@ private:
int _lightnessMax = 255; int _lightnessMax = 255;
rpl::event_stream<> _submitRequests; rpl::event_stream<> _submitRequests;
rpl::event_stream<QColor> _newChanges;
}; };