PuzzleSDK
UIPageViewButtonTest类 参考

#include <UIPageViewTest.h>

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

Public 成员函数

 CREATE_FUNC (UIPageViewButtonTest)
 
 UIPageViewButtonTest ()
 
 ~UIPageViewButtonTest ()
 
virtual bool init () override
 
void pageViewEvent (cocos2d::Ref *sender, cocos2d::ui::PageView::EventType type)
 
void onButtonClicked (cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
 
- 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.h49 行定义.

构造及析构函数说明

◆ UIPageViewButtonTest()

UIPageViewButtonTest::UIPageViewButtonTest ( )

在文件 UIPageViewTest.cpp143 行定义.

144: _displayValueLabel(nullptr)
145{
146
147}
cocos2d::ui::Text * _displayValueLabel

◆ ~UIPageViewButtonTest()

UIPageViewButtonTest::~UIPageViewButtonTest ( )

在文件 UIPageViewTest.cpp149 行定义.

150{
151}

成员函数说明

◆ CREATE_FUNC()

UIPageViewButtonTest::CREATE_FUNC ( UIPageViewButtonTest  )

◆ init()

bool UIPageViewButtonTest::init ( )
overridevirtual

重载 UIScene .

在文件 UIPageViewTest.cpp153 行定义.

154{
155 if (UIScene::init())
156 {
157 Size widgetSize = _widget->getContentSize();
158
159 // Add a label in which the drag panel events will be displayed
160 _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
161 _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
162 _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f,
163 widgetSize.height / 2.0f +
164 _displayValueLabel->getContentSize().height * 1.5));
165 _uiLayer->addChild(_displayValueLabel);
166
167 // Add the black background
168 Text* alert = Text::create("PageView with Buttons", "fonts/Marker Felt.ttf", 30);
169 alert->setColor(Color3B(159, 168, 176));
170 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
171 _uiLayer->addChild(alert);
172
173 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
174
175 Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
176
177 // Create the page view
178 PageView* pageView = PageView::create();
179 pageView->setContentSize(Size(240.0f, 130.0f));
180 Size backgroundSize = background->getContentSize();
181 pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
182 (backgroundSize.width - pageView->getContentSize().width) / 2.0f,
183 (widgetSize.height - backgroundSize.height) / 2.0f +
184 (backgroundSize.height - pageView->getContentSize().height) / 2.0f));
185
186 pageView->removeAllItems();
187
188 int pageCount = 4;
189 for (int i = 0; i < pageCount; ++i)
190 {
191 HBox* outerBox = HBox::create();
192 outerBox->setContentSize(Size(240.0f, 130.0f));
193
194 for (int k = 0; k < 2; ++k) {
195 VBox* innerBox = VBox::create();
196
197 for (int j = 0; j < 3; j++) {
198 Button *btn = Button::create("cocosui/animationbuttonnormal.png",
199 "cocosui/animationbuttonpressed.png");
200 btn->setName(StringUtils::format("button %d", j));
201 btn->addTouchEventListener( CC_CALLBACK_2(UIPageViewButtonTest::onButtonClicked, this));
202
203 innerBox->addChild(btn);
204 }
205
206 LinearLayoutParameter *parameter = LinearLayoutParameter::create();
207 parameter->setMargin(Margin(0.0f,0.0f,100.0f,0.0f));
208 innerBox->setLayoutParameter(parameter);
209
210 outerBox->addChild(innerBox);
211
212 }
213
214 pageView->insertCustomItem(outerBox, i);
215 }
216
217 pageView->removeItem(0);
218
219 pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewButtonTest::pageViewEvent, this));
220
221 _uiLayer->addChild(pageView);
222
223 return true;
224 }
225 return false;
226}
void pageViewEvent(cocos2d::Ref *sender, cocos2d::ui::PageView::EventType type)
void onButtonClicked(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
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(), onButtonClicked() , 以及 pageViewEvent().

+ 函数调用图:

◆ onButtonClicked()

void UIPageViewButtonTest::onButtonClicked ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIPageViewTest.cpp228 行定义.

229{
230 if(type == Widget::TouchEventType::ENDED) {
231 log("button %s clicked", static_cast<Button*>(sender)->getName().c_str());
232 }
233}

被这些函数引用 init().

+ 这是这个函数的调用关系图:

◆ pageViewEvent()

void UIPageViewButtonTest::pageViewEvent ( cocos2d::Ref *  sender,
cocos2d::ui::PageView::EventType  type 
)

在文件 UIPageViewTest.cpp236 行定义.

237{
238 switch (type)
239 {
240 case PageView::EventType::TURNING:
241 {
242 PageView* pageView = dynamic_cast<PageView*>(pSender);
243
244 _displayValueLabel->setString(StringUtils::format("page = %ld", static_cast<long>(pageView->getCurrentPageIndex() + 1)));
245 }
246 break;
247
248 default:
249 break;
250 }
251}

引用了 _displayValueLabel.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

类成员变量说明

◆ _displayValueLabel

cocos2d::ui::Text* UIPageViewButtonTest::_displayValueLabel
protected

在文件 UIPageViewTest.h62 行定义.

被这些函数引用 init() , 以及 pageViewEvent().


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