fix(color): scroll wheel direction not intuitive when editing color bars (#6056)
This commit is contained in:
@@ -33,7 +33,7 @@ class ColorBar : public FormField
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ColorBar(Window* parent, const rect_t& r, uint32_t value = 0,
|
ColorBar(Window* parent, const rect_t& r, uint32_t value = 0,
|
||||||
uint32_t maxValue = 0, bool invert = false) :
|
uint32_t maxValue = 0) :
|
||||||
FormField(parent, r)
|
FormField(parent, r)
|
||||||
{
|
{
|
||||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_ENCODER_ACCEL);
|
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_ENCODER_ACCEL);
|
||||||
@@ -55,7 +55,6 @@ class ColorBar : public FormField
|
|||||||
auto h = height() - 4; // exclude border
|
auto h = height() - 4; // exclude border
|
||||||
|
|
||||||
int scaledValue = (val * h + maxValue / 2) / maxValue;
|
int scaledValue = (val * h + maxValue / 2) / maxValue;
|
||||||
if (invert) scaledValue = h - scaledValue;
|
|
||||||
return scaledValue;
|
return scaledValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +67,6 @@ class ColorBar : public FormField
|
|||||||
pos = max<int>(pos, 0);
|
pos = max<int>(pos, 0);
|
||||||
|
|
||||||
uint32_t scaledValue = ((pos * maxValue + h / 2) / h);
|
uint32_t scaledValue = ((pos * maxValue + h / 2) / h);
|
||||||
if (invert) scaledValue = maxValue - scaledValue;
|
|
||||||
return scaledValue;
|
return scaledValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +104,7 @@ class ColorBar : public FormField
|
|||||||
if (!bar) return;
|
if (!bar) return;
|
||||||
|
|
||||||
uint32_t key = *(uint32_t*)lv_event_get_param(e);
|
uint32_t key = *(uint32_t*)lv_event_get_param(e);
|
||||||
|
|
||||||
if (key == LV_KEY_LEFT) {
|
if (key == LV_KEY_LEFT) {
|
||||||
if (bar->value > 0) {
|
if (bar->value > 0) {
|
||||||
uint32_t accel = rotaryEncoderGetAccel();
|
uint32_t accel = rotaryEncoderGetAccel();
|
||||||
@@ -191,7 +190,6 @@ class ColorBar : public FormField
|
|||||||
|
|
||||||
uint32_t maxValue = 0;
|
uint32_t maxValue = 0;
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
bool invert = false;
|
|
||||||
getRGBFromPos getRGB = nullptr;
|
getRGBFromPos getRGB = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -300,7 +298,6 @@ class HSVColorType : public BarColorType
|
|||||||
|
|
||||||
for (auto i = 0; i < MAX_BARS; i++) {
|
for (auto i = 0; i < MAX_BARS; i++) {
|
||||||
bars[i]->maxValue = (i == 0) ? MAX_HUE : (i == 1) ? MAX_SATURATION : MAX_BRIGHTNESS;
|
bars[i]->maxValue = (i == 0) ? MAX_HUE : (i == 1) ? MAX_SATURATION : MAX_BRIGHTNESS;
|
||||||
bars[i]->invert = i != 0;
|
|
||||||
bars[i]->value = values[i];
|
bars[i]->value = values[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +346,6 @@ class RGBColorType : public BarColorType
|
|||||||
for (auto i = 0; i < MAX_BARS; i++) {
|
for (auto i = 0; i < MAX_BARS; i++) {
|
||||||
bars[i]->maxValue = 255;
|
bars[i]->maxValue = 255;
|
||||||
bars[i]->value = values[i];
|
bars[i]->value = values[i];
|
||||||
bars[i]->invert = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bars[0]->getRGB = [=](int pos) { return RGB32(pos, 0, 0); };
|
bars[0]->getRGB = [=](int pos) { return RGB32(pos, 0, 0); };
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class ColorEditorPopup : public BaseDialog
|
|||||||
|
|
||||||
hbox = new Window(vbox, rect_t{});
|
hbox = new Window(vbox, rect_t{});
|
||||||
hbox->padTop(BTN_PAD_TOP);
|
hbox->padTop(BTN_PAD_TOP);
|
||||||
hbox->setFlexLayout(LV_FLEX_FLOW_ROW, EdgeTxStyles::STD_FONT_HEIGHT);
|
hbox->setFlexLayout(LV_FLEX_FLOW_ROW, PAD_MEDIUM);
|
||||||
lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER,
|
lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER,
|
||||||
LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_SPACE_BETWEEN);
|
LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_SPACE_BETWEEN);
|
||||||
lv_obj_set_flex_grow(hbox->getLvObj(), 1);
|
lv_obj_set_flex_grow(hbox->getLvObj(), 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user