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; }
void rut_shim_set_child (RutShim *shim, RutObject *child) { g_return_if_fail (rut_object_get_type (shim) == &rut_shim_type); if (shim->child == child) return; if (shim->child) { rut_graphable_remove_child (shim->child); rut_closure_disconnect (shim->child_preferred_size_closure); shim->child_preferred_size_closure = NULL; rut_refable_unref (shim->child); } if (child) { shim->child = rut_refable_ref (child); rut_graphable_add_child (shim, child); shim->child_preferred_size_closure = rut_sizable_add_preferred_size_callback (child, child_preferred_size_cb, shim, NULL /* destroy */); queue_allocation (shim); } else shim->child = NULL; rut_shell_queue_redraw (shim->context->shell); }
void rut_fold_set_label(rut_object_t *object, const char *label) { rut_fold_t *fold = object; rut_text_set_text(fold->label, label); rig_property_dirty(&fold->shell->property_ctx, &fold->properties[RUT_FOLD_PROP_LABEL]); rut_shell_queue_redraw(fold->shell); }
void rut_fold_set_label (RutObject *object, const char *label) { RutFold *fold = object; rut_text_set_text (fold->label, label); rut_property_dirty (&fold->context->property_ctx, &fold->properties[RUT_FOLD_PROP_LABEL]); rut_shell_queue_redraw (fold->context->shell); }
void rut_camera_set_depth_of_field (RutObject *obj, float depth_of_field) { RutCamera *camera = RUT_CAMERA (obj); if (camera->depth_of_field == depth_of_field) return; camera->depth_of_field = depth_of_field; rut_shell_queue_redraw (camera->ctx->shell); rut_property_dirty (&camera->ctx->property_ctx, &camera->properties[RUT_CAMERA_PROP_FOCAL_DISTANCE]); }
void rut_camera_set_focal_distance (RutObject *obj, float focal_distance) { RutCamera *camera = RUT_CAMERA (obj); if (camera->focal_distance == focal_distance) return; camera->focal_distance = focal_distance; rut_shell_queue_redraw (camera->ctx->shell); rut_property_dirty (&camera->ctx->property_ctx, &camera->properties[RUT_CAMERA_PROP_FOCAL_DISTANCE]); }
void rut_camera_set_zoom (RutObject *obj, float zoom) { RutCamera *camera = RUT_CAMERA (obj); if (camera->zoom == zoom) return; camera->zoom = zoom; rut_shell_queue_redraw (camera->ctx->shell); rut_property_dirty (&camera->ctx->property_ctx, &camera->properties[RUT_CAMERA_PROP_ZOOM]); camera->projection_age++; camera->transform_age++; }
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; }
void rut_fold_set_folded(rut_fold_t *fold, bool folded) { if (fold->folded == folded || fold->child == NULL) return; if (folded) { rut_fixed_remove_child(fold->fold_icon_shim, fold->fold_down_icon); rut_fixed_add_child(fold->fold_icon_shim, fold->fold_up_icon); rut_box_layout_remove(fold->vbox, fold->child); } else { rut_fixed_remove_child(fold->fold_icon_shim, fold->fold_up_icon); rut_fixed_add_child(fold->fold_icon_shim, fold->fold_down_icon); rut_box_layout_add(fold->vbox, true, fold->child); } fold->folded = folded; rut_shell_queue_redraw(fold->shell); }
void rut_headless_shell_handle_stream_event(rut_shell_t *shell, rut_stream_event_t *stream_event) { rut_input_event_t *event = c_slice_alloc0(sizeof(rut_input_event_t)); event->native = stream_event; event->type = 0; event->camera_entity = stream_event->camera_entity; event->onscreen = shell->headless_onscreen; switch (stream_event->type) { case RUT_STREAM_EVENT_POINTER_MOVE: case RUT_STREAM_EVENT_POINTER_DOWN: case RUT_STREAM_EVENT_POINTER_UP: event->type = RUT_INPUT_EVENT_TYPE_MOTION; break; case RUT_STREAM_EVENT_KEY_DOWN: case RUT_STREAM_EVENT_KEY_UP: event->type = RUT_INPUT_EVENT_TYPE_KEY; break; } /* Note: we don't use a default: case since we want the * compiler to warn us when we forget to handle a new * enum */ if (!event->type) { c_warning("Shell: Spurious stream event type %d\n", stream_event->type); c_slice_free(rut_input_event_t, event); return; } rut_input_queue_append(shell->input_queue, event); /* FIXME: we need a separate status so we can trigger a new * frame, but if the input doesn't affect anything then we * want to avoid any actual rendering. */ rut_shell_queue_redraw(shell); }
void rut_fold_set_folded (RutFold *fold, CoglBool folded) { if (fold->folded == folded || fold->child == NULL) return; if (folded) { rut_fixed_remove_child (fold->fold_icon_shim, fold->fold_down_icon); rut_fixed_add_child (fold->fold_icon_shim, fold->fold_up_icon); rut_box_layout_remove (fold->vbox, fold->child); } else { rut_fixed_remove_child (fold->fold_icon_shim, fold->fold_up_icon); rut_fixed_add_child (fold->fold_icon_shim, fold->fold_down_icon); rut_box_layout_add (fold->vbox, TRUE, fold->child); } fold->folded = folded; rut_shell_queue_redraw (fold->context->shell); }
void rut_bin_set_child (RutBin *bin, RutObject *child_widget) { g_return_if_fail (rut_object_get_type (bin) == &rut_bin_type); if (bin->child == child_widget) return; if (child_widget) rut_refable_claim (child_widget, bin); if (bin->child) { rut_graphable_remove_child (bin->child); rut_closure_disconnect (bin->child_preferred_size_closure); bin->child_preferred_size_closure = NULL; rut_refable_release (bin->child, bin); } bin->child = child_widget; if (child_widget) { rut_graphable_add_child (bin->child_transform, child_widget); bin->child_preferred_size_closure = rut_sizable_add_preferred_size_callback (child_widget, child_preferred_size_cb, bin, NULL /* destroy */); queue_allocation (bin); } preferred_size_changed (bin); rut_shell_queue_redraw (bin->context->shell); }