diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index d9288823af..d71acd4123 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -31,7 +31,12 @@ + ui/help: -- unregister notifications in dealloc +- flickering incremental layout +- expired aliens in view hash +- try launchpad with bevel buttons replaced by buttons: there's + overpainting +- artifacts while resizing +- unregister notifications and the view in dealloc - segfault when closing window - wheel mouse is a bit funny - changelog in the UI diff --git a/library/cocoa/application-utils.factor b/library/cocoa/application-utils.factor index 7bbd21ed75..2f0a47a1d4 100644 --- a/library/cocoa/application-utils.factor +++ b/library/cocoa/application-utils.factor @@ -27,7 +27,8 @@ objc-NSNotificationCenter objc-NSObject objc-NSView threads ; : event-loop ( -- ) [ - NSApplication [sharedApplication] do-events world-step + NSApplication [sharedApplication] do-events + world get world-step ] with-autorelease-pool 10 sleep event-loop ; : add-observer ( observer selector name object -- ) diff --git a/library/cocoa/ui.factor b/library/cocoa/ui.factor index 0896ff507d..cdd74f7b48 100644 --- a/library/cocoa/ui.factor +++ b/library/cocoa/ui.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays cocoa freetype gadgets-layouts gadgets-listener -gadgets-panes hashtables kernel lists math namespaces objc -objc-NSApplication objc-NSEvent objc-NSObject objc-NSOpenGLView -objc-NSView objc-NSWindow sequences threads ; +USING: arrays cocoa freetype gadgets-layouts +gadgets-listener gadgets-panes hashtables kernel lists math +namespaces objc objc-NSApplication objc-NSEvent objc-NSObject +objc-NSOpenGLView objc-NSView objc-NSWindow sequences threads ; ! Cocoa backend for Factor UI @@ -29,11 +29,6 @@ H{ } clone views set-global : view ( handle -- world ) views get hash ; -: draw-view ( view -- ) - dup [openGLContext] [ - dup view-dim init-gl view draw-gadget - ] with-gl-context ; - : mouse-location ( event view -- loc ) [ swap [locationInWindow] f [convertPoint:fromView:] @@ -85,7 +80,7 @@ H{ } clone views set-global "NSOpenGLView" "FactorView" { { "drawRect:" "void" { "id" "SEL" "NSRect" } - [ 2drop draw-view ] + [ 2drop [ view draw-world ] with-gl-view ] } { "mouseMoved:" "void" { "id" "SEL" "id" } @@ -158,8 +153,9 @@ IN: shells : ui [ [ - { 600 700 0 } >r r> world set - world get ui-title + + { 600 700 0 } world set + world get "Listener" drop [ clear listener-thread ] in-thread pane get request-focus finish-launching diff --git a/library/cocoa/view-utils.factor b/library/cocoa/view-utils.factor index dded1db0d4..e692f536c0 100644 --- a/library/cocoa/view-utils.factor +++ b/library/cocoa/view-utils.factor @@ -16,6 +16,9 @@ objc-NSOpenGLView objc-NSView opengl sequences ; [ [makeCurrentContext] call glFlush ] keep [flushBuffer] ; inline +: with-gl-view ( view quot -- | quot: view -- ) + >r dup [openGLContext] r> with-gl-context ; inline + : view-dim [bounds] dup NSRect-w swap NSRect-h 0 3array ; : NSViewFrameDidChangeNotification diff --git a/library/ui/commands.factor b/library/ui/commands.factor index edb824e495..de564e2db2 100644 --- a/library/ui/commands.factor +++ b/library/ui/commands.factor @@ -1,5 +1,5 @@ IN: gadgets-presentations -USING: compiler gadgets gadgets-buttons gadgets-listener +USING: arrays compiler gadgets gadgets-buttons gadgets-listener gadgets-menus gadgets-panes generic hashtables inference inspector io jedit kernel lists namespaces parser prettyprint sequences strings styles words ; @@ -39,7 +39,7 @@ TUPLE: command-button object ; : ( presented command -- item ) [ command>quot [ drop ] swap append ] keep - command-name swons ; + command-name swap 2array ; : ( presented -- menu ) dup applicable @@ -47,7 +47,7 @@ TUPLE: command-button object ; : command-menu ( command-button -- ) dup button-update - command-button-object + [ command-button-object ] keep show-hand-menu ; : command-button-actions ( gadget -- ) diff --git a/library/ui/editors.factor b/library/ui/editors.factor index 6277d446c7..dcf34b8834 100644 --- a/library/ui/editors.factor +++ b/library/ui/editors.factor @@ -74,13 +74,14 @@ TUPLE: editor line caret font color ; dup screen-loc swap editor-caret rect-extent nip v+ ; : ( completion editor -- menu-item ) - dupd [ [ complete ] with-editor drop ] curry curry cons ; + dupd [ [ complete ] with-editor drop ] curry curry 2array ; : ( editor completions -- menu ) [ swap ] map-with ; : completion-menu ( editor completions -- ) - over >r r> popup-location show-menu ; + over popup-location -rot + over >r r> show-menu ; : do-completion-1 ( editor completions -- ) swap [ first complete ] with-editor ; diff --git a/library/ui/launchpad.factor b/library/ui/launchpad.factor new file mode 100644 index 0000000000..ff683044a6 --- /dev/null +++ b/library/ui/launchpad.factor @@ -0,0 +1,18 @@ +IN: gadgets-launchpad +USING: gadgets-buttons gadgets-labels gadgets-layouts io kernel +memory namespaces sequences ; + +: ( menu -- ) + [ first2 >r