From 4f8632b6560bd79b72d6f66d48af3c620da26900 Mon Sep 17 00:00:00 2001 From: slava Date: Fri, 24 Mar 2006 08:28:46 +0000 Subject: [PATCH] New browser gadget --- TODO.FACTOR.txt | 1 - library/bootstrap/boot-stage1.factor | 6 +- library/help/commands.factor | 6 -- library/tools/components.factor | 24 ++++++++ library/ui/browser.factor | 70 +++++++++++++++++++++++ library/ui/commands.factor | 85 ---------------------------- library/ui/editors.factor | 11 ++-- library/ui/launchpad.factor | 26 ++++++--- library/ui/listener.factor | 11 +--- library/ui/menus.factor | 37 ------------ library/ui/presentations.factor | 18 +++--- library/ui/theme.factor | 6 +- library/ui/world.factor | 13 +---- 13 files changed, 132 insertions(+), 182 deletions(-) delete mode 100644 library/help/commands.factor create mode 100644 library/tools/components.factor create mode 100644 library/ui/browser.factor delete mode 100644 library/ui/commands.factor delete mode 100644 library/ui/menus.factor diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 06b03e2769..2f67058467 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -36,7 +36,6 @@ - use glRect - display lists - saving the image should save window configuration -- menu drag retarget broken - changelog in the UI - make the UI look better, something like this: http://twb.ath.cx/~twb/darcs/OBSOLETE/factor/final.html diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index a578319918..b8f4bb8db0 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -102,6 +102,7 @@ vectors words ; "/library/tools/annotations.factor" "/library/tools/inspector.factor" + "/library/tools/components.factor" "/library/test/test.factor" @@ -177,7 +178,6 @@ vectors words ; "/library/ui/line-editor.factor" "/library/ui/sliders.factor" "/library/ui/scrolling.factor" - "/library/ui/menus.factor" "/library/ui/editors.factor" "/library/ui/splitters.factor" "/library/ui/incremental.factor" @@ -185,12 +185,10 @@ vectors words ; "/library/ui/panes.factor" "/library/ui/outliner.factor" "/library/ui/listener.factor" + "/library/ui/browser.factor" "/library/ui/launchpad.factor" - "/library/ui/commands.factor" "/library/ui/presentations.factor" - "/library/help/commands.factor" - "/library/continuations.facts" "/library/errors.facts" "/library/kernel.facts" diff --git a/library/help/commands.factor b/library/help/commands.factor deleted file mode 100644 index e2839d8b28..0000000000 --- a/library/help/commands.factor +++ /dev/null @@ -1,6 +0,0 @@ -IN: help -USING: gadgets-listener gadgets-presentations words ; - -"Show word documentation" [ word? ] [ help ] \ in-browser define-default-command -"Show term definition" [ term? ] [ help ] \ in-browser define-default-command -"Show article" [ link? ] [ help ] \ in-browser define-default-command diff --git a/library/tools/components.factor b/library/tools/components.factor new file mode 100644 index 0000000000..fb405ccee1 --- /dev/null +++ b/library/tools/components.factor @@ -0,0 +1,24 @@ +IN: components +USING: help inspector kernel namespaces sequences words ; + +! Component document framework, like OpenDoc. + +TUPLE: component name predicate builder ; + +SYMBOL: components + +V{ } clone components set-global + +: get-components ( obj -- seq ) + components get-global + [ component-predicate call ] subset-with ; + +: define-component ( name predicate builder -- ) + components get-global push ; + +"Slots" [ drop t ] [ describe ] define-component +"Documentation" [ word? ] [ help ] define-component +"Calls in" [ word? ] [ usage. ] define-component +"Calls out" [ word? ] [ uses. ] define-component +"Definition" [ term? ] [ help ] define-component +"Documentation" [ link? ] [ help ] define-component diff --git a/library/ui/browser.factor b/library/ui/browser.factor new file mode 100644 index 0000000000..cd43d6a5e8 --- /dev/null +++ b/library/ui/browser.factor @@ -0,0 +1,70 @@ +IN: gadgets-browser +USING: components gadgets gadgets-buttons gadgets-labels +gadgets-layouts gadgets-panes gadgets-scrolling gadgets-theme +hashtables help inspector kernel lists math namespaces +prettyprint sequences words ; + +TUPLE: book page pages ; + +: show-page ( key book -- ) + dup book-page unparent + [ book-pages hash ] keep + [ set-book-page ] 2keep + add-gadget ; + +C: book ( page pages -- book ) + dup delegate>gadget + [ set-book-pages ] keep + [ show-page ] keep ; + +M: book pref-dim* ( book -- dim ) + { 0 0 0 } swap book-pages [ nip pref-dim vmax ] hash-each ; + +M: book layout* ( book -- ) + dup rect-dim swap book-page set-gadget-dim ; + +: component-page ( obj component -- gadget ) + component-builder make-pane ; + +: component-pages ( obj -- hash ) + dup get-components [ + [ component-name over ] keep component-page + ] map>hash nip ; + +: component-book ( hash -- book ) + dup hash-keys natural-sort first swap ; + +: ( name book -- button ) + dupd [ show-page ] curry curry + >r