axmol/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp

393 lines
14 KiB
C++
Raw Normal View History

2013-09-16 20:54:13 +08:00
#include "UISceneManager.h"
#include "UIScene.h"
#include "UIButtonTest/UIButtonTest.h"
#include "UICheckBoxTest/UICheckBoxTest.h"
#include "UISliderTest/UISliderTest.h"
#include "UIImageViewTest/UIImageViewTest.h"
#include "UILoadingBarTest/UILoadingBarTest.h"
2014-03-04 16:51:35 +08:00
#include "UITextAtlasTest/UITextAtlasTest.h"
#include "UITextTest/UITextTest.h"
#include "UITextBMFontTest/UITextBMFontTest.h"
2013-09-16 20:54:13 +08:00
#include "UITextFieldTest/UITextFieldTest.h"
2013-12-23 15:35:35 +08:00
#include "UILayoutTest/UILayoutTest.h"
2013-09-16 20:54:13 +08:00
#include "UIScrollViewTest/UIScrollViewTest.h"
#include "UIPageViewTest/UIPageViewTest.h"
#include "UIListViewTest/UIListViewTest.h"
2013-12-23 15:35:35 +08:00
#include "UIWidgetAddNodeTest/UIWidgetAddNodeTest.h"
2014-03-06 20:52:29 +08:00
#include "UIRichTextTest/UIRichTextTest.h"
#include "UIFocusTest/UIFocusTest.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
2014-05-09 11:30:07 +08:00
#include "UIVideoPlayerTest/UIVideoPlayerTest.h"
#endif
2013-12-23 15:35:35 +08:00
/*
#include "UISwitchTest/UISwitchTest.h"
2014-03-04 16:51:35 +08:00
*/
/*
2013-12-23 15:35:35 +08:00
#include "UIProgressTimerTest/UIProgressTimerTest.h"
2014-03-04 16:51:35 +08:00
*/
/*
2013-12-23 15:35:35 +08:00
#include "UIPotentiometerTest/UIPotentiometerTest.h"
*/
2014-03-04 16:51:35 +08:00
/*
#include "UIGridViewTest/UIGridViewTest.h"
*/
/*
#include "UIPickerViewTest/UIPickerViewTest.h"
*/
2013-09-16 20:54:13 +08:00
USING_NS_CC;
static const char* s_testArray[] =
{
"UIButtonTest",
"UIButtonTest_Scale9",
"UIButtonTest_PressedAction",
2013-12-23 15:35:35 +08:00
"UIButtonTest_Title",
2013-09-16 20:54:13 +08:00
"UICheckBoxTest",
"UISliderTest",
"UISliderTest_Scale9",
2013-12-23 15:35:35 +08:00
/*
"UIPotentiometerTest",
2014-03-04 16:51:35 +08:00
*/
/*
2013-12-23 15:35:35 +08:00
"UISwitchTest_Horizontal",
"UISwitchTest_Vertical",
"UISwitchTest_VerticalAndTitleVertical",
*/
2013-09-16 20:54:13 +08:00
"UIImageViewTest",
"UIImageViewTest_Scale9",
"UILoadingBarTest_Left",
"UILoadingBarTest_Right",
"UILoadingBarTest_Left_Scale9",
"UILoadingBarTest_Right_Scale9",
2013-12-23 15:35:35 +08:00
/*
"UIProgressTimerTest_Radial",
"UIProgressTimerTest_Horizontal",
"UIProgressTimerTest_Vertical",
"UIProgressTimerTest_RadialMidpointChanged",
"UIProgressTimerTest_BarVarious",
"UIProgressTimerTest_BarTintAndFade",
"UIProgressTimerTest_WithSpriteFrame",
*/
2014-03-04 16:51:35 +08:00
"UITextAtlasTest",
"UITextTest",
"UITextTest_LineWrap",
2014-06-09 14:34:46 +08:00
2013-12-23 15:35:35 +08:00
"UILabelTest_Effect",
2014-06-09 14:34:46 +08:00
2014-03-04 16:51:35 +08:00
"UITextTest_TTF",
"UITextBMFontTest",
2013-09-16 20:54:13 +08:00
"UITextFieldTest",
"UITextFieldTest_MaxLength",
"UITextFieldTest_Password",
2014-03-04 17:06:12 +08:00
"UITextFieldTest_LineWrap",
2013-12-23 15:35:35 +08:00
"UILayoutTest",
"UILayoutTest_Color",
"UILayoutTest_Gradient",
"UILayoutTest_BackGroundImage",
"UILayoutTest_BackGroundImage_Scale9",
"UILayoutTest_Layout_Linear_Vertical",
"UILayoutTest_Layout_Linear_Horizontal",
"UILayoutTest_Layout_Relative_Align_Parent",
"UILayoutTest_Layout_Relative_Location",
/*
"UILayoutTest_Layout_Grid",
*/
2013-09-16 20:54:13 +08:00
"UIScrollViewTest_Vertical",
"UIScrollViewTest_Horizontal",
2013-12-23 15:35:35 +08:00
"UIScrollViewTest_Both",
"UIScrollViewTest_ScrollToPercentBothDirection",
"UIScrollViewTest_ScrollToPercentBothDirection_Bounce",
2013-09-16 20:54:13 +08:00
"UIPageViewTest,",
"UIListViewTest_Vertical",
"UIListViewTest_Horizontal",
2013-12-23 15:35:35 +08:00
/*
"UIGridViewTest_Mode_Column",
"UIGridViewTest_Mode_Row",
2014-03-04 16:51:35 +08:00
*/
/*
2013-12-23 15:35:35 +08:00
"UIPickerViewTest_Vertical",
"UIPickerViewTest_Horizontal",
*/
"UIWidgetAddNodeTest",
2014-03-06 20:52:29 +08:00
"UIRichTextTest",
"UIFocusTest-HBox",
2014-05-06 14:38:45 +08:00
"UIFocusTest-VBox",
2014-05-07 11:40:01 +08:00
"UIFocusTest-NestedLayout1",
2014-05-07 18:27:05 +08:00
"UIFocusTest-NestedLayout2",
"UIFocusTest-NestedLayout3",
2014-05-20 17:56:52 +08:00
"UIFocusTest-ListView",
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
2014-05-09 11:30:07 +08:00
"UIVideoPlayerTest"
#endif
2013-09-16 20:54:13 +08:00
};
static UISceneManager *sharedInstance = NULL;
UISceneManager::UISceneManager()
{
2013-12-23 15:35:35 +08:00
_currentUISceneId = kUIButtonTest;
2013-09-16 20:54:13 +08:00
}
UISceneManager::~UISceneManager()
{
}
UISceneManager * UISceneManager::sharedUISceneManager()
{
if (sharedInstance == NULL)
{
sharedInstance = new UISceneManager();
}
return sharedInstance;
}
void UISceneManager::purgeUISceneManager()
{
CC_SAFE_DELETE(sharedInstance);
}
Scene *UISceneManager::nextUIScene()
{
2013-12-23 15:35:35 +08:00
_currentUISceneId = _currentUISceneId + 1;
if (_currentUISceneId > _maxUISceneId)
{
_currentUISceneId = _minUISceneId;
}
// _currentUISceneId = (_currentUISceneId + 1) % kUITestMax;
2013-09-16 20:54:13 +08:00
return currentUIScene();
}
Scene *UISceneManager::previousUIScene()
{
2013-12-23 15:35:35 +08:00
_currentUISceneId = _currentUISceneId - 1;
if (_currentUISceneId < _minUISceneId)
2013-09-16 20:54:13 +08:00
{
2013-12-23 15:35:35 +08:00
_currentUISceneId = _maxUISceneId;
2013-09-16 20:54:13 +08:00
}
2013-12-23 15:35:35 +08:00
/*
_currentUISceneId = _currentUISceneId - 1;
if (_currentUISceneId < 0)
{
_currentUISceneId = kUITestMax - 1;
}
*/
2013-09-16 20:54:13 +08:00
return currentUIScene();
}
Scene *UISceneManager::currentUIScene()
{
2013-12-23 15:35:35 +08:00
switch (_currentUISceneId)
2013-09-16 20:54:13 +08:00
{
case kUIButtonTest:
2013-12-23 15:35:35 +08:00
return UIButtonTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIButtonTest_Scale9:
2013-12-23 15:35:35 +08:00
return UIButtonTest_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIButtonTest_PressedAction:
2013-12-23 15:35:35 +08:00
return UIButtonTest_PressedAction::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUIButtonTest_Title:
return UIButtonTest_Title::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUICheckBoxTest:
2013-12-23 15:35:35 +08:00
return UICheckBoxTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUISliderTest:
2013-12-23 15:35:35 +08:00
return UISliderTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUISliderTest_Scale9:
2013-12-23 15:35:35 +08:00
return UISliderTest_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
/*
case kUIPotentiometerTest:
return UIPotentiometerTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-03-04 16:51:35 +08:00
*/
2013-12-23 15:35:35 +08:00
2014-03-04 16:51:35 +08:00
/*
2013-12-23 15:35:35 +08:00
case kUISwitchTest_Horizontal:
return UISwitchTest_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUISwitchTest_Vertical:
return UISwitchTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUISwitchTest_VerticalAndTitleVertical:
return UISwitchTest_VerticalAndTitleVertical::sceneWithTitle(s_testArray[_currentUISceneId]);
*/
2013-09-16 20:54:13 +08:00
case kUIImageViewTest:
2013-12-23 15:35:35 +08:00
return UIImageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIImageViewTest_Scale9:
2013-12-23 15:35:35 +08:00
return UIImageViewTest_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUILoadingBarTest_Left:
2013-12-23 15:35:35 +08:00
return UILoadingBarTest_Left::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUILoadingBarTest_Right:
2013-12-23 15:35:35 +08:00
return UILoadingBarTest_Right::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUILoadingBarTest_Left_Scale9:
2013-12-23 15:35:35 +08:00
return UILoadingBarTest_Left_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUILoadingBarTest_Right_Scale9:
2013-12-23 15:35:35 +08:00
return UILoadingBarTest_Right_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
/*
case kUIProgressTimerTest_Radial:
return UIProgressTimerTest_Radial::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIProgressTimerTest_Horizontal:
return UIProgressTimerTest_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIProgressTimerTest_Vertical:
return UIProgressTimerTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIProgressTimerTest_RadialMidpointChanged:
return UIProgressTimerTest_RadialMidpointChanged::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIProgressTimerTest_BarVarious:
return UIProgressTimerTest_BarVarious::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIProgressTimerTest_BarTintAndFade:
return UIProgressTimerTest_BarTintAndFade::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIProgressTimerTest_WithSpriteFrame:
return UIProgressTimerTest_WithSpriteFrame::sceneWithTitle(s_testArray[_currentUISceneId]);
*/
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextAtlasTest:
return UITextAtlasTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextBMFontTest:
return UITextBMFontTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextTest:
return UITextTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-12-23 15:35:35 +08:00
2014-03-04 16:51:35 +08:00
case kUITextTest_LineWrap:
return UITextTest_LineWrap::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-12-23 15:35:35 +08:00
2014-06-09 14:34:46 +08:00
2013-12-23 15:35:35 +08:00
case kUILabelTest_Effect:
return UILabelTest_Effect::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-06-09 14:34:46 +08:00
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextTest_TTF:
return UITextTest_TTF::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUITextFieldTest:
2013-12-23 15:35:35 +08:00
return UITextFieldTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUITextFieldTest_MaxLength:
2013-12-23 15:35:35 +08:00
return UITextFieldTest_MaxLength::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUITextFieldTest_Password:
2013-12-23 15:35:35 +08:00
return UITextFieldTest_Password::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextFieldTest_LineWrap:
return UITextFieldTest_LineWrap::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-12-23 15:35:35 +08:00
case kUILayoutTest:
return UILayoutTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Color:
return UILayoutTest_Color::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Gradient:
return UILayoutTest_Gradient::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_BackGroundImage:
return UILayoutTest_BackGroundImage::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_BackGroundImage_Scale9:
return UILayoutTest_BackGroundImage_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Layout_Linear_Vertical:
return UILayoutTest_Layout_Linear_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Layout_Linear_Horizontal:
return UILayoutTest_Layout_Linear_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUILayoutTest_Layout_Relative_Align_Parent:
return UILayoutTest_Layout_Relative_Align_Parent::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUILayoutTest_Layout_Relative_Location:
return UILayoutTest_Layout_Relative_Location::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
/*
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Layout_Grid:
return UILayoutTest_Layout_Grid::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
*/
case kUIScrollViewTest_Vertical:
2013-12-23 15:35:35 +08:00
return UIScrollViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIScrollViewTest_Horizontal:
2013-12-23 15:35:35 +08:00
return UIScrollViewTest_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScrollViewTest_Both:
return UIScrollViewTest_Both::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScrollViewTest_ScrollToPercentBothDirection:
return UIScrollViewTest_ScrollToPercentBothDirection::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScrollViewTest_ScrollToPercentBothDirection_Bounce:
return UIScrollViewTest_ScrollToPercentBothDirection_Bounce::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIPageViewTest:
2013-12-23 15:35:35 +08:00
return UIPageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIListViewTest_Vertical:
2013-12-23 15:35:35 +08:00
return UIListViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIListViewTest_Horizontal:
2013-12-23 15:35:35 +08:00
return UIListViewTest_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
/*
case kUIGridViewTest_Mode_Column:
return UIGridViewTest_Mode_Column::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIGridViewTest_Mode_Row:
return UIGridViewTest_Mode_Row::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-03-04 16:51:35 +08:00
*/
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
/*
2013-12-23 15:35:35 +08:00
case kUIPickerViewTest_Vertical:
return UIPickerViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIPickerViewTest_Horizontal:
return UIPickerViewTest_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-03-04 16:51:35 +08:00
*/
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUIWidgetAddNodeTest:
return UIWidgetAddNodeTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-03-06 20:52:29 +08:00
case kUIRichTextTest:
return UIRichTextTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case KUIFocusTest_HBox:
return UIFocusTestHorizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
case KUIFocusTest_VBox:
return UIFocusTestVertical::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-05-06 14:38:45 +08:00
case KUIFocusTest_NestedLayout1:
return UIFocusTestNestedLayout1::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-05-07 11:40:01 +08:00
case KUIFocusTest_NestedLayout2:
return UIFocusTestNestedLayout2::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-05-07 18:27:05 +08:00
case KUIFocusTest_NestedLayout3:
return UIFocusTestNestedLayout3::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-05-20 17:56:52 +08:00
case kUIFocusTest_ListView:
return UIFocusTestListView::sceneWithTitle(s_testArray[_currentUISceneId]);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
2014-05-09 11:30:07 +08:00
case kUIVideoPlayerTest:
return VideoPlayerTest::sceneWithTitle(s_testArray[_currentUISceneId]);
#endif
2013-09-16 20:54:13 +08:00
}
return NULL;
}