Clutter::Units3pm
A logical distance unit
Usage
$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();
Overview
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)
•
|
|
|---|---|
•
|
|
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' |
Releases
2 releases since Debian 5.0 (Lenny); the text changed 1 time.