Пример #1
0
//doc ClutterUnits withPx(valueInPx)
IO_METHOD(IoClutterUnits, withPx) {
  ClutterUnits units;
  clutter_units_from_pixels(
    &units,
    IoMessage_locals_intArgAt_(m, locals, 0)
  );

  return IoClutterUnits_newWithUnits(IOSTATE, units);
}
Пример #2
0
//doc ClutterUnits -(otherUnit)
IO_METHOD(IoClutterUnits, subtract) {
  IoObject *other     = IoMessage_locals_valueArgAt_(m, locals, 0);
  int self_in_pixels  = clutter_units_to_pixels(&IOCUNITS(self)),
        other_in_pixels = 0;
  ClutterUnits units;

  if(ISNUMBER(other)) {
    other_in_pixels = CNUMBER(other);
  } else if(ISCLUTTERUNITS(other)) {
    other_in_pixels = clutter_units_to_pixels(&IOCUNITS(other));
  } else {
    IoState_error_(IOSTATE, m, "ClutterUnits arithmetic works only for Numbers and other ClutterUnits.");
    return IONIL(self);
  }

  clutter_units_from_pixels(&units, self_in_pixels - other_in_pixels);
  return IoClutterUnits_newWithUnits(IOSTATE, units);
}
Пример #3
0
static void
dax_element_video_init (DaxElementVideo *self)
{
    DaxElementVideoPrivate *priv;
    DaxPreserveAspectRatio par;
    ClutterUnits zero;

    self->priv = priv = ELEMENT_VIDEO_PRIVATE (self);

    clutter_units_from_pixels (&zero, 0.0f);
    priv->x = clutter_units_copy (&zero);
    priv->y = clutter_units_copy (&zero);
    priv->width = clutter_units_copy (&zero);
    priv->height = clutter_units_copy (&zero);

    dax_preserve_aspect_ratio_set_default (&par);
    priv->par = dax_preserve_aspect_ratio_copy (&par);
}
Пример #4
0
static gboolean
clutter_units_progress (const GValue *a,
                        const GValue *b,
                        gdouble       progress,
                        GValue       *retval)
{
  ClutterUnits *a_units = (ClutterUnits *) clutter_value_get_units (a);
  ClutterUnits *b_units = (ClutterUnits *) clutter_value_get_units (b);
  ClutterUnits  res;
  gfloat a_px, b_px, value;

  a_px = clutter_units_to_pixels (a_units);
  b_px = clutter_units_to_pixels (b_units);
  value = progress * (b_px - a_px) + a_px;

  clutter_units_from_pixels (&res, value);
  clutter_value_set_units (retval, &res);

  return TRUE;
}
Пример #5
0
/* float to units */
static void
clutter_value_transform_float_units (const GValue *src,
                                     GValue       *dest)
{
  clutter_units_from_pixels (dest->data[0].v_pointer, src->data[0].v_float);
}