mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 04:15:26 +03:00
Cosmetics
This commit is contained in:
parent
6504b4f69c
commit
f5c60a86a9
24 changed files with 171 additions and 126 deletions
|
@ -29,7 +29,7 @@ ConfirmDialog::ConfirmDialog(const char *title, const char *message, std::functi
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void ConfirmDialog::onKeyEvent(event_t event)
|
void ConfirmDialog::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ConfirmDialog: public Dialog {
|
||||||
ConfirmDialog(const char * title, const char * message, std::function<void(void)> confirmHandler);
|
ConfirmDialog(const char * title, const char * message, std::function<void(void)> confirmHandler);
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -22,17 +22,17 @@
|
||||||
#ifndef _CURVE_H_
|
#ifndef _CURVE_H_
|
||||||
#define _CURVE_H_
|
#define _CURVE_H_
|
||||||
|
|
||||||
#include "window.h"
|
#include "form.h"
|
||||||
|
|
||||||
struct CurvePoint {
|
struct CurvePoint {
|
||||||
point_t coords;
|
point_t coords;
|
||||||
LcdFlags flags;
|
LcdFlags flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Curve: public Window {
|
class Curve: public FormField {
|
||||||
public:
|
public:
|
||||||
Curve(Window * parent, const rect_t & rect, std::function<int(int)> function, std::function<int()> position=nullptr):
|
Curve(Window * parent, const rect_t & rect, std::function<int(int)> function, std::function<int()> position=nullptr):
|
||||||
Window(parent, rect, OPAQUE),
|
FormField(parent, rect, OPAQUE),
|
||||||
function(std::move(function)),
|
function(std::move(function)),
|
||||||
position(std::move(position))
|
position(std::move(position))
|
||||||
{
|
{
|
||||||
|
@ -51,6 +51,8 @@ class Curve: public Window {
|
||||||
if (position) {
|
if (position) {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormField::checkEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPoint(const point_t & point, LcdFlags flags);
|
void addPoint(const point_t & point, LcdFlags flags);
|
||||||
|
|
|
@ -54,13 +54,9 @@ bool CurveEdit::onTouchEnd(coord_t x, coord_t y)
|
||||||
{
|
{
|
||||||
if (!hasFocus()) {
|
if (!hasFocus()) {
|
||||||
setFocus();
|
setFocus();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveKeyboard * keyboard = CurveKeyboard::instance();
|
CurveKeyboard::show(this, isCustomCurve());
|
||||||
if (keyboard->getField() != this) {
|
|
||||||
keyboard->setField(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
CurveInfo & curve = g_model.curves[index];
|
CurveInfo & curve = g_model.curves[index];
|
||||||
for (int i=0; i<5 + curve.points; i++) {
|
for (int i=0; i<5 + curve.points; i++) {
|
||||||
|
@ -79,13 +75,13 @@ bool CurveEdit::onTouchEnd(coord_t x, coord_t y)
|
||||||
|
|
||||||
void CurveEdit::onFocusLost()
|
void CurveEdit::onFocusLost()
|
||||||
{
|
{
|
||||||
CurveKeyboard::instance()->disable(true);
|
CurveKeyboard::hide();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void CurveEdit::next()
|
void CurveEdit::next()
|
||||||
{
|
{
|
||||||
if (++current == points.size()) {
|
if (current++ == points.size()) {
|
||||||
current = 0;
|
current = 0;
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
|
@ -94,7 +90,7 @@ void CurveEdit::next()
|
||||||
void CurveEdit::previous()
|
void CurveEdit::previous()
|
||||||
{
|
{
|
||||||
if (current-- == 0) {
|
if (current-- == 0) {
|
||||||
current = points.size() - 1;
|
current = points.size();
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -118,7 +114,7 @@ void CurveEdit::down()
|
||||||
void CurveEdit::right()
|
void CurveEdit::right()
|
||||||
{
|
{
|
||||||
CurveInfo & curve = g_model.curves[index];
|
CurveInfo & curve = g_model.curves[index];
|
||||||
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points - 1) {
|
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points + 5 - 1) {
|
||||||
int8_t * points = curveAddress(index);
|
int8_t * points = curveAddress(index);
|
||||||
int8_t * point = &points[5 + curve.points + current - 1];
|
int8_t * point = &points[5 + curve.points + current - 1];
|
||||||
int8_t xmax = (current == (curve.points - 2) ? +100 : *(point + 1));
|
int8_t xmax = (current == (curve.points - 2) ? +100 : *(point + 1));
|
||||||
|
@ -131,7 +127,7 @@ void CurveEdit::right()
|
||||||
void CurveEdit::left()
|
void CurveEdit::left()
|
||||||
{
|
{
|
||||||
CurveInfo & curve = g_model.curves[index];
|
CurveInfo & curve = g_model.curves[index];
|
||||||
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points - 1) {
|
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points + 5 - 1) {
|
||||||
int8_t * points = curveAddress(index);
|
int8_t * points = curveAddress(index);
|
||||||
int8_t * point = &points[5 + curve.points + current - 1];
|
int8_t * point = &points[5 + curve.points + current - 1];
|
||||||
int8_t xmin = (current == 1 ? -100 : *(point - 1));
|
int8_t xmin = (current == 1 ? -100 : *(point - 1));
|
||||||
|
@ -145,3 +141,40 @@ bool CurveEdit::isCustomCurve()
|
||||||
{
|
{
|
||||||
return g_model.curves[index].type == CURVE_TYPE_CUSTOM;
|
return g_model.curves[index].type == CURVE_TYPE_CUSTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CurveEdit::onEvent(event_t event)
|
||||||
|
{
|
||||||
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
case EVT_VIRTUAL_KEY_LEFT:
|
||||||
|
left();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVT_VIRTUAL_KEY_RIGHT:
|
||||||
|
right();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVT_VIRTUAL_KEY_UP:
|
||||||
|
up();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVT_VIRTUAL_KEY_DOWN:
|
||||||
|
down();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVT_VIRTUAL_KEY_PREVIOUS:
|
||||||
|
previous();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVT_VIRTUAL_KEY_NEXT:
|
||||||
|
next();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
FormField::onEvent(event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,18 +24,18 @@
|
||||||
#include "curve.h"
|
#include "curve.h"
|
||||||
|
|
||||||
class CurveEdit: public Curve {
|
class CurveEdit: public Curve {
|
||||||
friend class CurveKeyboard;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CurveEdit(Window * parent, const rect_t & rect, uint8_t index);
|
CurveEdit(Window * parent, const rect_t & rect, uint8_t index);
|
||||||
|
|
||||||
void checkEvents() override
|
void checkEvents() override
|
||||||
{
|
{
|
||||||
// no permanent refresh
|
Curve::checkEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
void onEvent(event_t event) override;
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ void FullScreenDialog::paint(BitmapBuffer * dc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void FullScreenDialog::onKeyEvent(event_t event)
|
void FullScreenDialog::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class FullScreenDialog : public Dialog {
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "keyboard_curve.h"
|
#include "keyboard_curve.h"
|
||||||
#include "curveedit.h"
|
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
|
||||||
|
@ -28,75 +27,64 @@ constexpr coord_t KEYBOARD_HEIGHT = 110;
|
||||||
CurveKeyboard * CurveKeyboard::_instance = nullptr;
|
CurveKeyboard * CurveKeyboard::_instance = nullptr;
|
||||||
|
|
||||||
CurveKeyboard::CurveKeyboard() :
|
CurveKeyboard::CurveKeyboard() :
|
||||||
Keyboard<CurveEdit>(KEYBOARD_HEIGHT)
|
Keyboard(KEYBOARD_HEIGHT)
|
||||||
{
|
{
|
||||||
// up
|
// up
|
||||||
new TextButton(this, {LCD_W / 2 - 20, 5, 40, 40}, "\200",
|
new TextButton(this, {LCD_W / 2 - 20, 5, 40, 40}, "\200",
|
||||||
[=]() -> uint8_t {
|
[=]() -> uint8_t {
|
||||||
if (field) {
|
putEvent(EVT_VIRTUAL_KEY_UP);
|
||||||
field->up();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||||
|
|
||||||
// down
|
// down
|
||||||
new TextButton(this, {LCD_W / 2 - 20, 65, 40, 40}, "\201",
|
new TextButton(this, {LCD_W / 2 - 20, 65, 40, 40}, "\201",
|
||||||
[=]() -> uint8_t {
|
[=]() -> uint8_t {
|
||||||
field->down();
|
putEvent(EVT_VIRTUAL_KEY_DOWN);
|
||||||
return 0;
|
return 0;
|
||||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||||
|
|
||||||
// left
|
// left
|
||||||
left = new TextButton(this, {LCD_W / 2 - 70, 35, 40, 40}, "\177",
|
left = new TextButton(this, {LCD_W / 2 - 70, 35, 40, 40}, "\177",
|
||||||
[=]() -> uint8_t {
|
[=]() -> uint8_t {
|
||||||
if (field) {
|
putEvent(EVT_VIRTUAL_KEY_LEFT);
|
||||||
field->left();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||||
|
|
||||||
// right
|
// right
|
||||||
right = new TextButton(this, {LCD_W / 2 + 30, 35, 40, 40}, "\176",
|
right = new TextButton(this, {LCD_W / 2 + 30, 35, 40, 40}, "\176",
|
||||||
[=]() -> uint8_t {
|
[=]() -> uint8_t {
|
||||||
if (field) {
|
putEvent(EVT_VIRTUAL_KEY_RIGHT);
|
||||||
field->right();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||||
|
|
||||||
// next
|
// next
|
||||||
new TextButton(this, {LCD_W / 2 + 80, 35, 60, 40}, "Next",
|
new TextButton(this, {LCD_W / 2 + 80, 35, 60, 40}, "Next",
|
||||||
[=]() -> uint8_t {
|
[=]() -> uint8_t {
|
||||||
if (field) {
|
putEvent(EVT_VIRTUAL_KEY_NEXT);
|
||||||
field->next();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||||
|
|
||||||
// previous
|
// previous
|
||||||
new TextButton(this, {LCD_W / 2 - 140, 35, 60, 40}, "Prev",
|
new TextButton(this, {LCD_W / 2 - 140, 35, 60, 40}, "Prev",
|
||||||
[=]() -> uint8_t {
|
[=]() -> uint8_t {
|
||||||
if (field) {
|
putEvent(EVT_VIRTUAL_KEY_PREVIOUS);
|
||||||
field->previous();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CurveKeyboard::enableRightLeft(bool enable)
|
||||||
|
{
|
||||||
|
TRACE("STOP %d", enable);
|
||||||
|
left->enable(enable);
|
||||||
|
right->enable(enable);
|
||||||
|
}
|
||||||
|
|
||||||
CurveKeyboard::~CurveKeyboard()
|
CurveKeyboard::~CurveKeyboard()
|
||||||
{
|
{
|
||||||
_instance = nullptr;
|
_instance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveKeyboard::setField(CurveEdit * field)
|
|
||||||
{
|
|
||||||
Keyboard<CurveEdit>::setField(field);
|
|
||||||
bool custom = field->isCustomCurve();
|
|
||||||
left->enable(custom);
|
|
||||||
right->enable(custom);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveKeyboard::paint(BitmapBuffer * dc)
|
void CurveKeyboard::paint(BitmapBuffer * dc)
|
||||||
{
|
{
|
||||||
lcdSetColor(RGB(0xE0, 0xE0, 0xE0));
|
lcdSetColor(RGB(0xE0, 0xE0, 0xE0));
|
||||||
|
|
|
@ -22,17 +22,14 @@
|
||||||
#define _KEYBOARD_CURVE_H_
|
#define _KEYBOARD_CURVE_H_
|
||||||
|
|
||||||
#include "keyboard_base.h"
|
#include "keyboard_base.h"
|
||||||
#include "curveedit.h"
|
|
||||||
|
|
||||||
class Button;
|
class Button;
|
||||||
|
|
||||||
class CurveKeyboard : public Keyboard<CurveEdit> {
|
class CurveKeyboard : public Keyboard {
|
||||||
friend class CurveEdit;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CurveKeyboard();
|
CurveKeyboard();
|
||||||
|
|
||||||
~CurveKeyboard();
|
~CurveKeyboard() override;
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() override
|
std::string getName() override
|
||||||
|
@ -41,15 +38,16 @@ class CurveKeyboard : public Keyboard<CurveEdit> {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static CurveKeyboard * instance()
|
void enableRightLeft(bool enable);
|
||||||
|
|
||||||
|
static void show(FormField * field, bool enableRightLeft)
|
||||||
{
|
{
|
||||||
if (!_instance)
|
if (!_instance)
|
||||||
_instance = new CurveKeyboard();
|
_instance = new CurveKeyboard();
|
||||||
return _instance;
|
_instance->setField(field);
|
||||||
|
_instance->enableRightLeft(enableRightLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setField(CurveEdit * field);
|
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -249,7 +249,7 @@ class BindWaitDialog: public Dialog {
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override
|
void onEvent(event_t event) override
|
||||||
{
|
{
|
||||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ void RadioCalibrationPage::checkEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void RadioCalibrationPage::onKeyEvent(event_t event)
|
void RadioCalibrationPage::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ void RadioCalibrationPage::onKeyEvent(event_t event)
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Page::onKeyEvent(event);
|
Page::onEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,7 +29,7 @@ class RadioCalibrationPage: public Page {
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -67,7 +67,7 @@ class LayoutChoice: public FormField {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override
|
void onEvent(event_t event) override
|
||||||
{
|
{
|
||||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class LayoutChoice: public FormField {
|
||||||
openMenu();
|
openMenu();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FormField::onKeyEvent(event);
|
FormField::onEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -113,7 +113,7 @@ void SourceChoice::openMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void SourceChoice::onKeyEvent(event_t event)
|
void SourceChoice::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ void SourceChoice::onKeyEvent(event_t event)
|
||||||
openMenu();
|
openMenu();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FormField::onKeyEvent(event);
|
FormField::onEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,6 +133,7 @@ bool SourceChoice::onTouchEnd(coord_t, coord_t)
|
||||||
{
|
{
|
||||||
openMenu();
|
openMenu();
|
||||||
setFocus();
|
setFocus();
|
||||||
|
setEditMode(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -50,7 +50,7 @@ class SourceChoice : public FormField {
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
|
|
@ -97,7 +97,7 @@ void SwitchChoice::openMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void SwitchChoice::onKeyEvent(event_t event)
|
void SwitchChoice::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void SwitchChoice::onKeyEvent(event_t event)
|
||||||
openMenu();
|
openMenu();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FormField::onKeyEvent(event);
|
FormField::onEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -117,6 +117,7 @@ bool SwitchChoice::onTouchEnd(coord_t, coord_t)
|
||||||
{
|
{
|
||||||
openMenu();
|
openMenu();
|
||||||
setFocus();
|
setFocus();
|
||||||
|
setEditMode(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -49,7 +49,7 @@ class SwitchChoice : public FormField {
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
|
|
@ -45,7 +45,7 @@ void TimeEdit::paint(BitmapBuffer * dc)
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
// TODO could be moved to BaseNumberEdit
|
// TODO could be moved to BaseNumberEdit
|
||||||
void TimeEdit::onKeyEvent(event_t event)
|
void TimeEdit::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void TimeEdit::onKeyEvent(event_t event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FormField::onKeyEvent(event);
|
FormField::onEvent(event);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -81,16 +81,16 @@ bool TimeEdit::onTouchEnd(coord_t x, coord_t y)
|
||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberKeyboard * keyboard = NumberKeyboard::instance();
|
// NumberKeyboard * keyboard = NumberKeyboard::instance();
|
||||||
if (keyboard->getField() != this) {
|
// if (keyboard->getField() != this) {
|
||||||
keyboard->setField(this);
|
// keyboard->setField(this);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimeEdit::onFocusLost()
|
void TimeEdit::onFocusLost()
|
||||||
{
|
{
|
||||||
NumberKeyboard::instance()->disable(true);
|
// NumberKeyboard::instance()->disable(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,7 +37,7 @@ class TimeEdit : public BaseNumberEdit {
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
|
|
@ -165,7 +165,7 @@ ViewMain::~ViewMain()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void ViewMain::onKeyEvent(event_t event)
|
void ViewMain::onEvent(event_t event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVT_KEY_LONG(KEY_MODEL):
|
case EVT_KEY_LONG(KEY_MODEL):
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ViewMain: public Window {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onKeyEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
|
|
|
@ -44,13 +44,10 @@ Key keys[NUM_KEYS];
|
||||||
|
|
||||||
event_t getEvent(bool trim)
|
event_t getEvent(bool trim)
|
||||||
{
|
{
|
||||||
event_t evt = s_evt;
|
event_t event = s_evt;
|
||||||
int8_t k = EVT_KEY_MASK(s_evt) - TRM_BASE;
|
if (trim == IS_TRIM_EVENT(event)) {
|
||||||
bool trim_evt = (k>=0 && k<TRM_LAST-TRM_BASE+1);
|
|
||||||
|
|
||||||
if (trim == trim_evt) {
|
|
||||||
s_evt = 0;
|
s_evt = 0;
|
||||||
return evt;
|
return event;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -26,7 +26,11 @@
|
||||||
#include "opentx_types.h"
|
#include "opentx_types.h"
|
||||||
#include "libopenui/src/libopenui_types.h"
|
#include "libopenui/src/libopenui_types.h"
|
||||||
|
|
||||||
#define EVT_KEY_MASK(e) ((e) & 0x1f)
|
constexpr event_t EVT_REFRESH = 0x1000;
|
||||||
|
constexpr event_t EVT_ENTRY = 0x1001;
|
||||||
|
constexpr event_t EVT_ENTRY_UP = 0x1002;
|
||||||
|
constexpr event_t EVT_ROTARY_LEFT = 0x1003;
|
||||||
|
constexpr event_t EVT_ROTARY_RIGHT = 0x1004;
|
||||||
|
|
||||||
#if defined(PCBHORUS)
|
#if defined(PCBHORUS)
|
||||||
constexpr event_t _MSK_KEY_BREAK = 0x0200;
|
constexpr event_t _MSK_KEY_BREAK = 0x0200;
|
||||||
|
@ -35,30 +39,61 @@ constexpr event_t _MSK_KEY_FIRST = 0x0600;
|
||||||
constexpr event_t _MSK_KEY_LONG = 0x0800;
|
constexpr event_t _MSK_KEY_LONG = 0x0800;
|
||||||
constexpr event_t _MSK_KEY_FLAGS = 0x0E00;
|
constexpr event_t _MSK_KEY_FLAGS = 0x0E00;
|
||||||
#else
|
#else
|
||||||
constexpr event_t _MSK_KEY_BREAK = 0x20;
|
constexpr event_t _MSK_KEY_BREAK = 0x0020;
|
||||||
constexpr event_t _MSK_KEY_REPT = 0x40;
|
constexpr event_t _MSK_KEY_REPT = 0x0040;
|
||||||
constexpr event_t _MSK_KEY_FIRST = 0x60;
|
constexpr event_t _MSK_KEY_FIRST = 0x0060;
|
||||||
constexpr event_t _MSK_KEY_LONG = 0x80;
|
constexpr event_t _MSK_KEY_LONG = 0x0080;
|
||||||
constexpr event_t _MSK_KEY_FLAGS = 0xE0;
|
constexpr event_t _MSK_KEY_FLAGS = 0x00E0;
|
||||||
constexpr event_t EVT_ENTRY = 0xBF;
|
|
||||||
constexpr event_t EVT_ENTRY_UP = 0xBE;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
constexpr event_t _MSK_VIRTUAL_KEY = 0x1000;
|
constexpr event_t _MSK_VIRTUAL_KEY = 0x2000;
|
||||||
|
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY(uint8_t key)
|
||||||
|
{
|
||||||
|
return (key | _MSK_VIRTUAL_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_MIN = EVT_VIRTUAL_KEY('m');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_MAX = EVT_VIRTUAL_KEY('M');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_PLUS = EVT_VIRTUAL_KEY('+');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_MINUS = EVT_VIRTUAL_KEY('-');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_FORWARD = EVT_VIRTUAL_KEY('F');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_BACKWARD = EVT_VIRTUAL_KEY('B');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_DEFAULT = EVT_VIRTUAL_KEY('0');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_UP = EVT_VIRTUAL_KEY('U');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_DOWN = EVT_VIRTUAL_KEY('D');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_LEFT = EVT_VIRTUAL_KEY('L');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_RIGHT = EVT_VIRTUAL_KEY('R');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_NEXT = EVT_VIRTUAL_KEY('N');
|
||||||
|
constexpr event_t EVT_VIRTUAL_KEY_PREVIOUS = EVT_VIRTUAL_KEY('P');
|
||||||
|
|
||||||
|
constexpr bool IS_VIRTUAL_KEY_EVENT(event_t event)
|
||||||
|
{
|
||||||
|
return (event & 0xF000) == _MSK_VIRTUAL_KEY;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EVT_VIRTUAL_KEY(key) ((key) | _MSK_VIRTUAL_KEY)
|
|
||||||
|
|
||||||
// normal order of events is: FIRST, LONG, REPEAT, REPEAT, ..., BREAK
|
// normal order of events is: FIRST, LONG, REPEAT, REPEAT, ..., BREAK
|
||||||
|
#define EVT_KEY_MASK(e) ((e) & 0x1F)
|
||||||
#define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST) // fired when key is pressed
|
#define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST) // fired when key is pressed
|
||||||
#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG) // fired when key is held pressed for a while
|
#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG) // fired when key is held pressed for a while
|
||||||
#define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT) // fired when key is held pressed long enough, fires multiple times with increasing speed
|
#define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT) // fired when key is held pressed long enough, fires multiple times with increasing speed
|
||||||
constexpr event_t EVT_KEY_BREAK(event_t key)
|
constexpr event_t EVT_KEY_BREAK(uint8_t key)
|
||||||
{
|
{
|
||||||
return (key | _MSK_KEY_BREAK); // fired when key is released (short or long), but only if the event was not killed
|
return (key | _MSK_KEY_BREAK); // fired when key is released (short or long), but only if the event was not killed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool IS_KEY_EVENT(event_t event)
|
||||||
|
{
|
||||||
|
return (event & 0xF000) == 0; // fired when key is released (short or long), but only if the event was not killed
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool IS_TRIM_EVENT(event_t event)
|
||||||
|
{
|
||||||
|
return (IS_KEY_EVENT(event) && EVT_KEY_MASK(event) >= TRM_BASE);
|
||||||
|
}
|
||||||
|
|
||||||
#define IS_KEY_FIRST(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_FIRST)
|
#define IS_KEY_FIRST(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_FIRST)
|
||||||
#define IS_KEY_LONG(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_LONG)
|
#define IS_KEY_LONG(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_LONG)
|
||||||
#define IS_KEY_REPT(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_REPT)
|
#define IS_KEY_REPT(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_REPT)
|
||||||
|
@ -67,22 +102,16 @@ constexpr event_t EVT_KEY_BREAK(event_t key)
|
||||||
#if defined(PCBXLITE)
|
#if defined(PCBXLITE)
|
||||||
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
||||||
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
||||||
#define EVT_ROTARY_LEFT 0xDF00
|
|
||||||
#define EVT_ROTARY_RIGHT 0xDE00
|
|
||||||
#define IS_NEXT_EVENT(event) (event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
|
#define IS_NEXT_EVENT(event) (event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
|
||||||
#define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
#define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
||||||
#elif defined(PCBFRSKY) && defined(ROTARY_ENCODER_NAVIGATION)
|
#elif defined(PCBFRSKY) && defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
||||||
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
||||||
#define EVT_ROTARY_LEFT 0xDF00
|
|
||||||
#define EVT_ROTARY_RIGHT 0xDE00
|
|
||||||
#define IS_NEXT_EVENT(event) (event==EVT_ROTARY_RIGHT)
|
#define IS_NEXT_EVENT(event) (event==EVT_ROTARY_RIGHT)
|
||||||
#define IS_PREVIOUS_EVENT(event) (event==EVT_ROTARY_LEFT)
|
#define IS_PREVIOUS_EVENT(event) (event==EVT_ROTARY_LEFT)
|
||||||
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
#define EVT_ROTARY_BREAK 0xcf
|
#define EVT_ROTARY_BREAK 0xcf
|
||||||
#define EVT_ROTARY_LONG 0xce
|
#define EVT_ROTARY_LONG 0xce
|
||||||
#define EVT_ROTARY_LEFT 0xdf
|
|
||||||
#define EVT_ROTARY_RIGHT 0xde
|
|
||||||
#define IS_NEXT_EVENT(event) (event==EVT_ROTARY_RIGHT || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
|
#define IS_NEXT_EVENT(event) (event==EVT_ROTARY_RIGHT || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
|
||||||
#define IS_PREVIOUS_EVENT(event) (event==EVT_ROTARY_LEFT || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
#define IS_PREVIOUS_EVENT(event) (event==EVT_ROTARY_LEFT || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
||||||
#else
|
#else
|
||||||
|
@ -90,10 +119,6 @@ constexpr event_t EVT_KEY_BREAK(event_t key)
|
||||||
#define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
#define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(COLORLCD)
|
|
||||||
#define EVT_REFRESH 0xDD00
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Key
|
class Key
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -218,8 +218,8 @@ char * getCurveString(char * dest, int idx)
|
||||||
idx = -idx;
|
idx = -idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ZEXIST(g_model.curves[idx - 1].name))
|
if (g_model.curves[idx - 1].name[0])
|
||||||
zchar2str(s, g_model.curves[idx - 1].name, LEN_CURVE_NAME);
|
strAppend(s, g_model.curves[idx - 1].name, LEN_CURVE_NAME);
|
||||||
else
|
else
|
||||||
strAppendStringWithIndex(s, STR_CV, idx);
|
strAppendStringWithIndex(s, STR_CV, idx);
|
||||||
|
|
||||||
|
@ -234,8 +234,8 @@ char * getGVarString(char * dest, int idx)
|
||||||
idx = -idx-1;
|
idx = -idx-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ZEXIST(g_model.gvars[idx].name))
|
if (g_model.gvars[idx].name[0])
|
||||||
zchar2str(s, g_model.gvars[idx].name, LEN_GVAR_NAME);
|
strAppend(s, g_model.gvars[idx].name, LEN_GVAR_NAME);
|
||||||
else
|
else
|
||||||
strAppendStringWithIndex(s, STR_GV, idx+1);
|
strAppendStringWithIndex(s, STR_GV, idx+1);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue