gi-clutter-1.0.5: 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.Rect

Description

The location and size of a rectangle.

The width and height of a Rect can be negative; Clutter considers a rectangle with an origin of [ 0.0, 0.0 ] and a size of [ 10.0, 10.0 ] to be equivalent to a rectangle with origin of [ 10.0, 10.0 ] and size of [ -10.0, -10.0 ].

Application code can normalize rectangles using rectNormalize: this function will ensure that the width and height of a Rect are positive values. All functions taking a Rect as an argument will implicitly normalize it before computing eventual results. For this reason it is safer to access the contents of a Rect by using the provided API at all times, instead of directly accessing the structure members.

Since: 1.12

Synopsis

Exported types

newtype Rect Source #

Memory-managed wrapper type.

Constructors

Rect (ManagedPtr Rect) 

Instances

Instances details
Eq Rect Source # 
Instance details

Defined in GI.Clutter.Structs.Rect

Methods

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

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

GBoxed Rect Source # 
Instance details

Defined in GI.Clutter.Structs.Rect

ManagedPtrNewtype Rect Source # 
Instance details

Defined in GI.Clutter.Structs.Rect

Methods

toManagedPtr :: Rect -> ManagedPtr Rect

TypedObject Rect Source # 
Instance details

Defined in GI.Clutter.Structs.Rect

Methods

glibType :: IO GType

HasParentTypes Rect Source # 
Instance details

Defined in GI.Clutter.Structs.Rect

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

Defined in GI.Clutter.Structs.Rect

Methods

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

IsGValue (Maybe Rect) Source #

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

Instance details

Defined in GI.Clutter.Structs.Rect

Methods

gvalueGType_ :: IO GType

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

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

type ParentTypes Rect Source # 
Instance details

Defined in GI.Clutter.Structs.Rect

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

newZeroRect :: MonadIO m => m Rect Source #

Construct a Rect struct initialized to zero.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

clampToPixel, containsPoint, containsRect, copy, equals, free, init, inset, intersection, normalize, offset, union.

Getters

getCenter, getHeight, getWidth, getX, getY.

Setters

None.

alloc

rectAlloc Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Rect

Returns: the newly allocated Rect. Use rectFree to free its resources

Creates a new, empty Rect.

You can use rectInit to initialize the returned rectangle, for instance:

 rect = clutter_rect_init (clutter_rect_alloc (), x, y, width, height);

Since: 1.12

clampToPixel

rectClampToPixel Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m () 

Rounds the origin of rect downwards to the nearest integer, and rounds the size of rect upwards to the nearest integer, so that rect is updated to the smallest rectangle capable of fully containing the original, fractional rectangle.

Since: 1.12

containsPoint

rectContainsPoint Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> Point

point: the point to check

-> m Bool

Returns: True if the point is contained by rect.

Checks whether point is contained by rect, after normalizing the rectangle.

Since: 1.12

containsRect

rectContainsRect Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> m Bool

Returns: True if the first rectangle contains the second.

Checks whether a contains b.

The first rectangle contains the second if the union of the two Rect is equal to the first rectangle.

Since: 1.12

copy

rectCopy Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m Rect

Returns: the newly allocate copy of rect. Use rectFree to free the associated resources

Copies rect into a new Rect instance.

Since: 1.12

equals

rectEquals Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> m Bool

Returns: True if the rectangles match in origin and size.

Checks whether a and b are equals.

This function will normalize both a and b before comparing their origin and size.

Since: 1.12

free

rectFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m () 

Frees the resources allocated by rect.

Since: 1.12

getCenter

rectGetCenter Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m Point 

Retrieves the center of rect, after normalizing the rectangle, and updates center with the correct coordinates.

Since: 1.12

getHeight

rectGetHeight Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m Float

Returns: the height of the rectangle

Retrieves the height of rect.

Since: 1.12

getWidth

rectGetWidth Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m Float

Returns: the width of the rectangle

Retrieves the width of rect.

Since: 1.12

getX

rectGetX Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m Float

Returns: the X coordinate of the origin of the rectangle

Retrieves the X coordinate of the origin of rect.

Since: 1.12

getY

rectGetY Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m Float

Returns: the Y coordinate of the origin of the rectangle

Retrieves the Y coordinate of the origin of rect.

Since: 1.12

init

rectInit Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> Float

x: X coordinate of the origin

-> Float

y: Y coordinate of the origin

-> Float

width: width of the rectangle

-> Float

height: height of the rectangle

-> m Rect

Returns: the updated rectangle

Initializes a Rect with the given origin and size.

Since: 1.12

inset

rectInset Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> Float

dX: an horizontal value; a positive dX will create an inset rectangle, and a negative value will create a larger rectangle

-> Float

dY: a vertical value; a positive dX will create an inset rectangle, and a negative value will create a larger rectangle

-> m () 

Normalizes the rect and offsets its origin by the dX and dY values; the size is adjusted by (2 * dX, 2 * dY).

If dX and dY are positive the size of the rectangle is decreased; if the values are negative, the size of the rectangle is increased.

If the resulting rectangle has a negative width or height, the size is set to 0.

Since: 1.12

intersection

rectIntersection Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> m (Bool, Rect)

Returns: True if the intersection of a and b is not empty

Computes the intersection of a and b, and places it in res, if res is not Nothing.

This function will normalize both a and b prior to computing their intersection.

This function can be used to simply check if the intersection of a and b is not empty, by using Nothing for res.

Since: 1.12

normalize

rectNormalize Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> m Rect 

Normalizes a Rect.

A Rect is defined by the area covered by its size; this means that a Rect with Rect.origin in [ 0, 0 ] and a Rect.size of [ 10, 10 ] is equivalent to a Rect with Rect.origin in [ 10, 10 ] and a Rect.size of [ -10, -10 ].

This function is useful to ensure that a rectangle has positive width and height; it will modify the passed rect and normalize its size.

Since: 1.12

offset

rectOffset Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

rect: a Rect

-> Float

dX: the horizontal offset value

-> Float

dY: the vertical offset value

-> m () 

Offsets the origin of rect by the given values, after normalizing the rectangle.

Since: 1.12

union

rectUnion Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> m Rect 

Computes the smallest possible rectangle capable of fully containing both a and b, and places it into res.

This function will normalize both a and b prior to computing their union.

Since: 1.12

zero

rectZero Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Rect

Returns: a rectangle with origin in (0, 0) and a size of 0. The returned Rect is owned by Clutter and it should not be modified or freed.

A Rect with Rect.origin set at (0, 0) and a size of 0.

The returned value can be used as a guard.

Since: 1.12

Properties

origin

the origin of the rectangle

getRectOrigin :: MonadIO m => Rect -> m Point Source #

Get the value of the “origin” field. When overloading is enabled, this is equivalent to

get rect #origin

size

the size of the rectangle

getRectSize :: MonadIO m => Rect -> m Size Source #

Get the value of the “size” field. When overloading is enabled, this is equivalent to

get rect #size