feat(color): use PAGE keys to cycle through top level quick menu items (#6723)
This commit is contained in:
@@ -37,11 +37,7 @@ ButtonBase* QuickSubMenu::addButton()
|
|||||||
{
|
{
|
||||||
menuButton = quickMenu->getTopMenu()->addButton(icon, title,
|
menuButton = quickMenu->getTopMenu()->addButton(icon, title,
|
||||||
[=]() -> uint8_t {
|
[=]() -> uint8_t {
|
||||||
if (!subMenu) buildSubMenu();
|
activate();
|
||||||
quickMenu->getTopMenu()->setCurrent(menuButton);
|
|
||||||
quickMenu->getTopMenu()->setDisabled(false);
|
|
||||||
quickMenu->getTopMenu()->clearFocus();
|
|
||||||
enableSubMenu();
|
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -68,6 +64,13 @@ bool QuickSubMenu::isSubMenu(QuickMenu::SubMenu n)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QuickSubMenu::isSubMenu(ButtonBase* b)
|
||||||
|
{
|
||||||
|
for (int i = 0; items[i].icon < EDGETX_ICONS_COUNT; i += 1)
|
||||||
|
if (menuButton == b) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int QuickSubMenu::getIndex(QuickMenu::SubMenu n)
|
int QuickSubMenu::getIndex(QuickMenu::SubMenu n)
|
||||||
{
|
{
|
||||||
for (int i = 0; items[i].icon < EDGETX_ICONS_COUNT; i += 1)
|
for (int i = 0; items[i].icon < EDGETX_ICONS_COUNT; i += 1)
|
||||||
@@ -99,6 +102,15 @@ void QuickSubMenu::setCurrent(QuickMenu::SubMenu n)
|
|||||||
enableSubMenu();
|
enableSubMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuickSubMenu::activate()
|
||||||
|
{
|
||||||
|
if (!subMenu) buildSubMenu();
|
||||||
|
quickMenu->getTopMenu()->setCurrent(menuButton);
|
||||||
|
quickMenu->getTopMenu()->setDisabled(false);
|
||||||
|
quickMenu->getTopMenu()->clearFocus();
|
||||||
|
enableSubMenu();
|
||||||
|
}
|
||||||
|
|
||||||
void QuickSubMenu::doLayout()
|
void QuickSubMenu::doLayout()
|
||||||
{
|
{
|
||||||
if (subMenu)
|
if (subMenu)
|
||||||
@@ -344,4 +356,31 @@ void QuickMenu::onLongPressMDL() { onSelect(true); new ModelLabelsWindow(); }
|
|||||||
void QuickMenu::onPressTELE() { subMenus[2]->onPress(ScreenSetupPage::FIRST_SCREEN_OFFSET); }
|
void QuickMenu::onPressTELE() { subMenus[2]->onPress(ScreenSetupPage::FIRST_SCREEN_OFFSET); }
|
||||||
void QuickMenu::onLongPressTELE() { onSelect(true); new ChannelsViewMenu(); }
|
void QuickMenu::onLongPressTELE() { onSelect(true); new ChannelsViewMenu(); }
|
||||||
void QuickMenu::onLongPressRTN() { closeMenu(); }
|
void QuickMenu::onLongPressRTN() { closeMenu(); }
|
||||||
|
|
||||||
|
void QuickMenu::afterPG()
|
||||||
|
{
|
||||||
|
auto b = mainMenu->getFocusedButton();
|
||||||
|
if (b) {
|
||||||
|
for(auto sub : subMenus) {
|
||||||
|
if (sub->isSubMenu(b)) {
|
||||||
|
sub->activate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
focusMainMenu();
|
||||||
|
curPage = QuickMenu::NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickMenu::onPressPGDN()
|
||||||
|
{
|
||||||
|
mainMenu->nextEntry();
|
||||||
|
afterPG();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickMenu::onPressPGUP()
|
||||||
|
{
|
||||||
|
mainMenu->prevEntry();
|
||||||
|
afterPG();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ class QuickMenu : public NavWindow
|
|||||||
void onPressTELE() override;
|
void onPressTELE() override;
|
||||||
void onLongPressTELE() override;
|
void onLongPressTELE() override;
|
||||||
void onLongPressRTN() override;
|
void onLongPressRTN() override;
|
||||||
|
void onPressPGDN() override;
|
||||||
|
void onPressPGUP() override;
|
||||||
|
void afterPG();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static constexpr int QM_MAIN_BTNS = 6;
|
static constexpr int QM_MAIN_BTNS = 6;
|
||||||
@@ -164,12 +167,14 @@ class QuickSubMenu
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
bool isSubMenu(QuickMenu::SubMenu n);
|
bool isSubMenu(QuickMenu::SubMenu n);
|
||||||
|
bool isSubMenu(ButtonBase* b);
|
||||||
int getIndex(QuickMenu::SubMenu n);
|
int getIndex(QuickMenu::SubMenu n);
|
||||||
|
|
||||||
ButtonBase* addButton();
|
ButtonBase* addButton();
|
||||||
void enableSubMenu();
|
void enableSubMenu();
|
||||||
void setDisabled(bool all);
|
void setDisabled(bool all);
|
||||||
void setCurrent(QuickMenu::SubMenu n);
|
void setCurrent(QuickMenu::SubMenu n);
|
||||||
|
void activate();
|
||||||
void buildSubMenu();
|
void buildSubMenu();
|
||||||
uint8_t onPress(int n);
|
uint8_t onPress(int n);
|
||||||
void onSelect(bool close);
|
void onSelect(bool close);
|
||||||
|
|||||||
@@ -232,3 +232,28 @@ void QuickMenuGroup::doLayout(int cols)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuickMenuGroup::nextEntry()
|
||||||
|
{
|
||||||
|
if (group)
|
||||||
|
lv_group_focus_next(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickMenuGroup::prevEntry()
|
||||||
|
{
|
||||||
|
if (group)
|
||||||
|
lv_group_focus_prev(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
ButtonBase* QuickMenuGroup::getFocusedButton()
|
||||||
|
{
|
||||||
|
if (group) {
|
||||||
|
lv_obj_t* b = lv_group_get_focused(group);
|
||||||
|
if (b) {
|
||||||
|
for (size_t i = 0; i < btns.size(); i += 1)
|
||||||
|
if (btns[i]->getLvObj() == b)
|
||||||
|
return btns[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ class QuickMenuGroup : public Window
|
|||||||
void setCurrent(ButtonBase* b);
|
void setCurrent(ButtonBase* b);
|
||||||
void setCurrent(int b) { setCurrent(btns[b]); }
|
void setCurrent(int b) { setCurrent(btns[b]); }
|
||||||
void doLayout(int cols);
|
void doLayout(int cols);
|
||||||
|
void nextEntry();
|
||||||
|
void prevEntry();
|
||||||
|
ButtonBase* getFocusedButton();
|
||||||
|
|
||||||
#if PORTRAIT
|
#if PORTRAIT
|
||||||
static LAYOUT_VAL_SCALED(QM_BUTTON_WIDTH, 72)
|
static LAYOUT_VAL_SCALED(QM_BUTTON_WIDTH, 72)
|
||||||
|
|||||||
Reference in New Issue
Block a user