Small improvements / fixes
This commit is contained in:
committed by
Raphael Coeffic
parent
00fda7f4ae
commit
dbe8405fe2
+3
-2
@@ -77,10 +77,11 @@ ChoiceBase::ChoiceBase(Window* parent, const rect_t& rect, ChoiceType type,
|
||||
|
||||
std::string Choice::getLabelText()
|
||||
{
|
||||
std::string text = "";
|
||||
std::string text;
|
||||
|
||||
if (textHandler != nullptr)
|
||||
text = textHandler(getValue());
|
||||
else {
|
||||
else if (getValue) {
|
||||
int val = getValue();
|
||||
val -= vmin;
|
||||
if (val >= 0 && val < (int)values.size()) {
|
||||
|
||||
+5
@@ -99,6 +99,11 @@ class Choice: public ChoiceBase {
|
||||
setValue = std::move(handler);
|
||||
}
|
||||
|
||||
void setGetValueHandler(std::function<int()> handler)
|
||||
{
|
||||
getValue = std::move(handler);
|
||||
}
|
||||
|
||||
void setAvailableHandler(std::function<bool(int)> handler)
|
||||
{
|
||||
isValueAvailable = std::move(handler);
|
||||
|
||||
+1
-2
@@ -64,14 +64,13 @@ class FlexGridLayout
|
||||
void resetPos() { col_pos = 0; row_pos = 0; }
|
||||
|
||||
void nextColumn() { col_pos += col_span; }
|
||||
void nextRow() { row_pos += row_span; }
|
||||
void nextRow() { row_pos += row_span; col_pos = 0; }
|
||||
|
||||
void nextCell()
|
||||
{
|
||||
nextColumn();
|
||||
if (col_dsc[col_pos] == LV_GRID_TEMPLATE_LAST) {
|
||||
nextRow();
|
||||
col_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ void FormField::onEvent(event_t event)
|
||||
extern lv_group_t* inputGroup;
|
||||
void FormField::setFocus(uint8_t flag, Window * from)
|
||||
{
|
||||
if (enabled) {
|
||||
if (enabled && !lv_obj_has_flag(lvobj, LV_OBJ_FLAG_HIDDEN)) {
|
||||
Window::setFocus(flag, from);
|
||||
if(lvobj != nullptr) {
|
||||
lv_group_focus_obj(lvobj);
|
||||
|
||||
+2
-1
@@ -26,7 +26,8 @@ NumberKeyboard * NumberKeyboard::_instance = nullptr;
|
||||
NumberKeyboard::NumberKeyboard() :
|
||||
Keyboard(KEYBOARD_HEIGHT)
|
||||
{
|
||||
lv_obj_add_flag(keyboard, LV_OBJ_FLAG_HIDDEN); // ToDo: for now we are still using the old keyboard
|
||||
// ToDo: for now we are still using the old keyboard
|
||||
lv_obj_add_flag(keyboard, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
new TextButton(this, {LCD_W / 2 - 115, 10, 50, 30}, "<<",
|
||||
[=]() -> uint8_t {
|
||||
|
||||
+2
@@ -183,6 +183,8 @@ void MenuBody::setIndex(int index)
|
||||
|
||||
lv_coord_t row_h = table->row_h[table->row_act];
|
||||
lv_coord_t scroll_y = lv_obj_get_scroll_y(lvobj);
|
||||
|
||||
lv_obj_update_layout(lvobj);
|
||||
lv_coord_t h = lv_obj_get_height(lvobj);
|
||||
|
||||
lv_coord_t diff_y = 0;
|
||||
|
||||
@@ -58,7 +58,6 @@ TextEdit::TextEdit(Window *parent, const rect_t &rect, char *value,
|
||||
lv_textarea_set_text(lvobj, value);
|
||||
lv_textarea_set_placeholder_text(lvobj, "---");
|
||||
lv_textarea_set_max_length(lvobj, length);
|
||||
lv_textarea_set_cursor_pos(lvobj, 0);
|
||||
|
||||
if (width() == 0) {
|
||||
lv_obj_set_width(lvobj, LV_DPI_DEF);
|
||||
|
||||
@@ -395,6 +395,7 @@ void Window::setFocus(uint8_t flag, Window * from)
|
||||
if (flag != SET_FOCUS_NO_SCROLL) {
|
||||
lv_obj_scroll_to_view_recursive(lvobj, LV_ANIM_OFF);
|
||||
}
|
||||
invalidate();
|
||||
|
||||
clearFocus();
|
||||
focusWindow = this;
|
||||
|
||||
Reference in New Issue
Block a user