Expansion panel link issue

This commit is contained in:
Bertrand Songis
2020-04-01 09:52:15 +02:00
parent 8e3a41d796
commit d6313ab1e1
3 changed files with 48 additions and 27 deletions
+1
View File
@@ -32,6 +32,7 @@ set(LIBOPENUI_SRC
table.cpp
modal_window.cpp
dialog.cpp
expansion_panel.cpp
)
if(SOFTWARE_KEYBOARD)
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright (C) OpenTX
*
* Source:
* https://github.com/opentx/libopenui
*
* This file is a part of libopenui library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#include "expansion_panel.h"
ExpansionPanelHeader::ExpansionPanelHeader(ExpansionPanel * parent):
FormGroup(parent, {0, 0, parent->width(), parent->height()}, FORWARD_SCROLL)
{
}
bool ExpansionPanelHeader::onTouchEnd(coord_t, coord_t)
{
static_cast<ExpansionPanel *>(parent)->toggle();
setFocus();
return true;
}
void ExpansionPanelHeader::onEvent(event_t event)
{
auto panel = static_cast<ExpansionPanel *>(parent);
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
panel->toggle();
}
else if (event == EVT_ROTARY_RIGHT && !panel->isOpen) {
panel->getNextField()->setFocus(SET_FOCUS_FORWARD);
}
else {
FormGroup::onEvent(event);
}
}
-27
View File
@@ -78,31 +78,4 @@ class ExpansionPanel: public FormGroup {
bool isOpen = false;
};
ExpansionPanelHeader::ExpansionPanelHeader(ExpansionPanel * parent):
FormGroup(parent, {0, 0, parent->width(), parent->height()}, FORWARD_SCROLL)
{
}
bool ExpansionPanelHeader::onTouchEnd(coord_t, coord_t)
{
static_cast<ExpansionPanel *>(parent)->toggle();
setFocus();
return true;
}
void ExpansionPanelHeader::onEvent(event_t event)
{
auto panel = static_cast<ExpansionPanel *>(parent);
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
panel->toggle();
}
else if (event == EVT_ROTARY_RIGHT && !panel->isOpen) {
panel->getNextField()->setFocus(SET_FOCUS_FORWARD);
}
else {
FormGroup::onEvent(event);
}
}
#endif // _EXPANSION_PANEL_H_