Skip to content

Commit

Permalink
headSize and tailSize use applyGTAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyrosenbluth committed Mar 25, 2014
1 parent c9407f8 commit 3092b71
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/Diagrams/TwoD.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ module Diagrams.TwoD
, tailStyle
, shaftColor
, shaftStyle
, HeadSize, headSize, headSizeA, getHeadSize, setHeadSize
, TailSize, tailSize, tailSizeA, getTailSize, setTailSize
, HeadSize, headSize, headSizeA, getHeadSize
, TailSize, tailSize, tailSizeA, getTailSize

-- * Text
, text, topLeftText, alignedText, baselineText
, font, fontSize, italic, oblique, bold, setFontSize
, font, fontSize, italic, oblique, bold

-- * Images
, Image, image
Expand Down
23 changes: 9 additions & 14 deletions src/Diagrams/TwoD/Arrow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ module Diagrams.TwoD.Arrow
, arrow'

-- * Attributes
, HeadSize, headSize, headSizeA, getHeadSize, setHeadSize
, TailSize, tailSize, tailSizeA, getTailSize, setTailSize
, HeadSize, headSize, headSizeA, getHeadSize
, TailSize, tailSize, tailSizeA, getTailSize

-- * Options
, ArrowOpts(..)
Expand Down Expand Up @@ -103,6 +103,7 @@ import Control.Lens (Lens', Setter', Traversal',
makeLensesWith, (%~), (&), (.~),
(^.))
import Data.AffineSpace
import Data.Data
import Data.Default.Class
import Data.Functor ((<$>))
import Data.Maybe (fromMaybe)
Expand Down Expand Up @@ -286,7 +287,7 @@ tailSty opts = fc black (opts^.tailStyle)

-- | Radius of a circumcircle around the head.
newtype HeadSize = HeadSize (Last (Measure Double))
deriving (Typeable, Semigroup)
deriving (Typeable, Data, Semigroup)
instance AttributeClass HeadSize

type instance V HeadSize = R2
Expand All @@ -301,19 +302,16 @@ instance Default HeadSize where

-- | Set the radius of the circumcircle around the head.
headSize :: (HasStyle a, V a ~ R2) => Measure Double -> a -> a
headSize = applyTAttr . HeadSize . Last

setHeadSize :: (Measure Double) -> Style R2 -> Style R2
setHeadSize = setAttr . HeadSize . Last
headSize = applyGTAttr . HeadSize . Last

headSizeA :: (HasStyle a, V a ~ R2) => HeadSize -> a -> a
headSizeA = applyTAttr
headSizeA = applyGTAttr

getHeadSize :: HeadSize -> Measure Double
getHeadSize (HeadSize (Last s)) = s

newtype TailSize = TailSize (Last (Measure Double))
deriving (Typeable, Semigroup)
deriving (Typeable, Data, Semigroup)
instance AttributeClass TailSize

type instance V TailSize = R2
Expand All @@ -328,13 +326,10 @@ instance Default TailSize where

-- | Set the radius of a circumcircle around the arrow tail.
tailSize :: (HasStyle a, V a ~ R2) => Measure Double -> a -> a
tailSize = applyTAttr . TailSize . Last

setTailSize :: (Measure Double) -> Style R2 -> Style R2
setTailSize = setAttr . TailSize . Last
tailSize = applyGTAttr . TailSize . Last

tailSizeA :: (HasStyle a, V a ~ R2) => TailSize -> a -> a
tailSizeA = applyTAttr
tailSizeA = applyGTAttr

getTailSize :: TailSize -> Measure Double
getTailSize (TailSize (Last s)) = s
Expand Down
8 changes: 1 addition & 7 deletions src/Diagrams/TwoD/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Diagrams.TwoD.Text (
-- ** Font family
, Font(..), getFont, font
-- ** Font size
, FontSize(..), getFontSize, fontSize, fontSizeA, setFontSize
, FontSize(..), getFontSize, fontSize, fontSizeA
-- ** Font slant
, FontSlant(..), FontSlantA, getFontSlant, fontSlant, italic, oblique
-- ** Font weight
Expand All @@ -37,13 +37,9 @@ import Diagrams.Core.Style (setAttr)
import Diagrams.TwoD.Types

import Data.AffineSpace ((.-.))

import Data.Semigroup

import Data.Colour

import Data.Default.Class

import Data.Typeable

------------------------------------------------------------
Expand Down Expand Up @@ -177,8 +173,6 @@ instance Default FontSize where
getFontSize :: FontSize -> Measure Double
getFontSize (FontSize (Last s)) = s

setFontSize :: (Measure Double) -> Style R2 -> Style R2
setFontSize = setAttr . FontSize . Last
-- | Set the font size, that is, the size of the font's em-square as
-- measured within the current local vector space. The default size
-- is @1@.
Expand Down

1 comment on commit 3092b71

@jeffreyrosenbluth
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to handle dashing properly

Please sign in to comment.