| 2189 | } |
| 2190 | |
| 2191 | void RichText::handleImageRenderer(std::string_view filePath, |
| 2192 | Widget::TextureResType textureType, |
| 2193 | const Color3B& /*color*/, |
| 2194 | uint8_t /*opacity*/, |
| 2195 | int width, |
| 2196 | int height, |
| 2197 | std::string_view url, |
| 2198 | float scaleX, |
| 2199 | float scaleY, |
| 2200 | std::string_view id) |
| 2201 | { |
| 2202 | Sprite* imageRenderer; |
| 2203 | if (textureType == Widget::TextureResType::LOCAL) |
| 2204 | imageRenderer = Sprite::create(filePath); |
| 2205 | else |
| 2206 | imageRenderer = Sprite::createWithSpriteFrameName(filePath); |
| 2207 | |
| 2208 | if (imageRenderer) |
| 2209 | { |
| 2210 | auto currentSize = imageRenderer->getContentSize(); |
| 2211 | if (width != -1) |
| 2212 | imageRenderer->setScaleX(width / currentSize.width); |
| 2213 | if (height != -1) |
| 2214 | imageRenderer->setScaleY(height / currentSize.height); |
| 2215 | |
| 2216 | imageRenderer->setName(id); |
| 2217 | |
| 2218 | imageRenderer->setScaleX(imageRenderer->getScaleX() * scaleX); |
| 2219 | imageRenderer->setScaleY(imageRenderer->getScaleY() * scaleY); |
| 2220 | |
| 2221 | imageRenderer->setContentSize( |
| 2222 | Vec2(currentSize.width * imageRenderer->getScaleX(), currentSize.height * imageRenderer->getScaleY())); |
| 2223 | imageRenderer->setScale(1.f, 1.f); |
| 2224 | handleCustomRenderer(imageRenderer); |
| 2225 | imageRenderer->addComponent( |
| 2226 | UrlTouchListenerComponent::create(imageRenderer, url, [this](std::string_view url) { openUrl(url); })); |
| 2227 | } |
| 2228 | } |
| 2229 | |
| 2230 | void RichText::handleCustomRenderer(ax::Node* renderer, std::string_view id) |
| 2231 | { |
nothing calls this directly
no test coverage detected