Clutter::Units(3) A logical distance unit

SYNOPSIS


$units = { type => 'mm', value => 12.0 };
$pixels = $units->to_pixels();
$units = Clutter::Units->from_em(3, "Sans 16px");
print $units->{value}; # "3"
print $units->to_string(); # "3 em"
$units = Clutter::Units->from_string("12 pt");
print $units->{type}; # "pt"
print $units->to_pixels();

DESCRIPTION

Clutter::Units is a data structure holding a logical distance value along with its type, expressed as a value of the Clutter::UnitType enumeration.

It is possible to use Clutter::Units to store a position or a size in units different than pixels, and convert them whenever needed (for instance inside the Clutter::Actor::allocate() virtual function, or inside the Clutter::Actor::get_preferred_width() and Clutter::Actor::get_preferred_height() virtual functions).

A Clutter::Units is represented by a hash reference with two keys, type, holding the unit type; and value, holding the value for the specified type.

The type key can contain one of the following:

px : pixels
em : em
pt : typographic points
mm : millimeters

The value key must contain a double.

HIERARCHY

  Glib::Boxed
  +----Clutter::Units

METHODS

units = Clutter::Units->from_em ($em, $font_name=undef)

  • $em (double)
  • $font_name (string)

units = Clutter::Units->from_mm ($mm)

  • $mm (double)

units = Clutter::Units->from_pixels ($pixels)

  • $pixels (integer)

units = Clutter::Units->from_pt ($pt)

  • $pt (double)

units = Clutter::Units->from_string ($string)

  • $string (string)

double = $units->to_pixels

string = $units->to_string

ENUMS AND FLAGS

enum Clutter::UnitType

  • 'pixel' / 'CLUTTER_UNIT_PIXEL'
  • 'em' / 'CLUTTER_UNIT_EM'
  • 'mm' / 'CLUTTER_UNIT_MM'
  • 'point' / 'CLUTTER_UNIT_POINT'

COPYRIGHT

Copyright (C) 2006, 2007, 2008 OpenedHand Ltd

Copyright (C) 2009 Intel Corporation

This module is free software; you can redistribute it and/or modify it under the terms of either:

  • the GNU Lesser General Public Library version 2.1; or
  • the Artistic License, version 2.0.

See Clutter for the full copyright notice.