module GUI.GUIExampleInfiniteBtnsAdvanced where
open import StateSizedIO.GUI.BaseStateDependent
open import StateSizedIO.writingOOsUsingIOVers4ReaderMethods hiding (nˢ) renaming(execˢⁱ to execᵢ ; returnˢⁱ to returnᵢ)
open import GUI.Vers1.GUIDefinitions
open import GUI.Vers1.GUIDefinitionsBase
open import SizedIO.Base hiding (_>>_ ; _>>=_) renaming (return to returnIO)
open import SizedIO.Console hiding (main)
open import Data.String hiding (show)
open import GUI.Vers1.GUIExampleLib
open import Data.Fin hiding (_+_)
open import Size
open import Data.Unit
open import Data.Product
open import Data.Nat
open import Data.Nat.Show using (show)
open import NativeIO renaming (nativeReturn to return;
_native>>=_ to _>>=_;
_native>>_ to _>>_)
open import GUI.Vers1.GUICompilation hiding (main)
open import GUI.Vers1.RasterificFFI
nFrame : (n : ℕ) → Frame
nFrame 0 = emptyFrame
nFrame (suc n) = addButton (show n) (nFrame n)
infiniteBtns : ∀{i} → (n : ℕ) → GUI {i}
infiniteBtns n .gui = nFrame n
infiniteBtns 0 .obj .method ()
infiniteBtns (suc n) .obj .method (m , _) =
returnGUI (infiniteBtns (suc n + finToℕ (invertFin m)))
where
finToℕ = toℕ
objn : ∀ {i} → (n : ℕ) → FrameObj {i} (nFrame n)
objn 0 .method ()
objn (suc n) .method (m , _) = returnIO (nFrame m' , objn m')
where
m' = n + toℕ m
main : NativeIO Unit
main = do win <- createWindowFFI
compile win (infiniteBtns 3)
nativePutStrLn "hello Agda"