From 8ae6d68640931d9e8c9b09a1c5c799c8346d0911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=B5=D1=81=D1=88=D0=B0=D0=BF=D0=BE=D1=88=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= Date: Fri, 8 Apr 2016 11:14:45 +0300 Subject: [PATCH] Add scroll view bar js test --- tests/js-tests/src/GUITest/UISceneManager.js | 6 +++ .../UIScrollViewTest/UIScrollViewTest.js | 46 ++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/tests/js-tests/src/GUITest/UISceneManager.js b/tests/js-tests/src/GUITest/UISceneManager.js index 1090c5efa9..e1067915d9 100644 --- a/tests/js-tests/src/GUITest/UISceneManager.js +++ b/tests/js-tests/src/GUITest/UISceneManager.js @@ -477,6 +477,12 @@ func: function () { return new UIScrollViewTest_Vertical_Multiple(); } + }, + { + title:"UIScrollView Scroll Bar Test", + func: function () { + return new UIScrollViewTest_ScrollBar(); + } } ], "UIPageView": [ diff --git a/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js b/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js index 0ea3fe81db..f5b712264c 100644 --- a/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js +++ b/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js @@ -603,4 +603,48 @@ var UIScrollViewTest_Vertical_Multiple = UIMainLayer.extend({ scrollView.addChild(button_scale9); } } -}); \ No newline at end of file +}); + +var UIScrollViewTest_ScrollBar = UIMainLayer.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("Scroll bar is red, 65% opacity, auto hide time: 5 sec"); + this._topDisplayLabel.setFontSize(14); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + + this._bottomDisplayLabel.setString(""); + this._bottomDisplayLabel.x = widgetSize.width / 2; + this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3; + + var background = this._widget.getChildByName("background_Panel"); + + // Create the scrollview + var scrollView = new ccui.ScrollView(); + scrollView.setTouchEnabled(true); + scrollView.setBounceEnabled(true); + scrollView.setBackGroundColor(cc.color.GREEN); + scrollView.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID); + scrollView.setDirection(ccui.ScrollView.DIR_BOTH); + scrollView.setInnerContainerSize(cc.size(480, 320)); + scrollView.setContentSize(cc.size(100, 100)); + var scrollViewSize = scrollView.getContentSize(); + + scrollView.x = (widgetSize.width - background.width) / 2 + (background.width - scrollViewSize.width) / 2; + scrollView.y = (widgetSize.height - background.height) / 2 + (background.height - scrollViewSize.height) / 2; + + this._mainNode.addChild(scrollView); + + scrollView.setScrollBarAutoHideTime(5); + scrollView.setScrollBarColor(cc.color.RED); + scrollView.setScrollBarOpacity(255 * 0.65); + scrollView.setScrollBarWidth(5); + + return true; + } + return false; + } +}); +