module GUI.RasterificFFI where
open import Data.String.Base
open import Data.List.Base
open import Data.Unit.Base
open import Data.Maybe
open import Data.Nat
open import Data.Product
open import NativeIO renaming (NativeIO to IO;
nativeReturn to return;
_native>>=_ to _>>=_;
_native>>_ to _>>_)
open import GUI.GUIDefinitionsBase
open import GUI.GUIDefinitions
{-# FOREIGN GHC import qualified DeclareGUI.AgdaInterface as AI #-}
{-# FOREIGN GHC import qualified DeclareGUI.Definitions as D #-}
{-# FOREIGN GHC import qualified DeclareGUI.SDLLIB as SDL #-}
postulate
SDLWindow : Set
FFIFrame : Set
FFIComponent : Set
{-# COMPILE GHC FFIFrame = type D.Frame #-}
{-# COMPILE GHC SDLWindow = type SDL.SDLWindow #-}
{-# COMPILE GHC FFIComponent = type D.Component #-}
FFIComponents : Set
FFIComponents = List FFIComponent
postulate
ffiButton : String → FFIComponent
ffiLabel : String → FFIComponent
ffiTextbox : String → FFIComponent
{-# COMPILE GHC ffiButton = (\x -> D.ButtonComponent (Data.Text.unpack x)) #-}
{-# COMPILE GHC ffiLabel = (\x -> D.LabelComponent (Data.Text.unpack x)) #-}
{-# COMPILE GHC ffiTextbox = (\x -> D.TextboxComponent (Data.Text.unpack x)) #-}
frame2FFI : Frame → FFIComponents
frame2FFI (createCmp tt) = []
frame2FFI (addCmp x buttonIdx (createCmp str)) = ffiButton str ∷ frame2FFI x
frame2FFI (addCmp x labelIdx (createCmp str)) = ffiLabel str ∷ frame2FFI x
frame2FFI (addCmp x textboxIdx (createCmp str)) = ffiTextbox str ∷ frame2FFI x
frame2FFI (addCmp _ buttonIdx (addCmp _ () _))
frame2FFI (addCmp _ labelIdx (addCmp _ () _))
frame2FFI (addCmp _ textboxIdx (addCmp _ () _))
postulate
NumAndStringList : Set
getNum : NumAndStringList → ℕ
getStringList : NumAndStringList → List String
getEventsFFIhs : SDLWindow → FFIComponents → IO NumAndStringList
{-# COMPILE GHC NumAndStringList = type AI.NumAndStringList #-}
{-# COMPILE GHC getNum = AI.getNum #-}
{-# COMPILE GHC getStringList = AI.getStringList #-}
{-# COMPILE GHC getEventsFFIhs = AI.getEventsFFI #-}
getEventsFFI : SDLWindow → Frame → IO (ℕ × (List String))
getEventsFFI win fr = do
x <- getEventsFFIhs win (frame2FFI fr)
return ( getNum x , getStringList x)
postulate
createWindowFFI : IO SDLWindow
renderFrameToScreenFFIhs : SDLWindow → FFIComponents → IO Unit
{-# COMPILE GHC createWindowFFI = SDL.createWindow #-}
{-# COMPILE GHC renderFrameToScreenFFIhs = AI.renderFrameToScreen #-}
renderFrameToScreenFFI : SDLWindow → Frame → IO Unit
renderFrameToScreenFFI win fr = renderFrameToScreenFFIhs win (frame2FFI fr)