axmol/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp

64 lines
1.8 KiB
C++
Raw Normal View History

2013-09-16 20:54:13 +08:00
#include "UIImageViewTest.h"
// UIImageViewTest
bool UIImageViewTest::init()
{
if (UIScene::init())
{
2013-12-23 15:35:35 +08:00
Size widgetSize = _widget->getSize();
2013-09-16 20:54:13 +08:00
2014-04-03 10:42:30 +08:00
Text* alert = Text::create("ImageView", "fonts/Marker Felt.ttf", 30);
2013-09-16 20:54:13 +08:00
alert->setColor(Color3B(159, 168, 176));
2014-04-03 10:42:30 +08:00
alert->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
2013-12-23 15:35:35 +08:00
_uiLayer->addChild(alert);
2013-09-16 20:54:13 +08:00
// Create the imageview
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
2014-04-03 10:42:30 +08:00
imageView->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
2013-12-23 15:35:35 +08:00
_uiLayer->addChild(imageView);
2014-04-03 10:42:30 +08:00
2013-09-16 20:54:13 +08:00
return true;
}
return false;
}
// UIImageViewTest_Scale9
bool UIImageViewTest_Scale9::init()
{
if (UIScene::init())
{
2013-12-23 15:35:35 +08:00
Size widgetSize = _widget->getSize();
2013-09-16 20:54:13 +08:00
2014-04-03 10:42:30 +08:00
Text* alert = Text::create("ImageView scale9 render", "fonts/Marker Felt.ttf", 26);
2013-09-16 20:54:13 +08:00
alert->setColor(Color3B(159, 168, 176));
2014-04-03 10:42:30 +08:00
alert->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f - alert->getSize().height * 2.125f));
2013-12-23 15:35:35 +08:00
_uiLayer->addChild(alert);
2013-09-16 20:54:13 +08:00
// Create the imageview
2014-04-03 10:42:30 +08:00
ImageView* imageView = ImageView::create("cocosui/buttonHighlighted.png");
2013-09-16 20:54:13 +08:00
imageView->setScale9Enabled(true);
2014-04-03 10:42:30 +08:00
imageView->setSize(Size(300, 115));
imageView->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
2013-12-23 15:35:35 +08:00
_uiLayer->addChild(imageView);
2013-09-16 20:54:13 +08:00
return true;
}
return false;
2014-03-11 17:13:54 +08:00
}