瀏覽代碼

固定在表情在左下角

xuxinyi 4 月之前
父節點
當前提交
d87068f6c9
共有 2 個文件被更改,包括 19 次插入2 次删除
  1. 2 0
      main/display/display.h
  2. 17 2
      main/display/lcd_display.cc

+ 2 - 0
main/display/display.h

@@ -39,6 +39,8 @@ protected:
     lv_display_t *display_ = nullptr;
 
     lv_obj_t *emotion_label_ = nullptr;
+    lv_obj_t *emotion_label_1 = nullptr;
+    lv_obj_t *emotion_label_2 = nullptr;
     lv_obj_t *network_label_ = nullptr;
     lv_obj_t *status_label_ = nullptr;
     lv_obj_t *notification_label_ = nullptr;

+ 17 - 2
main/display/lcd_display.cc

@@ -352,8 +352,7 @@ void LcdDisplay::Unlock() {
 #if CONFIG_USE_WECHAT_MESSAGE_STYLE
 void LcdDisplay::SetupUI() {
     DisplayLockGuard lock(this);
-    //printf("SetupUI1\n");
-    //P4微信界面应该是这里
+    printf("SetupUI1\n");
     auto screen = lv_screen_active();
     lv_obj_set_style_text_font(screen, fonts_.text_font, 0);
     lv_obj_set_style_text_color(screen, current_theme.text, 0);
@@ -392,6 +391,22 @@ void LcdDisplay::SetupUI() {
     // Create a flex container for chat messages
     lv_obj_set_flex_flow(content_, LV_FLEX_FLOW_COLUMN);
     lv_obj_set_flex_align(content_, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
+
+    // 替代方案:使用旧版本兼容方法固定元素位置
+    // 1. 创建一个固定在右下角的容器
+    lv_obj_t* fixed_container = lv_obj_create(screen);
+    lv_obj_set_size(fixed_container, 40, 40); // 根据图标大小调整
+    lv_obj_align(fixed_container, LV_ALIGN_BOTTOM_RIGHT, -10, -10);
+    lv_obj_set_style_bg_opa(fixed_container, LV_OPA_TRANSP, 0); // 透明背景
+    lv_obj_set_style_border_width(fixed_container, 0, 0); // 无边框
+    lv_obj_clear_flag(fixed_container, LV_OBJ_FLAG_SCROLLABLE); // 禁止滚动
+
+    // 2. 将图标添加到这个容器中
+    emotion_label_1 = lv_label_create(fixed_container);
+    lv_obj_set_style_text_font(emotion_label_1, &font_awesome_30_4, 0);
+    lv_obj_set_style_text_color(emotion_label_1, current_theme.text, 0);
+    lv_label_set_text(emotion_label_1, FONT_AWESOME_AI_CHIP);
+    lv_obj_center(emotion_label_1); // 居中显示在容器中
     lv_obj_set_style_pad_row(content_, 10, 0); // Space between messages
 
     // We'll create chat messages dynamically in SetChatMessage