Example #1
0
RutShape *
rut_shape_new (RutContext *ctx,
               CoglBool shaped,
               int tex_width,
               int tex_height)
{
  RutShape *shape = g_slice_new0 (RutShape);

  rut_object_init (&shape->_parent, &rut_shape_type);

  shape->ref_count = 1;

  shape->component.type = RUT_COMPONENT_TYPE_GEOMETRY;

  shape->ctx = rut_refable_ref (ctx);

  shape->tex_width = tex_width;
  shape->tex_height = tex_height;
  shape->shaped = shaped;

  rut_list_init (&shape->reshaped_cb_list);

  rut_simple_introspectable_init (shape,
                                  _rut_shape_prop_specs,
                                  shape->properties);

  return shape;
}
Example #2
0
RutCamera *
rut_camera_new (RutContext *ctx, CoglFramebuffer *framebuffer)
{
  RutCamera *camera = g_slice_new0 (RutCamera);

  camera->ctx = rut_refable_ref (ctx);

  rut_object_init (&camera->_parent, &rut_camera_type);

  camera->ref_count = 1;

  camera->component.type = RUT_COMPONENT_TYPE_CAMERA;

  rut_camera_set_background_color4f (camera, 0, 0, 0, 1);
  camera->clear_fb = TRUE;

  //rut_graphable_init (RUT_OBJECT (camera));

  camera->orthographic = TRUE;
  camera->x1 = 0;
  camera->y1 = 0;
  camera->x2 = 100;
  camera->y2 = 100;

  camera->near = -1;
  camera->far = 100;

  camera->zoom = 1;

  camera->focal_distance = 30;
  camera->depth_of_field = 3;

  camera->projection_cache_age = -1;
  camera->inverse_projection_age = -1;

  cogl_matrix_init_identity (&camera->view);
  camera->inverse_view_age = -1;

  camera->transform_age = 0;

  cogl_matrix_init_identity (&camera->input_transform);

  if (framebuffer)
    {
      int width = cogl_framebuffer_get_width (framebuffer);
      int height = cogl_framebuffer_get_height (framebuffer);
      camera->fb = cogl_object_ref (framebuffer);
      camera->viewport[2] = width;
      camera->viewport[3] = height;
      camera->x2 = width;
      camera->y2 = height;
    }

  rut_simple_introspectable_init (camera,
                                  _rut_camera_prop_specs,
                                  camera->properties);

  return camera;
}
Example #3
0
RutPointalismGrid *
rut_pointalism_grid_new (RutContext *ctx,
                         float size,
                         int tex_width,
                         int tex_height)
{
  RutPointalismGrid *grid = g_slice_new0 (RutPointalismGrid);
  RutBuffer *buffer = rut_buffer_new (sizeof (CoglVertexP3) * 6);
  RutMesh *pick_mesh = rut_mesh_new_from_buffer_p3 (COGL_VERTICES_MODE_TRIANGLES,
                                                    6,
                                                    buffer);
  CoglVertexP3 *pick_vertices = (CoglVertexP3 *)buffer->data;
  float half_tex_width;
  float half_tex_height;

  rut_object_init (&grid->_parent, &rut_pointalism_grid_type);

  grid->ref_count = 1;

  grid->component.type = RUT_COMPONENT_TYPE_GEOMETRY;

  grid->ctx = rut_refable_ref (ctx);

  rut_list_init (&grid->updated_cb_list);

  grid->slice = pointalism_grid_slice_new (tex_width, tex_height,
                                           size);

  half_tex_width = tex_width / 2.0f;
  half_tex_height = tex_height / 2.0f;

  pick_vertices[0].x = -half_tex_width;
  pick_vertices[0].y = -half_tex_height;
  pick_vertices[1].x = -half_tex_width;
  pick_vertices[1].y = half_tex_height;
  pick_vertices[2].x = half_tex_width;
  pick_vertices[2].y = half_tex_height;
  pick_vertices[3] = pick_vertices[0];
  pick_vertices[4] = pick_vertices[2];
  pick_vertices[5].x = half_tex_width;
  pick_vertices[5].y = -half_tex_height;

  grid->pick_mesh = pick_mesh;
  grid->pointalism_scale = 1;
  grid->pointalism_z = 1;
  grid->pointalism_lighter = TRUE;
  grid->cell_size = size;
  grid->tex_width = tex_width;
  grid->tex_height = tex_height;

  rut_simple_introspectable_init (grid, _rut_pointalism_grid_prop_specs,
                                  grid->properties);

  return grid;
}
Example #4
0
RigTransition *
rig_transition_new (RutContext *context,
                    uint32_t id)
{
  //CoglError *error = NULL;
  RigTransition *transition;
  static CoglBool initialized = FALSE;

  if (initialized == FALSE)
    {
      _rig_transition_type_init ();

      initialized = TRUE;
    }

  transition = g_slice_new0 (RigTransition);

  transition->id = id;
  transition->context = rut_refable_ref (context);

  rut_object_init (&transition->_parent, &rig_transition_type);

  rut_list_init (&transition->operation_cb_list);

  rut_simple_introspectable_init (transition, _rig_transition_prop_specs, transition->props);

  transition->progress = 0;

  transition->properties = g_hash_table_new_full (g_direct_hash,
                                                  g_direct_equal,
                                                  NULL, /* key_destroy */
                                                  free_prop_data_cb);

#if 0
  rut_property_set_binding (&transition->props[RUT_TRANSITION_PROP_PROGRESS],
                            update_transition_progress_cb,
                            engine,
                            engine->timeline_elapsed,
                            NULL);
#endif

  return transition;
}
Example #5
0
RutLight *
rut_light_new (RutContext *context)
{
  RutLight *light;

  light = g_slice_new0 (RutLight);
  rut_object_init (&light->_parent, &rut_light_type);

  light->ref_count = 1;
  light->component.type = RUT_COMPONENT_TYPE_LIGHT;
  light->context = rut_refable_ref (context);

  rut_simple_introspectable_init (light,
                                  _rut_light_prop_specs,
                                  light->properties);

  cogl_color_init_from_4f (&light->ambient, 1.0, 1.0, 1.0, 1.0);
  cogl_color_init_from_4f (&light->diffuse, 1.0, 1.0, 1.0, 1.0);
  cogl_color_init_from_4f (&light->specular, 1.0, 1.0, 1.0, 1.0);

  return light;
}
Example #6
0
File: rut-fold.c Project: cee1/rig
RutFold *
rut_fold_new (RutContext *ctx,
              const char *label)
{
  RutFold *fold = g_slice_new0 (RutFold);
  static CoglBool initialized = FALSE;
  RutBoxLayout *header_hbox;
  RutStack *left_header_stack;
  RutBoxLayout *left_header_hbox;
  RutBin *label_bin;
  RutBin *fold_icon_align;
  CoglTexture *texture;
  CoglColor black;

  if (initialized == FALSE)
    {
      _rut_fold_init_type ();

      initialized = TRUE;
    }

  fold->ref_count = 1;
  fold->context = ctx;

  rut_object_init (&fold->_parent, &rut_fold_type);

  rut_graphable_init (fold);

  rut_simple_introspectable_init (fold,
                                  _rut_fold_prop_specs,
                                  fold->properties);

  fold->vbox = rut_box_layout_new (ctx, RUT_BOX_LAYOUT_PACKING_TOP_TO_BOTTOM);

  header_hbox =
    rut_box_layout_new (ctx, RUT_BOX_LAYOUT_PACKING_LEFT_TO_RIGHT);
  rut_box_layout_add (fold->vbox, FALSE, header_hbox);
  rut_refable_unref (header_hbox);

  left_header_stack = rut_stack_new (ctx, 0, 0);
  rut_box_layout_add (header_hbox, TRUE, left_header_stack);
  rut_refable_unref (left_header_stack);

  left_header_hbox =
    rut_box_layout_new (ctx, RUT_BOX_LAYOUT_PACKING_LEFT_TO_RIGHT);
  rut_stack_add (left_header_stack, left_header_hbox);
  rut_refable_unref (left_header_hbox);

  fold_icon_align = rut_bin_new (ctx);
  rut_bin_set_x_position (fold_icon_align, RUT_BIN_POSITION_BEGIN);
  rut_bin_set_y_position (fold_icon_align, RUT_BIN_POSITION_CENTER);
  rut_bin_set_right_padding (fold_icon_align, 10);
  rut_box_layout_add (left_header_hbox, FALSE, fold_icon_align);
  rut_refable_unref (fold_icon_align);

  texture = rut_load_texture_from_data_file (ctx, "tri-fold-up.png", NULL);
  fold->fold_up_icon = rut_nine_slice_new (ctx, texture,
                                           0, 0, 0, 0,
                                           cogl_texture_get_width (texture),
                                           cogl_texture_get_height (texture));
  cogl_object_unref (texture);

  texture = rut_load_texture_from_data_file (ctx, "tri-fold-down.png", NULL);
  fold->fold_down_icon = rut_nine_slice_new (ctx, texture,
                                             0, 0, 0, 0,
                                             cogl_texture_get_width (texture),
                                             cogl_texture_get_height (texture));
  cogl_object_unref (texture);

  fold->fold_icon_shim = rut_fixed_new (ctx,
                                        cogl_texture_get_width (texture),
                                        cogl_texture_get_height (texture));
  rut_bin_set_child (fold_icon_align, fold->fold_icon_shim);
  rut_refable_unref (fold->fold_icon_shim);

  rut_graphable_add_child (fold->fold_icon_shim, fold->fold_down_icon);

  /* NB: we keep references to the icons so they can be swapped
   * without getting disposed. */

  label_bin = rut_bin_new (ctx);
  rut_bin_set_y_position (label_bin, RUT_BIN_POSITION_CENTER);
  rut_box_layout_add (left_header_hbox, FALSE, label_bin);
  rut_refable_unref (label_bin);

  fold->label = rut_text_new_with_text (ctx, NULL, label);
  rut_bin_set_child (label_bin, fold->label);
  rut_refable_unref (fold->label);

  fold->header_hbox_right =
    rut_box_layout_new (ctx, RUT_BOX_LAYOUT_PACKING_RIGHT_TO_LEFT);
  rut_box_layout_add (header_hbox, TRUE, fold->header_hbox_right);
  rut_refable_unref (fold->header_hbox_right);

  cogl_color_init_from_4f (&black, 0, 0, 0, 1);
  rut_fold_set_folder_color (fold, &black);
  rut_fold_set_label_color (fold, &black);

  rut_graphable_add_child (fold, fold->vbox);
  rut_refable_unref (fold->vbox);

  fold->input_region = rut_input_region_new_rectangle (0, 0, 0, 0,
                                                       input_cb,
                                                       fold);
  rut_stack_add (left_header_stack, fold->input_region);
  rut_refable_unref (fold->input_region);

  fold->folded = FALSE;

  return fold;
}