mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-01 10:21:59 +00:00
refactor(ui-lvgl): quick-message editor uses navTextEntry (bare mode)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VeBrxKyHHxWsmttVkUdBrj
This commit is contained in:
@@ -595,9 +595,19 @@ void UITask::navClosePopup() {
|
||||
}
|
||||
|
||||
lv_obj_t* UITask::navTextEntry(const TextEntry& t) {
|
||||
lv_obj_t* panel = navPopupPanel(t.title, false);
|
||||
lv_obj_align(panel, LV_ALIGN_TOP_MID, 0, theme::STATUS_H + 4); // above the keyboard
|
||||
_nav_ta = textField(panel, t.hint);
|
||||
lv_obj_t* panel;
|
||||
if (t.bare) { // a titled popup doesn't fit above 124 px of keys when a row sits under the field
|
||||
navClosePopup();
|
||||
panel = _nav_overlay = dimOverlay(screen());
|
||||
lv_obj_set_style_bg_opa(panel, LV_OPA_80, 0);
|
||||
_nav_ta = textField(panel, t.hint);
|
||||
lv_obj_set_width(_nav_ta, lv_display_get_horizontal_resolution(NULL) - 16);
|
||||
lv_obj_set_pos(_nav_ta, 8, theme::STATUS_H + 4);
|
||||
} else {
|
||||
panel = navPopupPanel(t.title, false);
|
||||
lv_obj_align(panel, LV_ALIGN_TOP_MID, 0, theme::STATUS_H + 4); // above the keyboard
|
||||
_nav_ta = textField(panel, t.hint);
|
||||
}
|
||||
if (t.password) lv_textarea_set_password_mode(_nav_ta, true);
|
||||
if (t.accepted) lv_textarea_set_accepted_chars(_nav_ta, t.accepted);
|
||||
if (t.text) lv_textarea_set_text(_nav_ta, t.text); // before the cap: a longer stored text is shown, not wiped
|
||||
@@ -609,6 +619,7 @@ lv_obj_t* UITask::navTextEntry(const TextEntry& t) {
|
||||
if (t.symbols) kb::apply(_nav_kb, kb::L_SYM);
|
||||
lv_obj_add_event_cb(_nav_kb, t.done, LV_EVENT_READY, NULL);
|
||||
lv_obj_add_event_cb(_nav_kb, t.done, LV_EVENT_CANCEL, NULL);
|
||||
if (t.bare) freeze::now(_nav_overlay); // typing redraws keys, not the list under the dim
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,37 +134,17 @@ void UITask::quickEdit(int slot) {
|
||||
if (!_prefs || slot < 0 || slot >= msgtext::QUICK_COUNT) return;
|
||||
collect();
|
||||
s_edit = slot;
|
||||
navClosePopup();
|
||||
_nav_overlay = lv_obj_create(screen());
|
||||
lv_obj_remove_style_all(_nav_overlay);
|
||||
lv_obj_set_size(_nav_overlay, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_style_bg_color(_nav_overlay, lv_color_hex(0x000000), 0);
|
||||
lv_obj_set_style_bg_opa(_nav_overlay, LV_OPA_80, 0);
|
||||
lv_obj_add_flag(_nav_overlay, LV_OBJ_FLAG_CLICKABLE);
|
||||
lv_obj_remove_flag(_nav_overlay, LV_OBJ_FLAG_SCROLLABLE);
|
||||
int w = lv_display_get_horizontal_resolution(NULL) - 16;
|
||||
|
||||
char ph[40];
|
||||
snprintf(ph, sizeof(ph), "Quick message %d (empty clears it)", slot + 1);
|
||||
_nav_ta = wifiField(_nav_overlay, ph, false);
|
||||
lv_obj_remove_event_cb(_nav_ta, onWifiField);
|
||||
lv_obj_set_width(_nav_ta, w);
|
||||
lv_obj_set_pos(_nav_ta, 8, theme::STATUS_H + 4);
|
||||
lv_textarea_set_text(_nav_ta, msgtext::quick(_prefs, slot));
|
||||
lv_obj_add_event_cb(_nav_ta, onByteCapInsert, LV_EVENT_INSERT, (void*)(uintptr_t)(msgtext::QUICK_LEN - 1));
|
||||
lv_obj_add_state(_nav_ta, LV_STATE_FOCUSED); // draws the cursor
|
||||
|
||||
lv_obj_t* row = chips(_nav_overlay, onQuickEditPh, false);
|
||||
lv_obj_set_width(row, w);
|
||||
TextEntry t = { "", onQuickEditKb };
|
||||
t.hint = ph;
|
||||
t.text = msgtext::quick(_prefs, slot);
|
||||
t.max_bytes = msgtext::QUICK_LEN - 1;
|
||||
t.bare = true;
|
||||
lv_obj_t* overlay = navTextEntry(t);
|
||||
lv_obj_t* row = chips(overlay, onQuickEditPh, false);
|
||||
lv_obj_set_width(row, lv_display_get_horizontal_resolution(NULL) - 16);
|
||||
lv_obj_set_pos(row, 8, theme::STATUS_H + 4 + 34 + 6);
|
||||
|
||||
_nav_kb = kb::create(_nav_overlay, _prefs);
|
||||
lv_obj_set_size(_nav_kb, LV_PCT(100), 124);
|
||||
lv_obj_align(_nav_kb, LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||
lv_keyboard_set_textarea(_nav_kb, _nav_ta);
|
||||
lv_obj_add_event_cb(_nav_kb, onQuickEditKb, LV_EVENT_READY, NULL);
|
||||
lv_obj_add_event_cb(_nav_kb, onQuickEditKb, LV_EVENT_CANCEL, NULL);
|
||||
freeze::now(_nav_overlay); // typing redraws keys, not the list under the dim
|
||||
}
|
||||
|
||||
void UITask::quickEditInsert(int ph) {
|
||||
|
||||
@@ -36,6 +36,7 @@ struct TextEntry {
|
||||
bool password = false;
|
||||
const char* accepted = nullptr; // only these characters (lv_textarea_set_accepted_chars)
|
||||
bool symbols = false; // open on the digits / symbols page
|
||||
bool bare = false; // no titled panel: the field straight on the dim, for the caller to add rows under it (returns the overlay)
|
||||
};
|
||||
|
||||
class UITask : public UITaskBase, public UiCoreHost {
|
||||
|
||||
Reference in New Issue
Block a user