本文整理汇总了C++中PageView::addPage方法的典型用法代码示例。如果您正苦于以下问题:C++ PageView::addPage方法的具体用法?C++ PageView::addPage怎么用?C++ PageView::addPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageView
的用法示例。
在下文中一共展示了PageView::addPage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PageInit
void CocosGUIExamplesPageScene::PageInit()
{
// page root from json
Layout* page_root = dynamic_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosgui/gui_examples/page_1/page_1.json"));
m_pUILayer->addWidget(page_root);
// page layout
Layout* page_layout = dynamic_cast<Layout*>(page_root->getChildByName("page_panel"));
// page view add to page layout
PageView* pageView = PageView::create();
pageView->setTouchEnabled(true);
pageView->setSize(page_layout->getSize());
// layout add to page view
for (int i = 0; i < 4; ++i)
{
Layout* layout = Layout::create();
layout->setSize(pageView->getSize());
ImageView* imageView = ImageView::create();
imageView->setTouchEnabled(true);
imageView->loadTexture(page_image_textures[i]);
imageView->setPosition(ccp(layout->getSize().width / 2, layout->getSize().height / 2));
layout->addChild(imageView);
pageView->addPage(layout);
}
pageView->addEventListenerPageView(this, pagevieweventselector(CocosGUIExamplesPageScene::pageViewEvent));
page_layout->addChild(pageView);
}
示例2: init
bool UIPageViewTest::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getSize();
// Add a label in which the dragpanel events will be displayed
_displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f +
_displayValueLabel->getContentSize().height * 1.5));
_uiLayer->addChild(_displayValueLabel);
// Add the black background
Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
_uiLayer->addChild(alert);
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
// Create the page view
PageView* pageView = PageView::create();
pageView->setSize(Size(240.0f, 130.0f));
Size backgroundSize = background->getContentSize();
pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
(backgroundSize.width - pageView->getSize().width) / 2.0f,
(widgetSize.height - backgroundSize.height) / 2.0f +
(backgroundSize.height - pageView->getSize().height) / 2.0f));
for (int i = 0; i < 3; ++i)
{
Layout* layout = Layout::create();
layout->setSize(Size(240.0f, 130.0f));
ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
imageView->setScale9Enabled(true);
imageView->setSize(Size(240, 130));
imageView->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
layout->addChild(imageView);
Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30);
label->setColor(Color3B(192, 192, 192));
label->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
layout->addChild(label);
pageView->addPage(layout);
}
pageView->addEventListener(CC_CALLBACK_2(UIPageViewTest::pageViewEvent, this));
_uiLayer->addChild(pageView);
return true;
}
return false;
}
示例3: loadNode
Node* CSLoader::loadNode(const rapidjson::Value& json)
{
Node* node = nullptr;
std::string nodeType = DICTOOL->getStringValue_json(json, CLASSNAME);
NodeCreateFunc func = _funcs[nodeType];
if (func != nullptr)
{
const rapidjson::Value& options = DICTOOL->getSubDictionary_json(json, OPTIONS);
node = func(options);
// component
if (node)
{
const rapidjson::Value& components = DICTOOL->getSubDictionary_json(options, COMPONENTS);
int componentSize = DICTOOL->getArrayCount_json(options, COMPONENTS, 0);
for (int i = 0; i < componentSize; ++i)
{
const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(components, COMPONENTS, i);
Component* component = loadComponent(dic);
if (component)
{
node->addComponent(component);
}
}
}
}
if(node)
{
int length = DICTOOL->getArrayCount_json(json, CHILDREN, 0);
for (int i = 0; i<length; i++)
{
const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, CHILDREN, i);
Node* child = loadNode(dic);
if (child)
{
PageView* pageView = dynamic_cast<PageView*>(node);
ListView* listView = dynamic_cast<ListView*>(node);
if (pageView)
{
Layout* layout = dynamic_cast<Layout*>(child);
if (layout)
{
pageView->addPage(layout);
}
}
else if (listView)
{
Widget* widget = dynamic_cast<Widget*>(child);
if (widget)
{
listView->pushBackCustomItem(widget);
}
}
else
{
if (_monoCocos2dxVersion != "3.x")
{
Widget* widget = dynamic_cast<Widget*>(child);
Widget* parent = dynamic_cast<Widget*>(node);
if (widget
&& parent
&& !dynamic_cast<Layout*>(parent))
{
if (widget->getPositionType() == ui::Widget::PositionType::PERCENT)
{
widget->setPositionPercent(Vec2(widget->getPositionPercent().x + parent->getAnchorPoint().x, widget->getPositionPercent().y + parent->getAnchorPoint().y));
widget->setPosition(Vec2(widget->getPositionX() + parent->getAnchorPointInPoints().x, widget->getPositionY() + parent->getAnchorPointInPoints().y));
}
else
{
Size parentSize = parent->getContentSize();
widget->setPosition(Vec2(widget->getPositionX() + parentSize.width * parent->getAnchorPoint().x,
widget->getPositionY() + parentSize.height * parent->getAnchorPoint().y));
}
}
}
node->addChild(child);
}
child->release();
}
}
}
else
{
CCLOG("Not supported NodeType: %s", nodeType.c_str());
}
return node;
}
示例4: nodeWithFlatBuffersForSimulator
Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nodetree)
{
Node* node = nullptr;
std::string classname = nodetree->classname()->c_str();
auto options = nodetree->options();
if (classname == "ProjectNode")
{
auto reader = ProjectNodeReader::getInstance();
auto projectNodeOptions = (ProjectNodeOptions*)options->data();
std::string filePath = projectNodeOptions->fileName()->c_str();
cocostudio::timeline::ActionTimeline* action = nullptr;
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
{
node = createNodeWithFlatBuffersForSimulator(filePath);
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath);
}
else
{
node = Node::create();
}
reader->setPropsWithFlatBuffers(node, (const flatbuffers::Table*)options->data());
if (action)
{
action->setTimeSpeed(projectNodeOptions->innerActionSpeed());
node->runAction(action);
action->gotoFrameAndPause(0);
}
}
else if (classname == "SimpleAudio")
{
node = Node::create();
auto reader = ComAudioReader::getInstance();
Component* component = reader->createComAudioWithFlatBuffers((const flatbuffers::Table*)options->data());
if (component)
{
node->addComponent(component);
reader->setPropsWithFlatBuffers(node, (const flatbuffers::Table*)options->data());
}
}
else
{
std::string readername = getGUIClassName(classname);
readername.append("Reader");
NodeReaderProtocol* reader = dynamic_cast<NodeReaderProtocol*>(ObjectFactory::getInstance()->createObject(readername));
if (reader)
{
node = reader->createNodeWithFlatBuffers((const flatbuffers::Table*)options->data());
}
Widget* widget = dynamic_cast<Widget*>(node);
if (widget)
{
std::string callbackName = widget->getCallbackName();
std::string callbackType = widget->getCallbackType();
bindCallback(callbackName, callbackType, widget, _rootNode);
}
if (_rootNode == nullptr)
{
_rootNode = node;
}
// _loadingNodeParentHierarchy.push_back(node);
}
// If node is invalid, there is no necessity to process children of node.
if (!node)
{
return nullptr;
}
auto children = nodetree->children();
int size = children->size();
for (int i = 0; i < size; ++i)
{
auto subNodeTree = children->Get(i);
Node* child = nodeWithFlatBuffersForSimulator(subNodeTree);
if (child)
{
PageView* pageView = dynamic_cast<PageView*>(node);
ListView* listView = dynamic_cast<ListView*>(node);
if (pageView)
{
Layout* layout = dynamic_cast<Layout*>(child);
if (layout)
{
pageView->addPage(layout);
}
}
else if (listView)
{
Widget* widget = dynamic_cast<Widget*>(child);
if (widget)
{
listView->pushBackCustomItem(widget);
//.........这里部分代码省略.........