# HG changeset patch # User Karn Kallio # Date 1308321725 16200 # Node ID 90be8b8917d52af85b7f4f35548f6d0cbcd1f9c5 # Parent 48a4180171b090a346b64868dc6787c6e54773f2 Add a widget that opens and closes a panel. diff -r 48a4180171b0 -r 90be8b8917d5 examples/togglepanel.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/togglepanel.ur Fri Jun 17 10:12:05 2011 -0430 @@ -0,0 +1,35 @@ +open Gui +open TogglePanel + +val defaultContent : xbody =

Here I am inside the panel.
Default format

+val otherContent : xbody =

Here I am inside the panel.
Other format

+ +val otherFormat = {FormatPanel = fn ctl panel => A Custom {ctl} Format{panel}, + OpenCtl = fn behaviour => View, + CloseCtl = fn behaviour => Hide} + +fun main () = + + defaultFormatPanel <- create defaultFormat defaultContent True; + otherFormatPanel <- create otherFormat otherContent False; + + return + + A panel that can be shown or hidden. + + +

Example using the togglePanel widget.

+

+ This is a widget which has a content display panel + which can be shown or hidden. +

+

Example of the default format, starting open.

+

+ {toXml defaultFormatPanel} +

+

Example of another format, starting closed.

+

+ {toXml otherFormatPanel} +

+ +
diff -r 48a4180171b0 -r 90be8b8917d5 examples/togglepanel.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/togglepanel.urp Fri Jun 17 10:12:05 2011 -0430 @@ -0,0 +1,7 @@ +path META=../../meta +library ../ +rewrite url Togglepanel/* +allow url http://* +prefix http://localhost:8080/ + +togglepanel diff -r 48a4180171b0 -r 90be8b8917d5 examples/togglepanel.urs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/togglepanel.urs Fri Jun 17 10:12:05 2011 -0430 @@ -0,0 +1,1 @@ +val main : unit -> transaction page diff -r 48a4180171b0 -r 90be8b8917d5 gui.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui.ur Fri Jun 17 10:12:05 2011 -0430 @@ -0,0 +1,7 @@ +class gui t = t -> xbody + +fun toXml [t ::: Type] (xmlize : gui t) = xmlize + +fun gui_xbody x = x + +fun mkGui [t ::: Type] (toXml : t -> xbody) = toXml diff -r 48a4180171b0 -r 90be8b8917d5 gui.urs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui.urs Fri Jun 17 10:12:05 2011 -0430 @@ -0,0 +1,14 @@ +(* Gui framework elements common across individual components. *) + +class gui +(* Types of this class describe gui components. *) + +val toXml : t ::: Type -> gui t -> t -> xbody +(* Currently the only thing a gui component can do is be + * pretty printed to a piece of xml. *) + +val gui_xbody : gui xbody +(* Xml itself can be a gui component. *) + +val mkGui : t ::: Type -> (t -> xbody) -> gui t +(* How to add components to the gui class. *) diff -r 48a4180171b0 -r 90be8b8917d5 lib.urp --- a/lib.urp Fri May 06 23:00:22 2011 -0430 +++ b/lib.urp Fri Jun 17 10:12:05 2011 -0430 @@ -2,12 +2,13 @@ $/string $/list +gui timer waitbox select forms datebox navbar +togglePanel popupNav navigation - diff -r 48a4180171b0 -r 90be8b8917d5 togglePanel.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/togglePanel.ur Fri Jun 17 10:12:05 2011 -0430 @@ -0,0 +1,51 @@ +datatype panelState = Open | Closed + +type formatCtl = {FormatPanel : xbody -> xbody -> xbody, + OpenCtl : transaction unit -> xbody, + CloseCtl : transaction unit -> xbody} + +val defaultFormat = {FormatPanel = fn ctl panel => {ctl}{panel}, + OpenCtl = fn behaviour =>