Commit 989a0940 authored by Bas Lijnse's avatar Bas Lijnse

Cleaned up and refactorred the layout rule mechanism

parent 361ecd95
......@@ -189,15 +189,13 @@ extractDownstreamChange :: (LUI,LUIMoves) -> (!UIChange,!(LUI,LUIMoves))
extractUIWithEffects :: (LUI,LUIMoves) -> (!UI,!(LUI,LUIMoves))
//Helper functions (exported for unit testing)
adjustIndex_ :: LUINo Int [LUI] LUIMoves -> Int
scanToPosition_ :: LUINo Int [LUI] LUIMoves -> (Int,Bool,Maybe LUI)
selectChildNodes_ :: LUINo ([LUI],LUIMoves) -> [LUI]
updateChildNodes_ :: LUINo (Int (LUI,LUIMoves) -> (LUI,LUIMoves)) ([LUI],LUIMoves) -> ([LUI],LUIMoves)
selectSubNode_ :: LUINo UIPath (LUI,LUIMoves) -> Maybe LUI
updateSubNode_ :: LUINo UIPath ((LUI,LUIMoves) -> (LUI,LUIMoves)) (LUI,LUIMoves) -> (LUI,LUIMoves)
scanToPosition_ :: LUINo Int [LUI] LUIMoves -> (Int,Bool,Maybe LUI)
selectAttributes_ :: UIAttributeSelection UIAttributes -> UIAttributes
overwriteAttribute_ :: LUINo UIAttribute (Map UIAttributeKey (LUIEffectStage (LUINo,JSONNode))) -> (Map UIAttributeKey (LUIEffectStage (LUINo,JSONNode)))
hideAttribute_ :: LUINo (UIAttributeKey -> Bool) UIAttributeKey (Map UIAttributeKey (LUIEffectStage LUINo)) -> (Map UIAttributeKey (LUIEffectStage LUINo))
matchKey_ :: UIAttributeSelection UIAttributeKey -> Bool
matchAttributeKey_ :: UIAttributeSelection UIAttributeKey -> Bool
This diff is collapsed.
......@@ -45,7 +45,7 @@ where
delUIAttributesRef_ :: UIAttributeSelection -> (UI -> UI)
delUIAttributesRef_ selection = ref
where
ref (UI type attr items) = UI type (foldl (\a k -> if (matchKey_ selection k) ('DM'.del k a) a) attr ('DM'.keys attr)) items
ref (UI type attr items) = UI type (foldl (\a k -> if (matchAttributeKey_ selection k) ('DM'.del k a) a) attr ('DM'.keys attr)) items
modifyUIAttributesRef_ :: UIAttributeSelection (UIAttributes -> UIAttributes) -> (UI -> UI)
modifyUIAttributesRef_ selection modifier = ref
......@@ -62,7 +62,7 @@ copySubUIAttributesRef_ selection src dst = ref
where
ref ui = updDst dst (selAttr src ui) ui
selAttr [] (UI _ attr _) = [a \\ a=:(k,_) <- 'DM'.toList attr | matchKey_ selection k]
selAttr [] (UI _ attr _) = [a \\ a=:(k,_) <- 'DM'.toList attr | matchAttributeKey_ selection k]
selAttr [s:ss] (UI _ _ items) = if (s >= 0 && s < length items) (selAttr ss (items !! s)) []
updDst [] selected (UI type attr items) = UI type (foldl (\a (k,v) -> 'DM'.put k v a) attr selected) items
......
......@@ -71,14 +71,6 @@ applyUpstreamChangeTests =
] noChanges noEffects
,initLUIMoves)
(applyUpstreamChange (ChangeUI [] [(1,ChangeChild (ReplaceUI (UI UIEmpty 'DM'.newMap [])))]) (lui0,initLUIMoves))
,assertEqual "Helper function for replace adjustIndex"
2
(adjustIndex_ (LUINo []) 1
[LUINode UIInteract 'DM'.newMap [] noChanges noEffects
,LUINode UIEmpty 'DM'.newMap [] noChanges {noEffects & additional = ESApplied (LUINo [1])}
,LUINode UIStep 'DM'.newMap [] {noChanges & toBeReplaced = Just (LUINode UIEmpty 'DM'.newMap [] noChanges noEffects)} noEffects
] initLUIMoves
)
,assertEqual "Child replace (with additional node)"
(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIInteract 'DM'.newMap [] noChanges noEffects
......@@ -136,13 +128,6 @@ applyUpstreamChangeTests =
] noChanges noEffects
,initLUIMoves)
(applyUpstreamChange (ChangeUI [] [(1,InsertChild (UI UIInteract 'DM'.newMap [])),(1,ChangeChild (ReplaceUI (UI UIEmpty 'DM'.newMap [])))]) (lui0,initLUIMoves))
,assertEqual "Helper function for shift adjustIndex"
2
(adjustIndex_ (LUINo [0]) 1
[LUINode UIInteract 'DM'.newMap [] noChanges noEffects
,LUINode UIStep 'DM'.newMap [] {noChanges & toBeShifted = Just 0} noEffects
] initLUIMoves
)
,assertEqual "Child shift down"
(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIInteract 'DM'.newMap [] {noChanges & toBeShifted = Just 0} noEffects
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment