Update to latest libopenui

This commit is contained in:
Bertrand Songis
2020-11-26 09:56:58 +01:00
parent 6e7f8176ed
commit 6a252b2b0a
10 changed files with 76 additions and 65 deletions
-5
View File
@@ -107,11 +107,6 @@ CurveEdit::CurveEdit(Window * parent, const rect_t & rect, uint8_t index) :
updatePreview(); updatePreview();
} }
CurveEdit::~CurveEdit()
{
preview.detach();
}
void CurveEdit::updatePreview() void CurveEdit::updatePreview()
{ {
preview.clearPoints(); preview.clearPoints();
+9 -1
View File
@@ -48,7 +48,15 @@ class CurveEdit: public FormField
public: public:
CurveEdit(Window * parent, const rect_t & rect, uint8_t index); CurveEdit(Window * parent, const rect_t & rect, uint8_t index);
~CurveEdit() override; void deleteLater(bool detach = true, bool trash = true) override
{
if (_deleted)
return;
preview.deleteLater(true, false);
FormField::deleteLater(detach, trash);
}
void updatePreview(); void updatePreview();
+4 -10
View File
@@ -29,10 +29,9 @@ FullScreenDialog::FullScreenDialog(uint8_t type, std::string title, std::string
message(std::move(message)), message(std::move(message)),
action(std::move(action)), action(std::move(action)),
confirmHandler(confirmHandler) confirmHandler(confirmHandler)
#if defined(HARDWARE_KEYS)
, previousFocus(focusWindow)
#endif
{ {
Layer::push(this);
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
new FabButton(this, LCD_W - 50, LCD_H - 50, ICON_NEXT, new FabButton(this, LCD_W - 50, LCD_H - 50, ICON_NEXT,
[=]() -> uint8_t { [=]() -> uint8_t {
@@ -41,6 +40,7 @@ FullScreenDialog::FullScreenDialog(uint8_t type, std::string title, std::string
return 0; return 0;
}); });
#endif #endif
bringToTop(); bringToTop();
setFocus(SET_FOCUS_DEFAULT); setFocus(SET_FOCUS_DEFAULT);
} }
@@ -115,17 +115,11 @@ void FullScreenDialog::checkEvents()
void FullScreenDialog::deleteLater(bool detach, bool trash) void FullScreenDialog::deleteLater(bool detach, bool trash)
{ {
#if defined(HARDWARE_KEYS)
#warning "TODO remove previousFocus from here, and use layers"
if (previousFocus) {
previousFocus->setFocus(SET_FOCUS_DEFAULT);
}
#endif
if (running) { if (running) {
running = false; running = false;
} }
else { else {
Layer::pop(this);
Window::deleteLater(detach, trash); Window::deleteLater(detach, trash);
} }
} }
@@ -78,9 +78,6 @@ class FullScreenDialog : public FormGroup
bool running = false; bool running = false;
std::function<bool(void)> closeCondition; std::function<bool(void)> closeCondition;
std::function<void(void)> confirmHandler; std::function<void(void)> confirmHandler;
#if defined(HARDWARE_KEYS)
Window * previousFocus = nullptr;
#endif
}; };
#endif // _FULLSCREEN_DIALOG_H_ #endif // _FULLSCREEN_DIALOG_H_
+9 -3
View File
@@ -90,7 +90,8 @@ void deleteExpo(uint8_t idx)
storageDirty(EE_MODEL); storageDirty(EE_MODEL);
} }
class InputEditWindow: public Page { class InputEditWindow: public Page
{
public: public:
InputEditWindow(int8_t input, uint8_t index): InputEditWindow(int8_t input, uint8_t index):
Page(ICON_MODEL_INPUTS), Page(ICON_MODEL_INPUTS),
@@ -116,9 +117,14 @@ class InputEditWindow: public Page {
buildHeader(&header); buildHeader(&header);
} }
~InputEditWindow() override void deleteLater(bool detach = true, bool trash = true) override
{ {
preview.detach(); if (_deleted)
return;
preview.deleteLater(true, false);
Page::deleteLater(detach, trash);
} }
protected: protected:
+11 -17
View File
@@ -38,7 +38,7 @@ PageHeader::PageHeader(Page * parent, uint8_t icon):
PageHeader::~PageHeader() PageHeader::~PageHeader()
{ {
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
back.detach(); back.deleteLater(true, false);
#endif #endif
} }
@@ -51,28 +51,22 @@ void PageHeader::paint(BitmapBuffer * dc)
Page::Page(unsigned icon): Page::Page(unsigned icon):
Window(&mainWindow, {0, 0, LCD_W, LCD_H}, OPAQUE), Window(&mainWindow, {0, 0, LCD_W, LCD_H}, OPAQUE),
header(this, icon), header(this, icon),
body(this, { 0, MENU_HEADER_HEIGHT, LCD_W, LCD_H - MENU_HEADER_HEIGHT }, FORM_FORWARD_FOCUS), body(this, { 0, MENU_HEADER_HEIGHT, LCD_W, LCD_H - MENU_HEADER_HEIGHT }, FORM_FORWARD_FOCUS)
previousFocus(focusWindow)
{ {
Layer::push(this);
clearFocus(); clearFocus();
} }
Page::~Page()
{
header.detach();
body.detach();
#if defined(HARDWARE_TOUCH)
Keyboard::hide();
#endif
}
void Page::deleteLater(bool detach, bool trash) void Page::deleteLater(bool detach, bool trash)
{ {
#warning "TODO remove previousFocus and use layers" Layer::pop(this);
if (previousFocus) {
previousFocus->setFocus(SET_FOCUS_DEFAULT); header.deleteLater(true, false);
} body.deleteLater(true, false);
#if defined(HARDWARE_TOUCH)
Keyboard::hide();
#endif
Window::deleteLater(detach, trash); Window::deleteLater(detach, trash);
} }
+5 -6
View File
@@ -25,7 +25,8 @@
class Page; class Page;
class PageHeader: public FormGroup { class PageHeader: public FormGroup
{
public: public:
PageHeader(Page * parent, uint8_t icon); PageHeader(Page * parent, uint8_t icon);
@@ -45,11 +46,12 @@ class PageHeader: public FormGroup {
#endif #endif
}; };
class Page: public Window { class Page: public Window
{
public: public:
explicit Page(unsigned icon); explicit Page(unsigned icon);
~Page() override; void deleteLater(bool detach = true, bool trash = true) override;
#if defined(DEBUG_WINDOWS) #if defined(DEBUG_WINDOWS)
std::string getName() const override std::string getName() const override
@@ -78,14 +80,11 @@ class Page: public Window {
} }
#endif #endif
void deleteLater(bool detach = true, bool trash = true) override;
void paint(BitmapBuffer * dc) override; void paint(BitmapBuffer * dc) override;
protected: protected:
PageHeader header; PageHeader header;
FormWindow body; FormWindow body;
Window * previousFocus;
}; };
#endif // _PAGE_H_ #endif // _PAGE_H_
+7 -2
View File
@@ -98,9 +98,14 @@ class FlashDialog: public FullScreenDialog
{ {
} }
~FlashDialog() override void deleteLater(bool detach = true, bool trash = true) override
{ {
progress.detach(); if (_deleted)
return;
progress.deleteLater(true, false);
FullScreenDialog::deleteLater(detach, trash);
} }
void flash(const char * filename) void flash(const char * filename)
-15
View File
@@ -42,14 +42,6 @@ TabsGroupHeader::TabsGroupHeader(TabsGroup * parent, uint8_t icon):
{ {
} }
TabsGroupHeader::~TabsGroupHeader()
{
#if defined(HARDWARE_TOUCH)
back.detach();
#endif
carousel.detach();
}
void TabsGroupHeader::paint(BitmapBuffer * dc) void TabsGroupHeader::paint(BitmapBuffer * dc)
{ {
OpenTxTheme::instance()->drawMenuBackground(dc, icon, title); OpenTxTheme::instance()->drawMenuBackground(dc, icon, title);
@@ -90,16 +82,9 @@ TabsGroup::TabsGroup(uint8_t icon):
TabsGroup::~TabsGroup() TabsGroup::~TabsGroup()
{ {
#if defined(HARDWARE_TOUCH)
Keyboard::hide();
#endif
for (auto tab: tabs) { for (auto tab: tabs) {
delete tab; delete tab;
} }
header.detach();
body.detach();
} }
void TabsGroup::addTab(PageTab * page) void TabsGroup::addTab(PageTab * page)
+30 -2
View File
@@ -115,7 +115,19 @@ class TabsGroupHeader: public FormGroup {
public: public:
TabsGroupHeader(TabsGroup * menu, uint8_t icon); TabsGroupHeader(TabsGroup * menu, uint8_t icon);
~TabsGroupHeader() override; void deleteLater(bool detach = true, bool trash = true) override
{
if (_deleted)
return;
#if defined(HARDWARE_TOUCH)
back.deleteLater(true, false);
#endif
carousel.deleteLater(true, false);
FormField::deleteLater(detach, trash);
}
#if defined(DEBUG_WINDOWS) #if defined(DEBUG_WINDOWS)
std::string getName() const override std::string getName() const override
@@ -140,7 +152,8 @@ class TabsGroupHeader: public FormGroup {
const char * title = nullptr; const char * title = nullptr;
}; };
class TabsGroup: public Window { class TabsGroup: public Window
{
friend class TabsCarousel; friend class TabsCarousel;
public: public:
@@ -148,6 +161,21 @@ class TabsGroup: public Window {
~TabsGroup() override; ~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);
}
#if defined(DEBUG_WINDOWS) #if defined(DEBUG_WINDOWS)
std::string getName() const override std::string getName() const override
{ {