dispatch_event Subroutine

private subroutine dispatch_event(self, e)

One event (see vkf_viewer_events): kind, key, key base, modifiers, button, buttons held, x, y (framebuffer pixels from the top left), the render area (x, y, width, height).

Arguments

Type IntentOptional Attributes Name
class(WindowProxy), intent(inout), target :: self
integer, intent(in) :: e(12)

the event (see above)


Calls

proc~~dispatch_event~~CallsGraph proc~dispatch_event dispatch_event proc~default_key default_key proc~dispatch_event->proc~default_key proc~drag_handle drag_handle proc~dispatch_event->proc~drag_handle proc~grab_handle grab_handle proc~dispatch_event->proc~grab_handle proc~handler_button_press WindowEventHandler%handler_button_press proc~dispatch_event->proc~handler_button_press proc~handler_button_release WindowEventHandler%handler_button_release proc~dispatch_event->proc~handler_button_release proc~handler_key_press WindowEventHandler%handler_key_press proc~dispatch_event->proc~handler_key_press proc~handler_key_release WindowEventHandler%handler_key_release proc~dispatch_event->proc~handler_key_release proc~handler_mouse_motion WindowEventHandler%handler_mouse_motion proc~dispatch_event->proc~handler_mouse_motion proc~hover_handle hover_handle proc~dispatch_event->proc~hover_handle proc~is_open WindowProxy%is_open proc~dispatch_event->proc~is_open proc~release_handle release_handle proc~dispatch_event->proc~release_handle proc~current_view WindowProxy%current_view proc~default_key->proc~current_view proc~next_view WindowProxy%next_view proc~default_key->proc~next_view proc~previous_view WindowProxy%previous_view proc~default_key->proc~previous_view proc~reset_view View%reset_view proc~default_key->proc~reset_view proc~cursor_ray WindowProxy%cursor_ray proc~drag_handle->proc~cursor_ray proc~drag DragHandle%drag proc~drag_handle->proc~drag proc~handler_handle_drag WindowEventHandler%handler_handle_drag proc~drag_handle->proc~handler_handle_drag proc~grab_handle->proc~cursor_ray proc~grab DragHandle%grab proc~grab_handle->proc~grab proc~grab_handle->proc~handler_handle_drag draggable draggable proc~hover_handle->draggable interface~vkf_viewer_set_grab vkf_viewer_set_grab proc~hover_handle->interface~vkf_viewer_set_grab priority priority proc~hover_handle->priority proc~handles_shown handles_shown proc~hover_handle->proc~handles_shown proc~set_hovered DragHandle%set_hovered proc~hover_handle->proc~set_hovered proc~window_pick WindowProxy%window_pick proc~hover_handle->proc~window_pick proc~release_handle->proc~hover_handle proc~release_handle->proc~is_open proc~release_handle->proc~handler_handle_drag proc~release DragHandle%release proc~release_handle->proc~release proc~ray ray proc~cursor_ray->proc~ray proc~view_camera view_camera proc~cursor_ray->proc~view_camera move_handle_point move_handle_point proc~drag->move_handle_point proc~constrained constrained proc~drag->proc~constrained proc~world_matrix ReferenceFrame%world_matrix proc~drag->proc~world_matrix handle_point handle_point proc~grab->handle_point proc~grab->proc~constrained proc~ray_sphere ray_sphere proc~grab->proc~ray_sphere proc~grab->proc~world_matrix show_state show_state proc~grab->show_state proc~select_view WindowProxy%select_view proc~next_view->proc~select_view proc~previous_view->proc~select_view proc~release->show_state proc~set_hovered->show_state proc~child ReferenceFrame%child proc~window_pick->proc~child proc~fm_frame FrameManager%fm_frame proc~window_pick->proc~fm_frame proc~identity_matrix identity_matrix proc~window_pick->proc~identity_matrix proc~local_matrix ReferenceFrame%local_matrix proc~window_pick->proc~local_matrix proc~num_children ReferenceFrame%num_children proc~window_pick->proc~num_children proc~pick ReferenceFrame%pick proc~window_pick->proc~pick proc~pickable ReferenceFrame%pickable proc~window_pick->proc~pickable proc~window_pick->proc~view_camera proc~constrained->proc~ray_sphere proc~ray_line ray_line proc~constrained->proc~ray_line proc~ray_plane ray_plane proc~constrained->proc~ray_plane proc~frame_matrix frame_matrix proc~local_matrix->proc~frame_matrix proc~add_pick_hit add_pick_hit proc~pick->proc~add_pick_hit proc~point_pick point_pick proc~pick->proc~point_pick proc~wants wants proc~pick->proc~wants proc~view_camera->proc~is_open interface~vkf_viewer_pixel_ratio vkf_viewer_pixel_ratio proc~view_camera->interface~vkf_viewer_pixel_ratio interface~vkf_viewer_size vkf_viewer_size proc~view_camera->interface~vkf_viewer_size proc~aspect_ratio aspect_ratio proc~view_camera->proc~aspect_ratio proc~field_of_view View%field_of_view proc~view_camera->proc~field_of_view proc~get_camera WindowProxy%get_camera proc~view_camera->proc~get_camera proc~orthographic_bounds View%orthographic_bounds proc~view_camera->proc~orthographic_bounds proc~pick_camera pick_camera proc~view_camera->proc~pick_camera proc~projection_type View%projection_type proc~view_camera->proc~projection_type proc~world_matrix->proc~local_matrix proc~world_matrix->proc~world_matrix proc~aspect_ratio->interface~vkf_viewer_size proc~quat_to_matrix quat_to_matrix proc~frame_matrix->proc~quat_to_matrix proc~get_camera->proc~is_open interface~vkf_viewer_get_look_at vkf_viewer_get_look_at proc~get_camera->interface~vkf_viewer_get_look_at proc~rigid_inverse rigid_inverse proc~get_camera->proc~rigid_inverse proc~transform_camera transform_camera proc~get_camera->proc~transform_camera proc~world_to_view View%world_to_view proc~get_camera->proc~world_to_view proc~cross cross proc~pick_camera->proc~cross proc~project project proc~point_pick->proc~project proc~world_to_view->proc~identity_matrix proc~world_to_view->proc~quat_to_matrix proc~world_to_view->proc~rigid_inverse proc~frame_to_root frame_to_root proc~world_to_view->proc~frame_to_root proc~quat_from_vectors quat_from_vectors proc~world_to_view->proc~quat_from_vectors proc~rotated rotated proc~world_to_view->proc~rotated proc~translation_matrix translation_matrix proc~world_to_view->proc~translation_matrix proc~frame_to_root->proc~world_matrix proc~frame_to_root->proc~rigid_inverse proc~quat_from_vectors->proc~cross proc~quat_normalize quat_normalize proc~quat_from_vectors->proc~quat_normalize proc~translation_matrix->proc~identity_matrix

