diff options
author | Camil Staps | 2018-01-07 10:37:27 +0100 |
---|---|---|
committer | Camil Staps | 2018-01-07 10:37:27 +0100 |
commit | ef8bbdd666328d40ed291a64840c962e760604e2 (patch) | |
tree | d55df1445676006cacac75c94687cdc94240ba1c /assignment-13/uFPL | |
parent | Fix import in assignment 8 (diff) |
Layouting
Diffstat (limited to 'assignment-13/uFPL')
-rw-r--r-- | assignment-13/uFPL/Sim.icl | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/assignment-13/uFPL/Sim.icl b/assignment-13/uFPL/Sim.icl index 7556867..35f0465 100644 --- a/assignment-13/uFPL/Sim.icl +++ b/assignment-13/uFPL/Sim.icl @@ -14,6 +14,7 @@ import Text.HTML import iTasks import iTasks.Extensions.DateTime import iTasks.UI.Editor.Common +import iTasks.UI.Layout.Default import uFPL import uFPL.Bootstrap @@ -28,7 +29,18 @@ where toString RunException = "Could not run" derive class iTask Signedness, CType, ReadOrWrite, IShared, IExpr, ITrigger, - IRule, INamedRule, IState, IShareState, Display + IRule, INamedRule, IState, IShareState + +gDefault{|Display|} = + { size = (16, 2) + , cursor = (0, 0) + , text = 'M'.newMap + } +derive gEditor Display +derive gText Display +derive gEq Display +derive JSONEncode Display +derive JSONDecode Display class lift a :: a -> Task Dynamic class unlift a b :: b -> a @@ -288,14 +300,18 @@ where set (unlift (allShares rs)) ishares sim = + (check -&&- show) + -&&- (updateSharedInformation (Title "Rules") - [UpdateUsing id (const id) (listEditor (Just $ const Nothing) True False Nothing gEditor{|*|})] irules + [UpdateUsing id (const id) (listEditor (Just $ const Nothing) True False Nothing ruleEditor)] irules -&&- updateSharedInformation (Title "Shares") [UpdateUsing id (const id) (listEditor (Just $ const Nothing) True False Nothing gEditor{|*|})] ishares - ) -&&- - (check -&&- show) + ) <<@ ArrangeHorizontal + where + ruleEditor :: Editor INamedRule + ruleEditor = gEditor{|*|} newShares :: [INamedRule] IShares -> Task IState newShares rs shrs = get istate >>= lift >>= \ist -> case ist of @@ -319,7 +335,7 @@ where show :: Task IState show = viewSharedInformation (Title "State") [viewAsLists] istate where - viewAsLists = ViewUsing tolists $ container3 listView listView listView + viewAsLists = ViewUsing tolists $ container4 listView listView listView (textView <<@ styleAttr "font-family:monospace;") with listView :: Editor [(String,IShareState a)] | iTask, == a listView = listEditor Nothing False False Nothing itemView @@ -336,20 +352,26 @@ where with intView s = comapEditorValue (\i -> s <+ ": " <+ i) textView - tolists :: IState -> ([(String, IShareState Int)], [(String, IShareState Char)], [(String, IShareState Bool)]) - tolists st = ('M'.toList st.isvalues, 'M'.toList st.csvalues, 'M'.toList st.bsvalues) + tolists :: IState -> ([(String, IShareState Int)], [(String, IShareState Char)], [(String, IShareState Bool)], String) + tolists st = ('M'.toList st.isvalues, 'M'.toList st.csvalues, 'M'.toList st.bsvalues, toString st.IState.display) check :: Task String check = whileUnchanged (irules >*< ishares) (\(rs,shrs) -> catchAll (lift rs >>| return "OK") return - >>= viewInformation (Title "Status") + >>= \stat -> (viewInformation (Title "Status") [ViewUsing id $ viewComponent (\text -> 'M'.unions [ valueAttr (JSONString (escapeStr text)) , styleAttr (if (text == "OK") "" "color:red;font-weight:bold;") - ]) UITextView] + ]) UITextView] stat >>* buttonActions shrs ++ millisActions shrs ++ [action "Step" $ step]) + <<@ ApplyLayout (sequenceLayouts + finalizeStep + (layoutSubUIs (SelectByType UIButtonBar) arrangeVertical)) + <<@ ApplyLayout (setUIAttributes (widthAttr (ExactSize 400))) + <<@ ApplyLayout (layoutSubUIs (SelectOR (SelectByPath []) (SelectByPath [0])) $ setUIAttributes (heightAttr WrapSize)) + ) where action :: String (Task a) -> TaskCont String (Task String) | iTask a action s t = OnAction (Action s) $ ifOk $ t >>- \_ -> check |