-/*** \r
+/***\r
* @Author: Caisking 3449750381@qq.com\r
* @Date: 2023-12-12 16:55:29\r
* @LastEditors: Caisking 3449750381@qq.com\r
- * @LastEditTime: 2024-01-15 17:19:52\r
+ * @LastEditTime: 2024-01-16 15:37:18\r
* @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h\r
- * @Description: \r
+ * @Description:\r
* @\r
- * @Copyright (c) 2024 by Caisking , All Rights Reserved. \r
+ * @Copyright (c) 2024 by Caisking , All Rights Reserved.\r
*/\r
/*\r
* Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
#include "components/ui_cross_view.h"\r
#include "dial/include/Digital_clockView.h"\r
#include "blood/include/BloodView.h"\r
-namespace OHOS {\r
-class MainPresenterSample;\r
-class MainViewSample : public View<MainPresenterSample> {\r
-public:\r
- MainViewSample();\r
- virtual ~MainViewSample();\r
- static MainViewSample *GetInstance(void);\r
- void OnStart() override;\r
- void OnSetUpView() override;\r
- void OnTearDownView() override;\r
- void OnStop() override;\r
- UICardPage *InitWatchFacePage(void);\r
- UICardPage *InitHeartRatePage(void);\r
- UICardPage *InitActivityPage(void);\r
- UICardPage *InitCompassPage(void);\r
- UICardPage *InitMusicPlayerPage(void);\r
- UICardPage *InitNewDialPage(void);\r
- UICardPage *InitBloodOxygenPage(void);\r
- \r
- void AnimatorStart(int pageIndex);\r
- void AnimatorStop(void);\r
- uint16_t GetHorCurrentPage() const\r
+#include "traing/include/TraingView.h"\r
+namespace OHOS\r
+{\r
+ class MainPresenterSample;\r
+ class MainViewSample : public View<MainPresenterSample>\r
{\r
- return mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical\r
- }\r
+ public:\r
+ MainViewSample();\r
+ virtual ~MainViewSample();\r
+ static MainViewSample *GetInstance(void);\r
+ void OnStart() override;\r
+ void OnSetUpView() override;\r
+ void OnTearDownView() override;\r
+ void OnStop() override;\r
+ UICardPage *InitWatchFacePage(void);\r
+ UICardPage *InitHeartRatePage(void);\r
+ UICardPage *InitActivityPage(void);\r
+ UICardPage *InitCompassPage(void);\r
+ UICardPage *InitMusicPlayerPage(void);\r
+ UICardPage *InitNewDialPage(void);\r
+ UICardPage *InitBloodOxygenPage(void);\r
+ UICardPage *InitTrainingPage(void);\r
\r
- UIView* GetMainViewGroup(void) const\r
- {\r
- return mainSwipeGroup;\r
- }\r
+ void AnimatorStart(int pageIndex);\r
+ void AnimatorStop(void);\r
+ uint16_t GetHorCurrentPage() const\r
+ {\r
+ return mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical\r
+ }\r
+\r
+ UIView *GetMainViewGroup(void) const\r
+ {\r
+ return mainSwipeGroup;\r
+ }\r
+\r
+ bool IsMainView(void);\r
+ void SetDragFg(bool continFg);\r
+ bool GetDragFg(void);\r
+\r
+ private:\r
+ int16_t maxPage{0};\r
+ bool continuDragFg{false};\r
+ PullUpDownView *dropDownView{nullptr};\r
+ UICardPage *messageView{nullptr};\r
+ UILabel *messageLable{nullptr};\r
+\r
+ /* -------------------------------------------------------------------------- */\r
+ Digital_clockView *mainClockView{nullptr};\r
+ ActivityWeekView *activityWeekView{nullptr};\r
+ PlayersView *playersView{nullptr};\r
+ /* -------------------------------------------------------------------------- */\r
\r
- bool IsMainView(void);\r
- void SetDragFg(bool continFg);\r
- bool GetDragFg(void);\r
- \r
-private:\r
- \r
- int16_t maxPage{0};\r
- bool continuDragFg{false};\r
- PullUpDownView *dropDownView{nullptr};\r
- UICardPage *messageView{nullptr};\r
- UILabel *messageLable{nullptr};\r
- \r
- /* -------------------------------------------------------------------------- */\r
- Digital_clockView *mainClockView{nullptr};\r
- ActivityWeekView *activityWeekView{nullptr};\r
- PlayersView *playersView{nullptr};\r
- /* -------------------------------------------------------------------------- */\r
+ CompassControlView *compassControlView{nullptr};\r
+ HeartRateView *heartRateView{nullptr};\r
+ Digital_clockView *dialView{nullptr};\r
+ BloodView *bloodView{nullptr};\r
+ TraingView *traingView{nullptr};\r
\r
- CompassControlView *compassControlView{nullptr};\r
- HeartRateView *heartRateView{nullptr};\r
- Digital_clockView*dialView{nullptr};\r
- BloodView*bloodView{nullptr};\r
- UICardPage *recordCard[MAX_CARD]{nullptr};\r
- bool pageStatus[MAX_CARD]{false};\r
- UICrossView *mainSwipeGroup{nullptr};\r
- ZoomEffect* callback{nullptr};\r
+ /* -------------------------------------------------------------------------- */\r
+ UICardPage *recordCard[MAX_CARD]{nullptr};\r
+ bool pageStatus[MAX_CARD]{false};\r
+ UICrossView *mainSwipeGroup{nullptr};\r
+ ZoomEffect *callback{nullptr};\r
\r
- bool HorizontalViewInit(void);\r
- void VerticalViewInit(void);\r
- void VertViewLoad(void);\r
- void HorViewLoad(void);\r
- UICardPage *CreatePage(int32_t cardId);\r
-};\r
+ bool HorizontalViewInit(void);\r
+ void VerticalViewInit(void);\r
+ void VertViewLoad(void);\r
+ void HorViewLoad(void);\r
+ UICardPage *CreatePage(int32_t cardId);\r
+ };\r
} // namespace OHOS\r
#endif // MAIN_VIEW_SAMPLE_H\r
#include "ui_resource_image.h"\r
#include <ui_scroll_view.h>\r
#include "components/ui_button.h"\r
-#include "UIInitializer.h"\r
+#include "components/ui_view_group.h"\r
+\r
namespace OHOS\r
{\r
static TraingView *g_pTraingView{nullptr};\r
\r
TraingView::TraingView()\r
{\r
-\r
+ SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
g_pTraingView = this;\r
}\r
\r
\r
TraingView *TraingView::GetInstance()\r
{\r
-\r
return g_pTraingView;\r
}\r
-\r
- void TraingView::Init()\r
+ bool TraingView::AddButton()\r
{\r
- if (container_ == nullptr)\r
+ std::string traing1 = "健走";\r
+ std::string traing2 = "骑行";\r
+ std::string traing3 = "跑步";\r
+ std::string traingmore = "更多";\r
+ /* -------------------------------------------------------------------------- */\r
+ if (Button1 == nullptr)\r
{\r
- container_ = new UIViewGroup();\r
- container_->SetPosition(0, 0, 466, 466);\r
- container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+ Button1 = new UILabelButtonExt();\r
}\r
-\r
- /* Add Label to App\r
- if (label1_ == nullptr)\r
+ Button1->SetPosition(86, 118); // widget's left position and top position\r
+ Button1->Resize(140, 140); // widget's width and height\r
+ Button1->SetViewId(BUTTON1); // Set style\r
+\r
+ const char *labelButton1defaultImgSrc = PNG_TRAING_BUTTONGRONG2_IMAGE;\r
+ char *labelButton1triggeredImgSrc = nullptr;\r
+ Button1->SetImageSrc(labelButton1defaultImgSrc, labelButton1triggeredImgSrc);\r
+ Button1->SetText(traing1.c_str());\r
+ Button1->SetLabelPosition(0, 70);\r
+ Button1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
+ Button1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED);\r
+ Button1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+\r
+ // UIView::OnClickListener *labelButton1Click = static_cast<UIView::OnClickListener *>(new Labelbutton1OnClickListener());\r
+ // Button1->SetOnClickListener(labelButton1Click);\r
+ Add(Button1);\r
+ /* -------------------------------------------------------------------------- */\r
+ if (Button2 == nullptr)\r
{\r
- label1_ = new UILabel();\r
+ Button2 = new UILabelButtonExt();\r
}\r
- label1_->SetPosition(173, 52); // widget's left position and top position\r
- label1_->Resize(200, 60); // widget's width and height\r
- label1_->SetViewId("label1"); // Set style\r
- label1_->SetStyle(STYLE_TEXT_FONT, 30);\r
+ Button2->SetPosition(236, 118); // widget's left position and top position\r
+ Button2->Resize(140, 140); // widget's width and height\r
+ Button2->SetViewId(BUTTON2); // Set style\r
\r
// Set additional property\r
- label1_->SetText("快速训练");\r
- label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label1_->SetRollSpeed(0);\r
- label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
- // Add to rootView\r
- container_->Add(label1_);\r
- label1_->SetVisible(true);\r
- */\r
-\r
- // 创建一个 ComponentConfig 结构体实例\r
- UILabelConfig labelConfig = {173, 52, 200, 60, "label1", "快速训练", DEFAULT_VECTOR_FONT_FILENAME, 30};\r
-\r
- // 使用 UIInitializer 类中的初始化函数来初始化标签\r
- UIInitializer::InitLabel(label1_, labelConfig);\r
-\r
- // Add Button to App\r
- if (button3_ == nullptr)\r
+ const char *labelButton2defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE;\r
+ char *labelButton2triggeredImgSrc = nullptr;\r
+ Button2->SetImageSrc(labelButton2defaultImgSrc, labelButton2triggeredImgSrc);\r
+ Button2->SetText(traing2.c_str());\r
+ Button2->SetLabelPosition(0, 70);\r
+ Button2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
+ Button2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED);\r
+ Button2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+\r
+ // UIView::OnClickListener *labelButton2Click = static_cast<UIView::OnClickListener *>(new Labelbutton1OnClickListener());\r
+ // Button2->SetOnClickListener(labelButton2Click);\r
+ Add(Button2);\r
+ /* -------------------------------------------------------------------------- */\r
+ if (Button3 == nullptr)\r
{\r
- button3_ = new UIButton();\r
+ Button3 = new UILabelButtonExt();\r
}\r
- button3_->SetPosition(236, 268); // widget's left position and top position\r
- button3_->Resize(140, 140); // widget's width and height\r
- button3_->SetViewId(BUTTONMORE); // Set style\r
- button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
- button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-\r
+ Button3->SetPosition(86, 268); // widget's left position and top position\r
+ Button3->Resize(140, 140); // widget's width and height\r
+ Button3->SetViewId(BUTTON3); // Set style\r
+ Button3->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
+ Button3->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
// Set additional property\r
-#ifdef _WIN32\r
- char *button3defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/More.bin";\r
-#else\r
- const char *button3defaultImgSrc = PNG_TRAING_BOUTTONMORE_IMAGE;\r
-#endif\r
+ const char *button3defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE;\r
char *button3triggeredImgSrc = nullptr;\r
- button3_->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc);\r
- button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);\r
- button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
- button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
- // Add the CallBack about events\r
- UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
- button3_->SetOnClickListener(button3Click);\r
- // Add to rootView\r
- container_->Add(button3_);\r
- button3_->SetVisible(true);\r
+ Button3->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc);\r
+ Button3->SetText(traing3.c_str());\r
+ Button3->SetLabelPosition(0, 70);\r
+ Button3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
+ Button3->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED);\r
+ Button3->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+\r
+ // UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+ // Button3->SetOnClickListener(button1Click);\r
+ Add(Button3);\r
+ /* -------------------------------------------------------------------------- */\r
\r
// Add Button to App\r
- if (button4_ == nullptr)\r
+ if (ButtonMore == nullptr)\r
{\r
- button4_ = new UIButton();\r
+ ButtonMore = new UILabelButtonExt();\r
}\r
- button4_->SetPosition(86, 118); // widget's left position and top position\r
- button4_->Resize(140, 140); // widget's width and height\r
- button4_->SetViewId(BUTTON2); // Set style\r
- button4_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
- button4_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+ ButtonMore->SetPosition(236, 268); // widget's left position and top position\r
+ ButtonMore->Resize(140, 140); // widget's width and height\r
+ ButtonMore->SetViewId(BUTTONMORE); // Set style\r
+ ButtonMore->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
+ ButtonMore->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
\r
// Set additional property\r
-#ifdef _WIN32\r
- char *button4defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Buttonground2.bin";\r
-#else\r
- const char *button4defaultImgSrc = PNG_TRAING_BUTTONGRONG2_IMAGE;\r
-#endif\r
+ const char *button4defaultImgSrc = PNG_TRAING_BOUTTONMORE_IMAGE;\r
char *button4triggeredImgSrc = nullptr;\r
- button4_->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc);\r
- button4_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);\r
- button4_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
- button4_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
- // Add the CallBack about events\r
- UIView::OnClickListener *button4Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
- button4_->SetOnClickListener(button4Click);\r
- // Add to rootView\r
- container_->Add(button4_);\r
- button4_->SetVisible(true);\r
-\r
- // Add Button to App\r
- if (button1_ == nullptr)\r
- {\r
- button1_ = new UIButton();\r
- }\r
- button1_->SetPosition(86, 268); // widget's left position and top position\r
- button1_->Resize(140, 140); // widget's width and height\r
- button1_->SetViewId(BUTTON3); // Set style\r
- button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
- button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-\r
- // Set additional property\r
-#ifdef _WIN32\r
- char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Bouttonground.bin";\r
-#else\r
- const char *button1defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE;\r
-#endif\r
- char *button1triggeredImgSrc = nullptr;\r
- button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);\r
- button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);\r
- button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
- button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
- // Add the CallBack about events\r
- UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
- button1_->SetOnClickListener(button1Click);\r
- // Add to rootView\r
- container_->Add(button1_);\r
- button1_->SetVisible(true);\r
-\r
- // Add Button to App\r
- if (button2_ == nullptr)\r
+ ButtonMore->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc);\r
+ //ButtonMore->SetText(traingmore.c_str());\r
+ ButtonMore->SetLabelPosition(0, 70);\r
+ ButtonMore->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
+ ButtonMore->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED);\r
+ ButtonMore->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+\r
+ // UIView::OnClickListener *button4Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+ // ButtonMore->SetOnClickListener(button4Click);\r
+ Add(ButtonMore);\r
+\r
+ return true;\r
+ }\r
+ bool TraingView::InitLable()\r
+ {\r
+ // 检查标签指针是否为空\r
+ if (titleLabel == nullptr)\r
{\r
- button2_ = new UIButton();\r
+ titleLabel = new UILabel();\r
}\r
- button2_->SetPosition(236, 118); // widget's left position and top position\r
- button2_->Resize(140, 140); // widget's width and height\r
- button2_->SetViewId(BUTTON1); // Set style\r
- button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
- button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-\r
- // Set additional property\r
-#ifdef _WIN32\r
- char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Bouttonground.bin";\r
-#else\r
- const char *button2defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE;\r
-#endif\r
- char *button2triggeredImgSrc = nullptr;\r
- button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);\r
- button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);\r
- button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
- button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
- // Add the CallBack about events\r
- UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
- button2_->SetOnClickListener(button2Click);\r
- // Add to rootView\r
- container_->Add(button2_);\r
- button2_->SetVisible(true);\r
-\r
+ // 设置标签的位置和大小\r
+ titleLabel->SetPosition(173, 52);\r
+ titleLabel->Resize(200, 60);\r
+ // 设置标签的视图 ID\r
+ titleLabel->SetViewId("titleLabel");\r
+ // 设置标签的样式\r
+ titleLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
+ titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+ // 设置标签的文本和其他属性\r
+ titleLabel->SetText("快速训练");\r
+ titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+ titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ titleLabel->SetRollSpeed(0);\r
+ Add(titleLabel);\r
+\r
+ return true;\r
+ }\r
+ bool TraingView::InitImage()\r
+ {\r
// Add ImageView to App\r
- if (image1_ == nullptr)\r
+ if (image1 == nullptr)\r
{\r
- image1_ = new UIImageView();\r
+ image1 = new UIImageView();\r
}\r
- image1_->SetPosition(276, 148); // widget's left position and top position\r
- image1_->Resize(100, 100); // widget's width and height\r
- image1_->SetViewId("image2"); // Set style\r
-\r
+ image1->SetPosition(126, 298); // widget's left position and top position\r
+ image1->Resize(100, 100); // widget's width and height\r
+ image1->SetViewId("image3"); // Set style\r
// Set additional property\r
-#ifdef _WIN32\r
- char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/riding-big2.bin";\r
-#else\r
- const char *image1imagesPath = PNG_TRAING_RIDINGBIG_IMAGE;\r
-#endif\r
- image1_->SetSrc(image1imagesPath);\r
-\r
+ const char *image1imagesPath = PNG_TRAING_WALKINGBIG_IMAGE;\r
+ image1->SetSrc(image1imagesPath);\r
// Add to rootView\r
- container_->Add(image1_);\r
- image1_->SetVisible(true);\r
+ Add(image1);\r
\r
- // Add Label to App\r
- if (label2_ == nullptr)\r
+ /* -------------------------------------------------------------------------- */\r
+ // Add ImageView to App\r
+ if (image2 == nullptr)\r
{\r
- label2_ = new UILabel();\r
+ image2 = new UIImageView();\r
}\r
- label2_->SetPosition(286, 210); // widget's left position and top position\r
- label2_->Resize(200, 60); // widget's width and height\r
- label2_->SetViewId("label2"); // Set style\r
- label2_->SetStyle(STYLE_TEXT_FONT, 20);\r
+ image2->SetPosition(276, 148); // widget's left position and top position\r
+ image2->Resize(100, 100); // widget's width and height\r
+ image2->SetViewId("image2"); // Set style\r
\r
// Set additional property\r
- label2_->SetText("骑行");\r
- label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label2_->SetRollSpeed(0);\r
- label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
+ const char *image2imagesPath = PNG_TRAING_RIDINGBIG_IMAGE;\r
+ image2->SetSrc(image2imagesPath);\r
\r
// Add to rootView\r
- container_->Add(label2_);\r
- label2_->SetVisible(true);\r
+ Add(image2);\r
\r
+ /* -------------------------------------------------------------------------- */\r
// Add ImageView to App\r
- if (image3_ == nullptr)\r
+ if (image3 == nullptr)\r
{\r
- image3_ = new UIImageView();\r
+ image3 = new UIImageView();\r
}\r
- image3_->SetPosition(126, 298); // widget's left position and top position\r
- image3_->Resize(100, 100); // widget's width and height\r
- image3_->SetViewId("image3"); // Set style\r
+ image3->SetPosition(126, 148); // widget's left position and top position\r
+ image3->Resize(100, 100); // widget's width and height\r
+ image3->SetViewId("image1"); // Set style\r
\r
// Set additional property\r
-#ifdef _WIN32\r
- char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/running-big.bin";\r
-#else\r
const char *image3imagesPath = PNG_TRAING_RUNNINGBIG_IMAGE;\r
-#endif\r
- image3_->SetSrc(image3imagesPath);\r
+ image3->SetSrc(image3imagesPath);\r
\r
// Add to rootView\r
- container_->Add(image3_);\r
- image3_->SetVisible(true);\r
-\r
- // Add Label to App\r
- if (label3_ == nullptr)\r
- {\r
- label3_ = new UILabel();\r
- }\r
- label3_->SetPosition(135, 210); // widget's left position and top position\r
- label3_->Resize(200, 60); // widget's width and height\r
- label3_->SetViewId("label3"); // Set style\r
- label3_->SetStyle(STYLE_TEXT_FONT, 20);\r
-\r
- // Set additional property\r
- label3_->SetText("健走");\r
- label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label3_->SetRollSpeed(0);\r
- label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
+ Add(image3);\r
\r
- // Add to rootView\r
- container_->Add(label3_);\r
- label3_->SetVisible(true);\r
+ return true;\r
+ }\r
\r
- // Add ImageView to App\r
- if (image5_ == nullptr)\r
+ bool TraingView::InitView()\r
+ {\r
+ printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__);\r
+ if (!InitLable())\r
{\r
- image5_ = new UIImageView();\r
- }\r
- image5_->SetPosition(126, 148); // widget's left position and top position\r
- image5_->Resize(100, 100); // widget's width and height\r
- image5_->SetViewId("image1"); // Set style\r
-\r
- // Set additional property\r
-#ifdef _WIN32\r
- char *image5imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/walking-big.bin";\r
-#else\r
- const char *image5imagesPath = PNG_TRAING_WALKINGBIG_IMAGE;\r
-#endif\r
- image5_->SetSrc(image5imagesPath);\r
-\r
- // Add to rootView\r
- container_->Add(image5_);\r
- image5_->SetVisible(true);\r
-\r
- // Add Label to App\r
- if (label4_ == nullptr)\r
+ printf("InitLable error!\n");\r
+ };\r
+ if (!AddButton())\r
{\r
- label4_ = new UILabel();\r
- }\r
- label4_->SetPosition(131, 365); // widget's left position and top position\r
- label4_->Resize(200, 60); // widget's width and height\r
- label4_->SetViewId("label4"); // Set style\r
- label4_->SetStyle(STYLE_TEXT_FONT, 20);\r
-\r
- // Set additional property\r
- label4_->SetText("跑步");\r
- label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label4_->SetRollSpeed(0);\r
- label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
-\r
- // Add to rootView\r
- container_->Add(label4_);\r
- label4_->SetVisible(true);\r
+ printf("AddButton error!\n");\r
+ };\r
+ if (!InitImage())\r
+ {\r
+ printf("InitImage error!\n");\r
+ };\r
+ SetCoverable(true);\r
+ return true;\r
}\r
\r
void TraingView::DeInit()\r
{\r
- if (label1_ != nullptr)\r
- {\r
- delete label1_;\r
- label1_ = nullptr;\r
- }\r
- if (button3_ != nullptr)\r
- {\r
- delete button3_;\r
- button3_ = nullptr;\r
- }\r
- if (button4_ != nullptr)\r
+ if (titleLabel != nullptr)\r
{\r
- delete button4_;\r
- button4_ = nullptr;\r
+ delete titleLabel;\r
+ titleLabel = nullptr;\r
}\r
- if (button1_ != nullptr)\r
+ if (ButtonMore != nullptr)\r
{\r
- delete button1_;\r
- button1_ = nullptr;\r
+ delete ButtonMore;\r
+ ButtonMore = nullptr;\r
}\r
- if (button2_ != nullptr)\r
+ if (Button1 != nullptr)\r
{\r
- delete button2_;\r
- button2_ = nullptr;\r
+ delete Button1;\r
+ Button1 = nullptr;\r
}\r
- if (image1_ != nullptr)\r
+ if (Button3 != nullptr)\r
{\r
- delete image1_;\r
- image1_ = nullptr;\r
+ delete Button3;\r
+ Button3 = nullptr;\r
}\r
- if (label2_ != nullptr)\r
+ if (Button2 != nullptr)\r
{\r
- delete label2_;\r
- label2_ = nullptr;\r
+ delete Button2;\r
+ Button2 = nullptr;\r
}\r
- if (image3_ != nullptr)\r
+ if (image2 != nullptr)\r
{\r
- delete image3_;\r
- image3_ = nullptr;\r
+ delete image2;\r
+ image2 = nullptr;\r
}\r
- if (label3_ != nullptr)\r
+ if (image1 != nullptr)\r
{\r
- delete label3_;\r
- label3_ = nullptr;\r
+ delete image1;\r
+ image1 = nullptr;\r
}\r
- if (image5_ != nullptr)\r
+ if (image3 != nullptr)\r
{\r
- delete image5_;\r
- image5_ = nullptr;\r
- }\r
- if (label4_ != nullptr)\r
- {\r
- delete label4_;\r
- label4_ = nullptr;\r
- }\r
- if (container_ != nullptr)\r
- {\r
- container_->RemoveAll();\r
- delete container_;\r
- container_ = nullptr;\r
+ delete image3;\r
+ image3 = nullptr;\r
}\r
}\r
-\r
- UIView *TraingView::GetView()\r
+ void TraingView::PreLoad(void)\r
{\r
- Init();\r
- return container_;\r
- }\r
-\r
- void TraingView::OnStart()\r
- {\r
- container_ = new UIViewGroup();\r
- if (container_ == nullptr)\r
- {\r
- return;\r
- }\r
- container_->SetPosition(0, 0);\r
- container_->SetWidth(Screen::GetInstance().GetWidth());\r
- container_->SetHeight(Screen::GetInstance().GetHeight());\r
-\r
- // 创建 draglistener 实例并设置为拖动监听器\r
- UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingPresenter::GetInstance());\r
- if (draglistener == nullptr)\r
+ printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__);\r
+ if (InitView())\r
{\r
- return;\r
+ viewiInitStatus = true;\r
}\r
- container_->SetOnDragListener(draglistener);\r
-\r
- container_->SetTouchable(true);\r
- container_->SetDraggable(true);\r
-\r
- GetView();\r
- RootView::GetInstance()->Add(container_);\r
- }\r
-\r
- void TraingView::OnSetUpView()\r
- {\r
-\r
- View<TraingPresenter>::OnSetUpView();\r
- Draw();\r
- }\r
-\r
- void TraingView::OnTearDownView()\r
- {\r
-\r
- View<TraingPresenter>::OnTearDownView();\r
- return;\r
}\r
\r
- void TraingView::OnStop()\r
+ void TraingView::UnLoad(void)\r
{\r
- View<TraingPresenter>::OnStop();\r
- RootView::GetInstance()->RemoveAll();\r
- return;\r
}\r
}\r