chore(color): simplify the code for the mix line multiplex icon (#7820)
This commit is contained in:
@@ -218,6 +218,20 @@ void InputMixButtonBase::updateHeight()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputMixButtonBase::swapLvglGroup(InputMixButtonBase* swapWith)
|
||||||
|
{
|
||||||
|
// Swap elements (focus + line list)
|
||||||
|
lv_obj_t* obj1 = getLvObj();
|
||||||
|
lv_obj_t* obj2 = swapWith->getLvObj();
|
||||||
|
if (lv_obj_get_parent(obj1) == lv_obj_get_parent(obj2)) {
|
||||||
|
// same input group: swap obj + focus group
|
||||||
|
lv_obj_swap(obj1, obj2);
|
||||||
|
} else {
|
||||||
|
// different input group: swap only focus group
|
||||||
|
lv_group_swap_obj(obj1, obj2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void group_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
|
static void group_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
|
||||||
{
|
{
|
||||||
etx_std_style(obj, LV_PART_MAIN, PAD_TINY);
|
etx_std_style(obj, LV_PART_MAIN, PAD_TINY);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class InputMixButtonBase : public ListLineButton
|
|||||||
|
|
||||||
void updateHeight();
|
void updateHeight();
|
||||||
virtual void updatePos(coord_t x, coord_t y) = 0;
|
virtual void updatePos(coord_t x, coord_t y) = 0;
|
||||||
virtual void swapLvglGroup(InputMixButtonBase* line2) = 0;
|
void swapLvglGroup(InputMixButtonBase* swapWith);
|
||||||
|
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
|
|
||||||
|
|||||||
@@ -193,10 +193,13 @@ void StaticIcon::setColor(LcdColorIndex color)
|
|||||||
|
|
||||||
void StaticIcon::setIcon(EdgeTxIcon icon)
|
void StaticIcon::setIcon(EdgeTxIcon icon)
|
||||||
{
|
{
|
||||||
auto newMask = getBuiltinIcon(icon);
|
if (currentIcon != icon) {
|
||||||
setSize(newMask->width, newMask->height);
|
currentIcon = icon;
|
||||||
lv_canvas_set_buffer(lvobj, (void*)newMask->data, newMask->width, newMask->height,
|
auto newMask = getBuiltinIcon(icon);
|
||||||
LV_IMG_CF_ALPHA_8BIT);
|
setSize(newMask->width, newMask->height);
|
||||||
|
lv_canvas_set_buffer(lvobj, (void*)newMask->data, newMask->width, newMask->height,
|
||||||
|
LV_IMG_CF_ALPHA_8BIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticIcon::center(coord_t w, coord_t h)
|
void StaticIcon::center(coord_t w, coord_t h)
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class StaticIcon : public Window
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
LcdColorIndex currentColor;
|
LcdColorIndex currentColor;
|
||||||
|
EdgeTxIcon currentIcon = EDGETX_ICONS_COUNT;
|
||||||
MaskBitmap* mask = nullptr;
|
MaskBitmap* mask = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -166,22 +166,6 @@ class InputLineButton : public InputMixButtonBase
|
|||||||
setPos(x, y);
|
setPos(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void swapLvglGroup(InputMixButtonBase* line2) override
|
|
||||||
{
|
|
||||||
InputLineButton* swapWith = (InputLineButton*)line2;
|
|
||||||
|
|
||||||
// Swap elements (focus + line list)
|
|
||||||
lv_obj_t* obj1 = getLvObj();
|
|
||||||
lv_obj_t* obj2 = swapWith->getLvObj();
|
|
||||||
if (lv_obj_get_parent(obj1) == lv_obj_get_parent(obj2)) {
|
|
||||||
// same input group: swap obj + focus group
|
|
||||||
lv_obj_swap(obj1, obj2);
|
|
||||||
} else {
|
|
||||||
// different input group: swap only focus group
|
|
||||||
lv_group_swap_obj(obj1, obj2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isActive() const override { return isExpoActive(index); }
|
bool isActive() const override { return isExpoActive(index); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -33,65 +33,25 @@
|
|||||||
|
|
||||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||||
|
|
||||||
class MPlexIcon : public Window
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MPlexIcon(Window* parent, uint8_t index) :
|
|
||||||
Window(parent, {0, 0, MPLEX_ICON_W, MPLEX_ICON_H}),
|
|
||||||
index(index)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void refresh()
|
|
||||||
{
|
|
||||||
MixData* mix = mixAddress(index);
|
|
||||||
EdgeTxIcon n = ICON_MPLEX_ADD;
|
|
||||||
if (mix->mltpx == MLTPX_MUL) {
|
|
||||||
n = ICON_MPLEX_MULTIPLY;
|
|
||||||
} else if (mix->mltpx == MLTPX_REPL) {
|
|
||||||
n = ICON_MPLEX_REPLACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!icon) {
|
|
||||||
icon = new StaticIcon(this, 0, 0, n, COLOR_THEME_SECONDARY1_INDEX);
|
|
||||||
icon->center(width(), height());
|
|
||||||
}
|
|
||||||
|
|
||||||
icon->show(lv_obj_get_index(lvobj) != 0);
|
|
||||||
icon->setIcon(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIndex(uint8_t i)
|
|
||||||
{
|
|
||||||
index = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static LAYOUT_VAL_SCALED(MPLEX_ICON_W, 25)
|
|
||||||
static LAYOUT_VAL_SCALED(MPLEX_ICON_H, 29)
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint8_t index;
|
|
||||||
StaticIcon* icon = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MixLineButton : public InputMixButtonBase
|
class MixLineButton : public InputMixButtonBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MixLineButton(Window* parent, uint8_t index) :
|
MixLineButton(Window* parent, uint8_t index) :
|
||||||
InputMixButtonBase(parent, index)
|
InputMixButtonBase(parent, index)
|
||||||
{
|
{
|
||||||
mplex = new MPlexIcon(parent, index);
|
// Allow multiplex icon to render outside this window
|
||||||
|
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_OVERFLOW_VISIBLE);
|
||||||
// mplex is a sibling (not a child) so must be closed explicitly
|
|
||||||
onClosing([=]() {
|
|
||||||
mplex->closeWindow();
|
|
||||||
});
|
|
||||||
|
|
||||||
delayLoad();
|
delayLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
void delayedInit() override
|
void delayedInit() override
|
||||||
{
|
{
|
||||||
|
// Add multiplex icon
|
||||||
|
mplex = new StaticIcon(this, 0, 0, ICON_MPLEX_ADD, COLOR_THEME_SECONDARY1_INDEX);
|
||||||
|
// Position multiplex icon to the left of the parent mix line
|
||||||
|
mplex->setPos(-mplex->width() - PAD_MEDIUM, PAD_SMALL);
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
((InputMixGroupBase*)parent)->adjustHeight();
|
((InputMixGroupBase*)parent)->adjustHeight();
|
||||||
}
|
}
|
||||||
@@ -125,50 +85,24 @@ class MixLineButton : public InputMixButtonBase
|
|||||||
|
|
||||||
setOpts(tmp_str);
|
setOpts(tmp_str);
|
||||||
|
|
||||||
mplex->refresh();
|
if (mplex)
|
||||||
|
mplex->setIcon((EdgeTxIcon)(ICON_MPLEX_ADD + line.mltpx));
|
||||||
|
|
||||||
setFlightModes(line.flightModes);
|
setFlightModes(line.flightModes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIndex(uint8_t i) override
|
|
||||||
{
|
|
||||||
ListLineButton::setIndex(i);
|
|
||||||
mplex->setIndex(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void updatePos(coord_t x, coord_t y) override
|
void updatePos(coord_t x, coord_t y) override
|
||||||
{
|
{
|
||||||
setPos(x, y);
|
setPos(x, y);
|
||||||
mplex->setPos(x - MPLEX_XO, y);
|
// Don't show multiplex icon for first line
|
||||||
mplex->show(y > ListLineButton::BTN_H);
|
if (mplex)
|
||||||
}
|
mplex->show(y > ListLineButton::BTN_H);
|
||||||
|
|
||||||
lv_obj_t* mplexLvObj() const { return mplex->getLvObj(); }
|
|
||||||
|
|
||||||
void swapLvglGroup(InputMixButtonBase* line2) override
|
|
||||||
{
|
|
||||||
MixLineButton* swapWith = (MixLineButton*)line2;
|
|
||||||
|
|
||||||
// Swap elements (focus + line list)
|
|
||||||
lv_obj_t* obj1 = getLvObj();
|
|
||||||
lv_obj_t* obj2 = swapWith->getLvObj();
|
|
||||||
if (lv_obj_get_parent(obj1) == lv_obj_get_parent(obj2)) {
|
|
||||||
// same input group: swap obj + focus group
|
|
||||||
lv_obj_swap(obj1, obj2);
|
|
||||||
lv_obj_swap(mplexLvObj(), swapWith->mplexLvObj());
|
|
||||||
} else {
|
|
||||||
// different input group: swap only focus group
|
|
||||||
lv_group_swap_obj(obj1, obj2);
|
|
||||||
lv_group_swap_obj(mplexLvObj(), swapWith->mplexLvObj());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isActive() const override { return isMixActive(index); }
|
bool isActive() const override { return isMixActive(index); }
|
||||||
|
|
||||||
static LAYOUT_VAL_SCALED(MPLEX_XO, 28)
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MPlexIcon* mplex = nullptr;
|
StaticIcon* mplex = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MixGroup : public InputMixGroupBase
|
class MixGroup : public InputMixGroupBase
|
||||||
|
|||||||
@@ -636,6 +636,7 @@ TEST_F(ModelCellManagerFsTest, RenameLabelOntoExistingLabelWithProgressDialog)
|
|||||||
// Dialogs are always shown over the main view
|
// Dialogs are always shown over the main view
|
||||||
ViewMain::instance();
|
ViewMain::instance();
|
||||||
MainWindow::instance()->run();
|
MainWindow::instance()->run();
|
||||||
|
lcdFlushed();
|
||||||
|
|
||||||
auto rndialog = new ProgressDialog(STR_RENAME_LABEL, [=]() {});
|
auto rndialog = new ProgressDialog(STR_RENAME_LABEL, [=]() {});
|
||||||
lv_obj_t* bar = findProgressBar(rndialog->getLvObj());
|
lv_obj_t* bar = findProgressBar(rndialog->getLvObj());
|
||||||
|
|||||||
Reference in New Issue
Block a user