module Monomer.Graph.GraphData
( GraphData(..)
, graphPoint
, graphPoints
, graphColor
, graphHoverColor
, graphActiveColor
, graphBorderColor
, graphWidth
, graphRadius
, graphSeparate
, graphSeparate_
, graphFill
, graphFill_
, graphFillAlpha
, graphDuration
, graphOnFinished
, graphOnFinishedReq
, graphOnChange
, graphOnChangeReq
, graphOnEnter
, graphOnEnterReq
, graphOnLeave
, graphOnLeaveReq
, graphOnClick
, graphOnClickReq
) where
import Control.Applicative ((<|>))
import Data.Default
import Monomer.Graphics.Types
import Monomer.Widgets.Single
data GraphData s e = GraphData
{ forall s e. GraphData s e -> [(Double, Double)]
_gdPoints :: [(Double, Double)]
, forall s e. GraphData s e -> Maybe Color
_gdColor :: Maybe Color
, forall s e. GraphData s e -> Maybe Color
_gdHoverColor :: Maybe Color
, forall s e. GraphData s e -> Maybe Color
_gdActiveColor :: Maybe Color
, forall s e. GraphData s e -> Maybe Color
_gdBorderColor :: Maybe Color
, forall s e. GraphData s e -> Maybe Double
_gdWidth :: Maybe Double
, forall s e. GraphData s e -> Maybe Double
_gdRadius :: Maybe Double
, forall s e. GraphData s e -> Maybe Bool
_gdSeparate :: Maybe Bool
, forall s e. GraphData s e -> Maybe Bool
_gdFill :: Maybe Bool
, forall s e. GraphData s e -> Maybe Double
_gdFillAlpha :: Maybe Double
, forall s e. GraphData s e -> Maybe Millisecond
_gdDuration :: Maybe Millisecond
, forall s e. GraphData s e -> [WidgetRequest s e]
_gdFinishedReq :: [WidgetRequest s e]
, forall s e.
GraphData s e -> [Int -> (Double, Double) -> WidgetRequest s e]
_gdChangeReq :: [Int -> (Double, Double) -> WidgetRequest s e]
, forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdEnterReq :: [Int -> WidgetRequest s e]
, forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdLeaveReq :: [Int -> WidgetRequest s e]
, forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdClickReq :: [Int -> WidgetRequest s e]
}
instance Default (GraphData s e) where
def :: GraphData s e
def = GraphData
{ _gdPoints :: [(Double, Double)]
_gdPoints = []
, _gdColor :: Maybe Color
_gdColor = forall a. Maybe a
Nothing
, _gdHoverColor :: Maybe Color
_gdHoverColor = forall a. Maybe a
Nothing
, _gdActiveColor :: Maybe Color
_gdActiveColor = forall a. Maybe a
Nothing
, _gdBorderColor :: Maybe Color
_gdBorderColor = forall a. Maybe a
Nothing
, _gdWidth :: Maybe Double
_gdWidth = forall a. Maybe a
Nothing
, _gdRadius :: Maybe Double
_gdRadius = forall a. Maybe a
Nothing
, _gdSeparate :: Maybe Bool
_gdSeparate = forall a. Maybe a
Nothing
, _gdFill :: Maybe Bool
_gdFill = forall a. Maybe a
Nothing
, _gdFillAlpha :: Maybe Double
_gdFillAlpha = forall a. Maybe a
Nothing
, _gdDuration :: Maybe Millisecond
_gdDuration = forall a. Maybe a
Nothing
, _gdFinishedReq :: [WidgetRequest s e]
_gdFinishedReq = []
, _gdChangeReq :: [Int -> (Double, Double) -> WidgetRequest s e]
_gdChangeReq = []
, _gdEnterReq :: [Int -> WidgetRequest s e]
_gdEnterReq = []
, _gdLeaveReq :: [Int -> WidgetRequest s e]
_gdLeaveReq = []
, _gdClickReq :: [Int -> WidgetRequest s e]
_gdClickReq = []
}
instance Semigroup (GraphData s e) where
<> :: GraphData s e -> GraphData s e -> GraphData s e
(<>) GraphData s e
a1 GraphData s e
a2 = forall a. Default a => a
def
{ _gdPoints :: [(Double, Double)]
_gdPoints = forall s e. GraphData s e -> [(Double, Double)]
_gdPoints GraphData s e
a1 forall a. Semigroup a => a -> a -> a
<> forall s e. GraphData s e -> [(Double, Double)]
_gdPoints GraphData s e
a2
, _gdColor :: Maybe Color
_gdColor = forall s e. GraphData s e -> Maybe Color
_gdColor GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Color
_gdColor GraphData s e
a1
, _gdHoverColor :: Maybe Color
_gdHoverColor = forall s e. GraphData s e -> Maybe Color
_gdHoverColor GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Color
_gdHoverColor GraphData s e
a1
, _gdActiveColor :: Maybe Color
_gdActiveColor = forall s e. GraphData s e -> Maybe Color
_gdActiveColor GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Color
_gdActiveColor GraphData s e
a1
, _gdBorderColor :: Maybe Color
_gdBorderColor = forall s e. GraphData s e -> Maybe Color
_gdBorderColor GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Color
_gdBorderColor GraphData s e
a1
, _gdWidth :: Maybe Double
_gdWidth = forall s e. GraphData s e -> Maybe Double
_gdWidth GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Double
_gdWidth GraphData s e
a1
, _gdRadius :: Maybe Double
_gdRadius = forall s e. GraphData s e -> Maybe Double
_gdRadius GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Double
_gdRadius GraphData s e
a1
, _gdSeparate :: Maybe Bool
_gdSeparate = forall s e. GraphData s e -> Maybe Bool
_gdSeparate GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Bool
_gdSeparate GraphData s e
a1
, _gdFill :: Maybe Bool
_gdFill = forall s e. GraphData s e -> Maybe Bool
_gdFill GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Bool
_gdFill GraphData s e
a1
, _gdFillAlpha :: Maybe Double
_gdFillAlpha = forall s e. GraphData s e -> Maybe Double
_gdFillAlpha GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Double
_gdFillAlpha GraphData s e
a1
, _gdDuration :: Maybe Millisecond
_gdDuration = forall s e. GraphData s e -> Maybe Millisecond
_gdDuration GraphData s e
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall s e. GraphData s e -> Maybe Millisecond
_gdDuration GraphData s e
a1
, _gdFinishedReq :: [WidgetRequest s e]
_gdFinishedReq = forall s e. GraphData s e -> [WidgetRequest s e]
_gdFinishedReq GraphData s e
a1 forall a. Semigroup a => a -> a -> a
<> forall s e. GraphData s e -> [WidgetRequest s e]
_gdFinishedReq GraphData s e
a2
, _gdChangeReq :: [Int -> (Double, Double) -> WidgetRequest s e]
_gdChangeReq = forall s e.
GraphData s e -> [Int -> (Double, Double) -> WidgetRequest s e]
_gdChangeReq GraphData s e
a1 forall a. Semigroup a => a -> a -> a
<> forall s e.
GraphData s e -> [Int -> (Double, Double) -> WidgetRequest s e]
_gdChangeReq GraphData s e
a2
, _gdEnterReq :: [Int -> WidgetRequest s e]
_gdEnterReq = forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdEnterReq GraphData s e
a1 forall a. Semigroup a => a -> a -> a
<> forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdEnterReq GraphData s e
a2
, _gdLeaveReq :: [Int -> WidgetRequest s e]
_gdLeaveReq = forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdLeaveReq GraphData s e
a1 forall a. Semigroup a => a -> a -> a
<> forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdLeaveReq GraphData s e
a2
, _gdClickReq :: [Int -> WidgetRequest s e]
_gdClickReq = forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdClickReq GraphData s e
a1 forall a. Semigroup a => a -> a -> a
<> forall s e. GraphData s e -> [Int -> WidgetRequest s e]
_gdClickReq GraphData s e
a2
}
instance Monoid (GraphData s e) where
mempty :: GraphData s e
mempty = forall a. Default a => a
def
graphPoint :: (Double, Double) -> GraphData s e
graphPoint :: forall s e. (Double, Double) -> GraphData s e
graphPoint (Double, Double)
point = forall s e. [(Double, Double)] -> GraphData s e
graphPoints [(Double, Double)
point]
graphPoints :: [(Double, Double)] -> GraphData s e
graphPoints :: forall s e. [(Double, Double)] -> GraphData s e
graphPoints [(Double, Double)]
points = forall a. Default a => a
def
{ _gdPoints :: [(Double, Double)]
_gdPoints = [(Double, Double)]
points
}
graphColor :: Color -> GraphData s e
graphColor :: forall s e. Color -> GraphData s e
graphColor Color
color = forall a. Default a => a
def
{ _gdColor :: Maybe Color
_gdColor = forall a. a -> Maybe a
Just Color
color
}
graphHoverColor :: Color -> GraphData s e
graphHoverColor :: forall s e. Color -> GraphData s e
graphHoverColor Color
color = forall a. Default a => a
def
{ _gdHoverColor :: Maybe Color
_gdHoverColor = forall a. a -> Maybe a
Just Color
color
}
graphActiveColor :: Color -> GraphData s e
graphActiveColor :: forall s e. Color -> GraphData s e
graphActiveColor Color
color = forall a. Default a => a
def
{ _gdActiveColor :: Maybe Color
_gdActiveColor = forall a. a -> Maybe a
Just Color
color
}
graphBorderColor :: Color -> GraphData s e
graphBorderColor :: forall s e. Color -> GraphData s e
graphBorderColor Color
color = forall a. Default a => a
def
{ _gdBorderColor :: Maybe Color
_gdBorderColor = forall a. a -> Maybe a
Just Color
color
}
graphWidth :: Double -> GraphData s e
graphWidth :: forall s e. Double -> GraphData s e
graphWidth Double
w = forall a. Default a => a
def
{ _gdWidth :: Maybe Double
_gdWidth = forall a. a -> Maybe a
Just Double
w
}
graphRadius :: Double -> GraphData s e
graphRadius :: forall s e. Double -> GraphData s e
graphRadius Double
r = forall a. Default a => a
def
{ _gdRadius :: Maybe Double
_gdRadius = forall a. a -> Maybe a
Just Double
r
}
graphSeparate :: GraphData s e
graphSeparate :: forall s e. GraphData s e
graphSeparate = forall s e. Bool -> GraphData s e
graphSeparate_ Bool
True
graphSeparate_ :: Bool -> GraphData s e
graphSeparate_ :: forall s e. Bool -> GraphData s e
graphSeparate_ Bool
separate = forall a. Default a => a
def
{ _gdSeparate :: Maybe Bool
_gdSeparate = forall a. a -> Maybe a
Just Bool
separate
}
graphFill :: GraphData s e
graphFill :: forall s e. GraphData s e
graphFill = forall s e. Bool -> GraphData s e
graphFill_ Bool
True
graphFill_ :: Bool -> GraphData s e
graphFill_ :: forall s e. Bool -> GraphData s e
graphFill_ Bool
v = forall a. Default a => a
def
{ _gdFill :: Maybe Bool
_gdFill = forall a. a -> Maybe a
Just Bool
v
}
graphFillAlpha :: Double -> GraphData s e
graphFillAlpha :: forall s e. Double -> GraphData s e
graphFillAlpha Double
alpha = forall a. Default a => a
def
{ _gdFillAlpha :: Maybe Double
_gdFillAlpha = forall a. a -> Maybe a
Just Double
alpha
}
graphDuration :: Millisecond -> GraphData s e
graphDuration :: forall s e. Millisecond -> GraphData s e
graphDuration Millisecond
dur = forall a. Default a => a
def
{ _gdDuration :: Maybe Millisecond
_gdDuration = forall a. a -> Maybe a
Just Millisecond
dur
}
graphOnFinished :: WidgetEvent e => e -> GraphData s e
graphOnFinished :: forall e s. WidgetEvent e => e -> GraphData s e
graphOnFinished e
handler = forall a. Default a => a
def
{ _gdFinishedReq :: [WidgetRequest s e]
_gdFinishedReq = [forall s e. WidgetEvent e => e -> WidgetRequest s e
RaiseEvent e
handler]
}
graphOnFinishedReq :: WidgetRequest s e -> GraphData s e
graphOnFinishedReq :: forall s e. WidgetRequest s e -> GraphData s e
graphOnFinishedReq WidgetRequest s e
req = forall a. Default a => a
def
{ _gdFinishedReq :: [WidgetRequest s e]
_gdFinishedReq = [WidgetRequest s e
req]
}
graphOnChange
:: WidgetEvent e
=> (Int -> (Double, Double) -> e)
-> GraphData s e
graphOnChange :: forall e s.
WidgetEvent e =>
(Int -> (Double, Double) -> e) -> GraphData s e
graphOnChange Int -> (Double, Double) -> e
f = forall a. Default a => a
def
{ _gdChangeReq :: [Int -> (Double, Double) -> WidgetRequest s e]
_gdChangeReq = [(forall s e. WidgetEvent e => e -> WidgetRequest s e
RaiseEvent forall b c a. (b -> c) -> (a -> b) -> a -> c
.) forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> (Double, Double) -> e
f]
}
graphOnChangeReq
:: (Int -> (Double, Double) -> WidgetRequest s e)
-> GraphData s e
graphOnChangeReq :: forall s e.
(Int -> (Double, Double) -> WidgetRequest s e) -> GraphData s e
graphOnChangeReq Int -> (Double, Double) -> WidgetRequest s e
req = forall a. Default a => a
def
{ _gdChangeReq :: [Int -> (Double, Double) -> WidgetRequest s e]
_gdChangeReq = [Int -> (Double, Double) -> WidgetRequest s e
req]
}
graphOnEnter :: WidgetEvent e => (Int -> e) -> GraphData s e
graphOnEnter :: forall e s. WidgetEvent e => (Int -> e) -> GraphData s e
graphOnEnter Int -> e
f = forall a. Default a => a
def
{ _gdEnterReq :: [Int -> WidgetRequest s e]
_gdEnterReq = [forall s e. WidgetEvent e => e -> WidgetRequest s e
RaiseEvent forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> e
f]
}
graphOnEnterReq :: (Int -> WidgetRequest s e) -> GraphData s e
graphOnEnterReq :: forall s e. (Int -> WidgetRequest s e) -> GraphData s e
graphOnEnterReq Int -> WidgetRequest s e
req = forall a. Default a => a
def
{ _gdEnterReq :: [Int -> WidgetRequest s e]
_gdEnterReq = [Int -> WidgetRequest s e
req]
}
graphOnLeave :: WidgetEvent e => (Int -> e) -> GraphData s e
graphOnLeave :: forall e s. WidgetEvent e => (Int -> e) -> GraphData s e
graphOnLeave Int -> e
f = forall a. Default a => a
def
{ _gdLeaveReq :: [Int -> WidgetRequest s e]
_gdLeaveReq = [forall s e. WidgetEvent e => e -> WidgetRequest s e
RaiseEvent forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> e
f]
}
graphOnLeaveReq :: (Int -> WidgetRequest s e) -> GraphData s e
graphOnLeaveReq :: forall s e. (Int -> WidgetRequest s e) -> GraphData s e
graphOnLeaveReq Int -> WidgetRequest s e
req = forall a. Default a => a
def
{ _gdLeaveReq :: [Int -> WidgetRequest s e]
_gdLeaveReq = [Int -> WidgetRequest s e
req]
}
graphOnClick :: WidgetEvent e => (Int -> e) -> GraphData s e
graphOnClick :: forall e s. WidgetEvent e => (Int -> e) -> GraphData s e
graphOnClick Int -> e
f = forall a. Default a => a
def
{ _gdClickReq :: [Int -> WidgetRequest s e]
_gdClickReq = [forall s e. WidgetEvent e => e -> WidgetRequest s e
RaiseEvent forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> e
f]
}
graphOnClickReq :: (Int -> WidgetRequest s e) -> GraphData s e
graphOnClickReq :: forall s e. (Int -> WidgetRequest s e) -> GraphData s e
graphOnClickReq Int -> WidgetRequest s e
req = forall a. Default a => a
def
{ _gdClickReq :: [Int -> WidgetRequest s e]
_gdClickReq = [Int -> WidgetRequest s e
req]
}