PuzzleSDK
UIPageViewJumpToPageTest类 参考

#include <UIPageViewTest.h>

+ 类 UIPageViewJumpToPageTest 继承关系图:
+ UIPageViewJumpToPageTest 的协作图:

Public 成员函数

 CREATE_FUNC (UIPageViewJumpToPageTest)
 
 UIPageViewJumpToPageTest ()
 
 ~UIPageViewJumpToPageTest ()
 
virtual bool init () override
 
- Public 成员函数 继承自 UIScene
 UIScene ()
 
 ~UIScene ()
 
virtual void onEnter () override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

Protected 属性

cocos2d::ui::Text * _displayValueLabel
 
- Protected 属性 继承自 UIScene
cocos2d::Layer * _uiLayer
 
cocos2d::ui::Layout * _widget
 
cocos2d::ui::Text * _sceneTitle
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 UIPageViewTest.h99 行定义.

构造及析构函数说明

◆ UIPageViewJumpToPageTest()

UIPageViewJumpToPageTest::UIPageViewJumpToPageTest ( )

在文件 UIPageViewTest.cpp637 行定义.

638: _displayValueLabel(nullptr)
639{
640
641}
cocos2d::ui::Text * _displayValueLabel

◆ ~UIPageViewJumpToPageTest()

UIPageViewJumpToPageTest::~UIPageViewJumpToPageTest ( )

在文件 UIPageViewTest.cpp643 行定义.

644{
645}

成员函数说明

◆ CREATE_FUNC()

UIPageViewJumpToPageTest::CREATE_FUNC ( UIPageViewJumpToPageTest  )

◆ init()

bool UIPageViewJumpToPageTest::init ( )
overridevirtual

重载 UIScene .

在文件 UIPageViewTest.cpp647 行定义.

648{
649 if (UIScene::init())
650 {
651 Size widgetSize = _widget->getContentSize();
652
653 // Add a label in which the dragpanel events will be displayed
654 _displayValueLabel = Text::create("setCurrentPageIndex API Test", "fonts/Marker Felt.ttf", 32);
655 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
656 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f,
657 widgetSize.height / 2.0f +
658 _displayValueLabel->getContentSize().height * 1.5));
659 _uiLayer->addChild(_displayValueLabel);
660
661 // Add the black background
662 Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30);
663 alert->setColor(Color3B(159, 168, 176));
664 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
665 _uiLayer->addChild(alert);
666
667 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
668
669 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
670
671 // Create the page view
672 PageView* pageView = PageView::create();
673 pageView->setContentSize(Size(240.0f, 130.0f));
674 Size backgroundSize = background->getContentSize();
675 pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
676 (backgroundSize.width - pageView->getContentSize().width) / 2.0f,
677 (widgetSize.height - backgroundSize.height) / 2.0f +
678 (backgroundSize.height - pageView->getContentSize().height) / 2.0f));
679 pageView->setIndicatorEnabled(true);
680 pageView->removeAllItems();
681
682 int pageCount = 4;
683 for (int i = 0; i < pageCount; ++i)
684 {
685 Layout* layout = Layout::create();
686 layout->setContentSize(Size(240.0f, 130.0f));
687
688 ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
689 imageView->setScale9Enabled(true);
690 imageView->setContentSize(Size(240.0f, 130.0f));
691 imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
692 layout->addChild(imageView);
693
694 Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30);
695 label->setColor(Color3B(192, 192, 192));
696 label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
697 layout->addChild(label);
698
699 pageView->insertCustomItem(layout, i);
700 }
701
702 pageView->setCurrentPageIndex(1);
703
704 //add buttons to jump to specific page
705 auto button1 = ui::Button::create();
706 button1->setPositionNormalized(Vec2(0.1f, 0.75f));
707 button1->setTitleText("Jump to Page1");
708 CCLOG("button1 content Size = %f, %f", button1->getContentSize().width,
709 button1->getContentSize().height);
710 button1->addClickEventListener([=](Ref*){
711 pageView->setCurrentPageIndex(0);
712 });
713 _uiLayer->addChild(button1);
714
715 auto button2 = static_cast<ui::Button*>(button1->clone());
716 button2->setTitleText("Jump to Page2");
717 button2->setPositionNormalized(Vec2(0.1f, 0.65f));
718 CCLOG("button2 content Size = %f, %f", button2->getContentSize().width,
719 button2->getContentSize().height);
720 button2->addClickEventListener([=](Ref*){
721 pageView->setCurrentPageIndex(1);
722 });
723 _uiLayer->addChild(button2);
724
725 auto button3 = static_cast<ui::Button*>(button2->clone());
726 button3->setTitleText("Jump to Page3");
727 button3->setPositionNormalized(Vec2(0.9f, 0.75f));
728 button3->addClickEventListener([=](Ref*){
729 pageView->setCurrentPageIndex(2);
730 });
731 _uiLayer->addChild(button3);
732
733 auto button4 = static_cast<ui::Button*>(button2->clone());
734 button4->setTitleText("Jump to Page4");
735 button4->setPositionNormalized(Vec2(0.9f, 0.65f));
736 button4->addClickEventListener([=](Ref*){
737 pageView->setCurrentPageIndex(3);
738 });
739 _uiLayer->addChild(button4);
740 _uiLayer->addChild(pageView);
741
742 return true;
743 }
744 return false;
745}
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45

引用了 _displayValueLabel, UIScene::_uiLayer, UIScene::_widget , 以及 UIScene::init().

+ 函数调用图:

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIPageViewJumpToPageTest::_displayValueLabel
protected

在文件 UIPageViewTest.h110 行定义.

被这些函数引用 init().


该类的文档由以下文件生成: