MayaFlux 1.0.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 379 of file Context.cpp.

380{
381 sync_size();
382 const glm::vec2 ndc = to_ndc(px, py);
383 const auto hit = m_layer->hit_test(ndc);
384
385 const int btn_idx = static_cast<int>(btn);
386
387 if (hit != m_focused) {
388 if (m_focused) {
389 auto it = m_callbacks.find(*m_focused);
390 if (it != m_callbacks.end() && it->second.focus_lost)
391 it->second.focus_lost(*m_focused);
392 }
393
394 m_focused = hit;
395
396 if (hit) {
397 auto it = m_callbacks.find(*hit);
398 if (it != m_callbacks.end() && it->second.focus_gained)
399 it->second.focus_gained(*hit);
400 }
401 }
402
403 if (hit && m_callbacks.contains(*hit) && m_callbacks[*hit].drag.contains(btn_idx)) {
404 m_dragging[btn_idx] = hit;
405 }
406
407 if (hit) {
408 auto it = m_callbacks.find(*hit);
409 if (it != m_callbacks.end() && it->second.press.count(btn_idx))
410 it->second.press[btn_idx](*hit, ndc);
411 }
412}
uint32_t py
uint32_t px
void sync_size()
Run the resize callbacks if the window's size differs from the size they last saw.
Definition Context.cpp:537
std::optional< uint32_t > m_dragging[3]
Definition Context.hpp:382
std::shared_ptr< Layer > m_layer
Definition Context.hpp:355
glm::vec2 to_ndc(double px, double py) const noexcept
Definition Context.cpp:338
std::unordered_map< uint32_t, ElementCallbacks > m_callbacks
Definition Context.hpp:361
std::optional< uint32_t > m_focused
Definition Context.hpp:383

References m_callbacks, m_dragging, m_focused, m_layer, px, py, sync_size(), and to_ndc().

Referenced by register_handlers().

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