touch interface support for time_edit

This commit is contained in:
eshifri
2021-08-03 11:32:02 +02:00
committed by Raphael Coeffic
parent 3cb496a477
commit 4c3f5e3fb4
2 changed files with 4 additions and 65 deletions
+2 -54
View File
@@ -20,11 +20,11 @@
#include "libopenui_config.h"
#include "timeedit.h"
#include "keyboard_number.h"
#include "strhelpers.h"
TimeEdit::TimeEdit(Window * parent, const rect_t & rect, int32_t vmin, int32_t vmax, std::function<int32_t()> getValue, std::function<void(int32_t)> setValue):
BaseNumberEdit(parent, rect, vmin, vmax, std::move(getValue), std::move(setValue))
NumberEdit(parent, rect, vmin, vmax, std::move(getValue), std::move(setValue))
{
}
@@ -45,55 +45,3 @@ void TimeEdit::paint(BitmapBuffer * dc)
textColor);
}
#if defined(HARDWARE_KEYS)
// TODO could be moved to BaseNumberEdit
void TimeEdit::onEvent(event_t event)
{
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
if (editMode) {
if (event == EVT_ROTARY_RIGHT) {
int value = getValue();
value += ROTARY_ENCODER_SPEED() * step;
if (value <= vmax)
setValue(value);
else
onKeyError();
return;
}
else if (event == EVT_ROTARY_LEFT) {
int value = getValue();
value -= ROTARY_ENCODER_SPEED() * step;
if (value >= vmin)
setValue(value);
else
onKeyError();
return;
}
}
FormField::onEvent(event);
}
#endif
#if defined(HARDWARE_TOUCH)
bool TimeEdit::onTouchEnd(coord_t x, coord_t y)
{
if (!hasFocus()) {
setFocus(SET_FOCUS_DEFAULT);
}
// NumberKeyboard * keyboard = NumberKeyboard::instance();
// if (keyboard->getField() != this) {
// keyboard->setField(this);
// }
return true;
}
void TimeEdit::onFocusLost()
{
BaseNumberEdit::onFocusLost();
// NumberKeyboard::instance()->disable(true);
}
#endif
+2 -11
View File
@@ -21,9 +21,9 @@
#ifndef _TIMEEDIT_H_
#define _TIMEEDIT_H_
#include "basenumberedit.h"
#include "numberedit.h"
class TimeEdit : public BaseNumberEdit {
class TimeEdit : public NumberEdit {
public:
TimeEdit(Window * parent, const rect_t & rect, int32_t vmin, int32_t vmax, std::function<int32_t()> getValue, std::function<void(int32_t)> setValue = nullptr);
@@ -36,15 +36,6 @@ class TimeEdit : public BaseNumberEdit {
void paint(BitmapBuffer * dc) override;
#if defined(HARDWARE_KEYS)
void onEvent(event_t event) override;
#endif
#if defined(HARDWARE_TOUCH)
bool onTouchEnd(coord_t x, coord_t y) override;
void onFocusLost() override;
#endif
};
#endif // _TIMEEDIT_H_