Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
An opaque structure, to be used to store sizing and positioning values along with their unit.
Since: 1.0
Synopsis
- newtype Units = Units (ManagedPtr Units)
- newZeroUnits :: MonadIO m => m Units
- unitsCopy :: (HasCallStack, MonadIO m) => Units -> m Units
- unitsFree :: (HasCallStack, MonadIO m) => Units -> m ()
- unitsFromCm :: (HasCallStack, MonadIO m) => Float -> m Units
- unitsFromEm :: (HasCallStack, MonadIO m) => Float -> m Units
- unitsFromEmForFont :: (HasCallStack, MonadIO m) => Maybe Text -> Float -> m Units
- unitsFromMm :: (HasCallStack, MonadIO m) => Float -> m Units
- unitsFromPixels :: (HasCallStack, MonadIO m) => Int32 -> m Units
- unitsFromPt :: (HasCallStack, MonadIO m) => Float -> m Units
- unitsFromString :: (HasCallStack, MonadIO m) => Text -> m (Bool, Units)
- unitsGetUnitType :: (HasCallStack, MonadIO m) => Units -> m UnitType
- unitsGetUnitValue :: (HasCallStack, MonadIO m) => Units -> m Float
- unitsToPixels :: (HasCallStack, MonadIO m) => Units -> m Float
- unitsToString :: (HasCallStack, MonadIO m) => Units -> m Text
Exported types
Memory-managed wrapper type.
Instances
Eq Units Source # | |
GBoxed Units Source # | |
Defined in GI.Clutter.Structs.Units | |
ManagedPtrNewtype Units Source # | |
Defined in GI.Clutter.Structs.Units toManagedPtr :: Units -> ManagedPtr Units | |
TypedObject Units Source # | |
Defined in GI.Clutter.Structs.Units | |
HasParentTypes Units Source # | |
Defined in GI.Clutter.Structs.Units | |
tag ~ 'AttrSet => Constructible Units tag Source # | |
IsGValue (Maybe Units) Source # | Convert |
Defined in GI.Clutter.Structs.Units gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Units -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Units) | |
type ParentTypes Units Source # | |
Defined in GI.Clutter.Structs.Units |
Methods
Click to display all available methods, including inherited ones
copy
:: (HasCallStack, MonadIO m) | |
=> Units |
|
-> m Units | Returns: the newly created copy of a
|
Copies units
Since: 1.0
free
:: (HasCallStack, MonadIO m) | |
=> Units |
|
-> m () |
fromCm
:: (HasCallStack, MonadIO m) | |
=> Float |
|
-> m Units |
Stores a value in centimeters inside units
Since: 1.2
fromEm
:: (HasCallStack, MonadIO m) | |
=> Float |
|
-> m Units |
Stores a value in em inside units
, using the default font
name as returned by backendGetFontName
Since: 1.0
fromEmForFont
Stores a value in em inside units
using fontName
Since: 1.0
fromMm
:: (HasCallStack, MonadIO m) | |
=> Float |
|
-> m Units |
Stores a value in millimiters inside units
Since: 1.0
fromPixels
:: (HasCallStack, MonadIO m) | |
=> Int32 |
|
-> m Units |
Stores a value in pixels inside units
Since: 1.0
fromPt
:: (HasCallStack, MonadIO m) | |
=> Float |
|
-> m Units |
Stores a value in typographic points inside units
Since: 1.0
fromString
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Bool, Units) | Returns: |
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
:: (HasCallStack, MonadIO m) | |
=> Units |
|
-> m UnitType | Returns: a unit type |
Retrieves the unit type of the value stored inside units
Since: 1.0
getUnitValue
:: (HasCallStack, MonadIO m) | |
=> Units |
|
-> m Float | Returns: the value stored inside a |
Retrieves the value stored inside units
Since: 1.0
toPixels
:: (HasCallStack, MonadIO m) | |
=> Units |
|
-> m Float | Returns: the value in pixels |
Converts a value in Units
to pixels
Since: 1.0
toString
:: (HasCallStack, MonadIO m) | |
=> Units |
|
-> m Text | Returns: a newly allocated string containing the encoded
|
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