MayaFlux 0.4.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 289 of file Context.cpp.

290{
291 const glm::vec2 ndc = to_ndc(px, py);
292 const auto hit = m_layer->hit_test(ndc);
293
294 const int btn_idx = static_cast<int>(btn);
295
296 if (hit != m_focused) {
297 if (m_focused) {
298 auto it = m_callbacks.find(*m_focused);
299 if (it != m_callbacks.end() && it->second.focus_lost)
300 it->second.focus_lost(*m_focused);
301 }
302
303 m_focused = hit;
304
305 if (hit) {
306 auto it = m_callbacks.find(*hit);
307 if (it != m_callbacks.end() && it->second.focus_gained)
308 it->second.focus_gained(*hit);
309 }
310 }
311
312 if (hit && m_callbacks.contains(*hit) && m_callbacks[*hit].drag.contains(btn_idx)) {
313 m_dragging[btn_idx] = hit;
314 }
315
316 if (hit) {
317 auto it = m_callbacks.find(*hit);
318 if (it != m_callbacks.end() && it->second.press.count(btn_idx))
319 it->second.press[btn_idx](*hit, ndc);
320 }
321}
std::optional< uint32_t > m_dragging[3]
Definition Context.hpp:268
std::shared_ptr< Layer > m_layer
Definition Context.hpp:246
glm::vec2 to_ndc(double px, double py) const noexcept
Definition Context.cpp:254
std::unordered_map< uint32_t, ElementCallbacks > m_callbacks
Definition Context.hpp:252
std::optional< uint32_t > m_focused
Definition Context.hpp:269

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: