diff --git a/radio/src/thirdparty/libopenui/src/CMakeLists.txt b/radio/src/thirdparty/libopenui/src/CMakeLists.txt index 3fc35eb0e..788521440 100644 --- a/radio/src/thirdparty/libopenui/src/CMakeLists.txt +++ b/radio/src/thirdparty/libopenui/src/CMakeLists.txt @@ -32,6 +32,7 @@ set(LIBOPENUI_SRC table.cpp modal_window.cpp dialog.cpp + expansion_panel.cpp ) if(SOFTWARE_KEYBOARD) diff --git a/radio/src/thirdparty/libopenui/src/expansion_panel.cpp b/radio/src/thirdparty/libopenui/src/expansion_panel.cpp new file mode 100644 index 000000000..a775a91f8 --- /dev/null +++ b/radio/src/thirdparty/libopenui/src/expansion_panel.cpp @@ -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(parent)->toggle(); + setFocus(); + return true; +} + +void ExpansionPanelHeader::onEvent(event_t event) +{ + auto panel = static_cast(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); + } +} diff --git a/radio/src/thirdparty/libopenui/src/expansion_panel.h b/radio/src/thirdparty/libopenui/src/expansion_panel.h index b624996c7..08fbb9126 100644 --- a/radio/src/thirdparty/libopenui/src/expansion_panel.h +++ b/radio/src/thirdparty/libopenui/src/expansion_panel.h @@ -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(parent)->toggle(); - setFocus(); - return true; -} - -void ExpansionPanelHeader::onEvent(event_t event) -{ - auto panel = static_cast(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_