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

◆ handle_press()

void MayaFlux::Portal::Forma::Context::handle_press ( double  px,
double  py,
IO::MouseButtons  btn 
)
private

Definition at line 303 of file Context.cpp.

304{
305 const glm::vec2 ndc = to_ndc(px, py);
306 const auto hit = m_layer->hit_test(ndc);
307
308 const int btn_idx = static_cast<int>(btn);
309
310 if (hit != m_focused) {
311 if (m_focused) {
312 auto it = m_callbacks.find(*m_focused);
313 if (it != m_callbacks.end() && it->second.focus_lost)
314 it->second.focus_lost(*m_focused);
315 }
316
317 m_focused = hit;
318
319 if (hit) {
320 auto it = m_callbacks.find(*hit);
321 if (it != m_callbacks.end() && it->second.focus_gained)
322 it->second.focus_gained(*hit);
323 }
324 }
325
326 if (hit && m_callbacks.contains(*hit) && m_callbacks[*hit].drag.contains(btn_idx)) {
327 m_dragging[btn_idx] = hit;
328 }
329
330 if (hit) {
331 auto it = m_callbacks.find(*hit);
332 if (it != m_callbacks.end() && it->second.press.count(btn_idx))
333 it->second.press[btn_idx](*hit, ndc);
334 }
335}
std::optional< uint32_t > m_dragging[3]
Definition Context.hpp:285
std::shared_ptr< Layer > m_layer
Definition Context.hpp:263
glm::vec2 to_ndc(double px, double py) const noexcept
Definition Context.cpp:268
std::unordered_map< uint32_t, ElementCallbacks > m_callbacks
Definition Context.hpp:269
std::optional< uint32_t > m_focused
Definition Context.hpp:286

References m_callbacks, m_dragging, m_focused, m_layer, and to_ndc().

Referenced by register_handlers().

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