From 940f955bbc34b20bb05b3810a7074aa8ba85eb62 Mon Sep 17 00:00:00 2001 From: eshifri <46511024+eshifri@users.noreply.github.com> Date: Tue, 22 Nov 2022 02:14:48 -0800 Subject: [PATCH] fix(color): Refresh color picker labels when chg between HSV and RGB (#2774) --- radio/src/gui/colorlcd/color_editor.cpp | 26 +++++++++++++++++++------ radio/src/gui/colorlcd/color_editor.h | 2 ++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/radio/src/gui/colorlcd/color_editor.cpp b/radio/src/gui/colorlcd/color_editor.cpp index 518d32084..146a0816c 100644 --- a/radio/src/gui/colorlcd/color_editor.cpp +++ b/radio/src/gui/colorlcd/color_editor.cpp @@ -334,20 +334,21 @@ void ColorEditor::setColorEditorType(COLOR_EDITOR_TYPE colorType) if (_colorType != nullptr) { delete _colorType; } - if (colorType == RGB_COLOR_EDITOR) + if (colorType == RGB_COLOR_EDITOR) { _colorType = new RGBColorType(this, _color); - else + setRGB(); + } else { _colorType = new HSVColorType(this, _color); + setHSV(); + } invalidate(); } -void ColorEditor::setRGB() +void ColorEditor::setText() { - _color = _colorType->getRGB(); - - // update bars & labels for (int i = 0; i < MAX_BARS; i++) { auto bar = _colorType->bars[i]; + lv_label_set_text_static(barLabels[i], _colorType->getLabelChars()[i]); lv_label_set_text_fmt(barValLabels[i], "%" PRIu32, bar->value); bar->invalidate(); } @@ -355,6 +356,19 @@ void ColorEditor::setRGB() if (_setValue != nullptr) _setValue(_color); } +void ColorEditor::setRGB() +{ + _color = _colorType->getRGB(); + // update bars & labels + setText(); +} + +void ColorEditor::setHSV() +{ + // update bars & labels + setText(); +} + void ColorEditor::value_changed(lv_event_t* e) { lv_obj_t* target = lv_event_get_target(e); diff --git a/radio/src/gui/colorlcd/color_editor.h b/radio/src/gui/colorlcd/color_editor.h index b0ba95f23..978a167dd 100644 --- a/radio/src/gui/colorlcd/color_editor.h +++ b/radio/src/gui/colorlcd/color_editor.h @@ -97,6 +97,8 @@ class ColorEditor : public FormGroup std::function _setValue; uint32_t _color; + void setText(); + void setHSV(); void setRGB(); static void value_changed(lv_event_t* e); };