fix some focus issues
This commit is contained in:
committed by
Raphael Coeffic
parent
a87e1564ea
commit
09c7c0bf67
@@ -61,19 +61,5 @@ ModelMenu::ModelMenu():
|
||||
#endif
|
||||
addTab(new ModelTelemetryPage());
|
||||
|
||||
addButton(&header);
|
||||
}
|
||||
|
||||
void ModelMenu::addButton(TabsGroupHeader* header)
|
||||
{
|
||||
OpenTxTheme::instance()->createTextButton(
|
||||
header, {LCD_W / 2 + 5, MENU_TITLE_TOP, LCD_W / 2 - 5, MENU_TITLE_HEIGHT},
|
||||
STR_OPEN_CHANNEL_MONITORS, [=]() {
|
||||
calledFromModel = 1;
|
||||
retTab = header->getCarousel()->getCurrentIndex();
|
||||
// TRACE("currentTab=%d %s", calledFromModel, typeid(*currentTab).name());
|
||||
new ChannelsViewMenu();
|
||||
deleteLater();
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@
|
||||
|
||||
#include "tabsgroup.h"
|
||||
|
||||
class ModelMenu: public TabsGroup {
|
||||
public:
|
||||
class ModelMenu : public TabsGroup
|
||||
{
|
||||
public:
|
||||
ModelMenu();
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() const override
|
||||
{
|
||||
return "ModelMenu";
|
||||
}
|
||||
#endif
|
||||
ModelMenu();
|
||||
std::string getName() const override { return "ModelMenu"; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void addButton(TabsGroupHeader* headerPtr);
|
||||
};
|
||||
|
||||
#endif // _MENU_MODEL_H_
|
||||
|
||||
@@ -48,40 +48,9 @@ class LayoutChoice : public Button
|
||||
update();
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(),
|
||||
event);
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
editMode = true;
|
||||
invalidate();
|
||||
openMenu();
|
||||
} else {
|
||||
FormField::onEvent(event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
bool onTouchEnd(coord_t, coord_t) override
|
||||
{
|
||||
if (enabled) {
|
||||
if (!hasFocus()) {
|
||||
setFocus(SET_FOCUS_DEFAULT);
|
||||
}
|
||||
onKeyPress();
|
||||
openMenu();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void openMenu()
|
||||
void onPress() override
|
||||
{
|
||||
auto menu = new Menu(parent);
|
||||
|
||||
for (auto layout : getRegisteredLayouts()) {
|
||||
menu->addLine(layout->getBitmap(), layout->getName(),
|
||||
[=]() { setValue(layout); });
|
||||
@@ -91,11 +60,10 @@ class LayoutChoice : public Button
|
||||
getRegisteredLayouts().end(), getValue());
|
||||
menu->select(std::distance(getRegisteredLayouts().begin(), it));
|
||||
|
||||
// menu->setCloseHandler([=]() {
|
||||
// editMode = false;
|
||||
// update();
|
||||
// // setFocus();
|
||||
// });
|
||||
menu->setCloseHandler([=]() {
|
||||
editMode = false;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -314,12 +282,12 @@ void ScreenSetupPage::build(FormWindow * form)
|
||||
void ScreenSetupPage::clearLayoutOptions()
|
||||
{
|
||||
if (!layoutOptions) return;
|
||||
layoutOptions->clear();
|
||||
}
|
||||
|
||||
void ScreenSetupPage::buildLayoutOptions()
|
||||
{
|
||||
if (!layoutOptions) return;
|
||||
layoutOptions->clear();
|
||||
|
||||
FlexGridLayout grid(line_col_dsc, line_row_dsc);
|
||||
layoutOptions->setFlexLayout();
|
||||
|
||||
@@ -22,12 +22,8 @@
|
||||
#include "tabsgroup.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "view_channels.h"
|
||||
#include "view_main.h"
|
||||
#include "model_outputs.h"
|
||||
#include "model_mixes.h"
|
||||
#include "static.h"
|
||||
#include "menu_model.h"
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
#include "keyboard_base.h"
|
||||
@@ -37,8 +33,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
int TabsGroup::calledFromModel = 0;
|
||||
int TabsGroup::retTab = 0;
|
||||
|
||||
TabsGroupHeader::TabsGroupHeader(TabsGroup* parent, uint8_t icon) :
|
||||
FormGroup(parent, {0, 0, LCD_W, MENU_BODY_TOP}, OPAQUE),
|
||||
@@ -47,13 +41,6 @@ TabsGroupHeader::TabsGroupHeader(TabsGroup* parent, uint8_t icon) :
|
||||
this,
|
||||
{0, 0, MENU_HEADER_BACK_BUTTON_WIDTH, MENU_HEADER_BACK_BUTTON_HEIGHT},
|
||||
[=]() -> uint8_t {
|
||||
if (!parent->calledFromModel) {
|
||||
ViewMain::instance()->setFocus(SET_FOCUS_DEFAULT);
|
||||
} else {
|
||||
auto menu = new ModelMenu();
|
||||
menu->setCurrentTab(parent->retTab);
|
||||
parent->calledFromModel = 0;
|
||||
}
|
||||
parent->deleteLater();
|
||||
return 1;
|
||||
},
|
||||
@@ -128,6 +115,7 @@ TabsGroup::TabsGroup(uint8_t icon):
|
||||
header(this, icon),
|
||||
body(this, { 0, MENU_BODY_TOP, LCD_W, MENU_BODY_HEIGHT }, FORM_FORWARD_FOCUS)
|
||||
{
|
||||
Layer::push(this);
|
||||
}
|
||||
|
||||
TabsGroup::~TabsGroup()
|
||||
@@ -137,6 +125,22 @@ TabsGroup::~TabsGroup()
|
||||
}
|
||||
}
|
||||
|
||||
void TabsGroup::deleteLater(bool detach, bool trash)
|
||||
{
|
||||
if (_deleted)
|
||||
return;
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
Keyboard::hide();
|
||||
#endif
|
||||
|
||||
header.deleteLater(true, false);
|
||||
body.deleteLater(true, false);
|
||||
|
||||
Window::deleteLater(detach, trash);
|
||||
Layer::pop(this);
|
||||
}
|
||||
|
||||
void TabsGroup::addTab(PageTab * page)
|
||||
{
|
||||
tabs.push_back(page);
|
||||
@@ -239,26 +243,7 @@ void TabsGroup::onEvent(event_t event)
|
||||
}
|
||||
else if (event == EVT_KEY_FIRST(KEY_EXIT)) {
|
||||
killEvents(event);
|
||||
if (!calledFromModel) {
|
||||
ViewMain::instance()->setFocus(SET_FOCUS_DEFAULT);
|
||||
}
|
||||
else {
|
||||
auto menu = new ModelMenu();
|
||||
menu->setCurrentTab(retTab);
|
||||
calledFromModel = 0;
|
||||
// TRACE("currentTab=%d %s", retTab, typeid(*currentTab).name());
|
||||
}
|
||||
deleteLater();
|
||||
} else if (event == EVT_KEY_FIRST(KEY_MODEL)) {
|
||||
TRACE("TabGroup %s", typeid(*this).name());
|
||||
if (typeid(*this) == typeid(ModelMenu) ) {
|
||||
killEvents(event);
|
||||
calledFromModel = 1;
|
||||
retTab = header.carousel.getCurrentIndex();
|
||||
// TRACE("currentTab=%d %s", calledFromModel, typeid(*currentTab).name());
|
||||
new ChannelsViewMenu();
|
||||
deleteLater();
|
||||
}
|
||||
} else if (parent) {
|
||||
parent->onEvent(event);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,6 @@ class TabsGroupHeader: public FormGroup {
|
||||
title = value;
|
||||
}
|
||||
|
||||
TabsCarousel* getCarousel() {return &carousel;}
|
||||
|
||||
protected:
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
@@ -167,23 +166,9 @@ class TabsGroup: public Window
|
||||
|
||||
public:
|
||||
explicit TabsGroup(uint8_t icon);
|
||||
|
||||
~TabsGroup() override;
|
||||
|
||||
void deleteLater(bool detach = true, bool trash = true) override
|
||||
{
|
||||
if (_deleted)
|
||||
return;
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
Keyboard::hide();
|
||||
#endif
|
||||
|
||||
header.deleteLater(true, false);
|
||||
body.deleteLater(true, false);
|
||||
|
||||
Window::deleteLater(detach, trash);
|
||||
}
|
||||
void deleteLater(bool detach = true, bool trash = true) override;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() const override
|
||||
@@ -227,8 +212,6 @@ class TabsGroup: public Window
|
||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||
#endif
|
||||
|
||||
static int calledFromModel;
|
||||
static int retTab;
|
||||
|
||||
protected:
|
||||
TabsGroupHeader header;
|
||||
|
||||
Vendored
+1
-1
Submodule radio/src/thirdparty/libopenui updated: 9d30170c49...5e8e53b5b2
Reference in New Issue
Block a user