Ejemplo n.º 1
0
void ListView::copySpecialProperties(Widget *widget)
{
    ListView* listViewEx = dynamic_cast<ListView*>(widget);
    if (listViewEx)
    {
        ScrollView::copySpecialProperties(widget);
        setItemModel(listViewEx->_model);
        setItemsMargin(listViewEx->_itemsMargin);
        setGravity(listViewEx->_gravity);
    }
}
Ejemplo n.º 2
0
void UIListViewEx::copySpecialProperties(UIWidget *widget)
{
    UIListViewEx* listViewEx = dynamic_cast<UIListViewEx*>(widget);
    if (listViewEx)
    {
        UIScrollView::copySpecialProperties(widget);
        setItemModel(listViewEx->m_pModel);
        setItemsMargin(listViewEx->m_fItemsMargin);
        setGravity(listViewEx->m_eGravity);
    }
}
Ejemplo n.º 3
0
void ListView::copySpecialProperties(Widget *widget)
{
    ListView* listViewEx = dynamic_cast<ListView*>(widget);
    if (listViewEx)
    {
        ScrollView::copySpecialProperties(widget);
        setItemModel(listViewEx->_model);
        setItemsMargin(listViewEx->_itemsMargin);
        setGravity(listViewEx->_gravity);
        _listViewEventListener = listViewEx->_listViewEventListener;
        _listViewEventSelector = listViewEx->_listViewEventSelector;
        _eventCallback = listViewEx->_eventCallback;
    }
}
Ejemplo n.º 4
0
void UI::initListView(){
    auto lv=ListView::create();
    lv->setContentSize(cocos2d::Size(640,480));
    lv->setItemsMargin(20);//设置间隔
    lv->setDirection(cocos2d::ui::ScrollView::Direction::VERTICAL);
        for (int i=0; i<50; i++) {
        auto ub=Button::create();
        ub->loadTextureNormal("0.png");
        ub->loadTexturePressed("1.png");
        ub->loadTextureDisabled("0.png");
        ub->setScale9Enabled(true);
        ub->setContentSize(Size(600,400));
        ub->setPressedActionEnabled(true);
        ub->setZoomScale(0.5f);
        ub->addClickEventListener(CC_CALLBACK_1(UI::buttonClick, this));
        ub->setTag(i);
        lv->pushBackCustomItem(ub);
    }
   
    lv->addEventListener(CC_CALLBACK_2(UI::ListViewCall, this));
    addChild(lv);

}
Ejemplo n.º 5
0
bool OptionScene::init()
{
	if (!Scene::init())
		return false;
	Size visibleSize = Director::getInstance()->getVisibleSize();
	//--·µ»Ø°´Å¥--//
	auto exitScene = [](Ref* pSender) {
		Director::getInstance()->replaceScene(TransitionFlipX::create(0.5f, MainScene::create(), TransitionScene::Orientation::LEFT_OVER));
	};
	auto backItem = MenuItemImage::create("UI/BackNormal.png", "UI/BackSelected.png", exitScene);
	backItem->setPosition(Vec2(backItem->getContentSize().width / 2 + 10, visibleSize.height - backItem->getContentSize().height / 2 - 10));
	auto backMenu = Menu::create(backItem, NULL);
	backMenu->setPosition(Vec2::ZERO);
	this->addChild(backMenu);
	//--¸ù²Ëµ¥--//
	auto rootLayout = createLayout(Lang::get("optionTitle"), this->getContentSize());
	this->addChild(rootLayout);

	auto list = ListView::create();
	list->setDirection(ScrollView::Direction::VERTICAL);
	list->setGravity(ListView::Gravity::CENTER_HORIZONTAL);
	list->setBounceEnabled(true);
	list->setItemsMargin(10);
	list->setContentSize(Size(700, 480));
	list->setAnchorPoint(Vec2(0.5f, 0.5f));
	list->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2 - 20));
	rootLayout->addChild(list);
	//--ÓïÑÔ°´Å¥--//
	auto langButton = createButton(Lang::get("selectLang"), Size(600, 60), [=](Ref* pSender) {
		auto button = (Button*)pSender;
		auto langLayout = createLayout(Lang::get("selectLang"), Size(600, 600));
		auto langList = ListView::create();
		langList->setDirection(ScrollView::Direction::VERTICAL);
		langList->setItemsMargin(10);
		langList->setGravity(ListView::Gravity::CENTER_HORIZONTAL);
		langList->setBounceEnabled(true);
		langList->setContentSize(Size(600, 480));
		langList->setAnchorPoint(Vec2(0.5f, 0.5f));
		langList->setPosition(Vec2(langLayout->getContentSize().width / 2, langLayout->getContentSize().height / 2 - 20));
		langLayout->addChild(langList);
		auto langs = Lang::getAllLangs();

		auto autoLangButton = createButton(Lang::get("autoLang"), Size(500, 60), [this](Ref* pSender) {
			auto button = static_cast<Button*> (pSender);
			highlightingButton->loadTextureNormal("UI/ButtonNormal.png");
			highlightingButton->setContentSize(Size(500, 60));
			highlightingButton = button;
			button->loadTextureNormal("UI/ButtonActive.png");
			button->setContentSize(Size(500, 60));
			Lang::setAutoLang(true);
			Lang::loadAutoLang();
		});
		if (Lang::isAutoLang()) {
			autoLangButton->loadTextureNormal("UI/ButtonActive.png");
			autoLangButton->setContentSize(Size(500, 60));
			highlightingButton = autoLangButton;
		}
		langList->addChild(autoLangButton);
		for (auto i : langs) {
			auto langButton = createButton(i.first, Size(500, 60), [i, this](Ref* pSender) {
				auto button = static_cast<Button*> (pSender);
				highlightingButton->loadTextureNormal("UI/ButtonNormal.png");
				highlightingButton->setContentSize(Size(500, 60));
				highlightingButton = button;
				button->loadTextureNormal("UI/ButtonActive.png");
				button->setContentSize(Size(500, 60));
				Lang::setAutoLang(false);
				Lang::loadLang(i.second);
			});
			if (!Lang::isAutoLang() && i.second == Lang::getCurrentLang()) {
				langButton->loadTextureNormal("UI/ButtonActive.png");
				langButton->setContentSize(Size(500, 60));
				highlightingButton = langButton;
			}
			langList->addChild(langButton);
		}
		goInto(rootLayout, button, langLayout);
		backItem->setCallback([=](Ref* pSender) {
			goOut(rootLayout, button, langLayout);
			backItem->setCallback(exitScene);
		});

	});
	list->addChild(langButton);
	return true;
}
Ejemplo n.º 6
0
void TableSelect::initTable(Size visibleSize,Vec2 origin){
    //layout left
    auto backgroundLeft = M9Path::create("tab_one.9.png",Size(visibleSize.width*0.2f,visibleSize.height*0.75f));
    backgroundLeft->setPosition(origin.x,origin.y+ visibleSize.height/2-backgroundLeft->getContentSize().height/2);
    this->addChild(backgroundLeft);
    
    auto hoatdong = MLabel::create("Hoạt động",32);
    hoatdong->setPosition(Vec2(origin.x+backgroundLeft->getContentSize().width/2-hoatdong->getContentSize().width/2,
                                backgroundLeft->getPosition().y+backgroundLeft->getContentSize().height
                                -1.8f*hoatdong->getContentSize().height));
    this->addChild(hoatdong);
    
    Layout* layoutLeft = Layout::create();
    layoutLeft->setContentSize(Size(backgroundLeft->getWidth()-30,backgroundLeft->getHeight()*5/6));
    layoutLeft->setPosition(Vec2(origin.x+15,origin.y+visibleSize.height*0.125f));
    this->addChild(layoutLeft);
    
    auto lv1 = ListView::create();
    //auto testxxx = MText::create("This is a notification xxxxxx!",15);
    //lv1->setItemModel(testxxx);
    for(int i=0;i<20;i++){
        auto testxxx = MText::create("This is a notification xxxxxx!,nothing.don't look at me!please!",15);
        testxxx->ignoreContentAdaptWithSize(false);
        testxxx->setContentSize(Size(layoutLeft->getContentSize().width,testxxx->getHeight()*2));
        lv1->pushBackCustomItem(testxxx);
    }
    
    lv1->setItemsMargin(10);
    //lv1->setBounceEnabled(true);
    lv1->setGravity(ListView::Gravity::LEFT);
    lv1->setContentSize(layoutLeft->getContentSize());
    //lv1->setPosition(layoutLeft->getPosition());
    lv1->setScrollBarEnabled(false);
    layoutLeft->addChild(lv1);
    
    //==========================Layout Right
    
    
    auto backgroundRight = M9Path::create("tab_two.9.png",Size(visibleSize.width*0.8f,visibleSize.height*0.75f));
    backgroundRight->setPosition(origin.x+visibleSize.width*0.2f,
                                 origin.y+visibleSize.height/2-backgroundRight->getHeight()/2);
    this->addChild(backgroundRight);
    
    auto ban_so = MLabel::create("Bàn số ▿",32);
    ban_so->setPosition(Vec2(origin.x-ban_so->getWidth()/2 + visibleSize.width*0.32f,
                              hoatdong->getPosition().y));
    this->addChild(ban_so);
    
    auto tien_cuoc = MLabel::create("Tiền cược ▿",32);
    tien_cuoc->setPosition(Vec2(origin.x-tien_cuoc->getWidth()/2 + visibleSize.width*0.55f,
                                 hoatdong->getPosition().y));
    this->addChild(tien_cuoc);
    
    auto trang_thai = MLabel::create("Trạng thái ▿",32);
    trang_thai->setPosition(Vec2(origin.x-trang_thai->getWidth()/2 + visibleSize.width*0.76f,
                                  hoatdong->getPosition().y));
    this->addChild(trang_thai);
    
    auto khoa = MLabel::create("Khóa ▿",32);
    khoa->setPosition(Vec2(origin.x-khoa->getWidth()/2 + visibleSize.width*0.945f,
                            hoatdong->getPosition().y));
    this->addChild(khoa);
    
    
    Layout* layoutRight = Layout::create();
    layoutRight->setContentSize(Size(backgroundRight->getWidth()-30,backgroundRight->getHeight()*5/6));
    layoutRight->setPosition(Vec2(origin.x+15+backgroundLeft->getWidth(),origin.y+visibleSize.height*0.125f));
    this->addChild(layoutRight);
    
    auto lvRight = ListView::create();
    //auto model = Button::create();
    //lvRight->setItemModel(model);
    
    for (int i=0; i<20; i++)
    {
        auto bkg_item = Sprite::create("bgr_list_item.png");
        auto number_table = MLabel::create("6",30);
        auto money = MLabel::create("1000 xu",30);
        auto status = MLabel::create("xxx",30);
        
        auto lock = Sprite::create("ic_lock.png");
        auto custom_item = Layout::create();
        
        custom_item->setContentSize(Size(layoutRight->getContentSize().width,lock->getContentSize().height*2));
        
        bkg_item->setScale(layoutRight->getContentSize().width/bkg_item->getContentSize().width,
                           lock->getContentSize().height*2/bkg_item->getContentSize().height);
        bkg_item->setPosition(layoutRight->getContentSize().width/2,custom_item->getContentSize().height/2);
        
        number_table->setPosition(Vec2(number_table->getContentSize().width/2+backgroundRight->getContentSize().width/8,
                                       custom_item->getContentSize().height / 2.0f-number_table->getContentSize().height/2));
        money->setPosition(Vec2(money->getContentSize().width/2+backgroundRight->getContentSize().width*2.5f/8,
                                custom_item->getContentSize().height / 2.0f-money->getContentSize().height/2));
        status->setPosition(Vec2(status->getContentSize().width/2+backgroundRight->getContentSize().width*5/8,
                                 custom_item->getContentSize().height / 2.0f-status->getContentSize().height/2));
        lock->setPosition(Vec2(lock->getContentSize().width/2+backgroundRight->getContentSize().width*7/8,
                               custom_item->getContentSize().height / 2.0f));
        
        custom_item->addChild(bkg_item);
        custom_item->addChild(number_table);
        custom_item->addChild(money);
        custom_item->addChild(status);
        custom_item->addChild(lock);
        lvRight->pushBackCustomItem(custom_item);
    }
    lvRight->setItemsMargin(15);
    lvRight->setBounceEnabled(true);
    lvRight->setGravity(ListView::Gravity::LEFT);
    lvRight->setContentSize(layoutRight->getContentSize());
    layoutRight->addChild(lvRight);
    
    //======
    
    

}