Mercurial > gui
changeset 27:5905b56e0cd9
Adapt to new HTML contexts
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Tue, 20 Dec 2011 21:04:21 -0500 |
parents | 86857ae0f386 |
children | 7d0014542199 |
files | calendar.ur calendar.urs datebox.ur datebox.urs forms.ur forms.urs gui.ur gui.urs togglePanel.ur togglePanel.urs |
diffstat | 10 files changed, 37 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/calendar.ur Fri Dec 09 17:38:20 2011 -0500 +++ b/calendar.ur Tue Dec 20 21:04:21 2011 -0500 @@ -207,7 +207,7 @@ SourceL.onChange ctl.Day f val gui_t = Gui.mkGui - (fn [body ~ []] ctl => + (fn [[Dyn] ~ body'] ctl => <xml> <dyn signal={render' ctl}/> </xml>)
--- a/calendar.urs Fri Dec 09 17:38:20 2011 -0500 +++ b/calendar.urs Tue Dec 20 21:04:21 2011 -0500 @@ -20,7 +20,7 @@ val value : t -> signal date (* Read the date of the calendar. *) -val gui_t : Gui.gui t [] +val gui_t : Gui.gui t body' (* Witness that this is a gui widget. *) val create : time -> transaction t
--- a/datebox.ur Fri Dec 09 17:38:20 2011 -0500 +++ b/datebox.ur Tue Dec 20 21:04:21 2011 -0500 @@ -1,5 +1,5 @@ type t = {Cal : Calendar.t, - Panel : TogglePanel.togglePanel Calendar.t []} + Panel : TogglePanel.togglePanel Calendar.t body'} type date = Calendar.date val date_eq = Calendar.date_eq @@ -7,7 +7,7 @@ val time = Calendar.time val date = Calendar.date -val format : TogglePanel.formatCtl [] = fn [body ~ []] => +val format : TogglePanel.formatCtl body' = fn [[Dyn] ~ body'] => TogglePanel.defaultFormat -- #OpenCtl -- #CloseCtl ++ {OpenCtl = fn behaviour => <xml><button value="Choose" onclick={behaviour}/></xml>, @@ -28,7 +28,7 @@ fun value db = Calendar.value db.Cal -val gui_t = Gui.mkGui (fn [body ~ []] db => +val gui_t = Gui.mkGui (fn [[Dyn] ~ body'] db => <xml> <dyn signal={date <- Calendar.value db.Cal; return <xml>{[date.Year]}-{[date.Month]}-{[date.Day]}</xml>}/>
--- a/datebox.urs Fri Dec 09 17:38:20 2011 -0500 +++ b/datebox.urs Tue Dec 20 21:04:21 2011 -0500 @@ -22,5 +22,5 @@ val value : t -> signal date (* Extract the current date value. *) -val gui_t : Gui.gui t [] +val gui_t : Gui.gui t body' (* Draws the datebox as a piece of xml. *)
--- a/forms.ur Fri Dec 09 17:38:20 2011 -0500 +++ b/forms.ur Tue Dec 20 21:04:21 2011 -0500 @@ -7,8 +7,8 @@ Invalid s => <xml><b>{[s]}</b></xml> | _ => <xml/>)}/></xml> -fun warningFmt [a ::: Type] [ctx ::: {Unit}] [ctx ~ body] - (wrap : string -> xml (body ++ ctx) [] []) +fun warningFmt [a ::: Type] [ctx ::: {Unit}] [ctx ~ [Dyn]] + (wrap : string -> xml ([Dyn] ++ ctx) [] []) (s : signal (readiness a)) = <xml><dyn signal={v <- s; return (case v of
--- a/forms.urs Fri Dec 09 17:38:20 2011 -0500 +++ b/forms.urs Tue Dec 20 21:04:21 2011 -0500 @@ -3,7 +3,7 @@ val warning : a ::: Type -> signal (readiness a) -> xbody -val warningFmt : a ::: Type -> ctx ::: {Unit} -> [ctx ~ body] - => (string -> xml (ctx ++ body) [] []) -> signal (readiness a) - -> xml (ctx ++ body) [] [] +val warningFmt : a ::: Type -> ctx ::: {Unit} -> [ctx ~ [Dyn]] + => (string -> xml (ctx ++ [Dyn]) [] []) -> signal (readiness a) + -> xml (ctx ++ [Dyn]) [] [] (* A version of warning that adds a chrome wrapper to the warning message. *)
--- a/gui.ur Fri Dec 09 17:38:20 2011 -0500 +++ b/gui.ur Tue Dec 20 21:04:21 2011 -0500 @@ -1,8 +1,8 @@ -class gui = fn (t :: Type) (ctx :: {Unit}) => [body ~ ctx] => t -> xml (body ++ ctx) [] [] +class gui = fn (t :: Type) (ctx :: {Unit}) => [[Dyn] ~ ctx] => t -> xml ([Dyn] ++ ctx) [] [] -fun gui_xbody [body ~ []] x = x -fun gui_xtable [body ~ _] x = x +fun gui_xbody [[Dyn] ~ _] x = x +fun gui_xtable [[Dyn] ~ _] x = x -fun mkGui [t ::: Type] [ctx ::: {Unit}] (toXml : [body ~ ctx] => t -> xml (body ++ ctx) [] []) = @toXml +fun mkGui [t ::: Type] [ctx ::: {Unit}] (toXml : [[Dyn] ~ ctx] => t -> xml ([Dyn] ++ ctx) [] []) = @toXml -fun toXml [t ::: Type] [ctx ::: {Unit}] [body ~ ctx] (toXml : gui t ctx) = toXml +fun toXml [t ::: Type] [ctx ::: {Unit}] [[Dyn] ~ ctx] (toXml : gui t ctx) = toXml
--- a/gui.urs Fri Dec 09 17:38:20 2011 -0500 +++ b/gui.urs Tue Dec 20 21:04:21 2011 -0500 @@ -2,16 +2,16 @@ (* Types of this class describe gui components. *) class gui :: Type (* The type of an object to render *) - -> {Unit} (* The HTML context to render it for (minus [body]) *) + -> {Unit} (* The HTML context to render it for (minus [Dyn]) *) -> Type (* How to add components to the gui class. *) -val mkGui : t ::: Type -> ctx ::: {Unit} -> ([body ~ ctx] => t -> xml (body ++ ctx) [] []) -> gui t ctx +val mkGui : t ::: Type -> ctx ::: {Unit} -> ([[Dyn] ~ ctx] => t -> xml ([Dyn] ++ ctx) [] []) -> gui t ctx (* XML itself can be a gui component. *) -val gui_xbody : gui xbody [] -val gui_xtable : gui xtable [Table] +val gui_xbody : gui xbody body' +val gui_xtable : gui xtable tabl' (* Currently the only thing a gui component can do is be * pretty printed to a piece of xml. *) -val toXml : t ::: Type -> ctx ::: {Unit} -> [body ~ ctx] => gui t ctx -> t -> xml (body ++ ctx) [] [] +val toXml : t ::: Type -> ctx ::: {Unit} -> [[Dyn] ~ ctx] => gui t ctx -> t -> xml ([Dyn] ++ ctx) [] []
--- a/togglePanel.ur Fri Dec 09 17:38:20 2011 -0500 +++ b/togglePanel.ur Tue Dec 20 21:04:21 2011 -0500 @@ -1,13 +1,13 @@ datatype panelState = Open | Closed -con formatCtl = fn ctx :: {Unit} => [body ~ ctx] => - {FormatPanel : xml (body ++ ctx) [] [] - -> xml (body ++ ctx) [] [] - -> xml (body ++ ctx) [] [], - OpenCtl : transaction unit -> xml (body ++ ctx) [] [], - CloseCtl : transaction unit -> xml (body ++ ctx) [] []} +con formatCtl = fn ctx :: {Unit} => [[Dyn] ~ ctx] => + {FormatPanel : xml ([Dyn] ++ ctx) [] [] + -> xml ([Dyn] ++ ctx) [] [] + -> xml ([Dyn] ++ ctx) [] [], + OpenCtl : transaction unit -> xml ([Dyn] ++ ctx) [] [], + CloseCtl : transaction unit -> xml ([Dyn] ++ ctx) [] []} -val defaultFormat [body ~ []] = +val defaultFormat [[Dyn] ~ body'] = {FormatPanel = fn ctl panel => <xml>{ctl}{panel}</xml>, OpenCtl = fn behaviour => <xml><button value="Open" onclick={behaviour}/></xml>, CloseCtl = fn behaviour => <xml><button value="Close" onclick={behaviour}/></xml>} @@ -25,7 +25,7 @@ FormatCtl = @f, Content = content} -fun render [t ::: Type] [ctx ::: {Unit}] (_ : gui t ctx) [body ~ ctx] (panel : togglePanel t ctx) = +fun render [t ::: Type] [ctx ::: {Unit}] (_ : gui t ctx) [[Dyn] ~ ctx] (panel : togglePanel t ctx) = let val format = panel.FormatCtl ! val openCtl = format.CloseCtl (set panel.PanelState Closed)
--- a/togglePanel.urs Fri Dec 09 17:38:20 2011 -0500 +++ b/togglePanel.urs Tue Dec 20 21:04:21 2011 -0500 @@ -6,10 +6,10 @@ (* The type of appearing and disappearing panels. The arguments * are as for [Gui.gui]. *) -con formatCtl = fn ctx :: {Unit} => [body ~ ctx] => - {FormatPanel : xml (body ++ ctx) [] [] - -> xml (body ++ ctx) [] [] - -> xml (body ++ ctx) [] [], +con formatCtl = fn ctx :: {Unit} => [[Dyn] ~ ctx] => + {FormatPanel : xml ([Dyn] ++ ctx) [] [] + -> xml ([Dyn] ++ ctx) [] [] + -> xml ([Dyn] ++ ctx) [] [], (* Allows for formatting the panel. The first two parameters * represent "holes" for the control and panel respectively while * the result should be the desired XML laying out the whole structure. @@ -17,19 +17,19 @@ * The panel part appears and disappears according to the use * of the controls. *) - OpenCtl : transaction unit -> xml (body ++ ctx) [] [], + OpenCtl : transaction unit -> xml ([Dyn] ++ ctx) [] [], (* This should accept the transaction representing the opening of * the panel and produce an XML control having this as action. *) - CloseCtl : transaction unit -> xml (body ++ ctx) [] []} + CloseCtl : transaction unit -> xml ([Dyn] ++ ctx) [] []} (* This should accept the transaction representing the closing of * the panel and produce an xml control having this as action. *) (* Some reasonable default formats for the layout and controls. *) -val defaultFormat : formatCtl [] +val defaultFormat : formatCtl body' val create : t ::: Type -> ctx ::: {Unit} -> - formatCtl ctx (* Formatting instructions *) + formatCtl ctx (* Formatting instructions *) -> t (* Enclosed widget *) -> bool (* Start in open state? *) -> transaction (togglePanel t ctx)