26#include "ui/UITabControl.h"
30using namespace cocos2d::ui;
32UITabControlTests::UITabControlTests()
52 Size widgetSize =
_widget->getContentSize();
54 auto displayText = Text::create();
58 auto tab = TabControl::create();
59 tab->setContentSize(Size(200.f, 200.f));
60 tab->setHeaderHeight(20.f);
61 tab->setHeaderWidth(70.f);
62 tab->setHeaderSelectedZoom(.1f);
63 tab->setHeaderDockPlace(TabControl::Dock::TOP);
65 auto header1 = TabHeader::create();
66 header1->setTitleText(
"background");
67 header1->loadTextureBackGround(
"cocosui/check_box_normal_disable.png");
68 auto header2 = TabHeader::create(
"cross",
"cocosui/check_box_normal_disable.png",
"cocosui/check_box_active.png");
69 auto header3 = TabHeader::create(
"press&cross",
"cocosui/check_box_normal.png",
70 "cocosui/check_box_normal_press.png",
71 "cocosui/check_box_active.png",
72 "cocosui/check_box_normal_disable.png",
73 "cocosui/check_box_active_disable.png");
75 auto container1 = Layout::create();
76 container1->setOpacity(255);
77 container1->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
78 container1->setBackGroundColor(Color3B::GRAY);
79 container1->setBackGroundColorOpacity(255);
80 auto container2 = Layout::create();
81 container2->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
82 container2->setOpacity(255);
83 container2->setBackGroundColor(Color3B::BLUE);
84 container2->setBackGroundColorOpacity(255);
85 auto container3 = Layout::create();
86 container3->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
87 container3->setOpacity(255);
88 container3->setBackGroundColor(Color3B::RED);
89 container3->setBackGroundColorOpacity(255);
91 tab->insertTab(0, header1, container1);
92 tab->insertTab(1, header2, container2);
93 tab->insertTab(2, header3, container3);
98 tab->setPosition(Vec2(widgetSize.width * .5f, widgetSize.height * .5f));
100 tab->setTabChangedEventListener(
101 [displayText](
int index, TabControl::EventType evtType)
103 displayText->retain();
105 sprintf(display,
"tab %d selected", index);
106 displayText->setString(display);
107 displayText->release();
#define ADD_TEST_CASE(__className__)
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget
static cocos2d::Vec2 bottom()