// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is succeed");
return true;
}
+ /***
+ * @description:
+ * @param {UILabelButton} *
+ * @param {int} left
+ * @param {int} top
+ * @param {int} width
+ * @param {int} height
+ * @param {char} *viewId
+ * @param {UIResourceTextId} id
+ * @param {int} fontSize
+ * @return {*}
+ * @brief 初始化带label的button
+ */
+ bool InitLabelButton(UILabelButton *&button, int left, int top, int width, int height, const char *viewId, const char *text, int fontSize)
+ {
+ // 创建新按钮(如果当前按钮为空)
+ if (button == nullptr)
+ {
+ button = new UILabelButton();
+ if (button == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error");
+ return false; // 内存分配失败,返回false
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UILabelButton UILabelButton is not nullptr");
+ return false; // 内存分配失败,返回false
+ }
+ button->SetPosition(left, top);
+ button->Resize(width, height);
+ button->SetViewId(viewId);
+ button->SetText(text);
+ button->SetStyle(STYLE_TEXT_FONT, fontSize);
+ button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize);
+ button->SetStyle(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR);
+ button->SetStyleForState(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, UIButton::PRESSED);
+ button->SetStyleForState(STYLE_BORDER_COLOR, PRESSED_BORDER_COLOR, UIButton::PRESSED);
+ button->SetVisible(true);
+ return true;
+ }
/* -------------------------------------------------------------------------- */
/*替换字符串中的变量*/
std::string UpdateLabelText(UILabelExt *&label, const std::string &newText, UIResourceTextId id)
+/***
+ * @Date: 2024-07-29 10:31:48
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-21 16:17:07
+ * @FilePath: /FD230/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h
+ */
/***
* @Date: 2024-05-30 15:59:37
* @LastEditors: Caisking 3449750381@qq.com
bool InitUILabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
/*初始化button*/
bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId);
- /*初始化buttonExt*/
+ /*初始化labelbutton*/
+ bool InitLabelButton(UILabelButton *&button, int left, int top, int width, int height, const char *viewId, const char *text, int fontSize);
/*初始化image*/
bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath);
/*生成动画资源数组*/