| 175 | } |
| 176 | |
| 177 | void SetTransformSetting(obs_scene_item *source, |
| 178 | const TransformSetting &setting, |
| 179 | const std::string &value) |
| 180 | { |
| 181 | auto id = setting.GetID(); |
| 182 | |
| 183 | struct obs_transform_info info = {}; |
| 184 | struct obs_sceneitem_crop crop = {}; |
| 185 | |
| 186 | #if (LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(30, 1, 0)) |
| 187 | obs_sceneitem_get_info2(source, &info); |
| 188 | #else |
| 189 | obs_sceneitem_get_info(source, &info); |
| 190 | #endif |
| 191 | obs_sceneitem_get_crop(source, &crop); |
| 192 | |
| 193 | if (id == "alignment") { |
| 194 | try { |
| 195 | auto val = std::stoul(value); |
| 196 | info.alignment = val; |
| 197 | } catch (const std::invalid_argument &e) { |
| 198 | logConversionError(e, __func__, id.c_str(), |
| 199 | value.c_str()); |
| 200 | } catch (const std::out_of_range &e) { |
| 201 | logConversionError(e, __func__, id.c_str(), |
| 202 | value.c_str()); |
| 203 | } |
| 204 | } else if (id == "left" || id == "top" || id == "right" || |
| 205 | id == "bottom") { |
| 206 | handleCrop(crop, id, value); |
| 207 | } else if (id == "bounds_alignment") { |
| 208 | uint32_t val = 0; |
| 209 | try { |
| 210 | val = std::stoul(value); |
| 211 | info.bounds_alignment = val; |
| 212 | } catch (const std::invalid_argument &e) { |
| 213 | logConversionError(e, __func__, id.c_str(), |
| 214 | value.c_str()); |
| 215 | } catch (const std::out_of_range &e) { |
| 216 | logConversionError(e, __func__, id.c_str(), |
| 217 | value.c_str()); |
| 218 | } |
| 219 | } else if (id == "bounds_type") { |
| 220 | try { |
| 221 | obs_bounds_type val = |
| 222 | static_cast<obs_bounds_type>(std::stoul(value)); |
| 223 | info.bounds_type = val; |
| 224 | } catch (const std::invalid_argument &e) { |
| 225 | logConversionError(e, __func__, id.c_str(), |
| 226 | value.c_str()); |
| 227 | } catch (const std::out_of_range &e) { |
| 228 | logConversionError(e, __func__, id.c_str(), |
| 229 | value.c_str()); |
| 230 | } |
| 231 | } else if (id == "x" || id == "y") { |
| 232 | handlePosOrScaleOrBounds(info, setting, value); |
| 233 | } else if (id == "width" || id == "height") { |
| 234 | float val = 0; |
no test coverage detected