From 2797277de86d5f25d4a6951951d5f7959a8d59e3 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 7 Jan 2016 17:07:27 +0800 Subject: [PATCH] Revert "fix scale9sprite gray state opacity issue." --- cocos/renderer/ccShader_UI_Gray.frag | 1 - .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 50 ------------------- .../CocoStudioGUITest/UIScale9SpriteTest.h | 9 ---- 3 files changed, 60 deletions(-) diff --git a/cocos/renderer/ccShader_UI_Gray.frag b/cocos/renderer/ccShader_UI_Gray.frag index 0824470a6b..b20508f80d 100644 --- a/cocos/renderer/ccShader_UI_Gray.frag +++ b/cocos/renderer/ccShader_UI_Gray.frag @@ -10,7 +10,6 @@ const char* ccPositionTexture_GrayScale_frag = STRINGIFY( \nvoid main(void)\n \n{\n \nvec4 c = texture2D(CC_Texture0, v_texCoord);\n - \n c = v_fragmentColor * c; \n \ngl_FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b);\n \ngl_FragColor.w = c.w;\n \n}\n diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index ff238a58d5..dd5628d656 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -59,7 +59,6 @@ UIScale9SpriteTests::UIScale9SpriteTests() ADD_TEST_CASE(UIS9ToggleRenderingTypeTest); ADD_TEST_CASE(UIS9GlobalZOrderTest); ADD_TEST_CASE(UIS9EnableScale9FalseTest); - ADD_TEST_CASE(UIS9GrayStateOpacityTest); } // UIScale9SpriteTest @@ -1141,52 +1140,3 @@ bool UIS9EnableScale9FalseTest::init() return false; } -bool UIS9GrayStateOpacityTest::init() -{ - if (UIScene::init()) { - - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2 + 10); - - auto label = Label::createWithSystemFont("Drap slider to change opacity of the scale9Sprite", "Arial", 15); - label->setPosition(Vec2(winSize.width/2, winSize.height - 60)); - this->addChild(label); - - auto blocks = ui::Scale9Sprite::create("Images/blocks9.png"); - - blocks->setPosition(Vec2(x, y)); - blocks->setPreferredSize(Size(96*2, 96*1.5)); - blocks->setOpacity(100); - blocks->setState(Scale9Sprite::State::GRAY); - blocks->setGlobalZOrder(1); - blocks->setName("GrayScale9"); - this->addChild(blocks); - - Slider* slider = Slider::create(); - slider->loadBarTexture("cocosui/sliderTrack.png"); - slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); - slider->loadProgressBarTexture("cocosui/sliderProgress.png"); - slider->setContentSize(Size(300, slider->getContentSize().height * 1.5)); - slider->setMaxPercent(100); - slider->setPercent(100 * 100.0 / 255.0); - slider->setPosition(Vec2(winSize.width / 2.0f, winSize.height / 2.0f - 100)); - slider->addEventListener(CC_CALLBACK_2(UIS9GrayStateOpacityTest::sliderEvent, this)); - _uiLayer->addChild(slider); - - return true; - } - return false; -} - -void UIS9GrayStateOpacityTest::sliderEvent(cocos2d::Ref *sender, cocos2d::ui::Slider::EventType type) -{ - if (type == Slider::EventType::ON_PERCENTAGE_CHANGED) - { - Slider* slider = dynamic_cast(sender); - int percent = slider->getPercent(); - int maxPercent = slider->getMaxPercent(); - auto scale9Sprite = (Scale9Sprite*)this->getChildByName("GrayScale9"); - scale9Sprite->setOpacity(1.0 * percent / maxPercent * 255.0); - } -} \ No newline at end of file diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h index 927499b528..11042a7990 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h @@ -311,13 +311,4 @@ public: virtual bool init() override; }; -class UIS9GrayStateOpacityTest: public UIScene -{ -public: - CREATE_FUNC(UIS9GrayStateOpacityTest); - void sliderEvent(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type); - - virtual bool init() override; -}; - #endif /* defined(__cocos2d_tests__UIScale9SpriteTest__) */