| 199 | } |
| 200 | |
| 201 | WidgetConstructResult WidgetParser::imageHandler(String const& name, Json const& config) { |
| 202 | auto image = make_shared<ImageWidget>(); |
| 203 | common(image, config); |
| 204 | |
| 205 | if (config.contains("file")) |
| 206 | image->setImage(config.getString("file")); |
| 207 | |
| 208 | if (config.contains("drawables")) |
| 209 | image->setDrawables(config.getArray("drawables").transformed([](Json const& d) { return Drawable(d); } )); |
| 210 | |
| 211 | if (config.contains("scale")) |
| 212 | image->setScale(config.getFloat("scale")); |
| 213 | |
| 214 | if (config.contains("rotation")) |
| 215 | image->setRotation(config.getFloat("rotation")); |
| 216 | |
| 217 | if (config.contains("centered")) |
| 218 | image->setCentered(config.getBool("centered")); |
| 219 | |
| 220 | if (config.contains("trim")) |
| 221 | image->setTrim(config.getBool("trim")); |
| 222 | else |
| 223 | image->setTrim(image->centered()); // once upon a time in a magical kingdom, these settings were linked |
| 224 | |
| 225 | if (config.contains("offset")) |
| 226 | image->setOffset(jsonToVec2I(config.get("offset"))); |
| 227 | |
| 228 | if (config.contains("maxSize")) |
| 229 | image->setMaxSize(jsonToVec2I(config.get("maxSize"))); |
| 230 | |
| 231 | if (config.contains("minSize")) |
| 232 | image->setMinSize(jsonToVec2I(config.get("minSize"))); |
| 233 | |
| 234 | return WidgetConstructResult(image, name, config.getFloat("zlevel", 0)); |
| 235 | } |
| 236 | |
| 237 | WidgetConstructResult WidgetParser::imageStretchHandler(String const& name, Json const& config) { |
| 238 | ImageStretchSet stretchSet = parseImageStretchSet(config.get("stretchSet")); |
nothing calls this directly
no test coverage detected