}
void MessageShowView::UpdateShowConfig()
{
- /*
- 默认配置 :
- 矩形长:60
- label长:40
- 通过字符串内容配置
- 一行最多显示 30 个字符
- 一行 矩形背景长加 40
- 一行 label长加 50
- */
-
- const int maxCharsPerLine = 30;
+ // 默认配置: 矩形和标签的初始宽度
+ const int maxCharsPerLine = 39;
+ const int baseRectWidth = defaultRectWidth;
+ const int baseLabelWidth = defaultLabelWidth;
+ const int extraRectWidthPerLine = 30;
+ const int extraLabelWidthPerLine = 50;
// 计算行数
- int lines = (messageStr.size() / maxCharsPerLine) + (messageStr.size() % maxCharsPerLine ? 1 : 0);
-
- // 默认情况下,矩形宽度不变。如果有多行,则更新
- int updatedRectWidth = defaultRectWidth + (lines > 1 ? (lines * 10) : 0);
- int updatedLabelWidth = defaultLabelWidth + (lines > 1 ? (lines * 50) : 0);
+ int totalChars = messageStr.size();
+ int lines = (totalChars / maxCharsPerLine) + (totalChars % maxCharsPerLine ? 1 : 0);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateShowConfig lines %d", lines);
- /*小于2行不需要变化*/
+ // 小于等于2行时,无需更新
if (lines <= 2)
return;
+ // 计算更新后的宽度
+ int additionalLines = lines - 1; // 增加一行预备
+ int updatedRectWidth = baseRectWidth + (additionalLines * extraRectWidthPerLine);
+ int updatedLabelWidth = baseLabelWidth + (additionalLines * extraLabelWidthPerLine);
+
// 输出配置结果
messageButton->SetPosition(33, 157, 400, updatedRectWidth);
deleteButton->SetPosition(43, 157 + updatedRectWidth + 20, 380, 100);
// messageButton->SetText(messageStr.c_str());
// messageButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
/* -------------------------------------------------------------------------- */
- InitUILabel(message, 68, 170, 320, 100, "message", messageStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30);
+ InitUILabel(message, 63, 165, 340, 100, "message", messageStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30);
message->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); // 宽固定 高度变长!
message->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
/*加载清除按键*/
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail");
return;
}
- container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
- container_->SetScrollBlankSize(35);
+ container_->SetPosition(0, 0);
+ container_->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+ container_->SetScrollBlankSize(20);
container_->SetReboundSize(50);
- container_->SetDirection(1);
+ // container_->SetHorizontalScrollState(false); // 设置水平滚动失效
+ // container_->SetDirection(1);
container_->SetOnDragListener(presenter_);
container_->SetTouchable(true);
// SetContainerView(new UIScrollView());
container_ = new UIScrollView();
container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ container_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
container_->SetOnDragListener(presenter_);
container_->SetTouchable(true);
container_->SetDraggable(true);
+ // container_->SetFullScreenBlur(true); // 设置高斯模糊
ShowLackView();
ShowMessageView();
{
messageView->Add(MessageList);
messageView->Add(DeleteButton);
+ // messageView->SetFullScreenBlur(true);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageList is add");
container_->Add(messageView);
+ // container_->SetFullScreenBlur(true);
MessageList->SetAdapter(p_MessageListAdapter);
}
Draw();