Menu black overlay fix (need to give the pointer of the current window)

This commit is contained in:
Bertrand Songis
2019-12-13 20:53:54 +01:00
parent 6cab260ee6
commit 81ce0398bd
30 changed files with 76 additions and 73 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 13 KiB

+2 -2
View File
@@ -21,8 +21,8 @@
#include "confirm_dialog.h" #include "confirm_dialog.h"
#include "static.h" #include "static.h"
ConfirmDialog::ConfirmDialog(const char * title, const char * message, std::function<void(void)> confirmHandler) : ConfirmDialog::ConfirmDialog(Window * parent, const char * title, const char * message, std::function<void(void)> confirmHandler) :
Dialog(title, {50, 73, LCD_W - 100, LCD_H - 146}), Dialog(parent, title, {50, 73, LCD_W - 100, LCD_H - 146}),
confirmHandler(std::move(confirmHandler)) confirmHandler(std::move(confirmHandler))
{ {
new StaticText(this, {0, height() / 2, width(), PAGE_LINE_HEIGHT}, message, CENTERED); new StaticText(this, {0, height() / 2, width(), PAGE_LINE_HEIGHT}, message, CENTERED);
+1 -1
View File
@@ -25,7 +25,7 @@
class ConfirmDialog: public Dialog { class ConfirmDialog: public Dialog {
public: public:
ConfirmDialog(const char * title, const char * message, std::function<void(void)> confirmHandler); ConfirmDialog(Window * parent, const char * title, const char * message, std::function<void(void)> confirmHandler);
#if defined(HARDWARE_KEYS) #if defined(HARDWARE_KEYS)
void onEvent(event_t event) override; void onEvent(event_t event) override;
+1 -1
View File
@@ -58,7 +58,7 @@
inline void POPUP_INFORMATION(const char * str) inline void POPUP_INFORMATION(const char * str)
{ {
new MessageDialog("Message", str); new MessageDialog(&mainWindow, "Message", str);
} }
#endif // _LIBOPENUI_H_ #endif // _LIBOPENUI_H_
+2 -2
View File
@@ -20,8 +20,8 @@
#include "message_dialog.h" #include "message_dialog.h"
#include "static.h" #include "static.h"
MessageDialog::MessageDialog(const char * title, const char * message): MessageDialog::MessageDialog(Window * parent, const char * title, const char * message):
Dialog(title, {50, 73, LCD_W - 100, LCD_H - 146}) Dialog(parent, title, {50, 73, LCD_W - 100, LCD_H - 146})
{ {
new StaticText(this, {0, coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), PAGE_LINE_HEIGHT}, message, 0, CENTERED); new StaticText(this, {0, coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), PAGE_LINE_HEIGHT}, message, 0, CENTERED);
} }
+1 -1
View File
@@ -24,7 +24,7 @@
class MessageDialog: public Dialog { class MessageDialog: public Dialog {
public: public:
MessageDialog(const char * title, const char * message); MessageDialog(Window * parent, const char * title, const char * message);
#if defined(HARDWARE_KEYS) #if defined(HARDWARE_KEYS)
void onEvent(event_t event) override; void onEvent(event_t event) override;
+2 -2
View File
@@ -274,12 +274,12 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex)
// Curve drawing // Curve drawing
Button * button = new CurveButton(window, grid.getFieldSlot(), index); Button * button = new CurveButton(window, grid.getFieldSlot(), index);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
editCurve(window, index); editCurve(window, index);
}); });
menu->addLine(STR_CURVE_PRESET, [=]() { menu->addLine(STR_CURVE_PRESET, [=]() {
Menu * menu = new Menu(); Menu * menu = new Menu(window);
for (int angle = -45; angle <= 45; angle += 15) { for (int angle = -45; angle <= 45; angle += 15) {
char label[16]; char label[16];
strAppend(strAppendSigned(label, angle), "@"); strAppend(strAppendSigned(label, angle), "@");
+2 -2
View File
@@ -337,8 +337,8 @@ void ModelGVarsPage::build(FormWindow * window)
for (uint8_t index = 0; index < MAX_GVARS; index++) { for (uint8_t index = 0; index < MAX_GVARS; index++) {
Button * button = new GVarButton(window, grid.getLineSlot(), index); Button * button = new GVarButton(window, grid.getLineSlot(), index);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() {
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
Window * editWindow = new GVarEditWindow(index); Window * editWindow = new GVarEditWindow(index);
editWindow->setCloseHandler([=]() { editWindow->setCloseHandler([=]() {
+2 -2
View File
@@ -407,7 +407,7 @@ void ModelInputsPage::build(FormWindow * window, int8_t focusIndex)
button->setFocus(); button->setFocus();
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
editInput(window, input, inputIndex); editInput(window, input, inputIndex);
}); });
@@ -468,7 +468,7 @@ void ModelInputsPage::build(FormWindow * window, int8_t focusIndex)
button->setFocus(); button->setFocus();
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
insertExpo(inputIndex, input); insertExpo(inputIndex, input);
editInput(window, input, inputIndex); editInput(window, input, inputIndex);
@@ -363,7 +363,7 @@ void ModelLogicalSwitchesPage::build(FormWindow * window, int8_t focusIndex)
auto button = new LogicalSwitchButton(window, grid.getFieldSlot(), i); auto button = new LogicalSwitchButton(window, grid.getFieldSlot(), i);
button->setPressHandler([=]() { button->setPressHandler([=]() {
Menu * menu = new Menu(); Menu * menu = new Menu(window);
LogicalSwitchData * ls = lswAddress(i); LogicalSwitchData * ls = lswAddress(i);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
editLogicalSwitch(window, i); editLogicalSwitch(window, i);
+2 -2
View File
@@ -338,7 +338,7 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
button->setFocus(); button->setFocus();
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
editMix(window, ch, mixIndex); editMix(window, ch, mixIndex);
}); });
@@ -402,7 +402,7 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
button->setFocus(); button->setFocus();
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
insertMix(mixIndex, ch); insertMix(mixIndex, ch);
editMix(window, ch, mixIndex); editMix(window, ch, mixIndex);
+1 -1
View File
@@ -176,7 +176,7 @@ void ModelOutputsPage::build(FormWindow * window, int8_t focusChannel)
// Channel settings // Channel settings
Button * button = new OutputLineButton(window, grid.getFieldSlot(), output); Button * button = new OutputLineButton(window, grid.getFieldSlot(), output);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
editOutput(window, ch); editOutput(window, ch);
}); });
+2 -2
View File
@@ -263,7 +263,7 @@ class ModelCategoryPageBody: public FormWindow {
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
if (button->hasFocus()) { if (button->hasFocus()) {
Menu * menu = new Menu(); Menu * menu = new Menu(parent);
if (model != modelslist.getCurrentModel()) { if (model != modelslist.getCurrentModel()) {
menu->addLine(STR_SELECT_MODEL, [=]() { menu->addLine(STR_SELECT_MODEL, [=]() {
// we store the latest changes if any // we store the latest changes if any
@@ -302,7 +302,7 @@ class ModelCategoryPageBody: public FormWindow {
// menu->addLine(STR_MOVE_MODEL); // menu->addLine(STR_MOVE_MODEL);
if (model != modelslist.getCurrentModel()) { if (model != modelslist.getCurrentModel()) {
menu->addLine(STR_DELETE_MODEL, [=]() { menu->addLine(STR_DELETE_MODEL, [=]() {
new ConfirmDialog(STR_DELETE_MODEL, std::string(model->modelName, sizeof(model->modelName)).c_str(), [=] { new ConfirmDialog(parent, STR_DELETE_MODEL, std::string(model->modelName, sizeof(model->modelName)).c_str(), [=] {
modelslist.removeModel(category, model); modelslist.removeModel(category, model);
update(index > 0 ? index - 1 : 0); update(index > 0 ? index - 1 : 0);
}); });
+14 -14
View File
@@ -170,8 +170,8 @@ class FailSafePage : public Page {
class RegisterDialog: public Dialog { class RegisterDialog: public Dialog {
public: public:
explicit RegisterDialog(uint8_t moduleIdx): RegisterDialog(Window * parent, uint8_t moduleIdx):
Dialog(STR_REGISTER, {50, 73, LCD_W - 100, 0}), Dialog(parent, STR_REGISTER, {50, 73, LCD_W - 100, 0}),
moduleIdx(moduleIdx) moduleIdx(moduleIdx)
{ {
FormGroup * form = &content->form; FormGroup * form = &content->form;
@@ -259,8 +259,8 @@ class RegisterDialog: public Dialog {
class BindWaitDialog: public Dialog { class BindWaitDialog: public Dialog {
public: public:
BindWaitDialog(uint8_t moduleIdx, uint8_t receiverIdx): BindWaitDialog(Window * parent, uint8_t moduleIdx, uint8_t receiverIdx):
Dialog(STR_BIND, {50, 73, LCD_W - 100, LCD_H - 146}), Dialog(parent, STR_BIND, {50, 73, LCD_W - 100, LCD_H - 146}),
moduleIdx(moduleIdx), moduleIdx(moduleIdx),
receiverIdx(receiverIdx) receiverIdx(receiverIdx)
{ {
@@ -288,8 +288,8 @@ class BindWaitDialog: public Dialog {
class BindRxChoiceMenu: public Menu { class BindRxChoiceMenu: public Menu {
public: public:
BindRxChoiceMenu(uint8_t moduleIdx, uint8_t receiverIdx): BindRxChoiceMenu(Window * parent, uint8_t moduleIdx, uint8_t receiverIdx):
Menu(), Menu(parent),
moduleIdx(moduleIdx), moduleIdx(moduleIdx),
receiverIdx(receiverIdx) receiverIdx(receiverIdx)
{ {
@@ -315,10 +315,10 @@ class BindRxChoiceMenu: public Menu {
memcpy(g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx], receiverName, PXX2_LEN_RX_NAME); memcpy(g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx], receiverName, PXX2_LEN_RX_NAME);
storageDirty(EE_MODEL); storageDirty(EE_MODEL);
reusableBuffer.moduleSetup.bindInformation.step = BIND_OK; reusableBuffer.moduleSetup.bindInformation.step = BIND_OK;
new MessageDialog(STR_BIND, STR_BIND_OK); new MessageDialog(parent, STR_BIND, STR_BIND_OK);
#else #else
reusableBuffer.moduleSetup.bindInformation.step = BIND_START; reusableBuffer.moduleSetup.bindInformation.step = BIND_START;
new BindWaitDialog(moduleIdx, receiverIdx); new BindWaitDialog(parent, moduleIdx, receiverIdx);
#endif #endif
} }
}); });
@@ -346,7 +346,7 @@ void BindWaitDialog::checkEvents()
if (reusableBuffer.moduleSetup.bindInformation.step == BIND_INIT && reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount > 0) { if (reusableBuffer.moduleSetup.bindInformation.step == BIND_INIT && reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount > 0) {
deleteLater(); deleteLater();
new BindRxChoiceMenu(moduleIdx, receiverIdx); new BindRxChoiceMenu(this, moduleIdx, receiverIdx);
return; return;
} }
@@ -361,7 +361,7 @@ class ReceiverButton: public TextButton {
startBind(); startBind();
} }
else { else {
auto menu = new Menu(); auto menu = new Menu(parent);
menu->addLine(STR_BIND, [=]() { menu->addLine(STR_BIND, [=]() {
startBind(); startBind();
return 0; return 0;
@@ -382,7 +382,7 @@ class ReceiverButton: public TextButton {
memclear(&reusableBuffer.moduleSetup.pxx2, sizeof(reusableBuffer.moduleSetup.pxx2)); memclear(&reusableBuffer.moduleSetup.pxx2, sizeof(reusableBuffer.moduleSetup.pxx2));
reusableBuffer.moduleSetup.pxx2.resetReceiverIndex = receiverIdx; reusableBuffer.moduleSetup.pxx2.resetReceiverIndex = receiverIdx;
reusableBuffer.moduleSetup.pxx2.resetReceiverFlags = 0x01; reusableBuffer.moduleSetup.pxx2.resetReceiverFlags = 0x01;
new ConfirmDialog(STR_RECEIVER, STR_RECEIVER_DELETE, [=]() { new ConfirmDialog(parent, STR_RECEIVER, STR_RECEIVER_DELETE, [=]() {
moduleState[moduleIdx].mode = MODULE_MODE_RESET; moduleState[moduleIdx].mode = MODULE_MODE_RESET;
removePXX2Receiver(moduleIdx, receiverIdx); removePXX2Receiver(moduleIdx, receiverIdx);
}); });
@@ -392,7 +392,7 @@ class ReceiverButton: public TextButton {
memclear(&reusableBuffer.moduleSetup.pxx2, sizeof(reusableBuffer.moduleSetup.pxx2)); memclear(&reusableBuffer.moduleSetup.pxx2, sizeof(reusableBuffer.moduleSetup.pxx2));
reusableBuffer.moduleSetup.pxx2.resetReceiverIndex = receiverIdx; reusableBuffer.moduleSetup.pxx2.resetReceiverIndex = receiverIdx;
reusableBuffer.moduleSetup.pxx2.resetReceiverFlags = 0xFF; reusableBuffer.moduleSetup.pxx2.resetReceiverFlags = 0xFF;
new ConfirmDialog(STR_RECEIVER, STR_RECEIVER_DELETE, [=]() { new ConfirmDialog(parent, STR_RECEIVER, STR_RECEIVER_DELETE, [=]() {
moduleState[moduleIdx].mode = MODULE_MODE_RESET; moduleState[moduleIdx].mode = MODULE_MODE_RESET;
removePXX2Receiver(moduleIdx, receiverIdx); removePXX2Receiver(moduleIdx, receiverIdx);
}); });
@@ -425,7 +425,7 @@ class ReceiverButton: public TextButton {
moduleState[moduleIdx].startBind(&reusableBuffer.moduleSetup.bindInformation); moduleState[moduleIdx].startBind(&reusableBuffer.moduleSetup.bindInformation);
} }
new BindWaitDialog(moduleIdx, receiverIdx); new BindWaitDialog(parent, moduleIdx, receiverIdx);
} }
void checkEvents() override void checkEvents() override
@@ -762,7 +762,7 @@ class ModuleWindow : public FormGroup {
new StaticText(this, grid.getLabelSlot(true), STR_MODULE); new StaticText(this, grid.getLabelSlot(true), STR_MODULE);
registerButton = new TextButton(this, grid.getFieldSlot(2, 0), STR_REGISTER); registerButton = new TextButton(this, grid.getFieldSlot(2, 0), STR_REGISTER);
registerButton->setPressHandler([=]() -> uint8_t { registerButton->setPressHandler([=]() -> uint8_t {
new RegisterDialog(moduleIdx); new RegisterDialog(this, moduleIdx);
return 0; return 0;
}); });
+1 -1
View File
@@ -440,7 +440,7 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
Button * button = new SensorButton(window, grid.getFieldSlot(), idx, ++count); Button * button = new SensorButton(window, grid.getFieldSlot(), idx, ++count);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
editSensor(window, idx); editSensor(window, idx);
}); });
+1 -3
View File
@@ -96,10 +96,8 @@ void Page::onEvent(event_t event)
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
bool Page::onTouchEnd(coord_t x, coord_t y) bool Page::onTouchEnd(coord_t x, coord_t y)
{ {
if (Window::onTouchEnd(x, y))
return true;
Keyboard::hide(); Keyboard::hide();
Window::onTouchEnd(x, y);
return true; return true;
} }
#endif #endif
+11 -11
View File
@@ -77,7 +77,7 @@ class RadioKeyDiagsWindow : public Window
#endif #endif
// SWITCHES // SWITCHES
for (uint8_t i = 0; i <= NUM_SWITCHES; i++) { for (uint8_t i = 0; i < NUM_SWITCHES; i++) {
if (SWITCH_EXISTS(i)) { if (SWITCH_EXISTS(i)) {
coord_t y = 1 + FH * i; coord_t y = 1 + FH * i;
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i); getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
@@ -86,16 +86,16 @@ class RadioKeyDiagsWindow : public Window
} }
} }
//TRIMS // TRIMS
for (uint8_t i = 0; i < NUM_TRIMS_KEYS; i++) { // for (uint8_t i = 0; i < NUM_TRIMS_KEYS; i++) {
const uint8_t trimMap[NUM_TRIMS_KEYS] = {6, 7, 4, 5, 2, 3, 0, 1, 8, 9, 10, 11}; // const uint8_t trimMap[NUM_TRIMS_KEYS] = {6, 7, 4, 5, 2, 3, 0, 1, 8, 9, 10, 11};
coord_t y = 1 + FH + FH * (i / 2); // coord_t y = 1 + FH + FH * (i / 2);
if (i & 1) { // if (i & 1) {
dc->drawText(TRIM_COLUMN, y, "T", 0); // dc->drawText(TRIM_COLUMN, y, "T", 0);
dc->drawNumber(TRIM_COLUMN + 10, y, i / 2 + 1, 0); // dc->drawNumber(TRIM_COLUMN + 10, y, i / 2 + 1, 0);
} // }
displayKeyState(dc, i & 1 ? TRIM_PLUS_COLUMN : TRIM_MINUS_COLUMN, y, TRM_BASE + trimMap[i]); // displayKeyState(dc, i & 1 ? TRIM_PLUS_COLUMN : TRIM_MINUS_COLUMN, y, TRM_BASE + trimMap[i]);
} // }
}; };
protected: protected:
+1 -1
View File
@@ -159,7 +159,7 @@ void RadioSdManagerPage::build(FormWindow * window)
for (auto name: files) { for (auto name: files) {
auto button = new TextButton(window, grid.getLabelSlot(), name, [=]() -> uint8_t { auto button = new TextButton(window, grid.getLabelSlot(), name, [=]() -> uint8_t {
auto menu = new Menu(); auto menu = new Menu(window);
const char *ext = getFileExtension(name.data()); const char *ext = getFileExtension(name.data());
if (ext) { if (ext) {
if (!strcasecmp(ext, SOUNDS_EXT)) { if (!strcasecmp(ext, SOUNDS_EXT)) {
@@ -260,7 +260,7 @@ void RadioSpectrumAnalyser::start()
void RadioSpectrumAnalyser::stop() void RadioSpectrumAnalyser::stop()
{ {
new MessageDialog(STR_MODULE, STR_STOPPING); new MessageDialog(this, STR_MODULE, STR_STOPPING);
if (isModulePXX2(moduleIdx)) { if (isModulePXX2(moduleIdx)) {
moduleState[moduleIdx].readModuleInformation(&reusableBuffer.moduleSetup.pxx2.moduleInformation, PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID); moduleState[moduleIdx].readModuleInformation(&reusableBuffer.moduleSetup.pxx2.moduleInformation, PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
} }
+1 -1
View File
@@ -84,7 +84,7 @@ class LayoutChoice: public FormField {
void openMenu() void openMenu()
{ {
auto menu = new Menu(); auto menu = new Menu(parent);
for (auto layout: getRegisteredLayouts()) { for (auto layout: getRegisteredLayouts()) {
menu->addCustomLine([=](BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags) { menu->addCustomLine([=](BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags) {
+1 -1
View File
@@ -103,7 +103,7 @@ void SourceChoice::fillMenu(Menu * menu, std::function<bool(int16_t)> filter)
void SourceChoice::openMenu() void SourceChoice::openMenu()
{ {
auto menu = new Menu(); auto menu = new Menu(this);
fillMenu(menu); fillMenu(menu);
menu->setToolbar(new SourceChoiceMenuToolbar(this, menu)); menu->setToolbar(new SourceChoiceMenuToolbar(this, menu));
menu->setCloseHandler([=]() { menu->setCloseHandler([=]() {
+1 -1
View File
@@ -438,7 +438,7 @@ void SpecialFunctionsPage::build(FormWindow * window, int8_t focusIndex)
auto button = new SpecialFunctionButton(window, grid.getFieldSlot(), functions, i); auto button = new SpecialFunctionButton(window, grid.getFieldSlot(), functions, i);
button->setPressHandler([=]() { button->setPressHandler([=]() {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
editSpecialFunction(window, i); editSpecialFunction(window, i);
}); });
+2 -1
View File
@@ -87,8 +87,9 @@ void SwitchChoice::fillMenu(Menu * menu, std::function<bool(int16_t)> filter)
void SwitchChoice::openMenu() void SwitchChoice::openMenu()
{ {
auto menu = new Menu(); auto menu = new Menu(this);
fillMenu(menu); fillMenu(menu);
menu->setToolbar(new SwitchChoiceMenuToolbar(this, menu)); menu->setToolbar(new SwitchChoiceMenuToolbar(this, menu));
menu->setCloseHandler([=]() { menu->setCloseHandler([=]() {
editMode = false; editMode = false;
+1 -3
View File
@@ -187,10 +187,8 @@ void TabsGroup::paint(BitmapBuffer * dc)
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
bool TabsGroup::onTouchEnd(coord_t x, coord_t y) bool TabsGroup::onTouchEnd(coord_t x, coord_t y)
{ {
if (Window::onTouchEnd(x, y))
return true;
Keyboard::hide(); Keyboard::hide();
Window::onTouchEnd(x, y);
return true; return true;
} }
#endif #endif
+1 -1
View File
@@ -362,7 +362,7 @@ class FlyskyTheme: public ThemeBase
dc->drawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, MENU_TITLE_HEIGHT, TITLE_BGCOLOR); // the title line background dc->drawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, MENU_TITLE_HEIGHT, TITLE_BGCOLOR); // the title line background
// //
if (title) { if (title) {
dc->drawText(MENUS_MARGIN_LEFT, MENU_TITLE_TOP, title, MENU_COLOR); dc->drawText(MENUS_MARGIN_LEFT, MENU_TITLE_TOP + 2, title, MENU_COLOR);
} }
} }
+2 -2
View File
@@ -198,7 +198,7 @@ void ViewMain::onEvent(event_t event)
void ViewMain::openMenu() void ViewMain::openMenu()
{ {
Menu * menu = new Menu(); Menu * menu = new Menu(this);
menu->addLine(STR_MODEL_SELECT, [=]() { menu->addLine(STR_MODEL_SELECT, [=]() {
new ModelSelectMenu(); new ModelSelectMenu();
}); });
@@ -211,7 +211,7 @@ void ViewMain::openMenu()
// new ChannelsMonitorMenu(); // new ChannelsMonitorMenu();
}); });
menu->addLine(STR_RESET_SUBMENU, [=]() { menu->addLine(STR_RESET_SUBMENU, [=]() {
Menu * menu = new Menu(); Menu * menu = new Menu(this);
menu->addLine(STR_RESET_FLIGHT, [=]() { menu->addLine(STR_RESET_FLIGHT, [=]() {
flightReset(); flightReset();
}); });
+1 -1
View File
@@ -31,7 +31,7 @@ uint8_t mainRequestFlags = 0;
#if defined(LIBOPENUI) #if defined(LIBOPENUI)
void openUsbMenu() void openUsbMenu()
{ {
auto menu = new Menu(); auto menu = new Menu(&mainWindow);
menu->setTitle("USB"); menu->setTitle("USB");
menu->addLine(STR_USB_JOYSTICK, [] { menu->addLine(STR_USB_JOYSTICK, [] {
setSelectedUsbMode(USB_JOYSTICK_MODE); setSelectedUsbMode(USB_JOYSTICK_MODE);
+12 -8
View File
@@ -252,12 +252,12 @@ long OpenTxSim::onKeypress(FXObject *, FXSelector, void * v)
return 0; return 0;
} }
long OpenTxSim::onMouseDown(FXObject*,FXSelector,void*v) long OpenTxSim::onMouseDown(FXObject *, FXSelector, void * v)
{ {
FXEvent * evt = (FXEvent *)v; FXEvent * evt = (FXEvent *)v;
UNUSED(evt); UNUSED(evt);
// TRACE("onMouseDown %d %d", evt->win_x, evt->win_y); TRACE_WINDOWS("[Mouse Press] %d %d", evt->win_x, evt->win_y);
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
touchState.event = TE_DOWN; touchState.event = TE_DOWN;
@@ -273,7 +273,7 @@ long OpenTxSim::onMouseUp(FXObject*,FXSelector,void*v)
FXEvent * evt = (FXEvent *)v; FXEvent * evt = (FXEvent *)v;
UNUSED(evt); UNUSED(evt);
// TRACE("onMouseUp %d %d", evt->win_x, evt->win_y); TRACE_WINDOWS("[Mouse Release] %d %d", evt->win_x, evt->win_y);
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
if (touchState.event == TE_DOWN) { if (touchState.event == TE_DOWN) {
@@ -294,13 +294,17 @@ long OpenTxSim::onMouseMove(FXObject*,FXSelector,void*v)
FXEvent * evt = (FXEvent *)v; FXEvent * evt = (FXEvent *)v;
UNUSED(evt); UNUSED(evt);
if (evt->state & LEFTBUTTONMASK) {
TRACE_WINDOWS("[Mouse Move] %d %d", evt->win_x, evt->win_y);
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
if (evt->state & LEFTBUTTONMASK && (touchState.event == TE_SLIDE || abs(evt->win_x - touchState.x) > 5 || abs(evt->win_y - touchState.y) > 5)) { if (touchState.event == TE_SLIDE || abs(evt->win_x - touchState.x) > 5 || abs(evt->win_y - touchState.y) > 5) {
touchState.event = TE_SLIDE; touchState.event = TE_SLIDE;
touchState.x = evt->win_x; touchState.x = evt->win_x;
touchState.y = evt->win_y; touchState.y = evt->win_y;
} }
#endif #endif
}
return 0; return 0;
} }
+5 -3
View File
@@ -55,7 +55,7 @@ constexpr uint32_t FH = PAGE_LINE_HEIGHT;
constexpr uint32_t NUM_BODY_LINES = MENU_BODY_HEIGHT / PAGE_LINE_HEIGHT; constexpr uint32_t NUM_BODY_LINES = MENU_BODY_HEIGHT / PAGE_LINE_HEIGHT;
constexpr uint32_t FIELD_PADDING_LEFT = 3; constexpr uint32_t FIELD_PADDING_LEFT = 3;
constexpr uint32_t FIELD_PADDING_TOP = 3; constexpr uint32_t FIELD_PADDING_TOP = 4;
constexpr uint32_t CURVE_SIDE_WIDTH = 100; constexpr uint32_t CURVE_SIDE_WIDTH = 100;
constexpr uint32_t CURVE_CENTER_X = LCD_W - CURVE_SIDE_WIDTH - 7; constexpr uint32_t CURVE_CENTER_X = LCD_W - CURVE_SIDE_WIDTH - 7;
@@ -70,7 +70,6 @@ constexpr uint32_t DATETIME_MIDDLE = (LCD_W + DATETIME_SEPARATOR_X
constexpr uint32_t MENUS_TOOLBAR_BUTTON_WIDTH = 50; constexpr uint32_t MENUS_TOOLBAR_BUTTON_WIDTH = 50;
constexpr uint32_t MENUS_TOOLBAR_BUTTON_PADDING = 11; constexpr uint32_t MENUS_TOOLBAR_BUTTON_PADDING = 11;
constexpr rect_t MENUS_TOOLBAR_RECT = { 35, 95, 50, 370 };
constexpr uint32_t ALERT_FRAME_TOP = 70; constexpr uint32_t ALERT_FRAME_TOP = 70;
constexpr uint32_t ALERT_FRAME_HEIGHT = (LCD_H - 2 * ALERT_FRAME_TOP); constexpr uint32_t ALERT_FRAME_HEIGHT = (LCD_H - 2 * ALERT_FRAME_TOP);
@@ -155,7 +154,10 @@ constexpr coord_t MENUS_WIDTH = 200;
constexpr coord_t MENUS_OFFSET_TOP = 20; constexpr coord_t MENUS_OFFSET_TOP = 20;
constexpr coord_t POPUP_HEADER_HEIGHT = 40; constexpr coord_t POPUP_HEADER_HEIGHT = 40;
constexpr coord_t MENUS_MIN_HEIGHT = 2 * MENUS_LINE_HEIGHT - 1; constexpr coord_t MENUS_MIN_HEIGHT = 2 * MENUS_LINE_HEIGHT - 1;
constexpr coord_t MENUS_MAX_HEIGHT = 7 * MENUS_LINE_HEIGHT - 1; constexpr coord_t MENUS_MAX_HEIGHT = 8 * MENUS_LINE_HEIGHT - 1;
constexpr rect_t MENUS_TOOLBAR_RECT = { 35, (LCD_H - MENUS_MAX_HEIGHT) / 2, 50, MENUS_MAX_HEIGHT };
constexpr coord_t MODEL_SELECT_FOOTER_HEIGHT = 24; constexpr coord_t MODEL_SELECT_FOOTER_HEIGHT = 24;
constexpr coord_t SCROLLBAR_WIDTH = 3; constexpr coord_t SCROLLBAR_WIDTH = 3;
constexpr coord_t TABLE_LINE_HEIGHT = 50; constexpr coord_t TABLE_LINE_HEIGHT = 50;