kkallio@6: datatype menuState = Open | Closed
kkallio@6:
kkallio@6: type formatCtl = {FormatMenu : xbody -> xbody -> xbody,
kkallio@7: WrapMenu : xbody -> xbody,
kkallio@6: OpenCtl : transaction unit -> xbody,
kkallio@6: CloseCtl : transaction unit -> xbody}
kkallio@6:
kkallio@7: val defaultFormat = {FormatMenu = fn ctl menu => {ctl}{menu},
kkallio@7: WrapMenu = fn menu => ,
kkallio@6: OpenCtl = fn behaviour => ,
kkallio@6: CloseCtl = fn behaviour => }
kkallio@6:
kkallio@6: open Navbar
kkallio@6:
kkallio@6: con popupNav t = {MenuState : source menuState,
kkallio@6: FormatCtl : formatCtl,
kkallio@6: NavBar : navBar t}
kkallio@6:
kkallio@6: fun create [t ::: Type] (f : formatCtl) (m : mode t) (bar : navBar t) : transaction (popupNav t) =
kkallio@6: state <- source Closed;
kkallio@6:
kkallio@6: return {MenuState = state,
kkallio@6: FormatCtl = f,
kkallio@6: NavBar = bar}
kkallio@6:
kkallio@6: fun render [t ::: Type] (m : mode t) (popup : popupNav t) =
kkallio@6: popup.FormatCtl.FormatMenu
kkallio@6:
kkallio@6: {popup.FormatCtl.CloseCtl (set popup.MenuState Closed)}
kkallio@6: | Closed => {popup.FormatCtl.OpenCtl (set popup.MenuState Open)})
kkallio@6: }/>
kkallio@6:
kkallio@6:
kkallio@6:
kkallio@6: {popup.FormatCtl.WrapMenu (navBarToXml popup.NavBar)}
kkallio@6: | Closed => )
kkallio@6: }/>
kkallio@6: