当前位置: 首页>>代码示例>>C++>>正文


C++ ImageView::ignoreContentAdaptWithSize方法代码示例

本文整理汇总了C++中ImageView::ignoreContentAdaptWithSize方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageView::ignoreContentAdaptWithSize方法的具体用法?C++ ImageView::ignoreContentAdaptWithSize怎么用?C++ ImageView::ignoreContentAdaptWithSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageView的用法示例。


在下文中一共展示了ImageView::ignoreContentAdaptWithSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setPropsWithFlatBuffers

 void ImageViewReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *imageViewOptions)
 {
     ImageView* imageView = static_cast<ImageView*>(node);
     auto options = (ImageViewOptions*)imageViewOptions;
     
     
     auto imageFileNameDic = options->fileNameData();
     int imageFileNameType = imageFileNameDic->resourceType();
     std::string imageFileName = imageFileNameDic->path()->c_str();
     imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
     
     bool scale9Enabled = options->scale9Enabled();
     imageView->setScale9Enabled(scale9Enabled);
     
     auto widgetReader = WidgetReader::getInstance();
     widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
     
     if (scale9Enabled)
     {
         imageView->setUnifySizeEnabled(false);
         imageView->ignoreContentAdaptWithSize(false);
         
         auto f_scale9Size = options->scale9Size();
         Size scale9Size(f_scale9Size->width(), f_scale9Size->height());
         imageView->setContentSize(scale9Size);
         
         
         auto f_capInset = options->capInsets();
         Rect capInsets(f_capInset->x(), f_capInset->y(), f_capInset->width(), f_capInset->height());
         imageView->setCapInsets(capInsets);
     }
     
 }
开发者ID:1097195326,项目名称:GameAreas,代码行数:33,代码来源:ImageViewReader.cpp

示例2: init

bool UIImageViewFlipTest::init()
{
    if (UIScene::init())
    {
        SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/blocks9ss.plist");
        Size widgetSize = _widget->getContentSize();
        
        Text* alert = Text::create("ImageView flip test", "fonts/Marker Felt.ttf", 26);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Vec2(widgetSize.width / 2.0f,
                                widgetSize.height / 2.0f - alert->getContentSize().height * 2.125f));
        
        _uiLayer->addChild(alert);
        
        // Create the imageview
        ImageView* imageView = ImageView::create("blocks9r.png", Widget::TextureResType::PLIST);
        imageView->setScale9Enabled(true);
        imageView->setContentSize(Size(250, 115));
        imageView->setFlippedX(true);
        imageView->setScale(0.5);
        imageView->ignoreContentAdaptWithSize(false);
        imageView->setPosition(Vec2(widgetSize.width / 2.0f,
                                    widgetSize.height / 2.0f));
        
        _uiLayer->addChild(imageView);
        
        auto toggleButton = Button::create();
        toggleButton->setTitleText("Toggle FlipX");
        toggleButton->setPosition(imageView->getPosition() + Vec2(-50, - imageView->getContentSize().height/2 - 20));
        this->addChild(toggleButton);
        toggleButton->addClickEventListener([=](Ref*){
            imageView->setFlippedX(!imageView->isFlippedX());
        });
        
        auto toggleScale9 = Button::create();
        toggleScale9->setTitleText("Toggle Scale9");
        toggleScale9->setPosition(imageView->getPosition() + Vec2(+50, - imageView->getContentSize().height/2- 20));
        this->addChild(toggleScale9);
        toggleScale9->addClickEventListener([=](Ref*){
            imageView->setScale9Enabled(!imageView->isScale9Enabled());
            //after switching scale9, you must call setContentSize to keep the size not change
             imageView->setContentSize(Size(250, 115));
        });
        
        return true;
    }
    return false;
}
开发者ID:AomXD,项目名称:workspace,代码行数:48,代码来源:UIImageViewTest.cpp

示例3: setPropsFromProtocolBuffers

    void ImageViewReader::setPropsFromProtocolBuffers(ui::Widget *widget, const protocolbuffers::NodeTree &nodeTree)
    {
        WidgetReader::setPropsFromProtocolBuffers(widget, nodeTree);
        
        const protocolbuffers::ImageViewOptions& options = nodeTree.imageviewoptions();        
        ImageView* imageView = static_cast<ImageView*>(widget);

		std::string protocolBuffersPath = GUIReader::getInstance()->getFilePath();
        
        const protocolbuffers::ResourceData& imageFileNameDic = options.filenamedata();
        int imageFileNameType = imageFileNameDic.resourcetype();
        std::string imageFileName = this->getResourcePath(imageFileNameDic.path(), (Widget::TextureResType)imageFileNameType);
        imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
        
        
        bool scale9EnableExist = options.has_scale9enable();
        bool scale9Enable = false;
        if (scale9EnableExist)
        {
            scale9Enable = options.scale9enable();
        }
        imageView->setScale9Enabled(scale9Enable);
        
        
        if (scale9Enable)
        {
            imageView->setUnifySizeEnabled(false);
            imageView->ignoreContentAdaptWithSize(false);
            
            float swf = options.has_scale9width() ? options.scale9width() : 80.0f;
            float shf = options.has_scale9height() ? options.scale9height() : 80.0f;
            imageView->setContentSize(Size(swf, shf));
            
            
            float cx = options.capinsetsx();
            float cy = options.capinsetsy();
            float cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1.0;
            float ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1.0;
            
            imageView->setCapInsets(Rect(cx, cy, cw, ch));
            
        }
        
        // other commonly protperties
        WidgetReader::setColorPropsFromProtocolBuffers(widget, nodeTree);
    }
