module GUI.GUIFeaturesPart4 where
open import Data.Sum
open import Data.Product
open import Data.Unit
open import GUI.GUIFeatures
open import GUI.GUIFeaturesPart2
open import GUI.GUIFeaturesPart3
open import GUI.GUIDefinitions
addStateFMachine : {BaseState : Set}
(vm : FMachine BaseState)
(Snew : Set)
(newSM : (s : Snew) →
SMachineState (BaseState ⊎ vm .AddStateF ⊎ Snew) )
→ FMachine BaseState
addStateFMachine {BaseState} vm Snew newSM .Features = vm .Features
addStateFMachine {BaseState} vm Snew newSM .AddStateF = vm .AddStateF ⊎ Snew
addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₁ s) =
mapFMachineHandle (inj₁ s) (vm .GUIF f (inj₁ s))
addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₂ (inj₁ s)) =
mapFMachineHandle (inj₂ s) (vm .GUIF f (inj₂ s))
addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₂ (inj₂ s)) .fSM = newSM s .fSM
addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₂ (inj₂ s)) .handlSM = newSM s .handlSM
addOneStateFMachine : {BaseState : Set}
(vm : FMachine BaseState)
(newSM : SMachineState (BaseState ⊎ vm .AddStateF ⊎ ⊤) )
→ FMachine BaseState
addOneStateFMachine vm newSM = addStateFMachine vm ⊤ λ _ → newSM
addDummyFeatures : {BaseState : Set}
(vm : FMachine BaseState)
(FeatureNew : Set)
→ FMachine BaseState
addDummyFeatures vm FeatureNew .Features = vm .Features × FeatureNew
addDummyFeatures vm FeatureNew .AddStateF = vm .AddStateF
addDummyFeatures vm FeatureNew .GUIF (f , _) s = vm .GUIF f s
cancelNewStateSM : (vm : FMachine StateV) →
SMachineState (StateV ⊎ vm .AddStateF ⊎ ⊤)
cancelNewStateSM vm = simpleSMState "Intermediate" (inj₁ s0)
cancelStateAdded : FMachine StateV → FMachine StateV
cancelStateAdded vm = addOneStateFMachine vm (cancelNewStateSM vm)
cancelFeatureAdded : FMachine StateV → FMachine StateV
cancelFeatureAdded vm = addDummyFeatures
(cancelStateAdded vm)
FeatureCancel
Cancel' : FMachine StateV → FMachine StateV
Cancel' vm .Features = cancelFeatureAdded vm .Features
Cancel' vm .AddStateF = cancelFeatureAdded vm .AddStateF
Cancel' vm .GUIF (f , yesCancel) (inj₁ s1) =
addBtn2StateMachine (cancelFeatureAdded vm .GUIF (f , yesCancel) (inj₁ s1))
"Cancel" (inj₂ (inj₂ _))
Cancel' vm .GUIF f s = cancelFeatureAdded vm .GUIF f s