From 20c540803ecb54cd6ce2cefc2703158734788667 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 24 Apr 2026 17:41:09 +0800 Subject: [PATCH] =?utf8?q?applist1201patch=E5=BC=A7=E5=BD=A2=E5=88=97?= =?utf8?q?=E8=A1=A8=E6=A0=B7=E5=BC=8F=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/applist/include/AppItemView.h | 25 ++ .../nativeui/applist/include/ApplistAdapter.h | 4 +- .../nativeui/applist/include/ApplistModel.h | 24 +- .../include/ArcScaleListDesktopFragment.h | 82 +++++ .../nativeui/applist/src/ApplistAdapter.cpp | 8 +- .../nativeui/applist/src/ApplistModel.cpp | 45 ++- .../nativeui/applist/src/ApplistView.cpp | 4 + .../src/ArcScaleListDesktopFragment.cpp | 307 ++++++++++++++++++ 8 files changed, 482 insertions(+), 17 deletions(-) create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ArcScaleListDesktopFragment.h create mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ArcScaleListDesktopFragment.cpp diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/AppItemView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/AppItemView.h index 836127a00..0e352e279 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/AppItemView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/AppItemView.h @@ -13,8 +13,11 @@ #include "components/ui_image_view.h" #include "applist/include/ApplistModel.h" #include "UiConfig.h" +#include "components/ui_transform_group.h" +#include "components/ui_transform_list.h" namespace OHOS { +//直线列表ItemView class AppItemView : public UIViewGroup { public: explicit AppItemView(); @@ -33,6 +36,28 @@ private: UILabelExt label_; AppItem itemInfo_; }; +//弧形列表ItemView +class ArcScaleListItemView : public UITransformGroup +{ +public: + ArcScaleListItemView(); + ~ArcScaleListItemView(); + + void SetItemInfo(const AppItem &itemInfo); + AppViewId GetViewId(); + const char * GetAppUid(); + void SetUpChild(); + UILabelExt *GetLabel(void); + UIImageView *GetImage(void); + + ArcScaleListItemView(const ArcScaleListItemView &) = delete; + ArcScaleListItemView &operator=(const ArcScaleListItemView &) = delete; + +private: + UIImageView * image_{nullptr}; + UILabelExt * label_{nullptr}; + AppItem itemInfo_ = { VIEW_INVALID, nullptr, nullptr, nullptr, nullptr, nullptr, 0 }; +}; } #endif diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ApplistAdapter.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ApplistAdapter.h index bd9c37d1e..af97d869a 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ApplistAdapter.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ApplistAdapter.h @@ -51,7 +51,7 @@ private: std::list listData_; UIView::OnClickListener *itemClickListener_; }; -#if 0 + /* -------------------------------------------------------------------------- */ /* ---------------------------------- 弧形列表 ---------------------------------- */ class ArcScaleListItemAdapter : public AbstractAdapter @@ -63,6 +63,7 @@ public: UIView* GetView(UIView* inView, int16_t index) override; uint16_t GetCount() override; void AddListItem(const AppItem &item); + void ClearItem(void); void SetItemClickListener(UIView::OnClickListener *itemClickListener) { @@ -73,6 +74,7 @@ private: List nodeList_; UIView::OnClickListener * itemClickListener_; }; +#if 0 /* -------------------------------------------------------------------------- */ /* ----------------------------------- 拨号盘 ---------------------------------- */ class CircleListAdapter diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ApplistModel.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ApplistModel.h index 17c89969b..2459fc40b 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ApplistModel.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ApplistModel.h @@ -54,17 +54,24 @@ public: const AppItem *GetApplistItems() const; uint8 GetAppListNum() const; void ResolvingJSAppItems(void); - void SetStartIndex(uint16_t index); - uint16_t GetStartIndex(void); void SetLastOffset(int16_t x, int16_t y); void GetLastOffset(int16_t& x, int16_t& y); - void SetHeadItemY(int index); - int GetHeadItemY(void); void ApplistUpdate(void); void SetPresenter(ApplistPresenter *p); void SetInitFlag(bool flag); void CleanupApplistStrings(uint8_t nativeAppNumTotal); + /* ---------------------------------- list列表 ---------------------------------- */ + void SetHeadItemY(int index); + int GetHeadItemY(void); + void SetStartIndex(uint16_t index); + uint16_t GetStartIndex(void); + /* ---------------------------------- 弧形列表 ---------------------------------- */ + void SetArcListStartIndex(uint16_t index); + uint16_t GetArcListStartIndex(void); + void SetArcListHeadItemY(int y); + int GetArcListHeadItemY(void); + private: ApplistModel(); ApplistModel(const ApplistModel &); @@ -77,11 +84,16 @@ private: int32 bundleLen = 0; uint8 appLen = 0; uint8 nativeAppNumTotal = 0; - uint16_t startIndex = 0; - int headItemY = 0; int16_t lastOffsetX = 0; int16_t lastOffsetY = 0; bool initFlag{false}; + + /* ---------------------------------- 直线列表 ---------------------------------- */ + uint16_t startIndex = 0; + int headItemY = 0; + /* ---------------------------------- 弧形列表 ---------------------------------- */ + uint16_t arcListstartIndex = 0; // 圆弧列表起始位置 + int arcListheadItemY = 0; // 圆弧列表头部位置 }; } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ArcScaleListDesktopFragment.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ArcScaleListDesktopFragment.h new file mode 100644 index 000000000..a0a8f8fae --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/ArcScaleListDesktopFragment.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. + * Description: ArcScaleListDesktopFragment.h + * Author: + * Create: 2025-07-04 + */ + +#ifndef ARC_SCALE_LIST_DESKTOP_FRAGMENT_H +#define ARC_SCALE_LIST_DESKTOP_FRAGMENT_H + +#include "UIDesktopFragment.h" +#include "ApplistAdapter.h" +#include "ChangeSliceListener.h" +#include "components/ui_list.h" +#include "drag_event.h" +#include "UiConfig.h" + + +namespace OHOS { +class ArcScaleListItemView; +class ArcScaleListDesktopFragment : public UIDesktopFragment { +public: + bool OnClick(UIView &view, const ClickEvent &event) override; + void AddAppItemToList(const AppItem &item) override; + void ClearAppItemToList() override; + void RefreshAppList() override; + +protected: + void OnCreateView(void* data) override; + void OnDestroyView() override; + +private: + UIViewGroup * ArcScaleListGroup_{nullptr}; + UITransformList * ArcScaleList_{nullptr}; + ArcScaleListItemAdapter * ArcScaleListAdapter_{nullptr}; + UIView::OnDragListener * ArcScaleListDragListener_{nullptr}; +}; + +class AppListOnDragListener : public UIView::OnDragListener { +public: + AppListOnDragListener() + { + continueDrag_ = false; + } + ~AppListOnDragListener() override {} + bool OnDragStart(UIView& view, const DragEvent& event) override + { + UNUSED(view); + UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Applist Ondragstart!!"); + continueDrag_ = true; + return false; + } + + bool OnDrag(UIView& view, const DragEvent& event) override + { + UNUSED(view); + if (!continueDrag_) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppList : Can not continue drag!!"); + return false; + } + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && + (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Applist Ondrag!!"); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN, TransitionType::TRANSITION_ZOOM); + } + + return false; + } + + bool OnDragEnd(UIView& view, const DragEvent& event) override + { + UNUSED(view); + UNUSED(event); + return false; + } +private: + bool continueDrag_{false}; +}; +} + +#endif // LIST_DESKTOP_FRAGMENT_H diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistAdapter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistAdapter.cpp index d90b1ba09..c1054d728 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistAdapter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistAdapter.cpp @@ -56,7 +56,7 @@ void ApplistAdapter::AddListItem(const AppItem &item) { listData_.push_back(item); } -#if 0 + /* -------------------------------------------------------------------------- */ /* ---------------------------------- 弧形列表 ---------------------------------- */ ArcScaleListItemAdapter::ArcScaleListItemAdapter(){} @@ -76,6 +76,11 @@ void ArcScaleListItemAdapter::AddListItem(const AppItem &item) nodeList_.PushBack(item); } +void ArcScaleListItemAdapter::ClearItem(void) +{ + nodeList_.Clear(); +} + UIView * ArcScaleListItemAdapter::GetView(UIView* inView, int16_t index) { if (nodeList_.IsEmpty() || index > nodeList_.Size() - 1 || index < 0) { @@ -108,6 +113,7 @@ UIView * ArcScaleListItemAdapter::GetView(UIView* inView, int16_t index) } return item; } +#if 0 /* -------------------------------------------------------------------------- */ /* ----------------------------------- 拨号盘 ---------------------------------- */ #define NATIVE_APP_NUM_MAX 50 diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistModel.cpp index 5f851f837..bd8d29e1c 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistModel.cpp @@ -139,15 +139,7 @@ namespace OHOS { { return appLen; } - void ApplistModel::SetStartIndex(uint16_t index) - { - startIndex = index; - } - - uint16_t ApplistModel::GetStartIndex(void) - { - return startIndex; - } + void ApplistModel::SetLastOffset(int16_t x, int16_t y) { @@ -161,6 +153,17 @@ namespace OHOS { y = lastOffsetY; } + /* ---------------------------------- 直线列表 ---------------------------------- */ + void ApplistModel::SetStartIndex(uint16_t index) + { + startIndex = index; + } + + uint16_t ApplistModel::GetStartIndex(void) + { + return startIndex; + } + void ApplistModel::SetHeadItemY(int y) { headItemY = y; @@ -170,6 +173,30 @@ namespace OHOS { { return headItemY; } + /* ---------------------------------- 弧形列表 ---------------------------------- */ + //设置弧形列表的起始位置 + void ApplistModel::SetArcListStartIndex(uint16_t index) + { + arcListstartIndex = index; + } + + //获取弧形列表的起始位置 + uint16_t ApplistModel::GetArcListStartIndex(void) + { + return arcListstartIndex; + } + + //设置弧形列表的头部位置 + void ApplistModel::SetArcListHeadItemY(int y) + { + arcListheadItemY = y; + } + + //获取弧形列表的头部位置 + int ApplistModel::GetArcListHeadItemY(void) + { + return arcListheadItemY; + } void ApplistModel::ApplistUpdate(void) { diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistView.cpp index 5d34ecabf..7bac38779 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ApplistView.cpp @@ -9,14 +9,17 @@ #include "applist/include/ApplistPresenter.h" #include "applist/include/DesktopFactory.h" #include "themestyle/include/ThemeStyleModel.h" +#include "wearable_log.h" namespace OHOS { void ApplistView::OnStart() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStart"); if (desktopFragment_ != nullptr) { OnStop(); } ThemeStyle style = ThemeStyleModel::GetInstance().GetAppListDisplayStyle(); //根据显示样式界面设置的返回当前applit样式 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStart,style = %d", style); desktopFragment_ = DesktopFactory::GetInstance().CreateDesktopStyle(style); desktopFragment_->SetPosition(0, 0, GetRootContainer()->GetWidth(), GetRootContainer()->GetHeight()); desktopFragment_->CreateView(); @@ -25,6 +28,7 @@ void ApplistView::OnStart() void ApplistView::OnStop() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStop"); if (desktopFragment_ == nullptr) { return; } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ArcScaleListDesktopFragment.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ArcScaleListDesktopFragment.cpp new file mode 100644 index 000000000..02d9402d2 --- /dev/null +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ArcScaleListDesktopFragment.cpp @@ -0,0 +1,307 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. + * Description: ArcScaleListDesktopFragment.cpp + * Author: + * Create: 2025-07-04 + */ + +#include "applist/include/ArcScaleListDesktopFragment.h" +#include "applist/include/DesktopFactory.h" +#include "applist/include/ApplistModel.h" +#include "wearable_log.h" + +namespace OHOS { +REGIST_DESKTOP_STYLE(ARC_SCALE_LIST_STYLE, ArcScaleListDesktopFragment); + +/* ---------------------------------- 弧形列表 ---------------------------------- */ +#define ARC_SCALE_LIST_SCALE_FACTOR (440) +#define ARC_SCALE_LIST_X (13) +#define ARC_SCALE_LIST_Y (0) +#define ARC_SCALE_LIST_WIDTH (HORIZONTAL_RESOLUTION - ARC_SCALE_LIST_X) +#define ARC_SCALE_LIST_HEIGHT (VERTICAL_RESOLUTION) + +/** + * @brief 根据位置变换列表项的基础函数 + * + * 这个函数根据列表项在垂直列表中的位置来调整其缩放比例。它使用一个缓动函数来计算缩放比例,使得列表项在接近列表中心时逐渐放大,远离列表中心时逐渐缩小。 + * + * @param list 指向 UITransformList 类型的指针,代表要操作的列表。 + * @param item 指向 UIView 类型的指针,代表要变换的列表项。 + * @return 如果变换成功,返回 true;否则返回 false。 + */ +static bool TransformItemBaseOnPosition(UITransformList* list, UIView* item) +{ + // 检查传入的参数是否有效 + if (list == nullptr || item == nullptr) { + return false; + } + // 检查列表项的类型是否为 UI_TRANSFORM_GROUP + if (item->GetViewType() != UI_TRANSFORM_GROUP) { + return false; + } + // 将列表项转换为 UITransformGroup 类型 + UITransformGroup* group = dynamic_cast(item); + // 如果转换失败,返回 false + if (group == nullptr) { + return false; + } + // 获取列表项的宽度和高度 + int16_t w = group->GetWidth(); + int16_t h = group->GetHeight(); + // 如果列表的方向是垂直的 + if (list->GetDirection() == UIList::VERTICAL) { + // 计算列表的垂直中心位置 + int16_t midY = list->GetY() + (list->GetHeight() >> 1); + // 获取列表项的垂直位置 + int16_t y = group->GetY(); + // 计算列表项到列表中心的垂直偏移量 + int offset = (y + (h >> 1) - midY); + // 使用 SineEaseIn 缓动函数计算缩放比例 + int temp = EasingEquation::SineEaseIn(0, ARC_SCALE_LIST_SCALE_FACTOR, abs(offset), ARC_SCALE_LIST_SCALE_FACTOR); + // 计算最终的缩放比例 + float scale = 1.0 - (static_cast(temp) / ARC_SCALE_LIST_SCALE_FACTOR); + // 应用缩放比例到列表项 + group->Scale(Vector2(scale, scale), Vector2(w * 0.75, h >> 1)); + // 如果列表项在列表的中心区域,返回 true + if ((y <= midY) && (y + group->GetHeight() >= midY)) { + return true; + } + } + // 如果列表项不在列表的中心区域,返回 false + return false; +} + + +void ArcScaleListDesktopFragment::OnCreateView(void* data) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ArcScaleListDesktopFragment::OnCreateView"); + if(nullptr == ArcScaleListAdapter_) + { + ArcScaleListAdapter_ = new ArcScaleListItemAdapter(); + if(nullptr == ArcScaleListAdapter_) + { + return; + } + } + ArcScaleListAdapter_->SetItemClickListener(this); + /* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + if (nullptr == ArcScaleList_) + { + ArcScaleList_ = new UITransformList(UIList::VERTICAL); + if (nullptr == ArcScaleList_) + { + return; + } + } + ArcScaleList_->SetPosition(ARC_SCALE_LIST_X, ARC_SCALE_LIST_Y, ARC_SCALE_LIST_WIDTH, ARC_SCALE_LIST_HEIGHT); + ArcScaleList_->SetItemTransformFunc(&TransformItemBaseOnPosition); + ArcScaleList_->SetDraggable(true); + ArcScaleList_->SetThrowDrag(true); + ArcScaleList_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + // 让首尾元素也能滑动到屏幕中线处:在顶部/底部各预留半屏的空白区 + ArcScaleList_->SetScrollBlankSize(VERTICAL_RESOLUTION / 2, UIAbstractScroll::Direction::TOP); + ArcScaleList_->SetScrollBlankSize(VERTICAL_RESOLUTION / 2, UIAbstractScroll::Direction::BOTTOM); + ArcScaleList_->SetMaxScrollDistance(1000); + ArcScaleList_->SetYScrollBarVisible(true); + ArcScaleList_->SetReboundSize(5); + ArcScaleList_->EnableAutoAlign(true); + ArcScaleList_->SetItemSpace(20); + ArcScaleList_->SetSelectPosition(ARC_SCALE_LIST_HEIGHT / 2); + ArcScaleList_->SetRotateFactor(1.0); + ArcScaleList_->RequestFocus(); + ArcScaleList_->RefreshList(); + /* -------------------------------------------------------------------------- */ + if(nullptr == ArcScaleListDragListener_) + { + ArcScaleListDragListener_ = new AppListOnDragListener(); + if (nullptr == ArcScaleListDragListener_) + return; + } + ArcScaleList_->SetOnDragListener(ArcScaleListDragListener_); + /* -------------------------------------------------------------------------- */ + fragmentView_.Add(ArcScaleList_); +} + + +void ArcScaleListDesktopFragment::OnDestroyView() +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ArcScaleListDesktopFragment::OnDestroyView"); + int16_t arclistHeadY = ArcScaleList_->GetChildrenHead()->GetY(); + int16_t arclistHeadIndex = ArcScaleList_->GetChildrenHead()->GetViewIndex(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[%d],listHeadY = %d,listHeadIndex = %d", __LINE__,arclistHeadY,arclistHeadIndex); + ApplistModel *model = &ApplistModel::GetInstance(); + model->SetArcListHeadItemY(arclistHeadY); //设置头部Y坐标 + model->SetArcListStartIndex(arclistHeadIndex); //设置头部Index + + ClearAppItemToList(); + + if (ArcScaleList_ != nullptr) { + delete ArcScaleList_; + ArcScaleList_ = nullptr; + } + if (ArcScaleListAdapter_ != nullptr) { + delete ArcScaleListAdapter_; + ArcScaleListAdapter_ = nullptr; + } + if (ArcScaleListDragListener_ != nullptr) { + delete ArcScaleListDragListener_; + ArcScaleListDragListener_ = nullptr; + } +} + +bool ArcScaleListDesktopFragment::OnClick(UIView &view, const ClickEvent &event) +{ + UNUSED(event); + AppItemView *itemView = dynamic_cast(&view); + if (itemView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "itemView is nullptr"); + return false; + } + AppViewId viewId = itemView->GetViewId(); + char *uid = (char *)itemView->GetAppUid(); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ArcScaleListDesktopFragment::OnClick viewid = %d", viewId); + return SwitchView(viewId, uid, TransitionType::TRANSITION_INVALID, ARC_SCALE_LIST_STYLE); +} + + + +void ArcScaleListDesktopFragment::AddAppItemToList(const AppItem &item) +{ + ArcScaleListAdapter_->AddListItem(item); +} + +void ArcScaleListDesktopFragment::ClearAppItemToList() +{ + ArcScaleListAdapter_->ClearItem(); +} + +void ArcScaleListDesktopFragment::RefreshAppList(void) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ArcScaleListDesktopFragment::RefreshAppList"); + if (ArcScaleList_ == nullptr || ArcScaleListAdapter_ == nullptr) { + return; + } + uint16_t startIndex = 0; + int16_t headY = 0; + ApplistModel *model = &ApplistModel::GetInstance(); + if (model->GetArcListStartIndex() >= model->GetAppListNum()) { + startIndex = model->GetAppListNum() - 1; + headY = VERTICAL_RESOLUTION / 2; + } else { + uint16_t presliceId = NativeAbility::GetInstance().GetPreSliceId(); + if (presliceId == VIEW_MAIN) //如果是从主页进入的,那么startIndex = 0,headY = 0 + { + startIndex = 0; + headY = 53; + } else { //如果是从其他页面进入的,那么startIndex = model->GetArcListStartIndex(),headY = model->GetArcListHeadItemY() + startIndex = model->GetArcListStartIndex(); + headY = model->GetArcListHeadItemY(); + } + if (headY == 0) { + headY = VERTICAL_RESOLUTION / 2; + // headY = -42; + } + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[%d],startIndex = %d,headY = %d", __LINE__,startIndex,headY); + ArcScaleList_->SetAdapter(ArcScaleListAdapter_); + ArcScaleList_->SetStartIndex(startIndex);//设置起始索引。 + ArcScaleList_->ScrollBy(headY);//滚动到指定的 headY 位置。 + ArcScaleList_->RefreshList(); +} + +/* ---------------------------------- 弧形列表 ---------------------------------- */ +#define ARC_SCALE_LIST_ITEM_WIDTH (440) +#define ARC_SCALE_LIST_ITEM_HEIGHT (120) + +#define ARC_SCALE_LIST_IMAGE_X (20) +#define ARC_SCALE_LIST_IMAGE_WIDTH (ARC_SCALE_LIST_ITEM_HEIGHT - 10) +#define ARC_SCALE_LIST_IMAGE_HEIGHT (ARC_SCALE_LIST_ITEM_HEIGHT - 10) +#define ARC_SCALE_LIST_IMAGE_Y ((ARC_SCALE_LIST_ITEM_HEIGHT - ARC_SCALE_LIST_IMAGE_HEIGHT) / 2) + +#define ARC_SCALE_LIST_TEXT_X (ARC_SCALE_LIST_IMAGE_X + ARC_SCALE_LIST_IMAGE_WIDTH + 20) +#define ARC_SCALE_LIST_TEXT_WIDTH (ARC_SCALE_LIST_ITEM_WIDTH - ARC_SCALE_LIST_TEXT_X) +#define ARC_SCALE_LIST_TEXT_HEIGHT (44) +#define ARC_SCALE_LIST_TEXT_Y ((ARC_SCALE_LIST_ITEM_HEIGHT - ARC_SCALE_LIST_TEXT_HEIGHT) / 2) + +ArcScaleListItemView::ArcScaleListItemView() +{ + Resize(ARC_SCALE_LIST_ITEM_WIDTH, ARC_SCALE_LIST_ITEM_HEIGHT); + SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SetStyle(STYLE_BORDER_RADIUS, 100); // 胶囊形状 + SetTouchable(true); + SetUpChild(); +} + +ArcScaleListItemView::~ArcScaleListItemView() +{ + RemoveAll(); + if (image_ != nullptr) { + delete image_; + image_ = nullptr; + } + if (label_ != nullptr) { + delete label_; + label_ = nullptr; + } +} + +void ArcScaleListItemView::SetItemInfo(const AppItem &itemInfo) +{ + itemInfo_ = itemInfo; + image_->SetSrc(itemInfo.iconSmall); + if(VIEW_EXTERN_APP != itemInfo.id) { + label_->SetTextId(itemInfo.labelId); + } else { + label_->SetText(itemInfo.label); + } +} + +void ArcScaleListItemView::SetUpChild() +{ + if (image_ == nullptr) { + image_ = new UIImageView(); + if (image_ == nullptr) { + return ; + } + } + image_->SetPosition(ARC_SCALE_LIST_IMAGE_X, ARC_SCALE_LIST_IMAGE_Y, ARC_SCALE_LIST_IMAGE_WIDTH, ARC_SCALE_LIST_IMAGE_HEIGHT); + image_->SetAutoEnable(false); + image_->SetResizeMode(UIImageView::FILL); + Add(image_); + /* -------------------------------------------------------------------------- */ + if (label_ == nullptr) { + label_ = new UILabelExt(); + if (label_ == nullptr) { + delete image_; + image_ = nullptr; + return ; + } + } + label_->SetPosition(ARC_SCALE_LIST_TEXT_X, ARC_SCALE_LIST_TEXT_Y, ARC_SCALE_LIST_TEXT_WIDTH, ARC_SCALE_LIST_TEXT_HEIGHT); + label_->SetStyle(STYLE_LINE_HEIGHT,44); + label_->SetStyle(STYLE_TEXT_FONT,38); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 38); + label_->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + label_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_TOP); + Add(label_); +} +AppViewId ArcScaleListItemView::GetViewId() +{ + return (AppViewId)itemInfo_.id; +} +const char *ArcScaleListItemView::GetAppUid() +{ + return itemInfo_.uid; +} +UILabelExt *ArcScaleListItemView::GetLabel(void) +{ + return label_; +} +UIImageView *ArcScaleListItemView::GetImage(void) +{ + return image_; +} +} -- 2.17.1