开发者ID:SunLightJuly,项目名称:Quick-PrebuiltRuntimeLua,代码行数:46,代码来源:ImageViewReader.cpp

示例4:

bool UIImageViewTest_Scale9_State_Change::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getContentSize();

        Text* alert = Text::create("Click The Image", "fonts/Marker Felt.ttf", 26);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Vec2(widgetSize.width / 2.0f,
            widgetSize.height / 2.0f - alert->getContentSize().height * 2.125f));

        _uiLayer->addChild(alert);

        // Create the imageview
        ImageView* imageView = ImageView::create("cocosui/ccicon.png");
        imageView->ignoreContentAdaptWithSize(false);
        imageView->setScale9Enabled(true);
        imageView->setContentSize(Size(100, 100));
        imageView->setCapInsets(Rect(20,20,20,20));
        imageView->setPosition(Vec2(widgetSize.width / 2.0f,
            widgetSize.height / 2.0f));

        imageView->setTouchEnabled(true);
        imageView->addTouchEventListener([=](Ref* sender, Widget::TouchEventType type){
            if (type == Widget::TouchEventType::ENDED) {
                if (imageView->isScale9Enabled())
                {
                    imageView->setScale9Enabled(false);
                }
                else
                    imageView->setScale9Enabled(true);
            }
        });

        _uiLayer->addChild(imageView);

        return true;
    }
    return false;
}
开发者ID:AomXD,项目名称:workspace,代码行数:40,代码来源:UIImageViewTest.cpp

示例5: setPropsWithFlatBuffers

 void ImageViewReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *imageViewOptions)
 {
     ImageView* imageView = static_cast<ImageView*>(node);
     auto options = (ImageViewOptions*)imageViewOptions;
     
     
     bool fileExist = false;
     std::string errorFilePath = "";
     auto imageFileNameDic = options->fileNameData();
     int imageFileNameType = imageFileNameDic->resourceType();
     std::string imageFileName = imageFileNameDic->path()->c_str();
     switch (imageFileNameType)
     {
         case 0:
         {
             if (FileUtils::getInstance()->isFileExist(imageFileName))
             {
                 fileExist = true;
             }
             else
             {
                 errorFilePath = imageFileName;
                 fileExist = false;
             }
             break;
         }
             
         case 1:
         {
             std::string plist = imageFileNameDic->plistFile()->c_str();
             SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
             if (spriteFrame)
             {
                 fileExist = true;
             }
             else
             {
                 if (FileUtils::getInstance()->isFileExist(plist))
                 {
                     ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
                     ValueMap metadata = value["metadata"].asValueMap();
                     std::string textureFileName = metadata["textureFileName"].asString();
                     if (!FileUtils::getInstance()->isFileExist(textureFileName))
                     {
                         errorFilePath = textureFileName;
                     }
                 }
                 else
                 {
                     errorFilePath = plist;
                 }
                 fileExist = false;
             }
             break;
         }
             
         default:
             break;
     }
     if (fileExist)
     {
         imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
     }
     //else
     //{
     //    auto label = Label::create();
     //    label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
     //    imageView->addChild(label);
     //}
     
     bool scale9Enabled = options->scale9Enabled() != 0;
     imageView->setScale9Enabled(scale9Enabled);
     
     auto widgetReader = WidgetReader::getInstance();
     widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
     
     if (scale9Enabled)
     {
         imageView->setUnifySizeEnabled(false);
         imageView->ignoreContentAdaptWithSize(false);
         
         auto f_scale9Size = options->scale9Size();
         Size scale9Size(f_scale9Size->width(), f_scale9Size->height());
         imageView->setContentSize(scale9Size);
         
         
         auto f_capInset = options->capInsets();
         Rect capInsets(f_capInset->x(), f_capInset->y(), f_capInset->width(), f_capInset->height());
         imageView->setCapInsets(capInsets);
     }
     else
     {
         Size contentSize(options->widgetOptions()->size()->width(), options->widgetOptions()->size()->height());
         imageView->setContentSize(contentSize);
     }
 }
开发者ID:DominicD,项目名称:Hyperdrive,代码行数:96,代码来源:ImageViewReader.cpp


注:本文中的ImageView::ignoreContentAdaptWithSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。