Scrollable* GameLayer::create_center_scrollview() { Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); auto scroll = Scrollable::create(); //scroll->setBackGroundColorType(ui::Layout::BackGroundColorType::SOLID); int scroll_w = sx(800); int scroll_h = sy(400); Size scroll_size = Size(scroll_w, scroll_h); scroll->setContentSize(scroll_size); scroll->setAnchorPoint(Vec2(0.5, 0.5)); scroll->setPosition( this->get_center_pos(0, -sy(50) )); scroll->setDirection(ui::ScrollView::Direction::VERTICAL); this->addChild(scroll); //scroll->setBackGroundColor(Color3B::GREEN); //auto container_size = Size(scroll_w, scroll_h*3); // scroll->setInnerContainerSize(container_size); scroll->setLayoutType(ui::Layout::Type::VERTICAL); // scroll->setBounceEnabled(true); //this sucks, needs to be smoother return scroll; }
/** * \class ds::ui::LayoutButton */ LayoutButton::LayoutButton(SpriteEngine& eng, const float widdy, const float hiddy) : ds::ui::LayoutSprite(eng) , mDown(*(new ds::ui::LayoutSprite(eng))) , mUp(*(new ds::ui::LayoutSprite(eng))) , mButtonBehaviour(*this) , mAnimDuration(0.1f) { setLayoutType(ds::ui::LayoutSprite::kLayoutNone); mUp.mExportWithXml = false; mUp.mLayoutUserType = ds::ui::LayoutSprite::kFillSize; mUp.setLayoutType(ds::ui::LayoutSprite::kLayoutSize); addChild(mUp); mDown.mExportWithXml = false; mDown.mLayoutUserType = ds::ui::LayoutSprite::kFillSize; mDown.setLayoutType(ds::ui::LayoutSprite::kLayoutSize); mDown.setOpacity(0.0f); addChild(mDown); mButtonBehaviour.setOnClickFn([this](){onClicked(); }); // Purely for visual state mButtonBehaviour.setOnDownFn([this](const ds::ui::TouchInfo&){showDown(); }); mButtonBehaviour.setOnEnterFn([this](){showDown(); }); mButtonBehaviour.setOnExitFn([this](){showUp(); }); mButtonBehaviour.setOnUpFn([this](){showUp(); }); }
void KListItem::itemReset( ) { if(layoutType() == KWidget::None) { setLayoutType(KWidget::HBox); setSpacing(3); } QString ico = itemIcon(); QString txt = itemText(); if(m_label == NULL) { m_label = new KLabel(this); addItem(m_label); } if(!ico.isEmpty() && m_icon == NULL) { m_icon = new KImageItem(this); insertItem(m_icon, 0); } if(m_icon) { m_icon->setImagePath(ico); QSize s = m_icon->pixmapSize(); m_icon->setFixWidth(s.width()); } if(m_label) { m_label->setText(txt); } }
bool ListView::init() { if (ScrollView::init()) { setLayoutType(LAYOUT_LINEAR_VERTICAL); return true; } return false; }
void ListView::setDirection(SCROLLVIEW_DIR dir) { switch (dir) { case SCROLLVIEW_DIR_VERTICAL: setLayoutType(LAYOUT_LINEAR_VERTICAL); break; case SCROLLVIEW_DIR_HORIZONTAL: setLayoutType(LAYOUT_LINEAR_HORIZONTAL); break; case SCROLLVIEW_DIR_BOTH: return; default: return; break; } ScrollView::setDirection(dir); }
bool ListView::init() { if (ScrollView::init()) { setLayoutType(Type::VERTICAL); return true; } return false; }
void ListView::setDirection(Direction dir) { switch (dir) { case Direction::VERTICAL: setLayoutType(Type::VERTICAL); break; case Direction::HORIZONTAL: setLayoutType(Type::HORIZONTAL); break; case Direction::BOTH: return; default: return; break; } ScrollView::setDirection(dir); }
bool HBox::init() { if (Layout::init()) { setLayoutType(Layout::Type::HORIZONTAL); return true; } return false; }
bool RelativeBox::init() { if (Layout::init()) { setLayoutType(Layout::Type::RELATIVE); return true; } return false; }
bool VBox::init() { if (Layout::init()) { setLayoutType(Layout::Type::VERTICAL); return true; } return false; }
void HGLayout::setWidget(HGWidget* widget) { //qDebug("HGLayout::setWidget"); mWidget = widget; //todo create layout object setLayoutType(mLayoutType); setMargins(mMargins); setSpacing(mSpacing); }
bool UIListViewEx::init() { if (UIScrollView::init()) { m_pItems = CCArray::create(); CC_SAFE_RETAIN(m_pItems); setLayoutType(LAYOUT_LINEAR_VERTICAL); return true; } return false; }
bool UIListView::init() { if (UIScrollView::init()) { _items = cocos2d::Array::create(); CC_SAFE_RETAIN(_items); setLayoutType(LAYOUT_LINEAR_VERTICAL); return true; } return false; }
SimpleGui::SimpleGui(): xmlgui::Container() { gui = this; addListener(this); setLayoutType(xmlgui::LayoutType_vertical); x = 10; y = 20; isSetup = false; SIMPLE_GUI_WIDTH = 150; autosave = true; autoLayout = true; type = "simplegui"; }
void UILayout::copySpecialProperties(UIWidget *widget) { UILayout* layout = dynamic_cast<UILayout*>(widget); if (layout) { setBackGroundImageScale9Enabled(layout->m_bBackGroundScale9Enabled); setBackGroundImage(layout->m_strBackGroundImageFileName.c_str(),layout->m_eBGImageTexType); setBackGroundImageCapInsets(layout->m_backGroundImageCapInsets); setBackGroundColorType(layout->m_colorType); setBackGroundColor(layout->m_cColor); setBackGroundColor(layout->m_gStartColor, layout->m_gEndColor); setBackGroundColorOpacity(layout->m_nCOpacity); setBackGroundColorVector(layout->m_AlongVector); setLayoutType(layout->m_eLayoutType); setClippingEnabled(layout->m_bClippingEnabled); } }
void Layout::copySpecialProperties(Widget *widget) { Layout* layout = dynamic_cast<Layout*>(widget); if (layout) { setBackGroundImageScale9Enabled(layout->_backGroundScale9Enabled); setBackGroundImage(layout->_backGroundImageFileName,layout->_bgImageTexType); setBackGroundImageCapInsets(layout->_backGroundImageCapInsets); setBackGroundColorType(layout->_colorType); setBackGroundColor(layout->_cColor); setBackGroundColor(layout->_gStartColor, layout->_gEndColor); setBackGroundColorOpacity(layout->_cOpacity); setBackGroundColorVector(layout->_alongVector); setLayoutType(layout->_layoutType); setClippingEnabled(layout->_clippingEnabled); setClippingType(layout->_clippingType); _loopFocus = layout->_loopFocus; _passFocusToChild = layout->_passFocusToChild; _isInterceptTouch = layout->_isInterceptTouch; } }
cocos2d::ui::ScrollView* GameLayer::create_center_scrollview() { Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); auto scroll = ui::ScrollView::create(); //scroll->setBackGroundColorType(ui::Layout::BackGroundColorType::SOLID); int scroll_w = sx(600); int scroll_h = sy(400); Size scroll_size = Size(scroll_w, scroll_h); scroll->setSize(scroll_size); scroll->setAnchorPoint(Vec2(0.5, 0.5)); scroll->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2)); scroll->setDirection(ui::ScrollView::Direction::VERTICAL); this->addChild(scroll); //scroll->setBackGroundColor(Color3B::GREEN); auto container_size = Size(scroll_w, scroll_h*3); scroll->setInnerContainerSize(container_size); scroll->setLayoutType(ui::Layout::Type::VERTICAL); return scroll; }