提交 63564dca 编写于 作者: O openharmony_ci 提交者: Gitee

!288 修复swipeview在仅包含两个元素时无法循环滚动问题

Merge pull request !288 from JayLeeHW/OpenHarmony-v2.2-Beta
...@@ -302,9 +302,9 @@ void UISwipeView::SortChild() ...@@ -302,9 +302,9 @@ void UISwipeView::SortChild()
while (next != nullptr) { while (next != nullptr) {
if (direction_ == HORIZONTAL) { if (direction_ == HORIZONTAL) {
next->SetX(pre->GetRelativeRect().GetRight() + pre->GetStyle(STYLE_MARGIN_RIGHT)); next->SetX(pre->GetRelativeRect().GetRight() + pre->GetStyle(STYLE_MARGIN_RIGHT) + 1);
} else { } else {
next->SetY(pre->GetRelativeRect().GetBottom() + pre->GetStyle(STYLE_MARGIN_BOTTOM)); next->SetY(pre->GetRelativeRect().GetBottom() + pre->GetStyle(STYLE_MARGIN_BOTTOM) + 1);
} }
pre = next; pre = next;
next->SetViewIndex(index); next->SetViewIndex(index);
......
...@@ -24,10 +24,11 @@ ...@@ -24,10 +24,11 @@
namespace OHOS { namespace OHOS {
namespace { namespace {
static int16_t g_buttonH = 80; static int16_t g_buttonH = 80;
static int16_t g_buttonW = 300; static int16_t g_buttonW = 400;
static int16_t g_blank = 20; static int16_t g_blank = 20;
static int16_t g_swipeH = 200; static int16_t g_swipeH = 200;
static int16_t g_swipeW = 400; static int16_t g_swipeW = 400;
static int16_t g_swipeHorH = 110;
static int16_t g_deltaCoordinateY = 19; static int16_t g_deltaCoordinateY = 19;
static int16_t g_deltaCoordinateY2 = 37; static int16_t g_deltaCoordinateY2 = 37;
} // namespace } // namespace
...@@ -60,6 +61,7 @@ const UIView* UITestUISwipeView::GetTestView() ...@@ -60,6 +61,7 @@ const UIView* UITestUISwipeView::GetTestView()
{ {
UIKit_Swipe_View_Test_Horizontal_001(); UIKit_Swipe_View_Test_Horizontal_001();
UIKit_Swipe_View_Test_Horizontal_002(); UIKit_Swipe_View_Test_Horizontal_002();
UIKit_Swipe_View_Test_Horizontal_003();
UIKit_Swipe_View_Test_Align_001(UISwipeView::ALIGN_LEFT); UIKit_Swipe_View_Test_Align_001(UISwipeView::ALIGN_LEFT);
UIKit_Swipe_View_Test_Align_001(UISwipeView::ALIGN_CENTER); UIKit_Swipe_View_Test_Align_001(UISwipeView::ALIGN_CENTER);
UIKit_Swipe_View_Test_Align_001(UISwipeView::ALIGN_RIGHT); UIKit_Swipe_View_Test_Align_001(UISwipeView::ALIGN_RIGHT);
...@@ -76,7 +78,7 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_001() ...@@ -76,7 +78,7 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_001()
if (container_ == nullptr) { if (container_ == nullptr) {
return; return;
} }
UILabel* label = GetTitleLabel("UISwipeView水平滑动"); UILabel* label = GetTitleLabel("两个子元素UISwipeView循环水平滑动");
container_->Add(label); container_->Add(label);
positionX_ = TEXT_DISTANCE_TO_LEFT_SIDE; positionX_ = TEXT_DISTANCE_TO_LEFT_SIDE;
positionY_ = TEXT_DISTANCE_TO_TOP_SIDE; positionY_ = TEXT_DISTANCE_TO_TOP_SIDE;
...@@ -85,8 +87,9 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_001() ...@@ -85,8 +87,9 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_001()
UISwipeView* swipe = new UISwipeView(UISwipeView::HORIZONTAL); UISwipeView* swipe = new UISwipeView(UISwipeView::HORIZONTAL);
swipe->SetIntercept(true); swipe->SetIntercept(true);
swipe->SetLoopState(true);
swipe->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); swipe->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
swipe->SetPosition(positionX_, positionY_, g_swipeW, g_swipeH); swipe->SetPosition(positionX_, positionY_, g_swipeW, g_swipeHorH);
swipe->SetBlankSize(100); // 100: is blank size swipe->SetBlankSize(100); // 100: is blank size
container_->Add(swipe); container_->Add(swipe);
UILabelButton* button1 = new UILabelButton(); UILabelButton* button1 = new UILabelButton();
...@@ -98,10 +101,43 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_001() ...@@ -98,10 +101,43 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_001()
button2->SetText("button2"); button2->SetText("button2");
swipe->Add(button2); swipe->Add(button2);
SetLastPos(swipe); SetLastPos(swipe);
positionY_ += g_swipeH; positionY_ += g_swipeHorH;
} }
void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_002() void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_002()
{
if (container_ == nullptr) {
return;
}
UILabel* label = GetTitleLabel("UISwipeView水平滑动");
container_->Add(label);
positionY_ += g_deltaCoordinateY;
label->SetPosition(positionX_, positionY_);
positionY_ += g_deltaCoordinateY2;
UISwipeView* swipe = new UISwipeView(UISwipeView::HORIZONTAL);
swipe->SetIntercept(true);
swipe->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
swipe->SetPosition(positionX_, positionY_, g_swipeW, g_swipeHorH);
swipe->SetAnimatorTime(100); // 100: mean animator drag time(ms)
container_->Add(swipe);
UILabelButton* button1 = new UILabelButton();
button1->SetPosition(0, 0, g_buttonW, g_buttonH);
button1->SetText("button1");
swipe->Add(button1);
UILabelButton* button2 = new UILabelButton();
button2->SetPosition(0, 0, g_buttonW, g_buttonH);
button2->SetText("button2");
swipe->Add(button2);
UILabelButton* button3 = new UILabelButton();
button3->SetPosition(0, 0, g_buttonW, g_buttonH);
button3->SetText("button3");
swipe->Add(button3);
SetLastPos(swipe);
positionY_ += g_swipeHorH;
}
void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_003()
{ {
if (container_ == nullptr) { if (container_ == nullptr) {
return; return;
...@@ -115,7 +151,7 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_002() ...@@ -115,7 +151,7 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_002()
UISwipeView* swipe = new UISwipeView(UISwipeView::HORIZONTAL); UISwipeView* swipe = new UISwipeView(UISwipeView::HORIZONTAL);
swipe->SetIntercept(true); swipe->SetIntercept(true);
swipe->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); swipe->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
swipe->SetPosition(positionX_, positionY_, g_swipeW, g_swipeH); swipe->SetPosition(positionX_, positionY_, g_swipeW, g_swipeHorH);
swipe->SetLoopState(true); swipe->SetLoopState(true);
swipe->SetAnimatorTime(100); // 100: mean animator drag time(ms) swipe->SetAnimatorTime(100); // 100: mean animator drag time(ms)
container_->Add(swipe); container_->Add(swipe);
...@@ -132,7 +168,7 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_002() ...@@ -132,7 +168,7 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Horizontal_002()
button3->SetText("button3"); button3->SetText("button3");
swipe->Add(button3); swipe->Add(button3);
SetLastPos(swipe); SetLastPos(swipe);
positionY_ += g_swipeH; positionY_ += g_swipeHorH;
} }
void UITestUISwipeView::UIKit_Swipe_View_Test_Ver_001() void UITestUISwipeView::UIKit_Swipe_View_Test_Ver_001()
......
...@@ -33,6 +33,7 @@ public: ...@@ -33,6 +33,7 @@ public:
void UIKit_Swipe_View_Test_Horizontal_001(); void UIKit_Swipe_View_Test_Horizontal_001();
void UIKit_Swipe_View_Test_Horizontal_002(); void UIKit_Swipe_View_Test_Horizontal_002();
void UIKit_Swipe_View_Test_Horizontal_003();
void UIKit_Swipe_View_Test_Ver_001(); void UIKit_Swipe_View_Test_Ver_001();
void UIKit_Swipe_View_Test_Ver_002(); void UIKit_Swipe_View_Test_Ver_002();
void UIKit_Swipe_View_Test_Remove_001(); void UIKit_Swipe_View_Test_Remove_001();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册