Пример #1
0
static void
clutter_align_constraint_get_property (GObject    *gobject,
                                       guint       prop_id,
                                       GValue     *value,
                                       GParamSpec *pspec)
{
  ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (gobject);

  switch (prop_id)
    {
    case PROP_SOURCE:
      g_value_set_object (value, align->source);
      break;

    case PROP_ALIGN_AXIS:
      g_value_set_enum (value, align->align_axis);
      break;

    case PROP_FACTOR:
      g_value_set_float (value, align->factor);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
      break;
    }
}
static void
clutter_align_constraint_set_actor (ClutterActorMeta *meta,
                                    ClutterActor     *new_actor)
{
  ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (meta);
  ClutterActorMetaClass *parent;

  if (new_actor != NULL &&
      align->source != NULL &&
      clutter_actor_contains (new_actor, align->source))
    {
      g_warning (G_STRLOC ": The source actor '%s' is contained "
                 "by the actor '%s' associated to the constraint "
                 "'%s'",
                 _clutter_actor_get_debug_name (align->source),
                 _clutter_actor_get_debug_name (new_actor),
                 _clutter_actor_meta_get_debug_name (meta));
      return;
    }

  /* store the pointer to the actor, for later use */
  align->actor = new_actor;

  parent = CLUTTER_ACTOR_META_CLASS (clutter_align_constraint_parent_class);
  parent->set_actor (meta, new_actor);
}
Пример #3
0
static void
clutter_align_constraint_set_actor (ClutterActorMeta *meta,
                                    ClutterActor     *new_actor)
{
  ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (meta);
  ClutterActorMetaClass *parent;

  /* store the pointer to the actor, for later use */
  align->actor = new_actor;

  parent = CLUTTER_ACTOR_META_CLASS (clutter_align_constraint_parent_class);
  parent->set_actor (meta, new_actor);
}
static void
clutter_align_constraint_update_allocation (ClutterConstraint *constraint,
                                            ClutterActor      *actor,
                                            ClutterActorBox   *allocation)
{
  ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (constraint);
  gfloat source_width, source_height;
  gfloat actor_width, actor_height;
  gfloat source_x, source_y;

  if (align->source == NULL)
    return;

  clutter_actor_box_get_size (allocation, &actor_width, &actor_height);

  clutter_actor_get_position (align->source, &source_x, &source_y);
  clutter_actor_get_size (align->source, &source_width, &source_height);

  switch (align->align_axis)
    {
    case CLUTTER_ALIGN_X_AXIS:
      allocation->x1 = ((source_width - actor_width) * align->factor)
                     + source_x;
      allocation->x1 = floorf (allocation->x1 + 0.5);
      allocation->x2 = allocation->x1 + actor_width;
      break;

    case CLUTTER_ALIGN_Y_AXIS:
      allocation->y1 = ((source_height - actor_height) * align->factor)
                     + source_y;
      allocation->y1 = floorf (allocation->y1 + 0.5);
      allocation->y2 = allocation->y1 + actor_height;
      break;

    case CLUTTER_ALIGN_BOTH:
      allocation->x1 = ((source_width - actor_width) * align->factor)
                     + source_x;
      allocation->y1 = ((source_height - actor_height) * align->factor)
                     + source_y;
      allocation->x1 = floorf (allocation->x1 + 0.5f);
      allocation->y1 = floorf (allocation->y1 + 0.5f);
      allocation->x2 = allocation->x1 + actor_width;
      allocation->y2 = allocation->y1 + actor_height;
      break;

    default:
      g_assert_not_reached ();
      break;
    }
}
Пример #5
0
static void
clutter_align_constraint_dispose (GObject *gobject)
{
  ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (gobject);

  if (align->source != NULL)
    {
      g_signal_handlers_disconnect_by_func (align->source,
                                            G_CALLBACK (source_destroyed),
                                            align);
      g_signal_handlers_disconnect_by_func (align->source,
                                            G_CALLBACK (source_position_changed),
                                            align);
      align->source = NULL;
    }

  G_OBJECT_CLASS (clutter_align_constraint_parent_class)->dispose (gobject);
}