void rig_transition_set_property_animated (RigTransition *transition, RutProperty *property, CoglBool animated) { RigTransitionPropData *prop_data; if (animated) { prop_data = rig_transition_get_prop_data_for_property (transition, property); } else { /* If the animated state is being disabled then we don't want to * create the property state if doesn't already exist */ prop_data = rig_transition_find_prop_data_for_property (transition, property); if (prop_data == NULL) return; } if (animated != prop_data->animated) { prop_data->animated = animated; rut_closure_list_invoke (&transition->operation_cb_list, RigTransitionOperationCallback, transition, RIG_TRANSITION_OPERATION_ANIMATED_CHANGED, prop_data); } }
RigTransitionPropData * rig_transition_get_prop_data_for_property (RigTransition *transition, RutProperty *property) { RigTransitionPropData *prop_data; prop_data = rig_transition_find_prop_data_for_property (transition, property); if (prop_data == NULL) { prop_data = g_slice_new (RigTransitionPropData); prop_data->animated = FALSE; prop_data->property = property; prop_data->path = NULL; rut_property_box (property, &prop_data->constant_value); g_hash_table_insert (transition->properties, property, prop_data); rut_closure_list_invoke (&transition->operation_cb_list, RigTransitionOperationCallback, transition, RIG_TRANSITION_OPERATION_ADDED, prop_data); } return prop_data; }
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 void on_address_resolved(uv_getaddrinfo_t *resolver, int status, struct addrinfo *result) { rig_pb_stream_t *stream = rut_container_of(resolver, stream, resolver); uv_loop_t *loop = rut_uv_shell_get_loop(stream->shell); char ip_address[17] = {'\0'}; c_return_if_fail(stream->resolving); if (status < 0) { c_warning("Failed to resolve slave address \"%s\": %s", stream->hostname, uv_strerror(status)); rut_closure_list_invoke(&stream->on_error_closures, rig_pb_stream_callback_t, stream); /* NB: we were at least keeping the stream alive while * waiting for the resolve request to finish... */ stream->resolving = false; rut_object_unref(stream); return; } uv_ip4_name((struct sockaddr_in*)result->ai_addr, ip_address, 16); c_message("stream: Resolved address of \"%s\" = %s", stream->hostname, ip_address); uv_tcp_init(loop, &stream->tcp.socket); stream->tcp.socket.data = stream; /* NB: we took a reference to keep the stream alive while * resolving the address, so conceptually we are now handing * the reference over to keep the stream alive while waiting * for it to connect... */ stream->resolving = false; stream->connecting = true; stream->connection_request.data = stream; uv_tcp_connect(&stream->connection_request, &stream->tcp.socket, result->ai_addr, on_connect); uv_freeaddrinfo(result); }
void rut_fixed_set_size (RutObject *self, float width, float height) { RutFixed *fixed = self; if (fixed->width == width && fixed->height == height) return; fixed->width = width; fixed->height = height; rut_closure_list_invoke (&fixed->preferred_size_cb_list, RutSizablePreferredSizeCallback, fixed); }
void rig_transition_remove_property (RigTransition *transition, RutProperty *property) { RigTransitionPropData *prop_data = rig_transition_find_prop_data_for_property (transition, property); if (prop_data) { rut_closure_list_invoke (&transition->operation_cb_list, RigTransitionOperationCallback, transition, RIG_TRANSITION_OPERATION_REMOVED, prop_data); g_hash_table_remove (transition->properties, property); } }
void rut_shape_set_texture_size (RutShape *shape, int tex_width, int tex_height) { if (shape->tex_width == tex_width && shape->tex_height == tex_height) return; shape->tex_width = tex_width; shape->tex_height = tex_height; if (shape->model) { rut_refable_unref (shape->model); shape->model = NULL; } rut_closure_list_invoke (&shape->reshaped_cb_list, RutShapeReShapedCallback, shape); }
void rut_shape_set_shaped (RutObject *obj, CoglBool shaped) { RutShape *shape = RUT_SHAPE (obj); if (shape->shaped == shaped) return; shape->shaped = shaped; if (shape->model) { rut_refable_unref (shape->model); shape->model = NULL; } rut_closure_list_invoke (&shape->reshaped_cb_list, RutShapeReShapedCallback, shape); rut_property_dirty (&shape->ctx->property_ctx, &shape->properties[RUT_SHAPE_PROP_SHAPED]); }
void rig_pb_stream_disconnect(rig_pb_stream_t *stream) { switch (stream->type) { #ifdef USE_UV case STREAM_TYPE_FD: uv_read_stop((uv_stream_t *)&stream->fd.uv_fd_pipe); uv_close((uv_handle_t *)&stream->fd.uv_fd_pipe, NULL /* closed callback */); break; case STREAM_TYPE_TCP: uv_read_stop((uv_stream_t *)&stream->tcp.socket); uv_close((uv_handle_t *)&stream->tcp.socket, NULL /* closed callback */); break; #endif case STREAM_TYPE_BUFFER: { int i; /* Give all incoming write closures back to the other end * so they can be freed */ for (i = 0; i < stream->buffer.incoming_write_closures->len; i++) { rig_pb_stream_write_closure_t *closure = c_array_index(stream->buffer.incoming_write_closures, void *, i); c_array_append_val(stream->buffer.other_end->buffer.finished_write_closures, closure); } c_array_free(stream->buffer.incoming_write_closures, true /* free storage */); stream->buffer.incoming_write_closures = NULL; drain_finished_write_closures(stream); c_array_free(stream->buffer.finished_write_closures, true /* free storage */); stream->buffer.finished_write_closures = NULL; stream->buffer.other_end->buffer.other_end = NULL; stream->buffer.other_end = NULL; } if (stream->buffer.read_idle) { rut_poll_shell_remove_idle_FIXME(stream->shell, stream->buffer.read_idle); stream->buffer.read_idle = NULL; } break; #ifdef __EMSCRIPTEN__ case STREAM_TYPE_WORKER_IPC: stream->worker_ipc.worker = 0; break; case STREAM_TYPE_WEBSOCKET_CLIENT: if (stream->websocket_client.socket != -1) { close(stream->websocket_client.socket); stream->websocket_client.socket = -1; } break; #endif #ifdef USE_UV case STREAM_TYPE_WEBSOCKET_SERVER: stream->websocket_server.ctx = NULL; break; #endif case STREAM_TYPE_DISCONNECTED: #ifdef USE_UV if (stream->resolving) uv_cancel((uv_req_t *)&stream->resolver); if (stream->connecting) uv_cancel((uv_req_t *)&stream->connection_request); #endif return; } stream->type = STREAM_TYPE_DISCONNECTED; rut_closure_list_invoke(&stream->on_error_closures, rig_pb_stream_callback_t, stream); }