Beispiel #1
0
void
rut_graphable_add_child (RutObject *parent, RutObject *child)
{
  RutGraphableProps *parent_props =
    rut_object_get_properties (parent, RUT_INTERFACE_ID_GRAPHABLE);
  RutGraphableVTable *parent_vtable =
    rut_object_get_vtable (parent, RUT_INTERFACE_ID_GRAPHABLE);
  RutGraphableProps *child_props =
    rut_object_get_properties (child, RUT_INTERFACE_ID_GRAPHABLE);
  RutGraphableVTable *child_vtable =
    rut_object_get_vtable (child, RUT_INTERFACE_ID_GRAPHABLE);
  RutObject *old_parent = child_props->parent;

  rut_refable_claim (child, parent);

  if (old_parent)
    rut_graphable_remove_child (child);

  child_props->parent = parent;
  if (child_vtable && child_vtable->parent_changed)
    child_vtable->parent_changed (child, old_parent, parent);

  if (parent_vtable && parent_vtable->child_added)
    parent_vtable->child_added (parent, child);

  /* XXX: maybe this should be deferred to parent_vtable->child_added ? */
  g_queue_push_tail (&parent_props->children, child);
}
Beispiel #2
0
RutClosure *
rut_sizable_add_preferred_size_callback (RutObject *object,
                                         RutSizablePreferredSizeCallback cb,
                                         void *user_data,
                                         RutClosureDestroyCallback destroy_cb)
{
  RutSizableVTable *sizable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_SIZABLE);

  /* If the object has no implementation for the needs layout callback
   * then we'll assume its preferred size never changes. We'll return
   * a dummy closure object that will never be invoked so that the
   * rest of the code doesn't need to handle this specially */
  if (sizable->add_preferred_size_callback == NULL)
    {
      RutList dummy_list;
      RutClosure *closure;

      rut_list_init (&dummy_list);

      closure = rut_closure_list_add (&dummy_list,
                                      cb,
                                      user_data,
                                      destroy_cb);

      rut_list_init (&closure->list_node);

      return closure;
    }
  else
    return sizable->add_preferred_size_callback (object,
                                                 cb,
                                                 user_data,
                                                 destroy_cb);
}
Beispiel #3
0
void
rut_graphable_remove_child (RutObject *child)
{
  RutGraphableProps *child_props =
    rut_object_get_properties (child, RUT_INTERFACE_ID_GRAPHABLE);
  RutObject *parent = child_props->parent;
  RutGraphableVTable *parent_vtable;
  RutGraphableProps *parent_props;

  if (!parent)
    return;

  parent_vtable = rut_object_get_vtable (parent, RUT_INTERFACE_ID_GRAPHABLE);
  parent_props = rut_object_get_properties (parent, RUT_INTERFACE_ID_GRAPHABLE);

  /* Note: we set ->parent to NULL here to avoid re-entrancy so
   * ->child_removed can be a general function for removing a child
   *  that might itself call rut_graphable_remove_child() */
  child_props->parent = NULL;

  if (parent_vtable->child_removed)
    parent_vtable->child_removed (parent, child);

  g_queue_remove (&parent_props->children, child);
  rut_refable_release (child, parent);
}
Beispiel #4
0
void
rut_selectable_cancel (RutObject *object)
{
  RutSelectableVTable *selectable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_SELECTABLE);

  selectable->cancel (object);
}
Beispiel #5
0
CoglPrimitive *
rut_primable_get_primitive (RutObject *object)
{
  RutPrimableVTable *primable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_PRIMABLE);

  return primable->get_primitive (object);
}
Beispiel #6
0
const CoglMatrix *
rut_transformable_get_matrix (RutObject *object)
{
  RutTransformableVTable *transformable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_TRANSFORMABLE);

  return transformable->get_matrix (object);
}
Beispiel #7
0
void
rut_renderer_free_priv(rut_object_t *object, rig_entity_t *entity)
{
    rut_renderer_vtable_t *renderer =
        rut_object_get_vtable(object, RUT_TRAIT_ID_RENDERER);

    return renderer->free_priv(entity);
}
Beispiel #8
0
RutProperty *
rut_introspectable_lookup_property (RutObject *object,
                                    const char *name)
{
  RutIntrospectableVTable *introspectable_vtable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_INTROSPECTABLE);

  return introspectable_vtable->lookup_property (object, name);
}
Beispiel #9
0
void
rut_renderer_notify_entity_changed(rut_object_t *object,
                                   rig_entity_t *entity)
{
    rut_renderer_vtable_t *renderer =
        rut_object_get_vtable(object, RUT_TRAIT_ID_RENDERER);

    return renderer->notify_entity_changed(entity);
}
Beispiel #10
0
void
rut_introspectable_foreach_property (RutObject *object,
                                     RutIntrospectablePropertyCallback callback,
                                     void *user_data)
{
  RutIntrospectableVTable *introspectable_vtable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_INTROSPECTABLE);

  introspectable_vtable->foreach_property (object, callback, user_data);
}
Beispiel #11
0
void
rut_sizable_get_size (void *object,
                      float *width,
                      float *height)
{
  RutSizableVTable *sizable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_SIZABLE);

  sizable->get_size (object,
                     width,
                     height);
}
Beispiel #12
0
void
rut_sizable_set_size (RutObject *object,
                      float width,
                      float height)
{
  RutSizableVTable *sizable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_SIZABLE);

  sizable->set_size (object,
                     width,
                     height);
}
Beispiel #13
0
static RutTraverseVisitFlags
_rut_graphable_paint_cb (RutObject *object,
                         int depth,
                         void *user_data)
{
  RutPaintContext *paint_ctx = user_data;
  RutPaintableVTable *vtable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_PAINTABLE);

  vtable->paint (object, paint_ctx);

  return RUT_TRAVERSE_VISIT_CONTINUE;
}
Beispiel #14
0
void
rut_refable_simple_unref (void *object)
{
  int *ref_count = rut_object_get_properties (object,
                                               RUT_INTERFACE_ID_REF_COUNTABLE);

  if (--(*ref_count) < 1)
    {
      RutRefableVTable *vtable =
        rut_object_get_vtable (object, RUT_INTERFACE_ID_REF_COUNTABLE);
      g_assert (*ref_count == 0);
      vtable->free (object);
    }
}
Beispiel #15
0
void
rut_sizable_get_preferred_height (RutObject *object,
                                  float for_width,
                                  float *min_height_p,
                                  float *natural_height_p)
{
  RutSizableVTable *sizable =
    rut_object_get_vtable (object, RUT_INTERFACE_ID_SIZABLE);

  sizable->get_preferred_height (object,
                                 for_width,
                                 min_height_p,
                                 natural_height_p);
}