annotate togglePanel.urs @ 30:c1f06342c81f

Add margin example
author Adam Chlipala <adam@chlipala.net>
date Sat, 12 May 2012 10:07:45 -0400
parents 7d0014542199
children
rev   line source
kkallio@8 1 (* TogglePanel provides a panel or section of xml which appears and
kkallio@8 2 * disappears when the user activates an associated control. The
kkallio@8 3 * panel may contain another gui widget as content. *)
kkallio@8 4
rmbruijn@19 5 con togglePanel :: Type -> {Unit} -> Type
adam@20 6 (* The type of appearing and disappearing panels. The arguments
adam@20 7 * are as for [Gui.gui]. *)
kkallio@8 8
adam@27 9 con formatCtl = fn ctx :: {Unit} => [[Dyn] ~ ctx] =>
adam@27 10 {FormatPanel : xml ([Dyn] ++ ctx) [] []
adam@27 11 -> xml ([Dyn] ++ ctx) [] []
adam@27 12 -> xml ([Dyn] ++ ctx) [] [],
adam@20 13 (* Allows for formatting the panel. The first two parameters
adam@20 14 * represent "holes" for the control and panel respectively while
adam@20 15 * the result should be the desired XML laying out the whole structure.
adam@20 16 * The controls can be formatted with the options below.
adam@20 17 * The panel part appears and disappears according to the use
adam@20 18 * of the controls. *)
adam@20 19
adam@27 20 OpenCtl : transaction unit -> xml ([Dyn] ++ ctx) [] [],
adam@20 21 (* This should accept the transaction representing the opening of
adam@20 22 * the panel and produce an XML control having this as action. *)
rmbruijn@19 23
adam@27 24 CloseCtl : transaction unit -> xml ([Dyn] ++ ctx) [] []}
adam@20 25 (* This should accept the transaction representing the closing of
adam@20 26 * the panel and produce an xml control having this as action. *)
kkallio@8 27
kkallio@8 28 (* Some reasonable default formats for the layout and controls. *)
adam@27 29 val defaultFormat : formatCtl body'
kkallio@8 30
adam@20 31 val create : t ::: Type -> ctx ::: {Unit} ->
adam@27 32 formatCtl ctx (* Formatting instructions *)
adam@20 33 -> t (* Enclosed widget *)
adam@20 34 -> bool (* Start in open state? *)
adam@20 35 -> transaction (togglePanel t ctx)
kkallio@8 36
adam@20 37 val gui_togglePanel : t ::: Type -> ctx ::: {Unit}
adam@20 38 -> Gui.gui t ctx
adam@20 39 -> Gui.gui (togglePanel t ctx) ctx
kkallio@8 40 (* The togglePanel is itself a widget. It can be pretty printed to a piece
adam@20 41 * of XML with a use of [toXml]. *)
adam@28 42
adam@28 43 val isOpen : t ::: Type -> ctx ::: {Unit} -> togglePanel t ctx -> signal bool
adam@28 44 (* Is the inner content currently being displayed? *)