MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ read_layer_attributes()

template<typename Source, typename Access>
bool MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::read_layer_attributes ( const Source & instance,
LayerAttributes & out )
inlineprivate

Definition at line 402 of file Instantiate.hpp.

403 {
406 if (!name.starts_with(reserved_prefix))
407 return true;
408 const std::string_view key = name.substr(reserved_prefix.size());
409 if (key == "hidden")
410 return read_flag(instance, name, value, out.hidden);
411 if (key == "front")
412 return read_flag(instance, name, value, out.front);
413 if (key == "back")
414 return read_flag(instance, name, value, out.back);
415 if (key == "interactive") {
416 bool flag {};
418 return false;
419 out.interactive = flag;
420 return true;
421 }
422 if (key == "relate") {
423 if (value.empty())
424 return fail(instance, "<instance> needs an instance id in " + std::string(name));
425 out.relate = std::string(value);
426 return true;
427 }
428 if (key == "clip") {
429 glm::vec4 rect {};
432 return fail(instance, "<instance> needs four numbers in " + std::string(name));
433 if (!(rect.z > 0.F) || !(rect.w > 0.F))
434 return fail(instance, std::string(name) + " needs a positive width and height");
435 out.clip = Kinesis::AABB2D::from_origin_size({ rect.x, rect.y }, { rect.z, rect.w });
436 return true;
437 }
438 return fail(instance, "<instance> has an unsupported attribute " + std::string(name));
439 });
440 if (!read)
441 return false;
442 if (out.front && out.back) {
443 return fail(instance, std::string(reserved_prefix) + "front and "
444 + std::string(reserved_prefix) + "back cannot both be set");
445 }
446 return true;
447 }
bool read_flag(const Source &instance, std::string_view name, std::string_view value, bool &out)
bool fail(const Source &at, std::string message)
static AABB2D from_origin_size(glm::vec2 origin, glm::vec2 size) noexcept
Construct from a minimum corner and a size.
Definition Bounds.hpp:104

References MayaFlux::Portal::Forma::Detail::LayerAttributes::back, MayaFlux::Portal::Forma::Detail::LayerAttributes::clip, fail(), MayaFlux::Kinesis::AABB2D::from_origin_size(), MayaFlux::Portal::Forma::Detail::LayerAttributes::front, MayaFlux::Portal::Forma::Detail::LayerAttributes::hidden, MayaFlux::Portal::Forma::Detail::LayerAttributes::interactive, MayaFlux::Reflect::Invalid, read_flag(), MayaFlux::Portal::Forma::Detail::LayerAttributes::relate, and MayaFlux::Portal::Forma::reserved_prefix.

Referenced by check_instances().

Here is the call graph for this function:
Here is the caller graph for this function: