module GHC.Vis.Types (
Point,
DrawFunction,
Signal(..),
View(..),
ViewType(..),
State(..),
Identifier,
NamedBox,
PState(..),
PrintState,
VisObject(..)
)
where
import GHC.HeapView
import qualified Control.Monad.State as MS
import Graphics.UI.Gtk hiding (Box, Signal, Point)
import Graphics.Rendering.Cairo
type Point = (Double, Double)
type DrawFunction = forall a. FilePath -> Double -> Double -> (Surface -> IO a) -> IO a
data Signal = NewSignal Box String
| UpdateSignal
| RedrawSignal
| ClearSignal
| RestoreSignal
| SwitchSignal
| HistorySignal (Int -> Int)
| ExportSignal DrawFunction String
data View = View
{ redraw :: WidgetClass w => w -> IO ()
, click :: IO ()
, move :: WidgetClass w => w -> IO ()
, updateObjects :: [NamedBox] -> IO ()
, exportView :: DrawFunction -> String -> IO ()
}
data ViewType = ListView
| GraphView
deriving (Enum)
data State = State
{ mousePos :: Point
, view :: ViewType
, zoomRatio :: Double
, position :: Point
, dragging :: Bool
, wasDragged :: Bool
}
type Identifier = [String]
type NamedBox = (Identifier, Box)
data PState = PState
{ tCounter' :: Integer
, fCounter' :: Integer
, xCounter' :: Integer
, bindings :: [HeapGraphIndex]
, heapGraph :: HeapGraph String
}
type PrintState = MS.State PState
data VisObject = Unnamed String
| Named String [VisObject]
| Link String
| Thunk String
| Function String
deriving Eq
instance Show VisObject where
show (Unnamed x) = x
show (Named x ys) = x ++ "=(" ++ show ys ++ ")"
show (Link x) = x
show (Thunk x) = x
show (Function x) = x
showList = foldr ((.) . showString . show) (showString "")