Update project version to 2.2.2, Noto fonts and emoji support. (#1720)
This commit is contained in:
@ -556,7 +556,6 @@ void LcdDisplay::SetChatMessage(const char* role, const char* content) {
|
||||
}
|
||||
|
||||
auto lvgl_theme = static_cast<LvglTheme*>(current_theme_);
|
||||
auto text_font = lvgl_theme->text_font()->font();
|
||||
|
||||
// Create a message bubble
|
||||
lv_obj_t* msg_bubble = lv_obj_create(content_);
|
||||
@ -774,6 +773,26 @@ void LcdDisplay::SetPreviewImage(std::unique_ptr<LvglImage> image) {
|
||||
// Auto-scroll to the image bubble
|
||||
lv_obj_scroll_to_view_recursive(img_bubble, LV_ANIM_ON);
|
||||
}
|
||||
|
||||
void LcdDisplay::ClearChatMessages() {
|
||||
DisplayLockGuard lock(this);
|
||||
if (content_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use lv_obj_clean to delete all children of content_ (chat message bubbles)
|
||||
lv_obj_clean(content_);
|
||||
|
||||
// Reset chat_message_label_ as it has been deleted
|
||||
chat_message_label_ = nullptr;
|
||||
|
||||
// Show the centered AI logo (emoji_label_) again
|
||||
if (emoji_label_ != nullptr) {
|
||||
lv_obj_remove_flag(emoji_label_, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Chat messages cleared");
|
||||
}
|
||||
#else
|
||||
void LcdDisplay::SetupUI() {
|
||||
DisplayLockGuard lock(this);
|
||||
@ -891,29 +910,35 @@ void LcdDisplay::SetupUI() {
|
||||
lv_label_set_text(status_label_, Lang::Strings::INITIALIZING);
|
||||
lv_obj_align(status_label_, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/* Top layer: Bottom bar - fixed at bottom, minimum height 48, height can be adaptive */
|
||||
/* Top layer: Bottom bar - fixed height at bottom */
|
||||
bottom_bar_ = lv_obj_create(screen);
|
||||
lv_obj_set_width(bottom_bar_, LV_HOR_RES);
|
||||
lv_obj_set_height(bottom_bar_, LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_min_height(bottom_bar_, 48, 0); // Set minimum height 48
|
||||
lv_obj_set_size(bottom_bar_, LV_HOR_RES, text_font->line_height + lvgl_theme->spacing(12));
|
||||
lv_obj_set_style_radius(bottom_bar_, 0, 0);
|
||||
lv_obj_set_style_bg_color(bottom_bar_, lvgl_theme->background_color(), 0);
|
||||
lv_obj_set_style_text_color(bottom_bar_, lvgl_theme->text_color(), 0);
|
||||
lv_obj_set_style_pad_top(bottom_bar_, lvgl_theme->spacing(2), 0);
|
||||
lv_obj_set_style_pad_bottom(bottom_bar_, lvgl_theme->spacing(2), 0);
|
||||
lv_obj_set_style_pad_all(bottom_bar_, 0, 0);
|
||||
lv_obj_set_style_pad_left(bottom_bar_, lvgl_theme->spacing(4), 0);
|
||||
lv_obj_set_style_pad_right(bottom_bar_, lvgl_theme->spacing(4), 0);
|
||||
lv_obj_set_style_border_width(bottom_bar_, 0, 0);
|
||||
lv_obj_set_scrollbar_mode(bottom_bar_, LV_SCROLLBAR_MODE_OFF);
|
||||
lv_obj_align(bottom_bar_, LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||
|
||||
/* chat_message_label_ placed in bottom_bar_ and vertically centered */
|
||||
/* chat_message_label_ placed in bottom_bar_, single-line horizontal scroll */
|
||||
chat_message_label_ = lv_label_create(bottom_bar_);
|
||||
lv_label_set_text(chat_message_label_, "");
|
||||
lv_obj_set_width(chat_message_label_, LV_HOR_RES - lvgl_theme->spacing(8)); // Subtract left and right padding
|
||||
lv_label_set_long_mode(chat_message_label_, LV_LABEL_LONG_WRAP); // Auto wrap mode
|
||||
lv_obj_set_style_text_align(chat_message_label_, LV_TEXT_ALIGN_CENTER, 0); // Center text alignment
|
||||
lv_obj_set_width(chat_message_label_, LV_HOR_RES - lvgl_theme->spacing(8));
|
||||
lv_label_set_long_mode(chat_message_label_, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
lv_obj_set_style_text_align(chat_message_label_, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_set_style_text_color(chat_message_label_, lvgl_theme->text_color(), 0);
|
||||
lv_obj_align(chat_message_label_, LV_ALIGN_CENTER, 0, 0); // Vertically and horizontally centered in bottom_bar_
|
||||
lv_obj_align(chat_message_label_, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
// Start scrolling after a delay (short text won't scroll)
|
||||
static lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_delay(&a, 1000);
|
||||
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
|
||||
lv_obj_set_style_anim(chat_message_label_, &a, LV_PART_MAIN);
|
||||
lv_obj_set_style_anim_duration(chat_message_label_, lv_anim_speed_clamped(60, 300, 60000), LV_PART_MAIN);
|
||||
|
||||
low_battery_popup_ = lv_obj_create(screen);
|
||||
lv_obj_set_scrollbar_mode(low_battery_popup_, LV_SCROLLBAR_MODE_OFF);
|
||||
@ -972,6 +997,14 @@ void LcdDisplay::SetChatMessage(const char* role, const char* content) {
|
||||
}
|
||||
lv_label_set_text(chat_message_label_, content);
|
||||
}
|
||||
|
||||
void LcdDisplay::ClearChatMessages() {
|
||||
DisplayLockGuard lock(this);
|
||||
// In non-wechat mode, just clear the chat message label
|
||||
if (chat_message_label_ != nullptr) {
|
||||
lv_label_set_text(chat_message_label_, "");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void LcdDisplay::SetEmotion(const char* emotion) {
|
||||
@ -1005,6 +1038,8 @@ void LcdDisplay::SetEmotion(const char* emotion) {
|
||||
gif_controller_ = std::make_unique<LvglGif>(image->image_dsc());
|
||||
|
||||
if (gif_controller_->IsLoaded()) {
|
||||
// Set loop delay to 1000ms
|
||||
gif_controller_->SetLoopDelay(3000);
|
||||
// Set up frame update callback
|
||||
gif_controller_->SetFrameCallback([this]() {
|
||||
lv_image_set_src(emoji_image_, gif_controller_->image_dsc());
|
||||
|
||||
Reference in New Issue
Block a user