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

◆ apply()

template<typename Source, typename Access>
bool MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::apply ( const Prepared & prepared,
const std::vector< uint32_t > & elements,
std::string & error )
inlinestatic

Names every placed element after its instance, then applies the document's Layer attributes: relations first, so a later front or back moves the whole group, then visibility, interaction and clip.

Definition at line 191 of file Instantiate.hpp.

193 {
194 for (size_t i = 0; i < prepared.size(); ++i) {
195 Element* element = prepared[i].surface->layer().get(elements[i]);
196 if (!element) {
197 error = Table::located(prepared[i].row, "instance " + prepared[i].id
198 + " placed an element the surface does not hold");
199 return false;
200 }
201 element->name = prepared[i].id;
202 }
203
204 for (size_t i = 0; i < prepared.size(); ++i) {
205 const auto& relate = prepared[i].layer.relate;
206 if (!relate)
207 continue;
208 const auto target = std::ranges::find_if(prepared, [&](const PreparedInstance& other) {
209 return other.surface_id == prepared[i].surface_id && other.id == *relate;
210 });
211 const size_t j = static_cast<size_t>(target - prepared.begin());
212 if (target == prepared.end()
213 || !prepared[i].surface->layer().relate(elements[j], elements[i])) {
214 error = Table::located(prepared[i].row, "could not relate " + prepared[i].id
215 + " to " + *relate);
216 return false;
217 }
218 }
219
220 for (size_t i = 0; i < prepared.size(); ++i) {
221 Layer& layer = prepared[i].surface->layer();
222 const LayerAttributes& attributes = prepared[i].layer;
223 if (attributes.hidden)
224 layer.set_visible(elements[i], false);
225 if (attributes.interactive)
226 layer.set_interactive(elements[i], *attributes.interactive);
227 if (attributes.clip)
228 layer.set_clip(elements[i], attributes.clip);
229 if (attributes.front)
230 layer.bring_to_front(elements[i]);
231 if (attributes.back)
232 layer.send_to_back(elements[i]);
233 }
234
235 for (size_t i = 0; i < prepared.size(); ++i) {
236 for (const ActionBinding& binding : prepared[i].actions)
238 }
239 return true;
240 }
static void wire(Surface &surface, uint32_t element, const std::string &instance, const ActionBinding &binding)
static std::string located(uint64_t row, std::string_view message)

References MayaFlux::Portal::Forma::Detail::LayerAttributes::back, MayaFlux::Portal::Forma::Layer::bring_to_front(), MayaFlux::Portal::Forma::Detail::LayerAttributes::clip, MayaFlux::Portal::Forma::Detail::LayerAttributes::front, MayaFlux::Portal::Forma::Detail::LayerAttributes::hidden, MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::PreparedInstance::id, MayaFlux::Portal::Forma::Detail::LayerAttributes::interactive, MayaFlux::Portal::Forma::FactoryTable< Source, Access >::located(), MayaFlux::Portal::Forma::Element::name, MayaFlux::Portal::Forma::Layer::send_to_back(), MayaFlux::Portal::Forma::Layer::set_clip(), MayaFlux::Portal::Forma::Layer::set_interactive(), MayaFlux::Portal::Forma::Layer::set_visible(), MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::PreparedInstance::surface_id, and wire().

Referenced by MayaFlux::Portal::Forma::Detail::instantiate().

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