2020-08-05 20:23:16 +00:00
|
|
|
{-# LANGUAGE NegativeLiterals #-}
|
|
|
|
|
2020-08-04 06:15:06 +00:00
|
|
|
module MetaBrush.Asset.TickBox
|
|
|
|
( drawBox, drawTickedBox )
|
|
|
|
where
|
|
|
|
|
|
|
|
-- gi-cairo-render
|
|
|
|
import qualified GI.Cairo.Render as Cairo
|
|
|
|
|
|
|
|
-- gi-gdk
|
|
|
|
import qualified GI.Gdk as GDK
|
|
|
|
|
|
|
|
-- MetaBrush
|
|
|
|
import MetaBrush.Render.Util
|
|
|
|
( withRGBA )
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- | Non-ticked box. Width = 14, height = 12.
|
2020-08-05 20:23:16 +00:00
|
|
|
drawBox :: GDK.RGBA -> Cairo.Render Bool
|
2020-08-04 06:15:06 +00:00
|
|
|
drawBox boxColour = do
|
2020-08-05 20:23:16 +00:00
|
|
|
withRGBA boxColour Cairo.setSourceRGBA
|
2020-08-04 06:15:06 +00:00
|
|
|
|
|
|
|
Cairo.newPath
|
|
|
|
Cairo.moveTo 2.015625 0.769531
|
|
|
|
Cairo.curveTo 0.910156 0.769531 0 1.6875 0 2.789063
|
|
|
|
Cairo.lineTo 0 10
|
|
|
|
Cairo.curveTo 0 11.101563 0.910156 12.015625 2.015625 12.015625
|
|
|
|
Cairo.lineTo 9.226563 12.015625
|
|
|
|
Cairo.curveTo 10.328125 12.015625 11.246094 11.101563 11.246094 10
|
|
|
|
Cairo.lineTo 11.246094 2.789063
|
|
|
|
Cairo.curveTo 11.246094 1.6875 10.328125 0.769531 9.226563 0.769531
|
|
|
|
Cairo.closePath
|
|
|
|
Cairo.moveTo 2.015625 2.375
|
|
|
|
Cairo.lineTo 9.226563 2.375
|
|
|
|
Cairo.curveTo 9.46875 2.375 9.640625 2.546875 9.640625 2.789063
|
|
|
|
Cairo.lineTo 9.640625 10
|
|
|
|
Cairo.curveTo 9.640625 10.242188 9.46875 10.414063 9.226563 10.414063
|
|
|
|
Cairo.lineTo 2.015625 10.414063
|
|
|
|
Cairo.curveTo 1.769531 10.414063 1.597656 10.242188 1.597656 10
|
|
|
|
Cairo.lineTo 1.597656 2.789063
|
|
|
|
Cairo.curveTo 1.597656 2.546875 1.769531 2.375 2.015625 2.375
|
|
|
|
Cairo.closePath
|
|
|
|
|
|
|
|
Cairo.setFillRule Cairo.FillRuleWinding
|
|
|
|
Cairo.fillPreserve
|
|
|
|
|
2020-08-05 20:23:16 +00:00
|
|
|
pure True
|
|
|
|
|
|
|
|
|
2020-08-04 06:15:06 +00:00
|
|
|
-- | Ticked box. Width = 14, height = 12.
|
2020-08-05 20:23:16 +00:00
|
|
|
drawTickedBox :: GDK.RGBA -> GDK.RGBA -> Cairo.Render Bool
|
2020-08-04 06:15:06 +00:00
|
|
|
drawTickedBox boxColour tickColour = do
|
|
|
|
|
|
|
|
-- Box
|
|
|
|
withRGBA boxColour Cairo.setSourceRGBA
|
|
|
|
Cairo.newPath
|
|
|
|
Cairo.moveTo 2.015625 0.769531
|
|
|
|
Cairo.curveTo 0.910156 0.769531 0 1.679688 0 2.785156
|
|
|
|
Cairo.lineTo 0 9.996094
|
|
|
|
Cairo.curveTo 0 11.097656 0.910156 12.015625 2.015625 12.015625
|
|
|
|
Cairo.lineTo 9.226563 12.015625
|
|
|
|
Cairo.curveTo 10.328125 12.015625 11.246094 11.097656 11.246094 9.996094
|
|
|
|
Cairo.lineTo 11.246094 5.867188
|
|
|
|
Cairo.lineTo 9.640625 7.476563
|
|
|
|
Cairo.lineTo 9.640625 9.996094
|
|
|
|
Cairo.curveTo 9.640625 10.238281 9.46875 10.410156 9.226563 10.410156
|
|
|
|
Cairo.lineTo 2.015625 10.410156
|
|
|
|
Cairo.curveTo 1.769531 10.410156 1.597656 10.238281 1.597656 9.996094
|
|
|
|
Cairo.lineTo 1.597656 2.785156
|
|
|
|
Cairo.curveTo 1.597656 2.539063 1.769531 2.371094 2.015625 2.371094
|
|
|
|
Cairo.lineTo 9.226563 2.371094
|
|
|
|
Cairo.curveTo 9.277344 2.371094 9.324219 2.378906 9.367188 2.394531
|
|
|
|
Cairo.lineTo 10.511719 1.25
|
|
|
|
Cairo.curveTo 10.160156 0.957031 9.710938 0.769531 9.226563 0.769531
|
|
|
|
Cairo.closePath
|
|
|
|
Cairo.fillPreserve
|
|
|
|
|
|
|
|
-- Tickmark
|
|
|
|
withRGBA tickColour Cairo.setSourceRGBA
|
|
|
|
Cairo.newPath
|
|
|
|
Cairo.moveTo 13.40625 0.0078125
|
|
|
|
Cairo.curveTo 13.191406 0.0390625 12.96875 0.144531 12.785156 0.328125
|
|
|
|
Cairo.lineTo 6.511719 6.605469
|
|
|
|
Cairo.lineTo 4.597656 4.691406
|
|
|
|
Cairo.curveTo 4.230469 4.328125 3.710938 4.257813 3.425781 4.542969
|
|
|
|
Cairo.lineTo 3.144531 4.820313
|
|
|
|
Cairo.curveTo 2.863281 5.105469 2.929688 5.628906 3.300781 5.992188
|
|
|
|
Cairo.lineTo 5.8125 8.5
|
|
|
|
Cairo.curveTo 5.925781 8.609375 6.046875 8.683594 6.175781 8.738281
|
|
|
|
Cairo.curveTo 6.261719 8.78125 6.332031 8.804688 6.417969 8.816406
|
|
|
|
Cairo.curveTo 6.425781 8.816406 6.429688 8.816406 6.445313 8.816406
|
|
|
|
Cairo.curveTo 6.53125 8.824219 6.605469 8.820313 6.6875 8.796875
|
|
|
|
Cairo.curveTo 6.71875 8.789063 6.746094 8.785156 6.773438 8.773438
|
|
|
|
Cairo.curveTo 6.929688 8.722656 7.085938 8.644531 7.21875 8.511719
|
|
|
|
Cairo.lineTo 14.097656 1.625
|
|
|
|
Cairo.curveTo 14.464844 1.261719 14.53125 0.738281 14.253906 0.453125
|
|
|
|
Cairo.lineTo 13.976563 0.179688
|
|
|
|
Cairo.curveTo 13.835938 0.0351563 13.632813 -0.0195313 13.421875 0.0078125
|
|
|
|
Cairo.closePath
|
|
|
|
Cairo.fillPreserve
|
2020-08-05 20:23:16 +00:00
|
|
|
|
|
|
|
pure True
|