diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 57d8f735d2..22876b7d8e 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,19 +1,4 @@ -+ prettyprinter bug: - -IN: gadgets-listener SYMBOL: listener-gadget -TUPLE: listener-gadget scroller stack ; -IN: gadgets M: listener-gadget focusable-child* - listener-gadget-pane ; -IN: gadgets-layouts M: listener-gadget pref-dim* - drop { 600 600 0 } ; -IN: gadgets-listener M: listener-gadget -set-listener-gadget-scroller 4 set-slot ; -IN: gadgets-listener M: listener-gadget listener-gadget-stack - 5 slot ; -IN: gadgets-listener M: listener-gadget -set-listener-gadget-stack 5 set-slot ; -IN: gadgets-listener M: listener-gadget -listener-gadget-scroller 4 slot ; +- make-image in the UI leaks memory... + httpd: - outliners don't work @@ -62,6 +47,10 @@ listener-gadget-scroller 4 slot ; + ui/help: +- restore windows with the correct stacking order +- if the listener is running a command when the image is saved, it + restores to an unresponsive gadget +- save window positions on x11 - roundoff is still not quite right with tracks - clearing pane with ^L leaves scrollbar a pixel off - new browser: @@ -84,11 +73,11 @@ listener-gadget-scroller 4 slot ; - polish OS X menu bar code - dock menu - services do not launch if factor not running + - new syntax - when scrolling wheel, or moving mouse out of window, rollover is not updated - focus is not top-level window aware - display lists -- saving the image should save window configuration - variable width word wrap + compiler/ffi: diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index 5c250fa6b7..1e7064cc11 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -163,45 +163,45 @@ vectors words ; ! This must be the last file of parsing words loaded "/library/syntax/parse-syntax.factor" - "/library/opengl/gl.factor" - "/library/opengl/glu.factor" - "/library/opengl/opengl-utils.factor" + "/library/ui/opengl/gl.factor" + "/library/ui/opengl/glu.factor" + "/library/ui/opengl/opengl-utils.factor" - "/library/freetype/freetype.factor" - "/library/freetype/freetype-gl.factor" + "/library/ui/freetype/freetype.factor" + "/library/ui/freetype/freetype-gl.factor" "/library/ui/backend.factor" "/library/ui/timers.factor" "/library/ui/gadgets.factor" "/library/ui/layouts.factor" "/library/ui/hierarchy.factor" - "/library/ui/frames.factor" + "/library/ui/gadgets/frames.factor" "/library/ui/world.factor" "/library/ui/paint.factor" - "/library/ui/theme.factor" - "/library/ui/labels.factor" + "/library/ui/gadgets/theme.factor" + "/library/ui/gadgets/labels.factor" "/library/ui/gestures.factor" - "/library/ui/borders.factor" - "/library/ui/buttons.factor" - "/library/ui/tiles.factor" - "/library/ui/line-editor.factor" - "/library/ui/sliders.factor" - "/library/ui/viewports.factor" - "/library/ui/scrolling.factor" - "/library/ui/editors.factor" - "/library/ui/tracks.factor" - "/library/ui/incremental.factor" - "/library/ui/paragraphs.factor" - "/library/ui/panes.factor" - "/library/ui/tabs.factor" - "/library/ui/outliner.factor" - "/library/ui/environment.factor" - "/library/ui/presentations.factor" - "/library/ui/listener.factor" - "/library/ui/browser.factor" - "/library/ui/apropos.factor" - "/library/ui/help.factor" - "/library/ui/launchpad.factor" + "/library/ui/gadgets/borders.factor" + "/library/ui/gadgets/buttons.factor" + "/library/ui/gadgets/tiles.factor" + "/library/ui/gadgets/line-editor.factor" + "/library/ui/gadgets/sliders.factor" + "/library/ui/gadgets/viewports.factor" + "/library/ui/gadgets/scrolling.factor" + "/library/ui/gadgets/editors.factor" + "/library/ui/gadgets/tracks.factor" + "/library/ui/gadgets/incremental.factor" + "/library/ui/gadgets/paragraphs.factor" + "/library/ui/gadgets/panes.factor" + "/library/ui/gadgets/tabs.factor" + "/library/ui/gadgets/outliner.factor" + "/library/ui/ui.factor" + "/library/ui/gadgets/presentations.factor" + "/library/ui/tools/listener.factor" + "/library/ui/tools/browser.factor" + "/library/ui/tools/apropos.factor" + "/library/ui/tools/help.factor" + "/library/ui/tools/launchpad.factor" "/library/continuations.facts" "/library/errors.facts" diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index 15751fd31c..105a1ee7d5 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -41,11 +41,11 @@ H{ } clone help-graph set-global xref-articles "native-io" get [ init-io ] when "cocoa" get [ - "/library/cocoa/load.factor" run-resource + "/library/ui/cocoa/load.factor" run-resource ] when "x11" get [ - "/library/x11/load.factor" run-resource + "/library/ui/x11/load.factor" run-resource ] when windows? "native-io" get and [ diff --git a/library/cocoa/load.factor b/library/cocoa/load.factor deleted file mode 100644 index a6f6280ff8..0000000000 --- a/library/cocoa/load.factor +++ /dev/null @@ -1,24 +0,0 @@ -USING: compiler io parser sequences words ; - -{ - "/library/cocoa/runtime.factor" - "/library/cocoa/utilities.factor" - "/library/cocoa/subclassing.factor" - "/library/cocoa/core-foundation.factor" - "/library/cocoa/types.factor" - "/library/cocoa/init-cocoa.factor" - "/library/cocoa/callback.factor" - "/library/cocoa/application-utils.factor" - "/library/cocoa/view-utils.factor" - "/library/cocoa/window-utils.factor" - "/library/cocoa/dialogs.factor" - "/library/cocoa/menu-bar.factor" - "/library/cocoa/pasteboard-utils.factor" - "/library/cocoa/services.factor" - "/library/cocoa/ui.factor" -} [ - run-resource -] each - -"Compiling Cocoa bindings..." print -vocabs [ "objc-" head? ] subset compile-vocabs diff --git a/library/compiler/inference/inference.factor b/library/compiler/inference/inference.factor index 6847f90973..1b428613f0 100644 --- a/library/compiler/inference/inference.factor +++ b/library/compiler/inference/inference.factor @@ -88,6 +88,8 @@ M: wrapper apply-object wrapped apply-literal ; GENERIC: infer-quot +M: f infer-quot ( f -- ) drop ; + M: quotation infer-quot ( quot -- ) #! Recursive calls to this word are made for nested #! quotations. diff --git a/library/test/inference.factor b/library/test/inference.factor index 54e34e352f..00c0d467a1 100644 --- a/library/test/inference.factor +++ b/library/test/inference.factor @@ -10,6 +10,7 @@ math math-internals namespaces parser sequences test vectors ; [ t ] [ [ [ ] [ ] if ] dataflow dup [ [ ] map-nodes ] with-node-iterator = ] unit-test +[ { 0 0 } ] [ f infer ] unit-test [ { 0 2 } ] [ [ 2 "Hello" ] infer ] unit-test [ { 1 2 } ] [ [ dup ] infer ] unit-test @@ -132,7 +133,7 @@ SYMBOL: sym-test dup [ length ] [ - not-a-number + "foo" throw ] if ; [ { 1 1 } ] [ [ terminator-branch ] infer ] unit-test diff --git a/library/tools/memory.factor b/library/tools/memory.factor index 7baae9b3b8..863e82a6f2 100644 --- a/library/tools/memory.factor +++ b/library/tools/memory.factor @@ -82,7 +82,8 @@ M: object each-slot ( obj quot -- ) pprint " instances" print ; : heap-stats. ( -- ) - heap-stats dup hash-keys natural-sort [ + heap-stats dup hash-keys + [ [ word-name ] 2apply <=> ] sort [ ( hash hash key -- ) [ [ pick hash ] keep pick hash ] keep heap-stat. ] each 2drop ; diff --git a/library/cocoa/application-utils.factor b/library/ui/cocoa/application-utils.factor similarity index 100% rename from library/cocoa/application-utils.factor rename to library/ui/cocoa/application-utils.factor diff --git a/library/cocoa/callback.factor b/library/ui/cocoa/callback.factor similarity index 100% rename from library/cocoa/callback.factor rename to library/ui/cocoa/callback.factor diff --git a/library/cocoa/core-foundation.factor b/library/ui/cocoa/core-foundation.factor similarity index 100% rename from library/cocoa/core-foundation.factor rename to library/ui/cocoa/core-foundation.factor diff --git a/library/cocoa/dialogs.factor b/library/ui/cocoa/dialogs.factor similarity index 100% rename from library/cocoa/dialogs.factor rename to library/ui/cocoa/dialogs.factor diff --git a/library/cocoa/init-cocoa.factor b/library/ui/cocoa/init-cocoa.factor similarity index 96% rename from library/cocoa/init-cocoa.factor rename to library/ui/cocoa/init-cocoa.factor index 9f34b8e653..7033092c9a 100644 --- a/library/cocoa/init-cocoa.factor +++ b/library/ui/cocoa/init-cocoa.factor @@ -15,6 +15,7 @@ USING: cocoa compiler io kernel objc sequences words ; "NSException" "NSMenu" "NSMenuItem" + "NSNotification" "NSNotificationCenter" "NSObject" "NSOpenGLContext" diff --git a/library/ui/cocoa/load.factor b/library/ui/cocoa/load.factor new file mode 100644 index 0000000000..8376434971 --- /dev/null +++ b/library/ui/cocoa/load.factor @@ -0,0 +1,24 @@ +USING: compiler io parser sequences words ; + +{ + "/library/ui/cocoa/runtime.factor" + "/library/ui/cocoa/utilities.factor" + "/library/ui/cocoa/subclassing.factor" + "/library/ui/cocoa/core-foundation.factor" + "/library/ui/cocoa/types.factor" + "/library/ui/cocoa/init-cocoa.factor" + "/library/ui/cocoa/callback.factor" + "/library/ui/cocoa/application-utils.factor" + "/library/ui/cocoa/view-utils.factor" + "/library/ui/cocoa/window-utils.factor" + "/library/ui/cocoa/dialogs.factor" + "/library/ui/cocoa/menu-bar.factor" + "/library/ui/cocoa/pasteboard-utils.factor" + "/library/ui/cocoa/services.factor" + "/library/ui/cocoa/ui.factor" +} [ + run-resource +] each + +"Compiling Cocoa bindings..." print +vocabs [ "objc-" head? ] subset compile-vocabs diff --git a/library/cocoa/menu-bar.factor b/library/ui/cocoa/menu-bar.factor similarity index 100% rename from library/cocoa/menu-bar.factor rename to library/ui/cocoa/menu-bar.factor diff --git a/library/cocoa/pasteboard-utils.factor b/library/ui/cocoa/pasteboard-utils.factor similarity index 100% rename from library/cocoa/pasteboard-utils.factor rename to library/ui/cocoa/pasteboard-utils.factor diff --git a/library/cocoa/runtime.factor b/library/ui/cocoa/runtime.factor similarity index 100% rename from library/cocoa/runtime.factor rename to library/ui/cocoa/runtime.factor diff --git a/library/cocoa/services.factor b/library/ui/cocoa/services.factor similarity index 100% rename from library/cocoa/services.factor rename to library/ui/cocoa/services.factor diff --git a/library/cocoa/subclassing.factor b/library/ui/cocoa/subclassing.factor similarity index 100% rename from library/cocoa/subclassing.factor rename to library/ui/cocoa/subclassing.factor diff --git a/library/cocoa/types.factor b/library/ui/cocoa/types.factor similarity index 84% rename from library/cocoa/types.factor rename to library/ui/cocoa/types.factor index b2c758cb26..d8550443cb 100644 --- a/library/cocoa/types.factor +++ b/library/ui/cocoa/types.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2006 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. IN: cocoa -USING: alien kernel math ; +USING: alien gadgets kernel math sequences ; BEGIN-STRUCT: NSRect FIELD: float x @@ -20,13 +20,13 @@ TYPEDEF: NSRect CGRect [ set-NSRect-y ] keep [ set-NSRect-x ] keep ; -: NSRect-x-y ( rect -- origin-x origin-y ) +: NSRect-x-y ( alien -- origin-x origin-y ) [ NSRect-x ] keep NSRect-y ; -: NSRect-x-far-y ( rect -- origin-x far-y ) +: NSRect-x-far-y ( alien -- origin-x far-y ) [ NSRect-x-y ] keep NSRect-h + ; -: ( x y w h -- rect ) +: ( x y w h -- alien ) tuck >r >r - r> r> ; BEGIN-STRUCT: NSPoint diff --git a/library/cocoa/ui.factor b/library/ui/cocoa/ui.factor similarity index 71% rename from library/cocoa/ui.factor rename to library/ui/cocoa/ui.factor index 2069404bd4..e228b3b2eb 100644 --- a/library/cocoa/ui.factor +++ b/library/ui/cocoa/ui.factor @@ -5,8 +5,9 @@ IN: objc-FactorApplicationDelegate DEFER: FactorApplicationDelegate IN: cocoa -USING: arrays gadgets gadgets-listener kernel objc -objc-NSApplication objc-NSObject objc-NSWindow sequences ; +USING: arrays gadgets gadgets-layouts gadgets-listener +hashtables kernel namespaces objc objc-NSApplication +objc-NSObject objc-NSWindow sequences ; : finder-run-files ( alien -- ) CF>string-array listener-run-files @@ -25,19 +26,21 @@ objc-NSApplication objc-NSObject objc-NSWindow sequences ; FactorApplicationDelegate [alloc] [init] [setDelegate:] ; : init-cocoa-ui ( -- ) - reset-views reset-callbacks init-ui install-app-delegate register-services default-main-menu ; +: rect>NSRect + dup world-loc first2 rot rect-dim first2 ; + : gadget-window ( world -- ) [ - - dup + dup + dup rot rect>NSRect dup install-window-delegate - dup [contentView] [release] + over [release] 2array ] keep set-world-handle ; @@ -52,8 +55,8 @@ objc-NSOpenGLView objc-NSView ; world-handle second swap [setTitle:] ; : open-window* ( world -- ) - dup gadget-window dup add-notify - dup gadget-title over set-title + dup gadget-window + dup start-world world-handle second f [makeKeyAndOrderFront:] ; : select-gl-context ( handle -- ) @@ -62,6 +65,13 @@ objc-NSOpenGLView objc-NSView ; : flush-gl-context ( handle -- ) first [openGLContext] [flushBuffer] ; +: restore-windows ( -- ) + views get hash-values reset-views + [ dup reset-world open-window* ] each ; + +: restore-windows? ( -- ? ) + views get [ hash-empty? not ] [ f ] if* ; + IN: shells : ui @@ -71,7 +81,11 @@ IN: shells [ [ init-cocoa-ui - listener-window + restore-windows? [ + restore-windows + ] [ + listener-window + ] if finish-launching event-loop ] with-cocoa diff --git a/library/cocoa/utilities.factor b/library/ui/cocoa/utilities.factor similarity index 100% rename from library/cocoa/utilities.factor rename to library/ui/cocoa/utilities.factor diff --git a/library/cocoa/view-utils.factor b/library/ui/cocoa/view-utils.factor similarity index 89% rename from library/cocoa/view-utils.factor rename to library/ui/cocoa/view-utils.factor index 584948de51..981eab34e6 100644 --- a/library/cocoa/view-utils.factor +++ b/library/ui/cocoa/view-utils.factor @@ -18,21 +18,6 @@ sequences ; : view-dim [bounds] dup NSRect-w swap NSRect-h 0 3array ; -: NSViewFrameDidChangeNotification - "NSViewFrameDidChangeNotification" ; - -: add-resize-observer ( view selector -- ) - NSViewFrameDidChangeNotification pick add-observer ; - -! Hash mapping aliens to gadgets -SYMBOL: views - -: reset-views ( hash -- hash ) H{ } clone views set-global ; - -reset-views - -: view ( handle -- world ) views get hash ; - : mouse-location ( view event -- loc ) over >r [locationInWindow] f [convertPoint:fromView:] @@ -101,6 +86,11 @@ reset-views : send-wheel$ ( view event -- ) [ [deltaY] 0 > ] 2keep mouse-location rot view send-wheel ; +: add-resize-observer ( observer object -- ) + >r "updateFactorGadgetSize:" + "NSViewFrameDidChangeNotification" + r> add-observer ; + "NSOpenGLView" "FactorView" { { "drawRect:" "void" { "id" "SEL" "NSRect" } [ 2drop view draw-world ] @@ -170,7 +160,7 @@ reset-views [ rot drop SUPER-> [initWithFrame:pixelFormat:] - dup "updateFactorGadgetSize:" add-resize-observer + dup dup add-resize-observer ] } @@ -178,7 +168,7 @@ reset-views [ drop dup view close-world - dup views get remove-hash + dup unregister-view dup remove-observer SUPER-> [dealloc] ] @@ -186,5 +176,4 @@ reset-views } { } define-objc-class : ( world -- view ) - FactorView over rect-dim - [ views get set-hash ] keep ; + FactorView over rect-dim [ register-view ] keep ; diff --git a/library/cocoa/window-utils.factor b/library/ui/cocoa/window-utils.factor similarity index 79% rename from library/cocoa/window-utils.factor rename to library/ui/cocoa/window-utils.factor index dfd384da8d..ab0b6780b2 100644 --- a/library/cocoa/window-utils.factor +++ b/library/ui/cocoa/window-utils.factor @@ -4,8 +4,9 @@ IN: objc-FactorWindowDelegate DEFER: FactorWindowDelegate IN: cocoa -USING: gadgets gadgets-layouts kernel math objc objc-NSObject -objc-NSView objc-NSWindow sequences ; +USING: arrays gadgets gadgets-layouts kernel math objc +objc-NSNotification objc-NSObject objc-NSView objc-NSWindow +sequences ; : NSBorderlessWindowMask 0 ; inline : NSTitledWindowMask 1 ; inline @@ -28,9 +29,8 @@ objc-NSView objc-NSWindow sequences ; standard-window-type NSBackingStoreBuffered 1 [initWithContentRect:styleMask:backing:defer:] ; -: ( view -- window ) - dup [bounds] - [ swap [setContentView:] ] keep +: ( view bounds -- window ) + [ swap [setContentView:] ] keep dup dup [contentView] [setInitialFirstResponder:] dup 1 [setAcceptsMouseMovedEvents:] ; @@ -55,6 +55,14 @@ objc-NSView objc-NSWindow sequences ; frame-content-rect ] } + + { + "windowDidMove:" "void" { "id" "SEL" "id" } [ + 2nip [object] + dup window-content-rect NSRect-x-y 0 3array + swap [contentView] view set-world-loc + ] + } } { } define-objc-class : install-window-delegate ( window -- ) diff --git a/library/freetype/freetype-gl.factor b/library/ui/freetype/freetype-gl.factor similarity index 100% rename from library/freetype/freetype-gl.factor rename to library/ui/freetype/freetype-gl.factor diff --git a/library/freetype/freetype.factor b/library/ui/freetype/freetype.factor similarity index 100% rename from library/freetype/freetype.factor rename to library/ui/freetype/freetype.factor diff --git a/library/ui/borders.factor b/library/ui/gadgets/borders.factor similarity index 100% rename from library/ui/borders.factor rename to library/ui/gadgets/borders.factor diff --git a/library/ui/buttons.factor b/library/ui/gadgets/buttons.factor similarity index 100% rename from library/ui/buttons.factor rename to library/ui/gadgets/buttons.factor diff --git a/library/ui/editors.factor b/library/ui/gadgets/editors.factor similarity index 98% rename from library/ui/editors.factor rename to library/ui/gadgets/editors.factor index 65ac6a32d4..c5823af79b 100644 --- a/library/ui/editors.factor +++ b/library/ui/gadgets/editors.factor @@ -92,7 +92,6 @@ M: editor gadget-gestures { T{ key-down f f "HOME" } [ [ T{ document-elt } prev-elt ] with-editor ] } { T{ key-down f f "END" } [ [ T{ document-elt } next-elt ] with-editor ] } { T{ key-down f { C+ } "k" } [ [ line-clear ] with-editor ] } - { T{ key-down f f "TAB" } [ do-completion ] } } ; C: editor ( text -- ) diff --git a/library/ui/frames.factor b/library/ui/gadgets/frames.factor similarity index 100% rename from library/ui/frames.factor rename to library/ui/gadgets/frames.factor diff --git a/library/ui/incremental.factor b/library/ui/gadgets/incremental.factor similarity index 100% rename from library/ui/incremental.factor rename to library/ui/gadgets/incremental.factor diff --git a/library/ui/labels.factor b/library/ui/gadgets/labels.factor similarity index 100% rename from library/ui/labels.factor rename to library/ui/gadgets/labels.factor diff --git a/library/ui/line-editor.factor b/library/ui/gadgets/line-editor.factor similarity index 100% rename from library/ui/line-editor.factor rename to library/ui/gadgets/line-editor.factor diff --git a/library/ui/outliner.factor b/library/ui/gadgets/outliner.factor similarity index 100% rename from library/ui/outliner.factor rename to library/ui/gadgets/outliner.factor diff --git a/library/ui/panes.factor b/library/ui/gadgets/panes.factor similarity index 98% rename from library/ui/panes.factor rename to library/ui/gadgets/panes.factor index 7e947cc860..4ab7b2ca24 100644 --- a/library/ui/panes.factor +++ b/library/ui/gadgets/panes.factor @@ -42,8 +42,7 @@ SYMBOL: structured-input "\"structured-input\" \"gadgets-panes\" lookup get-global call" r> pane-eval ; -: replace-input ( string pane -- ) - pane-input set-editor-text ; +: replace-input ( string pane -- ) pane-input set-editor-text ; : print-input ( string pane -- ) [ diff --git a/library/ui/paragraphs.factor b/library/ui/gadgets/paragraphs.factor similarity index 100% rename from library/ui/paragraphs.factor rename to library/ui/gadgets/paragraphs.factor diff --git a/library/ui/presentations.factor b/library/ui/gadgets/presentations.factor similarity index 100% rename from library/ui/presentations.factor rename to library/ui/gadgets/presentations.factor diff --git a/library/ui/scrolling.factor b/library/ui/gadgets/scrolling.factor similarity index 100% rename from library/ui/scrolling.factor rename to library/ui/gadgets/scrolling.factor diff --git a/library/ui/sliders.factor b/library/ui/gadgets/sliders.factor similarity index 100% rename from library/ui/sliders.factor rename to library/ui/gadgets/sliders.factor diff --git a/library/ui/tabs.factor b/library/ui/gadgets/tabs.factor similarity index 100% rename from library/ui/tabs.factor rename to library/ui/gadgets/tabs.factor diff --git a/library/ui/theme.factor b/library/ui/gadgets/theme.factor similarity index 100% rename from library/ui/theme.factor rename to library/ui/gadgets/theme.factor diff --git a/library/ui/tiles.factor b/library/ui/gadgets/tiles.factor similarity index 100% rename from library/ui/tiles.factor rename to library/ui/gadgets/tiles.factor diff --git a/library/ui/tracks.factor b/library/ui/gadgets/tracks.factor similarity index 100% rename from library/ui/tracks.factor rename to library/ui/gadgets/tracks.factor diff --git a/library/ui/viewports.factor b/library/ui/gadgets/viewports.factor similarity index 100% rename from library/ui/viewports.factor rename to library/ui/gadgets/viewports.factor diff --git a/library/opengl/gl.factor b/library/ui/opengl/gl.factor similarity index 100% rename from library/opengl/gl.factor rename to library/ui/opengl/gl.factor diff --git a/library/opengl/glu.factor b/library/ui/opengl/glu.factor similarity index 100% rename from library/opengl/glu.factor rename to library/ui/opengl/glu.factor diff --git a/library/opengl/opengl-utils.factor b/library/ui/opengl/opengl-utils.factor similarity index 100% rename from library/opengl/opengl-utils.factor rename to library/ui/opengl/opengl-utils.factor diff --git a/library/ui/apropos.factor b/library/ui/tools/apropos.factor similarity index 100% rename from library/ui/apropos.factor rename to library/ui/tools/apropos.factor diff --git a/library/ui/browser.factor b/library/ui/tools/browser.factor similarity index 100% rename from library/ui/browser.factor rename to library/ui/tools/browser.factor diff --git a/library/ui/help.factor b/library/ui/tools/help.factor similarity index 100% rename from library/ui/help.factor rename to library/ui/tools/help.factor diff --git a/library/ui/launchpad.factor b/library/ui/tools/launchpad.factor similarity index 100% rename from library/ui/launchpad.factor rename to library/ui/tools/launchpad.factor diff --git a/library/ui/listener.factor b/library/ui/tools/listener.factor similarity index 96% rename from library/ui/listener.factor rename to library/ui/tools/listener.factor index 35481ec944..d09b610b4b 100644 --- a/library/ui/listener.factor +++ b/library/ui/tools/listener.factor @@ -52,7 +52,8 @@ C: listener-gadget ( -- gadget ) { [ ] set-listener-gadget-scroller @center } } make-frame* dup start-listener ; -M: listener-gadget pref-dim* drop { 600 600 0 } ; +M: listener-gadget pref-dim* + delegate pref-dim* { 600 600 0 } vmax ; M: listener-gadget focusable-child* ( listener -- gadget ) listener-gadget-pane ; diff --git a/library/ui/environment.factor b/library/ui/ui.factor similarity index 74% rename from library/ui/environment.factor rename to library/ui/ui.factor index 85c1d20102..65ccc651d0 100644 --- a/library/ui/environment.factor +++ b/library/ui/ui.factor @@ -5,6 +5,17 @@ USING: gadgets gadgets-labels gadgets-layouts gadgets-theme gadgets-viewports hashtables kernel math namespaces queues sequences threads ; +! Hash mapping aliens to gadgets +SYMBOL: windows + +: reset-windows ( hash -- hash ) H{ } clone windows set-global ; + +: view ( handle -- world ) windows get hash ; + +: register-view ( world handle -- ) windows get set-hash ; + +: unregister-view ( handle -- ) windows get remove-hash ; + : layout-queued ( -- ) invalid dup queue-empty? [ drop @@ -24,16 +35,6 @@ sequences threads ; [ dup world-handle [ draw-world ] [ drop ] if ] each 10 sleep ; -: close-global ( world global -- ) - dup get-global find-world rot eq? - [ f swap set-global ] [ drop ] if ; - -: close-world ( world -- ) - dup hand-clicked close-global - dup hand-gadget close-global - f over request-focus* dup remove-notify - dup free-fonts f swap set-world-handle ; - : ( -- gadget ) ""