implement long press to launch curves from input and mixes
This commit is contained in:
@@ -66,6 +66,7 @@ set(GUI_SRC
|
|||||||
menu_screen.cpp
|
menu_screen.cpp
|
||||||
screen_setup.cpp
|
screen_setup.cpp
|
||||||
switch_warn_dialog.cpp
|
switch_warn_dialog.cpp
|
||||||
|
choiceex.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
macro(add_gui_src src)
|
macro(add_gui_src src)
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) OpenTX
|
||||||
|
*
|
||||||
|
* Based on code named
|
||||||
|
* th9x - http://code.google.com/p/th9x
|
||||||
|
* er9x - http://code.google.com/p/er9x
|
||||||
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
|
*
|
||||||
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "choiceex.h"
|
||||||
|
|
||||||
|
void ChoiceEx::setLongPressHandler(std::function<void(event_t)> handler)
|
||||||
|
{
|
||||||
|
longPressHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChoiceEx::ChoiceEx(FormGroup * parent, const rect_t & rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue, WindowFlags windowFlags) :
|
||||||
|
Choice(parent, rect, vmin, vmax, getValue, setValue, windowFlags)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChoiceEx::onTouchEnd(coord_t x, coord_t y)
|
||||||
|
{
|
||||||
|
return Choice::onTouchEnd(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChoiceEx::onEvent(event_t event)
|
||||||
|
{
|
||||||
|
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||||
|
if (longPressHandler) {
|
||||||
|
killEvents(event);
|
||||||
|
longPressHandler(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Choice::onEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) OpenTX
|
||||||
|
*
|
||||||
|
* Based on code named
|
||||||
|
* th9x - http://code.google.com/p/th9x
|
||||||
|
* er9x - http://code.google.com/p/er9x
|
||||||
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
|
*
|
||||||
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*/
|
||||||
|
#include "libopenui.h"
|
||||||
|
|
||||||
|
class ChoiceEx : public Choice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ChoiceEx(FormGroup * parent, const rect_t &rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
|
||||||
|
void setLongPressHandler(std::function<void(event_t)> handler);
|
||||||
|
|
||||||
|
#if defined(HARDWARE_KEYS)
|
||||||
|
void onEvent(event_t event) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(DEBUG_WINDOWS)
|
||||||
|
std::string getName() const override
|
||||||
|
{
|
||||||
|
return "CurvesListChoice";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::function<void(event_t)> longPressHandler = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
@@ -22,6 +22,8 @@
|
|||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "gvar_numberedit.h"
|
#include "gvar_numberedit.h"
|
||||||
#include "libopenui.h"
|
#include "libopenui.h"
|
||||||
|
#include "choiceex.h"
|
||||||
|
#include "model_curves.h"
|
||||||
|
|
||||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||||
|
|
||||||
@@ -173,9 +175,16 @@ class InputEditWindow : public Page
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CURVE_REF_CUSTOM: {
|
case CURVE_REF_CUSTOM: {
|
||||||
auto choice = new Choice(curveParamField, rect, -MAX_CURVES, MAX_CURVES,
|
auto choice = new ChoiceEx(curveParamField, rect, -MAX_CURVES, MAX_CURVES,
|
||||||
GET_SET_DEFAULT(line->curve.value));
|
GET_SET_DEFAULT(line->curve.value));
|
||||||
choice->setTextHandler([](int value) { return getCurveString(value); });
|
choice->setTextHandler([](int value) { return getCurveString(value); });
|
||||||
|
choice->setLongPressHandler([this](event_t event) {
|
||||||
|
ExpoData *line = expoAddress(index);
|
||||||
|
|
||||||
|
// if no curve is specified then dont link to curve page
|
||||||
|
if (line->curve.value != 0)
|
||||||
|
ModelCurvesPage::pushEditCurve(abs(line->curve.value) - 1);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "model_mixes.h"
|
#include "model_mixes.h"
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "libopenui.h"
|
#include "libopenui.h"
|
||||||
|
#include "choiceex.h"
|
||||||
#include "bitfield.h"
|
#include "bitfield.h"
|
||||||
#include "model_inputs.h"
|
#include "model_inputs.h"
|
||||||
#include "gvar_numberedit.h"
|
#include "gvar_numberedit.h"
|
||||||
@@ -31,59 +32,6 @@
|
|||||||
#define PASTE_BEFORE -2
|
#define PASTE_BEFORE -2
|
||||||
#define PASTE_AFTER -1
|
#define PASTE_AFTER -1
|
||||||
|
|
||||||
class CurvesListChoice : public Choice
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CurvesListChoice(FormGroup * parent, const rect_t &rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
|
|
||||||
void setLongPressHandler(std::function<void(event_t)> handler);
|
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
|
||||||
void onEvent(event_t event) override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
|
||||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
|
||||||
std::string getName() const override
|
|
||||||
{
|
|
||||||
return "CurvesListChoice";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::function<void(event_t)> longPressHandler = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CurvesListChoice::setLongPressHandler(std::function<void(event_t)> handler)
|
|
||||||
{
|
|
||||||
longPressHandler = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurvesListChoice::CurvesListChoice(FormGroup * parent, const rect_t & rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue, WindowFlags windowFlags) :
|
|
||||||
Choice(parent, rect, vmin, vmax, getValue, setValue, windowFlags)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CurvesListChoice::onTouchEnd(coord_t x, coord_t y)
|
|
||||||
{
|
|
||||||
return Choice::onTouchEnd(x,y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurvesListChoice::onEvent(event_t event)
|
|
||||||
{
|
|
||||||
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
|
||||||
if (longPressHandler) {
|
|
||||||
killEvents(event);
|
|
||||||
longPressHandler(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Choice::onEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t getMixesCount()
|
uint8_t getMixesCount()
|
||||||
{
|
{
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
@@ -282,7 +230,7 @@ class MixEditWindow : public Page
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CURVE_REF_CUSTOM: {
|
case CURVE_REF_CUSTOM: {
|
||||||
auto choice = new CurvesListChoice(curveParamField, rect, -MAX_CURVES, MAX_CURVES,
|
auto choice = new ChoiceEx(curveParamField, rect, -MAX_CURVES, MAX_CURVES,
|
||||||
GET_SET_DEFAULT(line->curve.value));
|
GET_SET_DEFAULT(line->curve.value));
|
||||||
choice->setTextHandler([](int value) { return getCurveString(value); });
|
choice->setTextHandler([](int value) { return getCurveString(value); });
|
||||||
choice->setLongPressHandler([this](event_t event) {
|
choice->setLongPressHandler([this](event_t event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user