changes for keyboard processing. It is pretty good now. The next thing will be to do the numeric keyboard. Stay tuned

This commit is contained in:
kkoenig1@optonline.com
2022-06-11 15:13:11 +02:00
committed by Raphael Coeffic
parent a6a387a87c
commit 684a004f9e
9 changed files with 274 additions and 243 deletions
+2 -2
View File
@@ -77,9 +77,9 @@ class FormField: public Window
virtual void setEditMode(bool newEditMode)
{
editMode = newEditMode;
if (editMode) {
if (editMode && lvobj != nullptr) {
lv_obj_add_state(lvobj, LV_STATE_EDITED | LV_STATE_FOCUSED);
} else {
} else if (lvobj != nullptr) {
lv_obj_clear_state(lvobj, LV_STATE_EDITED);
}
invalidate();
+10 -2
View File
@@ -18,6 +18,9 @@
*/
#include "keyboard_base.h"
Keyboard * Keyboard::activeKeyboard = nullptr;
lv_obj_t *Keyboard::keyboard = nullptr;
coord_t calcScrollOffsetForField(FormField *newField, Window *topWindow)
{
// now we need to calculate the offset of the field in the fields scroll container
@@ -32,7 +35,7 @@ coord_t calcScrollOffsetForField(FormField *newField, Window *topWindow)
// try and place it in the middle of the screen. The containing window MUST have
// already been resized
return offsetY - topWindow->height() / 2;
return offsetY - topWindow->height() * 2 / 7;
}
bool Keyboard::attachKeyboard()
@@ -99,7 +102,10 @@ void Keyboard::setField(FormField* newField)
#endif
// scroll the header of the window out of view to get more space to
// see the field being edited
lv_obj_scroll_to_y(fieldContainer->getLvObj(), fields->top(), LV_ANIM_OFF);
// TODO: this no longer works. we need to figure out something else
//lv_obj_scroll_to_y(fieldContainer->getLvObj(), fields->top(), LV_ANIM_OFF);
oldHeight = fields->height();
fields->setHeight(newHeight);
@@ -113,6 +119,8 @@ void Keyboard::setField(FormField* newField)
invalidate();
newField->setEditMode(true);
lv_keyboard_set_textarea(keyboard, newField->getLvObj());
field = newField;
} else {
clearField();
+11 -1
View File
@@ -25,13 +25,21 @@
class Keyboard: public FormWindow
{
public:
explicit Keyboard(coord_t height) : FormWindow(nullptr, {0, LCD_H - height, LCD_W, height}, OPAQUE)
explicit Keyboard(coord_t height) :
FormWindow(nullptr, {0, LCD_H - height, LCD_W, height}, OPAQUE)
{
// set the background of the window and opacity to 100%
lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_SECONDARY1), LV_PART_MAIN);
lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN);
}
void clearField()
{
TRACE("CLEAR FIELD");
if (keyboard != nullptr) {
lv_obj_add_flag(keyboard, LV_OBJ_FLAG_HIDDEN);
}
detach();
if (fields) {
fields->setHeight(oldHeight);
@@ -59,6 +67,8 @@ class Keyboard: public FormWindow
protected:
static Keyboard * activeKeyboard;
static lv_obj_t * keyboard;
FormField *field = nullptr;
Window *fieldContainer = nullptr;
FormWindow *fields = nullptr;
+215 -210
View File
@@ -22,283 +22,288 @@
#include "textedit.h"
#include "font.h"
constexpr coord_t KEYBOARD_HEIGHT = 160;
constexpr coord_t KEYBOARD_HEIGHT = LCD_H * 2 / 5;
TextKeyboard * TextKeyboard::_instance = nullptr;
const uint8_t LBM_KEY_UPPERCASE[] = {
#include "mask_key_uppercase.lbm"
};
// const uint8_t LBM_KEY_UPPERCASE[] = {
// #include "mask_key_uppercase.lbm"
// };
const uint8_t LBM_KEY_LOWERCASE[] = {
#include "mask_key_lowercase.lbm"
};
// const uint8_t LBM_KEY_LOWERCASE[] = {
// #include "mask_key_lowercase.lbm"
// };
const uint8_t LBM_KEY_BACKSPACE[] = {
#include "mask_key_backspace.lbm"
};
// const uint8_t LBM_KEY_BACKSPACE[] = {
// #include "mask_key_backspace.lbm"
// };
const uint8_t LBM_KEY_LETTERS[] = {
#include "mask_key_letters.lbm"
};
// const uint8_t LBM_KEY_LETTERS[] = {
// #include "mask_key_letters.lbm"
// };
const uint8_t LBM_KEY_NUMBERS[] = {
#include "mask_key_numbers.lbm"
};
// const uint8_t LBM_KEY_NUMBERS[] = {
// #include "mask_key_numbers.lbm"
// };
const uint8_t LBM_KEY_SPACEBAR[] = {
#include "mask_key_spacebar.lbm"
};
// const uint8_t LBM_KEY_SPACEBAR[] = {
// #include "mask_key_spacebar.lbm"
// };
const uint8_t * const LBM_SPECIAL_KEYS[] = {
LBM_KEY_BACKSPACE,
LBM_KEY_UPPERCASE,
LBM_KEY_LOWERCASE,
LBM_KEY_LETTERS,
LBM_KEY_NUMBERS,
};
// const uint8_t * const LBM_SPECIAL_KEYS[] = {
// LBM_KEY_BACKSPACE,
// LBM_KEY_UPPERCASE,
// LBM_KEY_LOWERCASE,
// LBM_KEY_LETTERS,
// LBM_KEY_NUMBERS,
// };
const char * const KEYBOARD_LOWERCASE[] = {
"qwertyuiop",
" asdfghjkl",
KEYBOARD_SET_UPPERCASE "zxcvbnm" KEYBOARD_BACKSPACE,
KEYBOARD_SET_NUMBERS KEYBOARD_SPACE KEYBOARD_ENTER
};
// const char * const KEYBOARD_LOWERCASE[] = {
// "qwertyuiop",
// " asdfghjkl",
// KEYBOARD_SET_UPPERCASE "zxcvbnm" KEYBOARD_BACKSPACE,
// KEYBOARD_SET_NUMBERS KEYBOARD_SPACE KEYBOARD_ENTER
// };
const char * const KEYBOARD_UPPERCASE[] = {
"QWERTYUIOP",
" ASDFGHJKL",
KEYBOARD_SET_LOWERCASE "ZXCVBNM" KEYBOARD_BACKSPACE,
KEYBOARD_SET_NUMBERS KEYBOARD_SPACE KEYBOARD_ENTER
};
// const char * const KEYBOARD_UPPERCASE[] = {
// "QWERTYUIOP",
// " ASDFGHJKL",
// KEYBOARD_SET_LOWERCASE "ZXCVBNM" KEYBOARD_BACKSPACE,
// KEYBOARD_SET_NUMBERS KEYBOARD_SPACE KEYBOARD_ENTER
// };
const char * const KEYBOARD_NUMBERS[] = {
"1234567890",
"_-",
" " KEYBOARD_BACKSPACE,
KEYBOARD_SET_LETTERS KEYBOARD_SPACE KEYBOARD_ENTER
};
// const char * const KEYBOARD_NUMBERS[] = {
// "1234567890",
// "_-",
// " " KEYBOARD_BACKSPACE,
// KEYBOARD_SET_LETTERS KEYBOARD_SPACE KEYBOARD_ENTER
// };
#define NUMBER_OF_KEYBOARD_LAYOUTS 4
const char * const * const KEYBOARD_LAYOUTS[NUMBER_OF_KEYBOARD_LAYOUTS] = {
KEYBOARD_UPPERCASE,
KEYBOARD_LOWERCASE,
KEYBOARD_LOWERCASE,
KEYBOARD_NUMBERS,
};
// #define NUMBER_OF_KEYBOARD_LAYOUTS 4
// const char * const * const KEYBOARD_LAYOUTS[NUMBER_OF_KEYBOARD_LAYOUTS] = {
// KEYBOARD_UPPERCASE,
// KEYBOARD_LOWERCASE,
// KEYBOARD_LOWERCASE,
// KEYBOARD_NUMBERS,
// };
TextKeyboard::TextKeyboard():
Keyboard(KEYBOARD_HEIGHT),
layout(KEYBOARD_LOWERCASE)
Keyboard(KEYBOARD_HEIGHT)
// layout(KEYBOARD_LOWERCASE)
{
if (keyboard == nullptr) {
keyboard = lv_keyboard_create(lv_scr_act());
lv_obj_set_size(keyboard, LCD_W, LCD_H * 2 / 5);
lv_obj_clear_flag(keyboard, LV_OBJ_FLAG_HIDDEN);
}
}
TextKeyboard::~TextKeyboard()
{
_instance = nullptr;
}
int TextKeyboard::getCharWidth(const char c)
{
if (int8_t(c) < 0) return KEYBOARD_BITMAP_WIDTH;
// if (int8_t(c) < 0) return KEYBOARD_BITMAP_WIDTH;
switch (c)
{
case ' ': return 15;
case KEYBOARD_SPACE[0]: return KEYBOARD_SPACE_WIDTH;
case KEYBOARD_ENTER[0]: return KEYBOARD_ENTER_WIDTH;
default: return KEYBOARD_CHAR_WIDTH;
}
// switch (c)
// {
// case ' ': return 15;
// case KEYBOARD_SPACE[0]: return KEYBOARD_SPACE_WIDTH;
// case KEYBOARD_ENTER[0]: return KEYBOARD_ENTER_WIDTH;
// default: return KEYBOARD_CHAR_WIDTH;
// }
}
int TextKeyboard::calculateMaxWidth()
{
int maxWidth = 0;
for (uint8_t i = 0; i < NUMBER_OF_KEYBOARD_LAYOUTS; i++) {
int lineWidth = 0;
const char * c = layout[i];
while (*c) {
lineWidth += getCharWidth(*c);
maxWidth = max(lineWidth, maxWidth);
c++;
}
}
// int maxWidth = 0;
// for (uint8_t i = 0; i < NUMBER_OF_KEYBOARD_LAYOUTS; i++) {
// int lineWidth = 0;
// const char * c = layout[i];
// while (*c) {
// lineWidth += getCharWidth(*c);
// maxWidth = max(lineWidth, maxWidth);
// c++;
// }
// }
return maxWidth;
// return maxWidth;
}
void TextKeyboard::paint(BitmapBuffer * dc)
{
lcdSetColor(RGB(0xE0, 0xE0, 0xE0));
dc->clear(CUSTOM_COLOR);
// lcdSetColor(RGB(0xE0, 0xE0, 0xE0));
// dc->clear(CUSTOM_COLOR);
// center the keyboard
coord_t start_x = (dc->width() - calculateMaxWidth()) / 2;
// // center the keyboard
// coord_t start_x = (dc->width() - calculateMaxWidth()) / 2;
for (uint8_t i = 0; i < NUMBER_OF_KEYBOARD_LAYOUTS; i++) {
coord_t y = KEYBOARD_OFFSET_Y + i * KEYBOARD_ROW_HEIGHT;
coord_t x = start_x;
const char * c = layout[i];
// for (uint8_t i = 0; i < NUMBER_OF_KEYBOARD_LAYOUTS; i++) {
// coord_t y = KEYBOARD_OFFSET_Y + i * KEYBOARD_ROW_HEIGHT;
// coord_t x = start_x;
// const char * c = layout[i];
while (*c) {
if (*c == KEYBOARD_SPACE[0]) {
// spacebar
dc->drawBitmapPattern(x, y, LBM_KEY_SPACEBAR, COLOR_THEME_SECONDARY1);
}
else if (*c == KEYBOARD_ENTER[0]) {
// enter
dc->drawSolidFilledRect(x, y - 2, KEYBOARD_ENTER_WIDTH, 25, COLOR_THEME_DISABLED);
dc->drawText(x + KEYBOARD_ENTER_WIDTH / 2, y + 2, "ENTER", CENTERED);
}
else if (int8_t(*c) < 0) {
const uint8_t *pBitmap = LBM_SPECIAL_KEYS[uint8_t(*c - 128)];
uint8_t bitmapWidth = *pBitmap, bitmapHeight = *(pBitmap + 2);
if (touched && *c == touch_key) {
dc->drawSolidFilledRect(x - 2, y + 3, bitmapWidth + 4, bitmapHeight + 4, COLOR_THEME_SECONDARY2);
}
// while (*c) {
// if (*c == KEYBOARD_SPACE[0]) {
// // spacebar
// dc->drawBitmapPattern(x, y, LBM_KEY_SPACEBAR, COLOR_THEME_SECONDARY1);
// }
// else if (*c == KEYBOARD_ENTER[0]) {
// // enter
// dc->drawSolidFilledRect(x, y - 2, KEYBOARD_ENTER_WIDTH, 25, COLOR_THEME_DISABLED);
// dc->drawText(x + KEYBOARD_ENTER_WIDTH / 2, y + 2, "ENTER", CENTERED);
// }
// else if (int8_t(*c) < 0) {
// const uint8_t *pBitmap = LBM_SPECIAL_KEYS[uint8_t(*c - 128)];
// uint8_t bitmapWidth = *pBitmap, bitmapHeight = *(pBitmap + 2);
// if (touched && *c == touch_key) {
// dc->drawSolidFilledRect(x - 2, y + 3, bitmapWidth + 4, bitmapHeight + 4, COLOR_THEME_SECONDARY2);
// }
dc->drawBitmapPattern(x, y + 5, pBitmap, COLOR_THEME_SECONDARY1);
}
else {
if (touched && *c == touch_key) {
dc->drawSolidFilledRect(x - KEYBOARD_CHAR_WIDTH / 2, y - ((KEYBOARD_ROW_HEIGHT - 16) / 2), KEYBOARD_CHAR_WIDTH, KEYBOARD_ROW_HEIGHT, COLOR_THEME_FOCUS);
}
dc->drawSizedText(x, y, c, 1, CENTERED);
}
x += getCharWidth(*c);
c++;
}
}
// dc->drawBitmapPattern(x, y + 5, pBitmap, COLOR_THEME_SECONDARY1);
// }
// else {
// if (touched && *c == touch_key) {
// dc->drawSolidFilledRect(x - KEYBOARD_CHAR_WIDTH / 2, y - ((KEYBOARD_ROW_HEIGHT - 16) / 2), KEYBOARD_CHAR_WIDTH, KEYBOARD_ROW_HEIGHT, COLOR_THEME_FOCUS);
// }
// dc->drawSizedText(x, y, c, 1, CENTERED);
// }
// x += getCharWidth(*c);
// c++;
// }
// }
}
bool TextKeyboard::onTouchStart(coord_t x, coord_t y)
{
// remove the centering. If x < 0 then this is an invalid touch event
x -= (this->width() - calculateMaxWidth()) / 2;
if (x < 0) {
if (touched) {
touched = false;
invalidate();
}
return true;
}
// // remove the centering. If x < 0 then this is an invalid touch event
// x -= (this->width() - calculateMaxWidth()) / 2;
// if (x < 0) {
// if (touched) {
// touched = false;
// invalidate();
// }
// return true;
// }
touched = false;
// touched = false;
uint8_t row = max<coord_t>(0, y - 5) / KEYBOARD_ROW_HEIGHT;
const char * key = layout[row];
// uint8_t row = max<coord_t>(0, y - 5) / KEYBOARD_ROW_HEIGHT;
// const char * key = layout[row];
while(*key) {
if (*key == KEYBOARD_SPACE[0] && x <= KEYBOARD_SPACE_WIDTH) {
touch_key = KEYBOARD_SPACE[0];
touched = true;
break;
}
else if (*key == KEYBOARD_ENTER[0] && x <= KEYBOARD_ENTER_WIDTH) {
touch_key = KEYBOARD_ENTER[0];
touched = true;
break;
}
else if (int8_t(*key) < 0 && x <= KEYBOARD_BITMAP_WIDTH) {
if (uint8_t(*key) == 128) {
touch_key = KEYBOARD_BACKSPACE[0];
touched = true;
break;
} else {
touched = false;
break;
}
}
else if (*key != ' ' && (x >= -(KEYBOARD_CHAR_WIDTH / 2) && x <= KEYBOARD_CHAR_WIDTH / 2)) {
touch_key = *key;
touched = true;
break;
}
// while(*key) {
// if (*key == KEYBOARD_SPACE[0] && x <= KEYBOARD_SPACE_WIDTH) {
// touch_key = KEYBOARD_SPACE[0];
// touched = true;
// break;
// }
// else if (*key == KEYBOARD_ENTER[0] && x <= KEYBOARD_ENTER_WIDTH) {
// touch_key = KEYBOARD_ENTER[0];
// touched = true;
// break;
// }
// else if (int8_t(*key) < 0 && x <= KEYBOARD_BITMAP_WIDTH) {
// if (uint8_t(*key) == 128) {
// touch_key = KEYBOARD_BACKSPACE[0];
// touched = true;
// break;
// } else {
// touched = false;
// break;
// }
// }
// else if (*key != ' ' && (x >= -(KEYBOARD_CHAR_WIDTH / 2) && x <= KEYBOARD_CHAR_WIDTH / 2)) {
// touch_key = *key;
// touched = true;
// break;
// }
x -= getCharWidth(*key);
key++;
// x -= getCharWidth(*key);
// key++;
if (touched) {
invalidate();
break;
}
}
return true;
// if (touched) {
// invalidate();
// break;
// }
// }
// return true;
}
bool TextKeyboard::onTouchEnd(coord_t x, coord_t y)
{
// remove the centering width, if x < 0 then this is an invalid touch on a centered keyboard.
x -= (this->width() - calculateMaxWidth()) / 2;
if (x < 0) {
touched = false;
return true;
}
// // remove the centering width, if x < 0 then this is an invalid touch on a centered keyboard.
// x -= (this->width() - calculateMaxWidth()) / 2;
// if (x < 0) {
// touched = false;
// return true;
// }
onKeyPress();
// onKeyPress();
if (touched)
invalidate();
touched = false;
// if (touched)
// invalidate();
// touched = false;
uint8_t row = max<coord_t>(0, y - 5) / KEYBOARD_ROW_HEIGHT;
// uint8_t row = max<coord_t>(0, y - 5) / KEYBOARD_ROW_HEIGHT;
const char * key = layout[row];
while (*key) {
if (*key == KEYBOARD_SPACE[0]) {
if (x <= KEYBOARD_SPACE_WIDTH) {
pushEvent(EVT_VIRTUAL_KEY(' '));
return true;
}
}
else if (*key == KEYBOARD_ENTER[0]) {
if (x <= KEYBOARD_ENTER_WIDTH) {
pushEvent(EVT_VIRTUAL_KEY(KEYBOARD_ENTER[0]));
// enter
hide();
return true;
}
}
else if (int8_t(*key) < 0) {
if (x <= KEYBOARD_BITMAP_WIDTH) {
uint8_t specialKey = *key;
if (specialKey == 128) {
// backspace
pushEvent(EVT_VIRTUAL_KEY(KEYBOARD_BACKSPACE[0]));
}
else {
layout = KEYBOARD_LAYOUTS[specialKey - 129];
invalidate();
}
break;
}
}
else {
if (*key != ' ' && (x >= -(KEYBOARD_CHAR_WIDTH / 2) && x <= KEYBOARD_CHAR_WIDTH / 2)) {
pushEvent(EVT_VIRTUAL_KEY(*key));
return true;
}
}
x -= getCharWidth(*key);
key++;
}
// const char * key = layout[row];
// while (*key) {
// if (*key == KEYBOARD_SPACE[0]) {
// if (x <= KEYBOARD_SPACE_WIDTH) {
// pushEvent(EVT_VIRTUAL_KEY(' '));
// return true;
// }
// }
// else if (*key == KEYBOARD_ENTER[0]) {
// if (x <= KEYBOARD_ENTER_WIDTH) {
// pushEvent(EVT_VIRTUAL_KEY(KEYBOARD_ENTER[0]));
// // enter
// hide();
// return true;
// }
// }
// else if (int8_t(*key) < 0) {
// if (x <= KEYBOARD_BITMAP_WIDTH) {
// uint8_t specialKey = *key;
// if (specialKey == 128) {
// // backspace
// pushEvent(EVT_VIRTUAL_KEY(KEYBOARD_BACKSPACE[0]));
// }
// else {
// layout = KEYBOARD_LAYOUTS[specialKey - 129];
// invalidate();
// }
// break;
// }
// }
// else {
// if (*key != ' ' && (x >= -(KEYBOARD_CHAR_WIDTH / 2) && x <= KEYBOARD_CHAR_WIDTH / 2)) {
// pushEvent(EVT_VIRTUAL_KEY(*key));
// return true;
// }
// }
// x -= getCharWidth(*key);
// key++;
// }
return true;
// return true;
}
bool TextKeyboard::onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, coord_t slideX, coord_t slideY)
{
if (touched)
invalidate();
// if (touched)
// invalidate();
touched = false;
return false;
// touched = false;
// return false;
}
#if defined(HARDWARE_KEYS)
void TextKeyboard::onEvent(event_t event)
{
}
#endif
+2
View File
@@ -53,6 +53,8 @@ class TextKeyboard : public Keyboard {
{
if (!_instance)
_instance = new TextKeyboard();
else
lv_obj_clear_flag(_instance->keyboard, LV_OBJ_FLAG_HIDDEN);
_instance->setField(field);
}
-1
View File
@@ -33,7 +33,6 @@ LvglWidgetFactory mainWindowFactory = LvglWidgetFactory([] (lv_obj_t *parent) {
#if defined(HARDWARE_TOUCH)
TouchState touchState;
Keyboard * Keyboard::activeKeyboard = nullptr;
#endif
void MainWindow::emptyTrash()
+23 -23
View File
@@ -47,24 +47,24 @@ static lv_obj_t *virtual_kb = nullptr;
static void ta_event_cb(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *ta = lv_event_get_target(e);
if (code == LV_EVENT_CLICKED) {
if (virtual_kb == nullptr) {
virtual_kb = lv_keyboard_create(lv_scr_act());
lv_obj_set_size(virtual_kb, LV_HOR_RES, LV_VER_RES / 2);
}
// lv_event_code_t code = lv_event_get_code(e);
// lv_obj_t *ta = lv_event_get_target(e);
// if (code == LV_EVENT_CLICKED) {
// if (virtual_kb == nullptr) {
// virtual_kb = lv_keyboard_create(lv_scr_act());
// lv_obj_set_size(virtual_kb, LV_HOR_RES, LV_VER_RES / 2);
// }
if (virtual_kb != NULL) {
lv_keyboard_set_textarea(virtual_kb, ta);
lv_obj_add_state(ta, LV_STATE_EDITED);
}
} else if (code == LV_EVENT_DEFOCUSED || code == LV_EVENT_DELETE) {
if (virtual_kb != nullptr) {
lv_obj_del(virtual_kb);
virtual_kb = nullptr;
}
}
// if (virtual_kb != NULL) {
// lv_keyboard_set_textarea(virtual_kb, ta);
// lv_obj_add_state(ta, LV_STATE_EDITED);
// }
// } else if (code == LV_EVENT_DEFOCUSED || code == LV_EVENT_DELETE) {
// if (virtual_kb != nullptr) {
// lv_obj_del(virtual_kb);
// virtual_kb = nullptr;
// }
// }
}
static lv_style_t style_main;
@@ -339,9 +339,9 @@ bool TextEdit::onTouchEnd(coord_t x, coord_t y)
setFocus(SET_FOCUS_DEFAULT);
}
// #if defined(SOFTWARE_KEYBOARD)
// TextKeyboard::show(this);
// #endif
#if defined(SOFTWARE_KEYBOARD)
TextKeyboard::show(this);
#endif
coord_t rest = x;
for (cursorPos = 0; cursorPos < length; cursorPos++) {
@@ -361,9 +361,9 @@ bool TextEdit::onTouchEnd(coord_t x, coord_t y)
void TextEdit::onFocusLost()
{
// #if defined(SOFTWARE_KEYBOARD)
// TextKeyboard::hide();
// #endif
#if defined(SOFTWARE_KEYBOARD)
TextKeyboard::hide();
#endif
changeEnd();
FormField::onFocusLost();
-2
View File
@@ -208,8 +208,6 @@ void Window::attach(Window * newParent)
if (newParent)
{
newParent->addChild(this);
if(lvobj != nullptr)
lv_obj_set_parent(lvobj, newParent->lvobj);
}
}
+11 -2
View File
@@ -210,11 +210,12 @@ class Window
void setHeight(coord_t value)
{
rect.h = value;
lv_obj_set_height(lvobj, rect.h);
if (lvobj != nullptr)
lv_obj_set_height(lvobj, rect.h);
if (windowFlags & FORWARD_SCROLL)
innerHeight = value;
else if (innerHeight <= value) {
else if (lvobj != nullptr && innerHeight <= value) {
lv_obj_scroll_to_y(lvobj, 0, LV_ANIM_OFF);
}
invalidate();
@@ -436,6 +437,12 @@ class Window
void addChild(Window * window, bool front = false)
{
if (lv_obj_get_parent(window->lvobj) != nullptr) {
lv_obj_set_parent(window->lvobj, this->lvobj);
if (front)
lv_obj_move_to_index(window->lvobj, 0);
}
if (front)
children.push_front(window);
else
@@ -445,6 +452,8 @@ class Window
void removeChild(Window * window)
{
children.remove(window);
if (window->lvobj != nullptr)
lv_obj_set_parent(window->lvobj, nullptr);
invalidate();
}