| 116 | } |
| 117 | |
| 118 | void ImageView::loadTexture(std::string_view fileName, TextureResType texType) |
| 119 | { |
| 120 | if (fileName.empty()) |
| 121 | { |
| 122 | return; |
| 123 | } |
| 124 | _textureFile = fileName; |
| 125 | _imageTexType = texType; |
| 126 | switch (_imageTexType) |
| 127 | { |
| 128 | case TextureResType::LOCAL: |
| 129 | _imageRenderer->initWithFile(fileName); |
| 130 | break; |
| 131 | case TextureResType::PLIST: |
| 132 | _imageRenderer->initWithSpriteFrameName(fileName); |
| 133 | break; |
| 134 | default: |
| 135 | break; |
| 136 | } |
| 137 | // FIXME: https://github.com/cocos2d/cocos2d-x/issues/12249 |
| 138 | if (!_ignoreSize && _customSize.equals(Vec2::ZERO)) |
| 139 | { |
| 140 | _customSize = _imageRenderer->getContentSize(); |
| 141 | } |
| 142 | this->setupTexture(); |
| 143 | } |
| 144 | |
| 145 | void ImageView::loadTexture(SpriteFrame* spriteframe) |
| 146 | { |