void CCSReader::setPropsForImageViewFromJsonDictionary(CocoWidget*widget,cs::CSJsonDictionary* options) { this->setPropsForWidgetFromJsonDictionary(widget, options); CocoImageView* imageView = (CocoImageView*)widget; const char* imageFileName = DICTOOL->getStringValue_json(options, "fileName"); imageView->setTexture(imageFileName,widget->getUseMergedTexture()); bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); imageView->setFlipX(flipX); imageView->setFlipY(flipY); this->setColorPropsForWidgetFromJsonDictionary(widget,options); }
void CocosGUITestScene::runThisTest() { CCDirector::sharedDirector()->replaceScene(this); ul = UILayer::create(); ul->scheduleUpdate(); this->addChild(ul); ul->addWidget(CCUIHELPER->createWidgetFromFile_json("cocosgui/CocoGUISample.json")); CocoScrollView* sc = (CocoScrollView*)(ul->getWidgetByName("scrollview")); sc->setUpdateEnable(true); sc->setMoveMode(SCROLLVIEW_MOVE_MODE_NORMAL); CocoImageView* image = dynamic_cast<CocoImageView*>(ul->getWidgetByName("imageview")); image->setBeTouchAble(true); // image->addReleaseEvent(this, coco_releaseselector(CocosGUITestScene::MainMenuCallback)); }
void CCSReader::setPropsForImageViewFromJsonDictionary(CocoWidget*widget,cs::CSJsonDictionary* options) { this->setPropsForWidgetFromJsonDictionary(widget, options); CocoImageView* imageView = (CocoImageView*)widget; const char* imageFileName = DICTOOL->getStringValue_json(options, "fileName"); bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); bool scale9Enable = false; if (scale9EnableExist) { scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); } imageView->setScale9Enable(scale9Enable); if (scale9Enable) { float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); imageView->setTexture(imageFileName, widget->getUseMergedTexture()); imageView->setCapInset(cocos2d::CCRect(cx, cy, cw, ch)); bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); if (sw && sh) { float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); imageView->setScale9Size(swf, shf); } } else { imageView->setTexture(imageFileName, widget->getUseMergedTexture()); } bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); imageView->setFlipX(flipX); imageView->setFlipY(flipY); this->setColorPropsForWidgetFromJsonDictionary(widget,options); }