本文整理汇总了C++中CocoWidget类的典型用法代码示例。如果您正苦于以下问题:C++ CocoWidget类的具体用法?C++ CocoWidget怎么用?C++ CocoWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CocoWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reorderChild
void CocoWidget::reorderChild(CocoWidget* child)
{
this->m_children->removeObject(child);
int childrenCount = this->m_children->count();
if (childrenCount <= 0) {
this->m_children->addObject(child);
}else{
bool seekSucceed = false;
for (int i=childrenCount-1; i>=0; --i) {
CocoWidget* widget = (CocoWidget*)(this->m_children->objectAtIndex(i));
if (child->getWidgetZOrder() >= widget->getWidgetZOrder()) {
if (i == childrenCount-1) {
this->m_children->addObject(child);
seekSucceed = true;
break;
}else{
this->m_children->insertObject(child, i+1);
seekSucceed = true;
break;
}
}
}
if (!seekSucceed) {
this->m_children->insertObject(child,0);
}
}
COCOUISYSTEM->getUIInputManager()->uiSceneHasChanged();
}
示例2: updateChildrenVisibleDirty
void CocoWidget::updateChildrenVisibleDirty(bool dirty)
{
for (int i=0; i<this->getChildren()->count(); i++) {
CocoWidget* child = (CocoWidget*)(this->getChildren()->objectAtIndex(i));
child->m_bVisibleDirty = dirty;
child->updateChildrenVisibleDirty(dirty);
}
}
示例3: getChildByTag
CocoWidget* CocoWidget::getChildByTag(int tag)
{
for (int i=0; i<this->m_children->count(); i++) {
CocoWidget* child = (CocoWidget*)(this->m_children->objectAtIndex(i));
if (child->getWidgetTag() == tag) {
return child;
}
}
return NULL;
}
示例4: CocoWidget
CocoWidget* CocoWidget::create()
{
// return CocoWidget::create(NULL);
CocoWidget* widget = new CocoWidget();
if (widget && widget->init()) {
return widget;
}
CC_SAFE_DELETE(widget);
return NULL;
}
示例5: getChildByName
CocoWidget* CocoWidget::getChildByName(const char *name)
{
for (int i=0; i<this->m_children->count(); i++) {
CocoWidget* child = (CocoWidget*)(this->m_children->objectAtIndex(i));
if (strcmp(child->getName().c_str(), name) == 0) {
return child;
}
}
return NULL;
}
示例6: if
CocoWidget* CCSReader::widgetFromCCDictionary(cocos2d::CCDictionary* data)
{
CocoWidget* widget = NULL;
const char* classname = DICTOOL->getStringValue(data, "classname");
cocos2d::CCDictionary* uiOptions = DICTOOL->getSubDictionary(data, "options");
if (classname && strcmp(classname, "Button") == 0) {
widget = CocoButton::create();
this->setPropsForButtonFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "CheckBox") == 0){
widget = CocoCheckBox::create();
this->setPropsForCheckBoxFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "Label") == 0){
widget = CocoLabel::create();
this->setPropsForLabelFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "LabelAtlas") == 0){
widget = CocoLabelAtlas::create();
this->setPropsForLabelAtlasFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "LoadingBar") == 0){
widget = CocoLoadingBar::create();
this->setPropsForLoadingBarFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "ScrollView") == 0){
widget = CocoScrollView::create();
this->setPropsForScrollViewFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "TextArea") == 0){
widget = CocoTextArea::create();
this->setPropsForTextAreaFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "TextButton") == 0){
widget = CocoTextButton::create();
this->setPropsForTextButtonFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "TextField") == 0){
widget = CocoTextField::create();
this->setPropsForTextFieldFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "ImageView") == 0){
widget = CocoImageView::create();
this->setPropsForImageViewFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "Panel") == 0){
widget = CocoPanel::create();
this->setPropsForPanelFromCCDictionary(widget, uiOptions);
}else if (classname && strcmp(classname, "Slider") == 0){
widget = CocoSlider::create();
this->setPropsForSliderFromCCDictionary(widget, uiOptions);
}
cocos2d::CCArray* arr = DICTOOL->getArrayValue(data, "children");
if (arr) {
for (int i=0;i<arr->count();i++){
cocos2d::CCDictionary* subData = (cocos2d::CCDictionary*)(arr->objectAtIndex(i));
CocoWidget* child = this->widgetFromCCDictionary(subData);
if (child) {
widget->addChild(child);
}
}
}
return widget;
}
示例7: setVisibleTouch
void CocoWidget::setVisibleTouch(bool visible)
{
this->m_bVisibleTouch = visible;
if (this->m_children){
for (int i=0;i<this->m_children->count();i++)
{
CocoWidget* child = (CocoWidget*)(this->m_children->objectAtIndex(i));
child->setVisibleTouch(visible);
}
}
}
示例8: setNeedCheckVisibleDepandParent
void CocoWidget::setNeedCheckVisibleDepandParent(bool need)
{
this->m_bNeedCheckVisibleDependParent = need;
if (this->m_children){
for (int i=0;i<this->m_children->count();i++)
{
CocoWidget* child = (CocoWidget*)(this->m_children->objectAtIndex(i));
child->setNeedCheckVisibleDepandParent(need);
}
}
}
示例9: removeAllChildrenAndCleanUp
void CocoWidget::removeAllChildrenAndCleanUp(bool cleanup)
{
int times = this->m_children->count();
for (int i=0;i<times;i++){
CocoWidget* child = (CocoWidget*)(m_children->lastObject());
m_children->removeObject(child);
child->cleanFromUIInputManager();
child->releaseResoures();
delete child;
child = NULL;
}
}
示例10: getAbsoluteScaleY
float CocoWidget::getAbsoluteScaleY()
{
if (this->m_bScaleYDirty) {
float scaleY = this->getScaleY();
CocoWidget* parent = this->getWidgetParent();
while (parent){
scaleY *= parent->getScaleY();
parent = parent->getWidgetParent();
}
this->m_fAbsoluteScaleY = scaleY;
this->m_bScaleYDirty = false;
}
return this->m_fAbsoluteScaleY;
}
示例11: onTouchPressed
bool UIInputManager::onTouchPressed(float x,float y)
{
this->touchBeganedPoint.x = x;
this->touchBeganedPoint.y = y;
CocoWidget* hitWidget = this->checkEventWidget(this->touchBeganedPoint);
if (!hitWidget || !hitWidget->getActive()){
this->m_pCurSelectedWidget = NULL;
return false;
}
this->m_pCurSelectedWidget = hitWidget;
hitWidget->onTouchPressed(this->touchBeganedPoint);
this->m_bTouchDown = true;
return true;
}
示例12: onTouchCanceled
bool UIInputManager::onTouchCanceled(float x,float y)
{
this->m_bTouchDown = false;
CocoWidget* hitWidget = this->m_pCurSelectedWidget;
if (!hitWidget || !hitWidget->getActive()){
return false;
}
this->touchEndedPoint.x = x;
this->touchEndedPoint.y = y;
hitWidget->onTouchReleased(this->touchEndedPoint);
this->m_pCurSelectedWidget = NULL;
hitWidget = NULL;
return true;
}
示例13: onTouchMoved
bool UIInputManager::onTouchMoved(cocos2d::CCTouch* touch)
{
CocoWidget* hitWidget = this->m_pCurSelectedWidget;
if (!hitWidget || !hitWidget->getActive()){
return false;
}
this->touchMovedPoint.x = touch->getLocation().x;
this->touchMovedPoint.y = touch->getLocation().y;
hitWidget->onTouchMoved(this->touchMovedPoint);
if (this->m_bTouchDown){
this->m_fLongClickRecordTime = 0;
this->m_bTouchDown = false;
}
return true;
}
示例14: getAbsoluteVisible
bool CocoWidget::getAbsoluteVisible()
{
if (this->m_bVisibleDirty) {
CocoWidget* parent = this;
bool visible = this->getVisible();
while (parent){
visible &= parent->getVisible();
if (!visible) {
break;
}
parent = parent->getWidgetParent();
}
this->m_bAbsoluteVisible = visible;
this->m_bVisibleDirty = false;
}
return this->m_bAbsoluteVisible;
}
示例15: update
void UIInputManager::update(float dt)
{
if (this->m_bTouchDown){
this->m_fLongClickRecordTime += dt;
if (this->m_fLongClickRecordTime >= this->m_fLongClickTime){
this->m_fLongClickRecordTime = 0;
this->m_bTouchDown = false;
this->m_pCurSelectedWidget->onTouchLongClicked(this->touchBeganedPoint);
}
}
for (int i=0;i<this->checkedDoubleClickWidget->count();i++){
CocoWidget* widget = (CocoWidget*)(this->checkedDoubleClickWidget->objectAtIndex(i));
if (!widget->getVisible()){
continue;
}
// widget->checkDoubleClick(dt);
}
}