From 9f693ef8f3dfb56e8b3dfcfb9ea6f3dbb41a0a18 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 24 Aug 2015 18:19:28 +0900 Subject: [PATCH 1/2] Enhance readability --- cocos/ui/UIScrollViewBar.cpp | 10 ++++++++-- cocos/ui/UIScrollViewBar.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UIScrollViewBar.cpp b/cocos/ui/UIScrollViewBar.cpp index ec10cb2efc..d4682d9451 100644 --- a/cocos/ui/UIScrollViewBar.cpp +++ b/cocos/ui/UIScrollViewBar.cpp @@ -37,6 +37,7 @@ static const char* BODY_IMAGE_1_PIXEL_HEIGHT = "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAB static const Color3B DEFAULT_COLOR(52, 65, 87); static const float DEFAULT_MARGIN = 20; static const float DEFAULT_AUTO_HIDE_TIME = 0.2f; +static const float DEFAULT_SCROLLBAR_OPACITY = 0.4f; static Sprite* createSpriteFromBase64(const char* base64String) { @@ -65,7 +66,7 @@ _direction(direction), _upperHalfCircle(nullptr), _lowerHalfCircle(nullptr), _body(nullptr), -_opacity(100), +_opacity(255 * DEFAULT_SCROLLBAR_OPACITY), _marginFromBoundary(DEFAULT_MARGIN), _marginForLength(DEFAULT_MARGIN), _touching(false), @@ -197,7 +198,12 @@ void ScrollViewBar::onEnter() void ScrollViewBar::update(float deltaTime) { - if(!_autoHideEnabled || _autoHideRemainingTime <= 0) + processAutoHide(deltaTime); +} + +void ScrollViewBar::processAutoHide(float deltaTime) +{ + if(!_autoHideEnabled || _autoHideRemainingTime <= 0) { return; } diff --git a/cocos/ui/UIScrollViewBar.h b/cocos/ui/UIScrollViewBar.h index 2331720c8b..8b466466da 100644 --- a/cocos/ui/UIScrollViewBar.h +++ b/cocos/ui/UIScrollViewBar.h @@ -153,6 +153,7 @@ private: Vec2 calculatePosition(float innerContainerMeasure, float scrollViewMeasure, float innerContainerPosition, float outOfBoundaryValue, float actualLength); void updateLength(float length); + void processAutoHide(float deltaTime); ScrollView* _parent; ScrollView::Direction _direction; From edd9fecf396b25fcfa1e974a00e29707d217baa7 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 24 Aug 2015 18:43:53 +0900 Subject: [PATCH 2/2] Update scroll bar when the inner container's size changes --- cocos/ui/UIScrollView.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 401e4a8552..bce9d81253 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -210,6 +210,8 @@ void ScrollView::setInnerContainerSize(const Size &size) pos.y = _contentSize.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getContentSize().height; } setInnerContainerPosition(pos); + + updateScrollBar(Vec2::ZERO); } const Size& ScrollView::getInnerContainerSize() const