static void objects_selection_event_cb(rig_objects_selection_t *selection, rig_objects_selection_event_t event, rut_object_t *object, void *user_data) { rig_selection_tool_t *tool = user_data; entity_state_t *entity_state; c_llist_t *l; if (!tool->active && event == RIG_OBJECTS_SELECTION_ADD_EVENT) return; if (rut_object_get_type(object) != &rig_entity_type) return; for (l = tool->selected_entities; l; l = l->next) { entity_state = l->data; if (entity_state->entity == object) break; } if (l == NULL) entity_state = NULL; switch (event) { case RIG_OBJECTS_SELECTION_ADD_EVENT: { c_return_if_fail(entity_state == NULL); entity_state = c_slice_new0(entity_state_t); entity_state->tool = tool; entity_state->entity = rut_object_ref(object); entity_state->control_points = NULL; tool->selected_entities = c_llist_prepend(tool->selected_entities, entity_state); entity_state->sizeable = find_sizeable_component(entity_state->entity); if (entity_state->sizeable) create_sizeable_control_points(entity_state); else create_dummy_control_points(entity_state); break; } case RIG_OBJECTS_SELECTION_REMOVE_EVENT: c_return_if_fail(entity_state != NULL); tool->selected_entities = c_llist_remove(tool->selected_entities, entity_state); entity_state_destroy(entity_state); break; } }
static void objects_selection_event_cb (RigObjectsSelection *selection, RigObjectsSelectionEvent event, RutObject *object, void *user_data) { RigSelectionTool *tool = user_data; EntityState *entity_state; GList *l; if (!tool->active && event == RIG_OBJECTS_SELECTION_ADD_EVENT) return; if (rut_object_get_type (object) != &rut_entity_type) return; for (l = tool->selected_entities; l; l = l->next) { entity_state = l->data; if (entity_state->entity == object) break; } if (l == NULL) entity_state = NULL; switch (event) { case RIG_OBJECTS_SELECTION_ADD_EVENT: { g_return_if_fail (entity_state == NULL); entity_state = g_slice_new0 (EntityState); entity_state->tool = tool; entity_state->entity = rut_refable_ref (object); entity_state->control_points = NULL; tool->selected_entities = g_list_prepend (tool->selected_entities, entity_state); #warning "TODO: create meaningful control points!" create_dummy_control_points (entity_state); break; } case RIG_OBJECTS_SELECTION_REMOVE_EVENT: g_return_if_fail (entity_state != NULL); tool->selected_entities = g_list_remove (tool->selected_entities, entity_state); entity_state_destroy (entity_state); break; } }
void rig_selection_tool_destroy(rig_selection_tool_t *tool) { c_llist_t *l; rut_closure_list_disconnect_all_FIXME(&tool->selection_event_cb_list); cg_object_unref(tool->default_pipeline); for (l = tool->selected_entities; l; l = l->next) entity_state_destroy(l->data); c_llist_free(tool->selected_entities); c_slice_free(rig_selection_tool_t, tool); }
void rig_selection_tool_destroy (RigSelectionTool *tool) { GList *l; rut_closure_list_disconnect_all (&tool->selection_event_cb_list); cogl_object_unref (tool->default_pipeline); for (l = tool->selected_entities; l; l = l->next) entity_state_destroy (l->data); g_list_free (tool->selected_entities); g_slice_free (RigSelectionTool, tool); }