gi-clutter-1.0.3: clutter GObject bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Clutter.Structs.Units

Description

An opaque structure, to be used to store sizing and positioning values along with their unit.

Since: 1.0

Synopsis

Exported types

newtype Units Source #

Memory-managed wrapper type.

Constructors

Units (ManagedPtr Units) 

Instances

Instances details
Eq Units Source # 
Instance details

Defined in GI.Clutter.Structs.Units

Methods

(==) :: Units -> Units -> Bool #

(/=) :: Units -> Units -> Bool #

GBoxed Units Source # 
Instance details

Defined in GI.Clutter.Structs.Units

ManagedPtrNewtype Units Source # 
Instance details

Defined in GI.Clutter.Structs.Units

Methods

toManagedPtr :: Units -> ManagedPtr Units

TypedObject Units Source # 
Instance details

Defined in GI.Clutter.Structs.Units

Methods

glibType :: IO GType

HasParentTypes Units Source # 
Instance details

Defined in GI.Clutter.Structs.Units

tag ~ 'AttrSet => Constructible Units tag Source # 
Instance details

Defined in GI.Clutter.Structs.Units

Methods

new :: MonadIO m => (ManagedPtr Units -> Units) -> [AttrOp Units tag] -> m Units

IsGValue (Maybe Units) Source #

Convert Units to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Clutter.Structs.Units

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Units -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Units)

type ParentTypes Units Source # 
Instance details

Defined in GI.Clutter.Structs.Units

type ParentTypes Units = '[] :: [Type]

newZeroUnits :: MonadIO m => m Units Source #

Construct a Units struct initialized to zero.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

copy, free, toPixels, toString.

Getters

getUnitType, getUnitValue.

Setters

None.

copy

unitsCopy Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Units

units: the Units to copy

-> m Units

Returns: the newly created copy of a Units structure. Use unitsFree to free the allocated resources

Copies units

Since: 1.0

free

unitsFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Units

units: the Units to free

-> m () 

Frees the resources allocated by units

You should only call this function on a Units created using unitsCopy

Since: 1.0

fromCm

unitsFromCm Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Float

cm: centimeters

-> m Units 

Stores a value in centimeters inside units

Since: 1.2

fromEm

unitsFromEm Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Float

em: em

-> m Units 

Stores a value in em inside units, using the default font name as returned by backendGetFontName

Since: 1.0

fromEmForFont

unitsFromEmForFont Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Maybe Text

fontName: the font name and size

-> Float

em: em

-> m Units 

Stores a value in em inside units using fontName

Since: 1.0

fromMm

unitsFromMm Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Float

mm: millimeters

-> m Units 

Stores a value in millimiters inside units

Since: 1.0

fromPixels

unitsFromPixels Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Int32

px: pixels

-> m Units 

Stores a value in pixels inside units

Since: 1.0

fromPt

unitsFromPt Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Float

pt: typographic points

-> m Units 

Stores a value in typographic points inside units

Since: 1.0

fromString

unitsFromString Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

str: the string to convert

-> m (Bool, Units)

Returns: True if the string was successfully parsed, and False otherwise

Parses a value and updates units with it

A Units expressed in string should match:

 units: wsp* unit-value wsp* unit-name? wsp*
 unit-value: number
 unit-name: 'px' | 'pt' | 'mm' | 'em' | 'cm'
 number: digit+
         | digit* sep digit+
 sep: '.' | ','
 digit: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
 wsp: (#0x20 | #0x9 | #0xA | #0xB | #0xC | #0xD)+

For instance, these are valid strings:

 10 px
 5.1 em
 24 pt
 12.6 mm
 .3 cm

While these are not:

 42 cats
 omg!1!ponies

If no unit is specified, pixels are assumed.

Since: 1.0

getUnitType

unitsGetUnitType Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Units

units: a Units

-> m UnitType

Returns: a unit type

Retrieves the unit type of the value stored inside units

Since: 1.0

getUnitValue

unitsGetUnitValue Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Units

units: a Units

-> m Float

Returns: the value stored inside a Units

Retrieves the value stored inside units

Since: 1.0

toPixels

unitsToPixels Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Units

units: units to convert

-> m Float

Returns: the value in pixels

Converts a value in Units to pixels

Since: 1.0

toString

unitsToString Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Units

units: a Units

-> m Text

Returns: a newly allocated string containing the encoded Units value. Use free to free the string

Converts units into a string

See unitsFromString for the units syntax and for examples of output

Fractional values are truncated to the second decimal position for em, mm and cm, and to the first decimal position for typographic points. Pixels are integers.

Since: 1.0