585 Size widgetSize =
_widget->getContentSize();
588 _displayValueLabel = Text::create(
"ScrollView Disable Test",
"fonts/Marker Felt.ttf", 32);
595 Text* alert = Text::create(
"ScrollView vertical",
"fonts/Marker Felt.ttf", 30);
596 alert->setColor(Color3B(159, 168, 176));
597 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
600 Layout* root =
static_cast<Layout*
>(
_uiLayer->getChildByTag(81));
602 Layout* background =
dynamic_cast<Layout*
>(root->getChildByName(
"background_Panel"));
605 ui::ScrollView* scrollView = ui::ScrollView::create();
606 scrollView->setContentSize(Size(280.0f, 100.0f));
607 Size backgroundSize = background->getContentSize();
608 scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
609 (backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
610 (widgetSize.height - backgroundSize.height) / 2.0f +
611 (backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
612 scrollView->setScrollBarWidth(4);
613 scrollView->setTouchEnabled(
false);
614 scrollView->setScrollBarPositionFromCorner(Vec2(2, 2));
615 scrollView->setScrollBarColor(Color3B::WHITE);
618 ImageView* imageView = ImageView::create(
"cocosui/ccicon.png");
620 float innerWidth = scrollView->getContentSize().width;
621 float innerHeight = scrollView->getContentSize().height + imageView->getContentSize().height;
623 scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
625 Button* button = Button::create(
"cocosui/animationbuttonnormal.png",
"cocosui/animationbuttonpressed.png");
626 button->setPosition(Vec2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getContentSize().height / 2.0f));
627 scrollView->addChild(button);
629 Button* titleButton = Button::create(
"cocosui/backtotopnormal.png",
"cocosui/backtotoppressed.png");
630 titleButton->setTitleText(
"Title Button");
631 titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomBoundary() - button->getContentSize().height));
632 scrollView->addChild(titleButton);
634 Button* button_scale9 = Button::create(
"cocosui/button.png",
"cocosui/buttonHighlighted.png");
635 button_scale9->setScale9Enabled(
true);
636 button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
637 button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomBoundary() - titleButton->getContentSize().height));
638 scrollView->addChild(button_scale9);
640 imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getContentSize().height / 2.0f));
641 scrollView->addChild(imageView);
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget