bool UIListViewTest_Vertical::init() { if (UIScene::init()) { Size widgetSize = _widget->getSize(); _displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f)); _displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); Text* alert = Text::create("ListView vertical", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Point(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")); Size backgroundSize = background->getContentSize(); // create list view ex data _array = Array::create(); CC_SAFE_RETAIN(_array); for (int i = 0; i < 20; ++i) { __String* ccstr = __String::createWithFormat("listview_item_%d", i); _array->addObject(ccstr); } // Create the list view ex ListView* listView = ListView::create(); // set list view ex direction listView->setDirection(SCROLLVIEW_DIR_VERTICAL); listView->setTouchEnabled(true); listView->setBounceEnabled(true); listView->setBackGroundImage("cocosui/green_edit.png"); listView->setBackGroundImageScale9Enabled(true); listView->setSize(Size(240, 130)); listView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - listView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - listView->getSize().height) / 2.0f)); listView->addEventListenerListView(this, listvieweventselector(UIListViewTest_Vertical::selectedItemEvent)); _uiLayer->addChild(listView); // create model Button* default_button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png"); default_button->setName("Title Button"); Layout* default_item = Layout::create(); default_item->setTouchEnabled(true); default_item->setSize(default_button->getSize()); default_button->setPosition(Point(default_item->getSize().width / 2.0f, default_item->getSize().height / 2.0f)); default_item->addChild(default_button); // set model listView->setItemModel(default_item); // add default item ssize_t count = _array->count(); for (int i = 0; i < count / 4; ++i) { listView->pushBackDefaultItem(); } // insert default item for (int i = 0; i < count / 4; ++i) { listView->insertDefaultItem(0); } // add custom item for (int i = 0; i < count / 4; ++i) { Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); custom_button->setName("Title Button"); custom_button->setScale9Enabled(true); custom_button->setSize(default_button->getSize()); Layout *custom_item = Layout::create(); custom_item->setSize(custom_button->getSize()); custom_button->setPosition(Point(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); custom_item->addChild(custom_button); listView->pushBackCustomItem(custom_item); } // insert custom item Vector<Widget*>& items = listView->getItems(); ssize_t items_count = items.size(); for (int i = 0; i < count / 4; ++i) { Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); custom_button->setName("Title Button"); custom_button->setScale9Enabled(true); custom_button->setSize(default_button->getSize()); Layout *custom_item = Layout::create(); custom_item->setSize(custom_button->getSize()); custom_button->setPosition(Point(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); custom_item->addChild(custom_button); listView->insertCustomItem(custom_item, items_count); } // set item data items_count = items.size(); for (int i = 0; i < items_count; ++i) { Widget* item = listView->getItem(i); Button* button = static_cast<Button*>(item->getChildByName("Title Button")); ssize_t index = listView->getIndex(item); button->setTitleText(static_cast<__String*>(_array->getObjectAtIndex(index))->getCString()); } // remove last item listView->removeLastItem(); // remove item by index items_count = items.size(); listView->removeItem(items_count - 1); // set all items layout gravity listView->setGravity(LISTVIEW_GRAVITY_CENTER_VERTICAL); // set items margin listView->setItemsMargin(2.0f); return true; } return false; }
bool UIListViewTest_Horizontal::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); _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.5f)); _uiLayer->addChild(_displayValueLabel); Text* alert = Text::create("ListView horizontal", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = static_cast<Layout*>(root->getChildByName("background_Panel")); Size backgroundSize = background->getContentSize(); // create list view ex data for (int i = 0; i < 20; ++i) { std::string ccstr = StringUtils::format("listview_item_%d", i); _array.push_back(ccstr); } // Create the list view ex ListView* listView = ListView::create(); // set list view ex direction listView->setDirection(ui::ScrollView::Direction::HORIZONTAL); listView->setTouchEnabled(true); listView->setBounceEnabled(true); listView->setBackGroundImage("cocosui/green_edit.png"); listView->setBackGroundImageScale9Enabled(true); listView->setContentSize(Size(240, 130)); listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - listView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - listView->getContentSize().height) / 2.0f)); listView->addEventListener((ui::ListView::ccListViewCallback)CC_CALLBACK_2(UIListViewTest_Horizontal::selectedItemEvent, this)); _uiLayer->addChild(listView); // create model Button* default_button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png"); default_button->setName("Title Button"); Layout *default_item = Layout::create(); default_item->setTouchEnabled(true); default_item->setContentSize(default_button->getContentSize()); default_button->setPosition(Vec2(default_item->getContentSize().width / 2.0f, default_item->getContentSize().height / 2.0f)); default_item->addChild(default_button); // set model listView->setItemModel(default_item); // add default item ssize_t count = _array.size(); for (int i = 0; i < count / 4; ++i) { listView->pushBackDefaultItem(); } // insert default item for (int i = 0; i < count / 4; ++i) { listView->insertDefaultItem(0); } // add custom item for (int i = 0; i < count / 4; ++i) { Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); custom_button->setName("Title Button"); custom_button->setScale9Enabled(true); custom_button->setContentSize(default_button->getContentSize()); Layout* custom_item = Layout::create(); custom_item->setContentSize(custom_button->getContentSize()); custom_button->setPosition(Vec2(custom_item->getContentSize().width / 2.0f, custom_item->getContentSize().height / 2.0f)); custom_item->addChild(custom_button); listView->pushBackCustomItem(custom_item); } // insert custom item Vector<Widget*>& items = listView->getItems(); ssize_t items_count = items.size(); for (int i = 0; i < count / 4; ++i) { Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); custom_button->setName("Title Button"); custom_button->setScale9Enabled(true); custom_button->setContentSize(default_button->getContentSize()); Layout* custom_item = Layout::create(); custom_item->setContentSize(custom_button->getContentSize()); custom_button->setPosition(Vec2(custom_item->getContentSize().width / 2.0f, custom_item->getContentSize().height / 2.0f)); custom_item->addChild(custom_button); listView->insertCustomItem(custom_item, items_count); } // set item data items_count = items.size(); for (int i = 0; i < items_count; ++i) { Widget *item = listView->getItem(i); Button *button = static_cast<Button*>(item->getChildByName("Title Button")); ssize_t index = listView->getIndex(item); button->setTitleText(_array[index]); } // remove last item listView->removeLastItem(); // remove item by index items_count = items.size(); listView->removeItem(items_count - 1); // set all items layout gravity listView->setGravity(ListView::Gravity::CENTER_VERTICAL); // set items margin listView->setItemsMargin(2); return true; } return false; }
bool Issue8316::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); auto label = Text::create("Issue 8316", "fonts/Marker Felt.ttf", 32); label->setAnchorPoint(Vec2(0.5f, -1.0f)); label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + label->getContentSize().height * 1.5f)); _uiLayer->addChild(label); Text* alert = Text::create("ListView Disable Touch", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); Size backgroundSize = background->getContentSize(); // Create the list view ex ListView* listView = ListView::create(); // set list view ex direction listView->setDirection(ui::ScrollView::Direction::VERTICAL); listView->setBounceEnabled(true); listView->setTouchEnabled(false); listView->setBackGroundImage("cocosui/green_edit.png"); listView->setBackGroundImageScale9Enabled(true); listView->setContentSize(Size(240, 130)); listView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - listView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - listView->getContentSize().height) / 2.0f)); listView->setScrollBarPositionFromCorner(Vec2(7, 7)); listView->setClippingEnabled(true); listView->setClippingType(ui::Layout::ClippingType::SCISSOR); listView->setName("listview1"); { Button* default_button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png"); default_button->setName("Title Button"); Layout* default_item = Layout::create(); default_item->setTouchEnabled(true); default_item->setContentSize(default_button->getContentSize()); default_button->setPosition(Vec2(default_item->getContentSize().width / 2.0f, default_item->getContentSize().height / 2.0f)); default_item->addChild(default_button); // set model listView->setItemModel(default_item); listView->pushBackDefaultItem(); listView->pushBackDefaultItem(); listView->pushBackDefaultItem(); } _uiLayer->addChild(listView); return true; } return false; }
void ListViewReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *listViewOptions) { ListView* listView = static_cast<ListView*>(node); auto options = (ListViewOptions*)listViewOptions; bool clipEnabled = options->clipEnabled(); listView->setClippingEnabled(clipEnabled); bool backGroundScale9Enabled = options->backGroundScale9Enabled(); listView->setBackGroundImageScale9Enabled(backGroundScale9Enabled); auto f_bgColor = options->bgColor(); Color3B bgColor(f_bgColor->r(), f_bgColor->g(), f_bgColor->b()); auto f_bgStartColor = options->bgStartColor(); Color3B bgStartColor(f_bgStartColor->r(), f_bgStartColor->g(), f_bgStartColor->b()); auto f_bgEndColor = options->bgEndColor(); Color3B bgEndColor(f_bgEndColor->r(), f_bgEndColor->g(), f_bgEndColor->b()); auto f_colorVecor = options->colorVector(); Vec2 colorVector(f_colorVecor->vectorX(), f_colorVecor->vectorY()); listView->setBackGroundColorVector(colorVector); int bgColorOpacity = options->bgColorOpacity(); int colorType = options->colorType(); listView->setBackGroundColorType(Layout::BackGroundColorType(colorType)); listView->setBackGroundColor(bgStartColor, bgEndColor); listView->setBackGroundColor(bgColor); listView->setBackGroundColorOpacity(bgColorOpacity); auto imageFileNameDic = options->backGroundImageData(); int imageFileNameType = imageFileNameDic->resourceType(); std::string imageFileName = imageFileNameDic->path()->c_str(); listView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType); if (backGroundScale9Enabled) { auto f_capInsets = options->capInsets(); Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); listView->setBackGroundImageCapInsets(capInsets); auto f_scale9Size = options->scale9Size(); Size scale9Size(f_scale9Size->width(), f_scale9Size->height()); listView->setContentSize(scale9Size); } auto widgetOptions = options->widgetOptions(); auto f_color = widgetOptions->color(); Color3B color(f_color->r(), f_color->g(), f_color->b()); listView->setColor(color); int opacity = widgetOptions->alpha(); listView->setOpacity(opacity); auto f_innerSize = options->innerSize(); Size innerSize(f_innerSize->width(), f_innerSize->height()); listView->setInnerContainerSize(innerSize); int direction = options->direction(); listView->setDirection((ScrollView::Direction)direction); bool bounceEnabled = options->bounceEnabled(); listView->setBounceEnabled(bounceEnabled); int gravityValue = options->gravity(); ListView::Gravity gravity = (ListView::Gravity)gravityValue; listView->setGravity(gravity); float itemMargin = options->itemMargin(); listView->setItemsMargin(itemMargin); auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); }
bool UIListViewTest_Vertical::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); _displayValueLabel = Text::create("Move by vertical 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.5f)); _uiLayer->addChild(_displayValueLabel); Text* alert = Text::create("ListView vertical", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); Size backgroundSize = background->getContentSize(); // create list view ex data for (int i = 0; i < 20; ++i) { std::string ccstr = StringUtils::format("listview_item_%d", i); _array.push_back(ccstr); } // Create the list view ex ListView* listView = ListView::create(); // set list view ex direction listView->setDirection(ui::ScrollView::Direction::VERTICAL); listView->setBounceEnabled(true); listView->setBackGroundImage("cocosui/green_edit.png"); listView->setBackGroundImageScale9Enabled(true); listView->setContentSize(Size(240, 130)); listView->setPosition(Vec2((widgetSize - listView->getContentSize()) / 2.0f)); listView->addEventListener((ui::ListView::ccListViewCallback)CC_CALLBACK_2(UIListViewTest_Vertical::selectedItemEvent, this)); listView->addEventListener((ui::ListView::ccScrollViewCallback)CC_CALLBACK_2(UIListViewTest_Vertical::selectedItemEventScrollView,this)); listView->setScrollBarPositionFromCorner(Vec2(7, 7)); _uiLayer->addChild(listView); // create model Button* default_button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png"); default_button->setName("Title Button"); Layout* default_item = Layout::create(); default_item->setTouchEnabled(true); default_item->setContentSize(default_button->getContentSize()); default_button->setPosition(Vec2(default_item->getContentSize() / 2.0f)); default_item->addChild(default_button); // set model listView->setItemModel(default_item); // add default item ssize_t count = _array.size(); for (int i = 0; i < count / 4; ++i) { listView->pushBackDefaultItem(); } // insert default item for (int i = 0; i < count / 4; ++i) { listView->insertDefaultItem(0); } listView->removeAllChildren(); Sprite* testSprite = Sprite::create("cocosui/backtotoppressed.png"); testSprite->setPosition(Vec2(200,200)); listView->addChild(testSprite); // add custom item for (int i = 0; i < count / 4; ++i) { Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); custom_button->setName("Title Button"); custom_button->setScale9Enabled(true); custom_button->setContentSize(default_button->getContentSize()); Layout *custom_item = Layout::create(); custom_item->setContentSize(custom_button->getContentSize()); custom_button->setPosition(Vec2(custom_item->getContentSize().width / 2.0f, custom_item->getContentSize().height / 2.0f)); custom_item->addChild(custom_button); listView->addChild(custom_item); } // insert custom item Vector<Widget*>& items = listView->getItems(); ssize_t items_count = items.size(); for (int i = 0; i < count / 4; ++i) { Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); custom_button->setName("Title Button"); custom_button->setScale9Enabled(true); custom_button->setContentSize(default_button->getContentSize()); Layout *custom_item = Layout::create(); custom_item->setContentSize(custom_button->getContentSize()); custom_button->setPosition(Vec2(custom_item->getContentSize().width / 2.0f, custom_item->getContentSize().height / 2.0f)); custom_item->addChild(custom_button); custom_item->setTag(1); listView->insertCustomItem(custom_item, items_count); } // set item data items_count = items.size(); for (int i = 0; i < items_count; ++i) { Widget* item = listView->getItem(i); Button* button = static_cast<Button*>(item->getChildByName("Title Button")); ssize_t index = listView->getIndex(item); button->setTitleText(_array[index]); } // remove last item listView->removeChildByTag(1); // remove item by index items_count = items.size(); listView->removeItem(items_count - 1); // set all items layout gravity listView->setGravity(ListView::Gravity::CENTER_VERTICAL); // set items margin listView->setItemsMargin(2.0f); // Show the indexes of items on each boundary. { float position = 75; // Labels _indexLabels[0] = Text::create(" ", "fonts/Marker Felt.ttf", 12); _indexLabels[0]->setAnchorPoint(Vec2::ANCHOR_MIDDLE); _indexLabels[0]->setPosition(_uiLayer->getContentSize() / 2 + Size(0, position)); _uiLayer->addChild(_indexLabels[0]); _indexLabels[1] = Text::create(" ", "fonts/Marker Felt.ttf", 12); _indexLabels[1]->setAnchorPoint(Vec2::ANCHOR_MIDDLE); _indexLabels[1]->setPosition(_uiLayer->getContentSize() / 2 + Size(140, 0)); _uiLayer->addChild(_indexLabels[1]); _indexLabels[2] = Text::create(" ", "fonts/Marker Felt.ttf", 12); _indexLabels[2]->setAnchorPoint(Vec2::ANCHOR_MIDDLE); _indexLabels[2]->setPosition(_uiLayer->getContentSize() / 2 + Size(0, -position)); _uiLayer->addChild(_indexLabels[2]); // Callback listView->ScrollView::addEventListener([this](Ref* ref, ScrollView::EventType eventType) { ListView* listView = dynamic_cast<ListView*>(ref); if(listView == nullptr || eventType != ScrollView::EventType::CONTAINER_MOVED) { return; } auto bottom = listView->getBottommostItemInCurrentView(); auto center = listView->getCenterItemInCurrentView(); auto top = listView->getTopmostItemInCurrentView(); _indexLabels[0]->setString(StringUtils::format("Top index=%zd", listView->getIndex(top))); _indexLabels[1]->setString(StringUtils::format("Center\nindex=%zd", listView->getIndex(center))); _indexLabels[2]->setString(StringUtils::format("Bottom index=%zd", listView->getIndex(bottom))); }); } return true; } return false; }
//运输机内士兵 void UIConveyorLayer::showConveyorInfoLayer() { auto node = this->getContentInfoNode(); auto Nodesize = Size(node->getContentSize().width/2.5,node->getContentSize().height); if(m_ConveyorInfolist) { m_ConveyorInfolist->removeAllItems(); } else { ListView* listView = ListView::create(); // set list view ex direction listView->setDirection(SCROLLVIEW_DIR_VERTICAL); listView->setTouchEnabled(true); listView->setBounceEnabled(true); listView->setBackGroundImage("dian9/[email protected]"); //背景图 listView->setBackGroundImageScale9Enabled(true); //是否用的是点9图 listView->setSize(Nodesize*0.98f); listView->setPosition(Point(120,5)); node->addChild(listView); m_ConveyorInfolist = listView; } int i = 1; auto info = ConveyorConfig::getConveyorConfigFromId(m_iCurState); if(info) { auto iter = info->soldieritems.begin(); for (iter;iter != info->soldieritems.end(); iter++) { auto iteminfo = (*iter); while (iteminfo->number == 0) { iter++; if(iter == info->soldieritems.end())return; iteminfo = (*iter); } auto soldierInfo = SoldierConfig::getSoldierConfig(iteminfo->soldierid); if(!soldierInfo){ return ; } auto layer1 = UISoldierHeadLayer::create(soldierInfo,iteminfo->number,true); layer1->getCurDownLayer()->setVisible(false); layer1->setIsTopVisible(false); layer1->setRecruitCallBack(CC_CALLBACK_1( UIConveyorLayer::ReductionSoldier,this)); layer1->setTag(i); iter++; i++; if(iter != info->soldieritems.end()) { auto iteminfo = (*iter); while (iteminfo->number == 0) { iter++; if(iter == info->soldieritems.end()){ auto tmpnode = getOneItem(layer1,nullptr); Layout* custom_item = Layout::create(); custom_item->setSize(tmpnode->getContentSize()); tmpnode->setPosition(Point(custom_item->getSize().width / 2.0f-tmpnode->getContentSize().width/2, custom_item->getSize().height / 2.0f-tmpnode->getContentSize().height/2)); custom_item->addChild(tmpnode); m_ConveyorInfolist->pushBackCustomItem(custom_item); return; } iteminfo = (*iter); } soldierInfo = SoldierConfig::getSoldierConfig(iteminfo->soldierid); if(!soldierInfo){ return ; } auto layer2 = UISoldierHeadLayer::create(soldierInfo,iteminfo->number,true); layer2->getCurDownLayer()->setVisible(false); layer2->setIsTopVisible(false); layer2->setRecruitCallBack(CC_CALLBACK_1( UIConveyorLayer::ReductionSoldier,this)); layer2->setTag(i); auto tmpnode = getOneItem(layer1,layer2); Layout* custom_item = Layout::create(); custom_item->setSize(tmpnode->getContentSize()); tmpnode->setPosition(Point(custom_item->getSize().width / 2.0f-tmpnode->getContentSize().width/2, custom_item->getSize().height / 2.0f-tmpnode->getContentSize().height/2)); custom_item->addChild(tmpnode); m_ConveyorInfolist->pushBackCustomItem(custom_item); } else { auto tmpnode = getOneItem(layer1,nullptr); Layout* custom_item = Layout::create(); custom_item->setSize(tmpnode->getContentSize()); tmpnode->setPosition(Point(custom_item->getSize().width / 2.0f-tmpnode->getContentSize().width/2, custom_item->getSize().height / 2.0f-tmpnode->getContentSize().height/2)); custom_item->addChild(tmpnode); m_ConveyorInfolist->pushBackCustomItem(custom_item); return ; } } } }
void ListViewReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *listViewOptions) { ListView* listView = static_cast<ListView*>(node); auto options = (ListViewOptions*)listViewOptions; bool clipEnabled = options->clipEnabled(); listView->setClippingEnabled(clipEnabled); bool backGroundScale9Enabled = options->backGroundScale9Enabled(); listView->setBackGroundImageScale9Enabled(backGroundScale9Enabled); auto f_bgColor = options->bgColor(); Color3B bgColor(f_bgColor->r(), f_bgColor->g(), f_bgColor->b()); auto f_bgStartColor = options->bgStartColor(); Color3B bgStartColor(f_bgStartColor->r(), f_bgStartColor->g(), f_bgStartColor->b()); auto f_bgEndColor = options->bgEndColor(); Color3B bgEndColor(f_bgEndColor->r(), f_bgEndColor->g(), f_bgEndColor->b()); auto f_colorVecor = options->colorVector(); Vec2 colorVector(f_colorVecor->vectorX(), f_colorVecor->vectorY()); listView->setBackGroundColorVector(colorVector); int bgColorOpacity = options->bgColorOpacity(); int colorType = options->colorType(); listView->setBackGroundColorType(Layout::BackGroundColorType(colorType)); listView->setBackGroundColor(bgStartColor, bgEndColor); listView->setBackGroundColor(bgColor); listView->setBackGroundColorOpacity(bgColorOpacity); auto imageFileNameDic = options->backGroundImageData(); int imageFileNameType = imageFileNameDic->resourceType(); std::string imageFileName = imageFileNameDic->path()->c_str(); listView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType); auto widgetOptions = options->widgetOptions(); auto f_color = widgetOptions->color(); Color3B color(f_color->r(), f_color->g(), f_color->b()); listView->setColor(color); int opacity = widgetOptions->alpha(); listView->setOpacity(opacity); auto f_innerSize = options->innerSize(); Size innerSize(f_innerSize->width(), f_innerSize->height()); listView->setInnerContainerSize(innerSize); bool bounceEnabled = options->bounceEnabled(); listView->setBounceEnabled(bounceEnabled); std::string directionType = options->directionType()->c_str(); if (directionType == "") { listView->setDirection(ListView::Direction::HORIZONTAL); std::string verticalType = options->verticalType()->c_str(); if (verticalType == "") { listView->setGravity(ListView::Gravity::TOP); } else if (verticalType == "Align_Bottom") { listView->setGravity(ListView::Gravity::BOTTOM); } else if (verticalType == "Align_VerticalCenter") { listView->setGravity(ListView::Gravity::CENTER_VERTICAL); } } else if (directionType == "Vertical") { listView->setDirection(ListView::Direction::VERTICAL); std::string horizontalType = options->horizontalType()->c_str(); if (horizontalType == "") { listView->setGravity(ListView::Gravity::LEFT); } else if (horizontalType == "Align_Right") { listView->setGravity(ListView::Gravity::RIGHT); } else if (horizontalType == "Align_HorizontalCenter") { listView->setGravity(ListView::Gravity::CENTER_HORIZONTAL); } } float itemMargin = options->itemMargin(); listView->setItemsMargin(itemMargin); auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); if (backGroundScale9Enabled) { auto f_capInsets = options->capInsets(); Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); listView->setBackGroundImageCapInsets(capInsets); auto f_scale9Size = options->scale9Size(); Size scale9Size(f_scale9Size->width(), f_scale9Size->height()); listView->setContentSize(scale9Size); } else { auto widgetOptions = options->widgetOptions(); if (!listView->isIgnoreContentAdaptWithSize()) { Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); listView->setContentSize(contentSize); } } }