/// Search the widget that the mouse is pointing and call the function of the widget
Search the widget that the mouse is pointing and call the function of the widget
Search the widget that the mouse is pointing and call the function of the widget
fn handle_mouse(&mut self, internal: &mut WidgetInternal<T>, mouse: &MouseState<T>) {
        if self.mouse_id.is_some() || !internal.check(GRAB) {
            let widget_n = self
                .mouse_id
                .filter(|&n| {
                    internal.check(GRAB) || self.widgets_i[n].p_intersect(mouse.absolute_pos())
                })
                .or_else(|| {
                    self.widgets_i
                        .iter()
                        .enumerate()
                        .find_map(|(n, w_internal)| {
                            if w_internal.p_intersect(mouse.absolute_pos()) {
                                Some(n)
                            } else {
                                None
                            }
                        })
                });
            if widget_n != self.mouse_id {
                if let Some(id) = std::mem::replace(&mut self.mouse_id, widget_n) {
                    let w_internal = &mut self.widgets_i[id];
                    // HOVER | GRAB | PREV_LAYOUT
                    self.widgets[id].hover_out(w_internal);
                    internal.on(w_internal.drain(REACTIVE, 0b10_01100000));
                }
            }
            if let Some(n) = widget_n {
                let w_internal = unsafe { self.widgets_i.get_unchecked_mut(n) };
                if w_internal.check(GRAB) {
                    w_internal.turn(HOVER, w_internal.p_intersect(mouse.absolute_pos()));
                } else {
                    w_internal.on(HOVER);
                }
                self.widgets[n].handle_mouse(w_internal, mouse);
                internal.on(w_internal.drain(REACTIVE, PREV_LAYOUT));
                internal.turn(GRAB, w_internal.check(GRAB));
                // ENABLED | VISIBLE
                let focus_check = w_internal.flags & FOCUSABLE ^ 0b00011000;
                // Check if FOCUS is turned on and if ENABLED or VISIBLE is turned off
                if focus_check & FOCUS == FOCUS && focus_check > FOCUS {
                    self.widgets[n].focus_out(w_internal);
                    internal.on(w_internal.drain(REACTIVE, DRAIN_FOCUS));
                }
                if let Some(id) = self.focus_id {
                    if id != n {
                        if focus_check == FOCUS {
                            let o_internal = &mut self.widgets_i[id];
                            self.widgets[id].focus_out(o_internal);
                            internal.on(o_internal.drain(REACTIVE, DRAIN_FOCUS));
                            self.focus_id = widget_n;
                        }
                    } else if focus_check != FOCUS {
                        self.focus_id = None;
                    }
                } else if focus_check == FOCUS {
                    self.focus_id = widget_n;
                    internal.on(FOCUS);
                }
            } else {
                if mouse.m_count > 0 {
                    internal.on(GRAB);
                }
            }
        } else {
            if mouse.m_count == 0 {
                internal.off(GRAB);
            }
        }
        if internal.check(PREV_LAYOUT) {
            internal.off_on(PREV_LAYOUT, PARTIAL_TURN);
        }
    }
fn handle_mouse ( & mut self , internal : & mut WidgetInternal < T > , mouse : & MouseState < T > ) { if self . mouse_id . is_some ( ) || ! internal . check ( GRAB ) { let widget_n = self . mouse_id . filter ( | & n | { internal . check ( GRAB ) || self . widgets_i [ n ] . p_intersect ( mouse . absolute_pos ( ) ) } ) . or_else ( | | { self . widgets_i . iter ( ) . enumerate ( ) . find_map ( | ( n , w_internal ) | { if w_internal . p_intersect ( mouse . absolute_pos ( ) ) { Some ( n ) } else { None } } ) } ) ; if widget_n != self . mouse_id { if let Some ( id ) = std :: mem :: replace ( & mut self . mouse_id , widget_n ) { let w_internal = & mut self . widgets_i [ id ] ; // HOVER | GRAB | PREV_LAYOUT self . widgets [ id ] . hover_out ( w_internal ) ; internal . on ( w_internal . drain ( REACTIVE , 0b10_01100000 ) ) ; } } if let Some ( n ) = widget_n { let w_internal = unsafe { self . widgets_i . get_unchecked_mut ( n ) } ; if w_internal . check ( GRAB ) { w_internal . turn ( HOVER , w_internal . p_intersect ( mouse . absolute_pos ( ) ) ) ; } else { w_internal . on ( HOVER ) ; } self . widgets [ n ] . handle_mouse ( w_internal , mouse ) ; internal . on ( w_internal . drain ( REACTIVE , PREV_LAYOUT ) ) ; internal . turn ( GRAB , w_internal . check ( GRAB ) ) ; // ENABLED | VISIBLE let focus_check = w_internal . flags & FOCUSABLE ^ 0b00011000 ; // Check if FOCUS is turned on and if ENABLED or VISIBLE is turned off if focus_check & FOCUS == FOCUS && focus_check > FOCUS { self . widgets [ n ] . focus_out ( w_internal ) ; internal . on ( w_internal . drain ( REACTIVE , DRAIN_FOCUS ) ) ; } if let Some ( id ) = self . focus_id { if id != n { if focus_check == FOCUS { let o_internal = & mut self . widgets_i [ id ] ; self . widgets [ id ] . focus_out ( o_internal ) ; internal . on ( o_internal . drain ( REACTIVE , DRAIN_FOCUS ) ) ; self . focus_id = widget_n ; } } else if focus_check != FOCUS { self . focus_id = None ; } } else if focus_check == FOCUS { self . focus_id = widget_n ; internal . on ( FOCUS ) ; } } else { if mouse . m_count > 0 { internal . on ( GRAB ) ; } } } else { if mouse . m_count == 0 { internal . off ( GRAB ) ; } } if internal . check ( PREV_LAYOUT ) { internal . off_on ( PREV_LAYOUT , PARTIAL_TURN ) ; } }
Search the widget that the mouse is pointing and call the function of the widget
Search the widget that the mouse is pointing and call the function of the widget
&mut self
internal
&mut WidgetInternal<T>
mouse
&MouseState<T>