module Graphics.UI.GLUT.Overlay (
hasOverlay, overlayPossible,
overlayVisible,
Layer(..), layerInUse,
postOverlayRedisplay
) where
import Control.Monad.IO.Class ( MonadIO(..) )
import Data.StateVar ( GettableStateVar, makeGettableStateVar
, SettableStateVar, makeSettableStateVar
, StateVar, makeStateVar )
import Graphics.Rendering.OpenGL ( GLenum )
import Graphics.UI.GLUT.QueryUtils
import Graphics.UI.GLUT.Raw
import Graphics.UI.GLUT.Types
hasOverlay :: StateVar Bool
hasOverlay :: StateVar Bool
hasOverlay = IO Bool -> (Bool -> IO ()) -> StateVar Bool
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO Bool
getHasOverlay Bool -> IO ()
setHasOverlay
setHasOverlay :: Bool -> IO ()
setHasOverlay :: Bool -> IO ()
setHasOverlay Bool
False = IO ()
forall (m :: * -> *). MonadIO m => m ()
glutRemoveOverlay
setHasOverlay Bool
True = IO ()
forall (m :: * -> *). MonadIO m => m ()
glutEstablishOverlay
getHasOverlay :: IO Bool
getHasOverlay :: IO Bool
getHasOverlay = Getter Bool
forall a. Getter a
layerGet (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) GLenum
glut_HAS_OVERLAY
overlayPossible :: GettableStateVar Bool
overlayPossible :: IO Bool
overlayPossible = IO Bool -> IO Bool
forall a. IO a -> IO a
makeGettableStateVar (IO Bool -> IO Bool) -> IO Bool -> IO Bool
forall a b. (a -> b) -> a -> b
$ Getter Bool
forall a. Getter a
layerGet (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) GLenum
glut_OVERLAY_POSSIBLE
overlayVisible :: SettableStateVar Bool
overlayVisible :: SettableStateVar Bool
overlayVisible =
(Bool -> IO ()) -> SettableStateVar Bool
forall a. (a -> IO ()) -> SettableStateVar a
makeSettableStateVar ((Bool -> IO ()) -> SettableStateVar Bool)
-> (Bool -> IO ()) -> SettableStateVar Bool
forall a b. (a -> b) -> a -> b
$ \Bool
flag ->
if Bool
flag then IO ()
forall (m :: * -> *). MonadIO m => m ()
glutShowOverlay else IO ()
forall (m :: * -> *). MonadIO m => m ()
glutHideOverlay
data Layer
= Normal
| Overlay
deriving ( Layer -> Layer -> Bool
(Layer -> Layer -> Bool) -> (Layer -> Layer -> Bool) -> Eq Layer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Layer -> Layer -> Bool
$c/= :: Layer -> Layer -> Bool
== :: Layer -> Layer -> Bool
$c== :: Layer -> Layer -> Bool
Eq, Eq Layer
Eq Layer
-> (Layer -> Layer -> Ordering)
-> (Layer -> Layer -> Bool)
-> (Layer -> Layer -> Bool)
-> (Layer -> Layer -> Bool)
-> (Layer -> Layer -> Bool)
-> (Layer -> Layer -> Layer)
-> (Layer -> Layer -> Layer)
-> Ord Layer
Layer -> Layer -> Bool
Layer -> Layer -> Ordering
Layer -> Layer -> Layer
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Layer -> Layer -> Layer
$cmin :: Layer -> Layer -> Layer
max :: Layer -> Layer -> Layer
$cmax :: Layer -> Layer -> Layer
>= :: Layer -> Layer -> Bool
$c>= :: Layer -> Layer -> Bool
> :: Layer -> Layer -> Bool
$c> :: Layer -> Layer -> Bool
<= :: Layer -> Layer -> Bool
$c<= :: Layer -> Layer -> Bool
< :: Layer -> Layer -> Bool
$c< :: Layer -> Layer -> Bool
compare :: Layer -> Layer -> Ordering
$ccompare :: Layer -> Layer -> Ordering
$cp1Ord :: Eq Layer
Ord, Int -> Layer -> ShowS
[Layer] -> ShowS
Layer -> String
(Int -> Layer -> ShowS)
-> (Layer -> String) -> ([Layer] -> ShowS) -> Show Layer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Layer] -> ShowS
$cshowList :: [Layer] -> ShowS
show :: Layer -> String
$cshow :: Layer -> String
showsPrec :: Int -> Layer -> ShowS
$cshowsPrec :: Int -> Layer -> ShowS
Show )
marshalLayer :: Layer -> GLenum
marshalLayer :: Layer -> GLenum
marshalLayer Layer
x = case Layer
x of
Layer
Normal -> GLenum
glut_NORMAL
Layer
Overlay -> GLenum
glut_OVERLAY
unmarshalLayer :: GLenum -> Layer
unmarshalLayer :: GLenum -> Layer
unmarshalLayer GLenum
x
| GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
glut_NORMAL = Layer
Normal
| GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
glut_OVERLAY = Layer
Overlay
| Bool
otherwise = String -> Layer
forall a. HasCallStack => String -> a
error (String
"unmarshalLayer: illegal value " String -> ShowS
forall a. [a] -> [a] -> [a]
++ GLenum -> String
forall a. Show a => a -> String
show GLenum
x)
layerInUse :: StateVar Layer
layerInUse :: StateVar Layer
layerInUse =
IO Layer -> (Layer -> IO ()) -> StateVar Layer
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO Layer
getLayerInUse Layer -> IO ()
setLayerInUse
setLayerInUse :: Layer -> IO ()
setLayerInUse :: Layer -> IO ()
setLayerInUse = GLenum -> IO ()
forall (m :: * -> *). MonadIO m => GLenum -> m ()
glutUseLayer (GLenum -> IO ()) -> (Layer -> GLenum) -> Layer -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Layer -> GLenum
marshalLayer
getLayerInUse :: IO Layer
getLayerInUse :: IO Layer
getLayerInUse = Getter Layer
forall a. Getter a
layerGet (GLenum -> Layer
unmarshalLayer (GLenum -> Layer) -> (CInt -> GLenum) -> CInt -> Layer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> GLenum
forall a b. (Integral a, Num b) => a -> b
fromIntegral) GLenum
glut_LAYER_IN_USE
postOverlayRedisplay :: MonadIO m => Maybe Window -> m ()
postOverlayRedisplay :: Maybe Window -> m ()
postOverlayRedisplay =
m () -> (Window -> m ()) -> Maybe Window -> m ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe m ()
forall (m :: * -> *). MonadIO m => m ()
glutPostOverlayRedisplay (\(Window CInt
win) -> CInt -> m ()
forall (m :: * -> *). MonadIO m => CInt -> m ()
glutPostWindowOverlayRedisplay CInt
win)