static RutInputEventStatus _rut_button_grab_input_cb (RutInputEvent *event, void *user_data) { ButtonGrabState *state = user_data; RutButton *button = state->button; if(rut_input_event_get_type (event) == RUT_INPUT_EVENT_TYPE_MOTION) { RutShell *shell = button->ctx->shell; if (rut_motion_event_get_action (event) == RUT_MOTION_EVENT_ACTION_UP) { rut_shell_ungrab_input (shell, _rut_button_grab_input_cb, user_data); rut_closure_list_invoke (&button->on_click_cb_list, RutButtonClickCallback, button); g_slice_free (ButtonGrabState, state); button->state = BUTTON_STATE_NORMAL; rut_shell_queue_redraw (button->ctx->shell); return RUT_INPUT_EVENT_STATUS_HANDLED; } else if (rut_motion_event_get_action (event) == RUT_MOTION_EVENT_ACTION_MOVE) { float x = rut_motion_event_get_x (event); float y = rut_motion_event_get_y (event); RutCamera *camera = state->camera; rut_camera_unproject_coord (camera, &state->transform, &state->inverse_transform, 0, &x, &y); if (x < 0 || x > button->width || y < 0 || y > button->height) button->state = BUTTON_STATE_ACTIVE_CANCEL; else button->state = BUTTON_STATE_ACTIVE; rut_shell_queue_redraw (button->ctx->shell); return RUT_INPUT_EVENT_STATUS_HANDLED; } } return RUT_INPUT_EVENT_STATUS_UNHANDLED; }
static rut_input_event_status_t control_point_input_cb( rut_input_region_t *region, rut_input_event_t *event, void *user_data) { control_point_t *point = user_data; entity_state_t *entity_state = point->entity_state; rig_selection_tool_t *tool = entity_state->tool; c_return_val_if_fail(tool->selected_entities != NULL, RUT_INPUT_EVENT_STATUS_UNHANDLED); if (rut_input_event_get_type(event) == RUT_INPUT_EVENT_TYPE_MOTION && rut_motion_event_get_action(event) == RUT_MOTION_EVENT_ACTION_DOWN && rut_motion_event_get_button_state(event) == RUT_BUTTON_STATE_1) { // float x = rut_motion_event_get_x (event); // float y = rut_motion_event_get_y (event); grab_state_t *state = c_slice_new0(grab_state_t); state->tool = tool; state->entity_state = entity_state; state->point = point; rut_shell_grab_input(tool->shell, rut_input_event_get_camera(event), control_point_grab_cb, state); return RUT_INPUT_EVENT_STATUS_HANDLED; } return RUT_INPUT_EVENT_STATUS_UNHANDLED; }
static RutInputEventStatus control_point_input_cb (RutInputRegion *region, RutInputEvent *event, void *user_data) { ControlPoint *point = user_data; EntityState *entity_state = point->entity_state; RigSelectionTool *tool = entity_state->tool; g_return_val_if_fail (tool->selected_entities != NULL, RUT_INPUT_EVENT_STATUS_UNHANDLED); if (rut_input_event_get_type (event) == RUT_INPUT_EVENT_TYPE_MOTION && rut_motion_event_get_action (event) == RUT_MOTION_EVENT_ACTION_DOWN && rut_motion_event_get_button_state (event) == RUT_BUTTON_STATE_1) { //float x = rut_motion_event_get_x (event); //float y = rut_motion_event_get_y (event); GrabState *state = g_slice_new0 (GrabState); state->tool = tool; state->entity_state = entity_state; state->point = point; rut_shell_grab_input (tool->ctx->shell, rut_input_event_get_camera (event), control_point_grab_cb, state); return RUT_INPUT_EVENT_STATUS_HANDLED; } return RUT_INPUT_EVENT_STATUS_UNHANDLED; }
static rut_input_event_status_t control_point_grab_cb(rut_input_event_t *event, void *user_data) { grab_state_t *state = user_data; rig_selection_tool_t *tool = state->tool; // entity_state_t *entity_state = state->entity_state; // control_point_t *point = state->point; rut_input_event_status_t status = RUT_INPUT_EVENT_STATUS_UNHANDLED; rut_motion_event_action_t action; if (rut_input_event_get_type(event) == RUT_INPUT_EVENT_TYPE_KEY && rut_key_event_get_keysym(event) == RUT_KEY_Escape) { rut_shell_ungrab_input( tool->view->shell, control_point_grab_cb, state); c_slice_free(grab_state_t, state); return RUT_INPUT_EVENT_STATUS_HANDLED; } if (rut_input_event_get_type(event) != RUT_INPUT_EVENT_TYPE_MOTION) return RUT_INPUT_EVENT_STATUS_UNHANDLED; action = rut_motion_event_get_action(event); switch (action) { case RUT_MOTION_EVENT_ACTION_MOVE: case RUT_MOTION_EVENT_ACTION_UP: { // float x = rut_motion_event_get_x (event); // float y = rut_motion_event_get_y (event); if (action == RUT_MOTION_EVENT_ACTION_UP) { if ((rut_motion_event_get_button_state(event) & RUT_BUTTON_STATE_1) == 0) { status = RUT_INPUT_EVENT_STATUS_HANDLED; rut_shell_ungrab_input( tool->shell, control_point_grab_cb, state); c_slice_free(grab_state_t, state); } } else status = RUT_INPUT_EVENT_STATUS_HANDLED; } break; default: break; } return status; }
static rut_input_event_status_t input_cb(rut_input_region_t *region, rut_input_event_t *event, void *user_data) { rut_fold_t *fold = user_data; if (rut_input_event_get_type(event) == RUT_INPUT_EVENT_TYPE_MOTION && rut_motion_event_get_action(event) == RUT_MOTION_EVENT_ACTION_UP) { rut_fold_set_folded(fold, !fold->folded); return RUT_INPUT_EVENT_STATUS_HANDLED; } return RUT_INPUT_EVENT_STATUS_UNHANDLED; }
static RutInputEventStatus input_cb (RutInputRegion *region, RutInputEvent *event, void *user_data) { RutFold *fold = user_data; if (rut_input_event_get_type (event) == RUT_INPUT_EVENT_TYPE_MOTION && rut_motion_event_get_action (event) == RUT_MOTION_EVENT_ACTION_UP) { rut_fold_set_folded (fold, !fold->folded); return RUT_INPUT_EVENT_STATUS_HANDLED; } return RUT_INPUT_EVENT_STATUS_UNHANDLED; }
static RutInputEventStatus _rut_button_input_cb (RutInputRegion *region, RutInputEvent *event, void *user_data) { RutButton *button = user_data; if(rut_input_event_get_type (event) == RUT_INPUT_EVENT_TYPE_MOTION && rut_motion_event_get_action (event) == RUT_MOTION_EVENT_ACTION_DOWN) { RutShell *shell = button->ctx->shell; ButtonGrabState *state = g_slice_new (ButtonGrabState); const CoglMatrix *view; state->button = button; state->camera = rut_input_event_get_camera (event); view = rut_camera_get_view_transform (state->camera); state->transform = *view; rut_graphable_apply_transform (button, &state->transform); if (!cogl_matrix_get_inverse (&state->transform, &state->inverse_transform)) { g_warning ("Failed to calculate inverse of button transform\n"); g_slice_free (ButtonGrabState, state); return RUT_INPUT_EVENT_STATUS_UNHANDLED; } rut_shell_grab_input (shell, state->camera, _rut_button_grab_input_cb, state); //button->grab_x = rut_motion_event_get_x (event); //button->grab_y = rut_motion_event_get_y (event); button->state = BUTTON_STATE_ACTIVE; rut_shell_queue_redraw (button->ctx->shell); return RUT_INPUT_EVENT_STATUS_HANDLED; } return RUT_INPUT_EVENT_STATUS_UNHANDLED; }
static RutInputEventStatus control_point_grab_cb (RutInputEvent *event, void *user_data) { GrabState *state = user_data; RigSelectionTool *tool = state->tool; //EntityState *entity_state = state->entity_state; //ControlPoint *point = state->point; RutInputEventStatus status = RUT_INPUT_EVENT_STATUS_UNHANDLED; RutMotionEventAction action; if (rut_input_event_get_type (event) == RUT_INPUT_EVENT_TYPE_KEY && rut_key_event_get_keysym (event) == RUT_KEY_Escape) { rut_shell_ungrab_input (tool->view->context->shell, control_point_grab_cb, state); g_slice_free (GrabState, state); return RUT_INPUT_EVENT_STATUS_HANDLED; } if (rut_input_event_get_type (event) != RUT_INPUT_EVENT_TYPE_MOTION) return RUT_INPUT_EVENT_STATUS_UNHANDLED; action = rut_motion_event_get_action (event); switch (action) { case RUT_MOTION_EVENT_ACTION_MOVE: case RUT_MOTION_EVENT_ACTION_UP: { //float x = rut_motion_event_get_x (event); //float y = rut_motion_event_get_y (event); if (action == RUT_MOTION_EVENT_ACTION_UP) { if ((rut_motion_event_get_button_state (event) & RUT_BUTTON_STATE_1) == 0) { status = RUT_INPUT_EVENT_STATUS_HANDLED; rut_shell_ungrab_input (tool->ctx->shell, control_point_grab_cb, state); g_slice_free (GrabState, state); } } else status = RUT_INPUT_EVENT_STATUS_HANDLED; } break; default: break; } return status; }