|
From: <kr_...@us...> - 2003-01-30 23:59:17
|
Update of /cvsroot/htoolkit/port/src/Port
In directory sc8-pr-cvs1:/tmp/cvs-serv31455/port/src/Port
Modified Files:
Types.hs
Log Message:
Move Geometry combinators from gio to port
Index: Types.hs
===================================================================
RCS file: /cvsroot/htoolkit/port/src/Port/Types.hs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Types.hs 30 Jan 2003 23:09:46 -0000 1.10
--- Types.hs 30 Jan 2003 23:58:07 -0000 1.11
***************
*** 19,32 ****
-- ** Points
! Point(..), pointFromVec, pointMove, pointMoveBySize, pointAdd, pointSub, pointScale
-- ** Sizes
! , Size(..), sizeEncloses, maxSize, addh, addv, sizeDistance
-- ** Vectors
! , Vector(..), vecNegate, vecOrtogonal, vecFromPoint, vecAdd, vecSub, vecScale, vecDistance
-- ** Rectangles
! , Rect(..), rectBetween, rectAt, rectSize, rectOfSize, rectIsEmpty
, pointInRect, rectMoveTo, pointToRect, centralPoint, centralRect, rectStretchTo
, rectMove, disjointRects, rectsDiff, rectUnion, rectSect
--- 19,33 ----
-- ** Points
! Point(..), pt, pointFromVec, pointMove, pointMoveBySize, pointAdd, pointSub, pointScale
-- ** Sizes
! , Size(..), sz, sizeEncloses, maxSize, addh, addv, sizeDistance
-- ** Vectors
! , Vector(..), vc, vecNegate, vecOrtogonal, vecFromPoint, vecAdd, vecSub, vecScale, vecDistance
-- ** Rectangles
! , Rect(..), topLeft, topRight, bottomLeft, bottomRight
! , rect, rectAt, rectSize, rectOfSize, rectIsEmpty
, pointInRect, rectMoveTo, pointToRect, centralPoint, centralRect, rectStretchTo
, rectMove, disjointRects, rectsDiff, rectUnion, rectSect
***************
*** 67,71 ****
-- ** Modifiers
, Modifiers(..)
! , noneDown, noModifiers
-- ** Mouse events
--- 68,72 ----
-- ** Modifiers
, Modifiers(..)
! , noneDown, justShift, justAlt, justControl, noModifiers
-- ** Mouse events
***************
*** 230,235 ****
-- upper-left corner of their view frame, where a positive x goes to the right and
-- a positive y to the bottom of the view.
! data Point = Point !Int !Int -- ^ x and y coordinate
! deriving (Eq,Show)
pointFromVec :: Vector -> Point
--- 231,243 ----
-- upper-left corner of their view frame, where a positive x goes to the right and
-- a positive y to the bottom of the view.
! data Point = Point
! { px :: !Int -- ^ x component of a point.
! , py :: !Int -- ^ y component of a point.
! }
! deriving (Eq,Show)
!
! -- | Short function to construct a point.
! pt :: Int -> Int -> Point
! pt x y = Point x y
pointFromVec :: Vector -> Point
***************
*** 267,273 ****
-----------------------------------------------------------------------------------------}
-- | A @Size@ has a width and height.
! data Size = Size !Int !Int -- ^ width and height.
! deriving (Eq,Show)
!
sizeEncloses :: Size -> Size -> Bool
sizeEncloses (Size w0 h0) (Size w1 h1)
--- 275,288 ----
-----------------------------------------------------------------------------------------}
-- | A @Size@ has a width and height.
! data Size = Size
! { sw :: !Int -- ^ the width of a size
! , sh :: !Int -- ^ the height of a size
! }
! deriving (Eq,Show)
!
! -- | Short function to construct a size
! sz :: Int -> Int -> Size
! sz w h = Size w h
!
sizeEncloses :: Size -> Size -> Bool
sizeEncloses (Size w0 h0) (Size w1 h1)
***************
*** 306,312 ****
Vector
-----------------------------------------------------------------------------------------}
! data Vector = Vector !Int !Int -- ^ x and y coordinate
! deriving (Eq,Show)
vecNegate :: Vector -> Vector
--- 321,334 ----
Vector
-----------------------------------------------------------------------------------------}
+ -- | A vector with an x and y delta.
+ data Vector = Vector
+ { vx :: !Int -- ^ delta-x component of a vector
+ , vy :: !Int -- ^ delta-y component of a vector
+ }
+ deriving (Eq,Show)
! -- | Short function to construct a vector.
! vc :: Int -> Int -> Vector
! vc dx dy = Vector dx dy
vecNegate :: Vector -> Vector
***************
*** 341,352 ****
-- (and not a single pixel). The pixel width of a rectangle is therefore simply the difference
-- between the right and left, or bottom and top coordinate.
! data Rect = Rect !Int !Int !Int !Int
! deriving (Eq,Show)
-- | Construct a (positive) rectangle between two (arbitraty) points.
! rectBetween :: Point -> Point -> Rect
! rectBetween (Point x0 y0) (Point x1 y1)
= Rect (min x0 x1) (min y0 y1) (max x0 x1) (max y0 y1)
--- 363,384 ----
-- (and not a single pixel). The pixel width of a rectangle is therefore simply the difference
-- between the right and left, or bottom and top coordinate.
! data Rect = Rect
! { left :: !Int
! , top :: !Int
! , right :: !Int
! , bottom :: !Int
! }
! deriving (Eq,Show)
+ topLeft, topRight, bottomLeft, bottomRight :: Rect -> Point
+ topLeft (Rect l t r b) = Point l t
+ topRight (Rect l t r b) = Point r t
+ bottomLeft (Rect l t r b) = Point l b
+ bottomRight (Rect l t r b) = Point r b
-- | Construct a (positive) rectangle between two (arbitraty) points.
! rect :: Point -> Point -> Rect
! rect (Point x0 y0) (Point x1 y1)
= Rect (min x0 x1) (min y0 y1) (max x0 x1) (max y0 y1)
***************
*** 459,469 ****
-- | Construct a 'Modifiers' structure with no meta keys pressed.
noModifiers :: Modifiers
! noModifiers
! = Modifiers False False False
-- | Test if no meta key was pressed.
noneDown :: Modifiers -> Bool
! noneDown (Modifiers shift control alt)
! = not (shift || control || alt)
--- 491,512 ----
-- | Construct a 'Modifiers' structure with no meta keys pressed.
noModifiers :: Modifiers
! noModifiers = Modifiers False False False
!
! -- | Construct a 'Modifiers' structure with just Shift meta key pressed.
! justShift :: Modifiers
! justShift = noModifiers{ shiftDown = True }
!
! -- | Construct a 'Modifiers' structure with just Alt meta key pressed.
! justAlt :: Modifiers
! justAlt = noModifiers{ altDown = True }
!
! -- | Construct a 'Modifiers' structure with just Ctrl meta key pressed.
! justControl :: Modifiers
! justControl = noModifiers{ controlDown = True }
-- | Test if no meta key was pressed.
noneDown :: Modifiers -> Bool
! noneDown (Modifiers shift control alt) = not (shift || control || alt)
!
|