Called by

proc~~dispatch_event~~CalledByGraph proc~dispatch_event dispatch_event proc~dispatch_events dispatch_events proc~dispatch_events->proc~dispatch_event proc~frame WindowProxy%frame proc~frame->proc~dispatch_events proc~resize WindowProxy%resize proc~resize->proc~frame proc~run WindowProxy%run proc~run->proc~frame

Source Code

    subroutine dispatch_event(self, e)
        class(WindowProxy), intent(inout), target :: self
        integer, intent(in) :: e(12)                        !! the event (see above)
        integer, parameter :: KEY_PRESS = 1, KEY_RELEASE = 2, MOVE = 3, BUTTON_PRESS = 4, BUTTON_RELEASE = 5
        integer, parameter :: BUTTON_MASKS(3) = [256, 512, 1024]            ! (VSG's BUTTON_MASK_1/2/3)
        integer :: key
        real(wp) :: x, y
        logical :: handled
        key = e(2)
        if (key == 0) key = e(3)                                             ! (no modified key given)
        x = 0.0_wp
        y = 0.0_wp
        if (e(11) > 0) x = 2.0_wp * real(e(7) - e(9), wp) / real(e(11), wp) - 1.0_wp
        if (e(12) > 0) y = 1.0_wp - 2.0_wp * real(e(8) - e(10), wp) / real(e(12), wp)
        select case (e(1))
        case (KEY_PRESS)
            handled = .false.
            if (associated(self%handler)) call self%handler%key_press(self, key, e(4), handled)
            if (.not. handled .and. self%default_keys_ .and. self%is_open()) call default_key(self, key, e(4))
        case (KEY_RELEASE)
            if (associated(self%handler)) call self%handler%key_release(self, key, e(4))
        case (MOVE)
            if (e(2) == 1) then                                              ! (grabbed: a handle dragged)
                call drag_handle(self, x, y)
                return
            end if
            if (all(iand(e(6), BUTTON_MASKS) == 0)) call hover_handle(self, x, y)    ! (no button held)
            if (associated(self%handler)) call self%handler%mouse_motion(self, x, y, iand(e(6), BUTTON_MASKS) /= 0)
        case (BUTTON_PRESS)
            self%flight%active = .false.                                     ! (the mouse takes the camera)
            if (e(2) == 1) then
                call grab_handle(self, x, y)
                return
            end if
            if (associated(self%handler)) call self%handler%button_press(self, x, y, e(5))
        case (BUTTON_RELEASE)
            if (e(2) == 1) then
                call release_handle(self, x, y)
                return
            end if
            if (associated(self%handler)) call self%handler%button_release(self, x, y, e(5))
        end select
    end subroutine dispatch_event