ui: rename ui-windows to worlds.
							parent
							
								
									d588a9dd3a
								
							
						
					
					
						commit
						cccdc09a71
					
				| 
						 | 
				
			
			@ -76,8 +76,8 @@ M: pasteboard set-clipboard-contents
 | 
			
		|||
    ! after register-window.
 | 
			
		||||
    dup { 0 0 } = [
 | 
			
		||||
        drop
 | 
			
		||||
        ui-windows get-global length 1 <= [ -> center ] [
 | 
			
		||||
            ui-windows get-global last second window-loc>>
 | 
			
		||||
        worlds get-global length 1 <= [ -> center ] [
 | 
			
		||||
            worlds get-global last second window-loc>>
 | 
			
		||||
            dupd first2 <CGPoint> -> cascadeTopLeftFromPoint:
 | 
			
		||||
            -> setFrameTopLeftPoint:
 | 
			
		||||
        ] if
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ IN: ui.event-loop
 | 
			
		|||
: event-loop? ( -- ? )
 | 
			
		||||
    {
 | 
			
		||||
        { [ graft-queue deque-empty? not ] [ t ] }
 | 
			
		||||
        { [ ui-windows get-global empty? not ] [ t ] }
 | 
			
		||||
        { [ worlds get-global empty? not ] [ t ] }
 | 
			
		||||
        [ f ]
 | 
			
		||||
    } cond ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,10 +30,10 @@ HELP: ui-running?
 | 
			
		|||
{ $values { "?" boolean } }
 | 
			
		||||
{ $description "Whether the UI is running or not." } ;
 | 
			
		||||
 | 
			
		||||
HELP: ui-windows
 | 
			
		||||
HELP: worlds
 | 
			
		||||
{ $var-description "Global variable holding an association list mapping native window handles to " { $link world } " instances." } ;
 | 
			
		||||
 | 
			
		||||
{ ui-windows open-window find-window world-attributes } related-words
 | 
			
		||||
{ worlds open-window find-window world-attributes } related-words
 | 
			
		||||
 | 
			
		||||
HELP: world-attributes
 | 
			
		||||
{ $values { "world-class" class } { "title" string } { "status" gadget } { "gadgets" sequence } { "pixel-format-attributes" sequence } { "window-controls" sequence } }
 | 
			
		||||
| 
						 | 
				
			
			@ -63,12 +63,12 @@ HELP: find-window
 | 
			
		|||
 | 
			
		||||
HELP: register-window
 | 
			
		||||
{ $values { "world" world } { "handle" "a backend-specific handle" } }
 | 
			
		||||
{ $description "Adds a window to the global " { $link ui-windows } " variable." }
 | 
			
		||||
{ $description "Adds a window to the global " { $link worlds } " variable." }
 | 
			
		||||
{ $notes "This word should only be called by the UI backend. User code can open new windows with " { $link open-window } "." } ;
 | 
			
		||||
 | 
			
		||||
HELP: unregister-window
 | 
			
		||||
{ $values { "handle" "a backend-specific handle" } }
 | 
			
		||||
{ $description "Removes a window from the global " { $link ui-windows } " variable." }
 | 
			
		||||
{ $description "Removes a window from the global " { $link worlds } " variable." }
 | 
			
		||||
{ $notes "This word should only be called only by the UI backend, and not user code." } ;
 | 
			
		||||
 | 
			
		||||
HELP: (with-ui)
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +126,7 @@ ARTICLE: "building-ui" "Building user interfaces"
 | 
			
		|||
    "ui-geometry"
 | 
			
		||||
    "ui-layouts"
 | 
			
		||||
    "gadgets"
 | 
			
		||||
    "ui-windows"
 | 
			
		||||
    "ui-worlds"
 | 
			
		||||
    "ui.gadgets.status-bar"
 | 
			
		||||
}
 | 
			
		||||
{ $see-also "models" } ;
 | 
			
		||||
| 
						 | 
				
			
			@ -160,13 +160,13 @@ ARTICLE: "ui-geometry" "Gadget geometry"
 | 
			
		|||
    children-on
 | 
			
		||||
} ;
 | 
			
		||||
 | 
			
		||||
ARTICLE: "ui-windows" "Top-level windows"
 | 
			
		||||
ARTICLE: "ui-worlds" "Top-level windows"
 | 
			
		||||
"Opening a top-level window:"
 | 
			
		||||
{ $subsections open-window }
 | 
			
		||||
"Finding top-level windows:"
 | 
			
		||||
{ $subsections find-window }
 | 
			
		||||
"Top-level windows are stored in a global variable:"
 | 
			
		||||
{ $subsections ui-windows }
 | 
			
		||||
{ $subsections worlds }
 | 
			
		||||
"When a gadget is displayed in a top-level window, or added to a parent which is already showing in a top-level window, a generic word is called allowing the gadget to perform initialization tasks:"
 | 
			
		||||
{ $subsections graft* }
 | 
			
		||||
"When the gadget is removed from a parent shown in a top-level window, or when the top-level window is closed, a corresponding generic word is called to clean up:"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,10 +11,10 @@ IN: ui
 | 
			
		|||
 | 
			
		||||
<PRIVATE
 | 
			
		||||
 | 
			
		||||
! Assoc mapping aliens to gadgets
 | 
			
		||||
SYMBOL: ui-windows
 | 
			
		||||
! Assoc mapping aliens to worlds
 | 
			
		||||
SYMBOL: worlds
 | 
			
		||||
 | 
			
		||||
: window ( handle -- world ) ui-windows get-global at ;
 | 
			
		||||
: window ( handle -- world ) worlds get-global at ;
 | 
			
		||||
 | 
			
		||||
: register-window ( world handle -- )
 | 
			
		||||
    ! Add the new window just below the topmost window. Why?
 | 
			
		||||
| 
						 | 
				
			
			@ -23,15 +23,15 @@ SYMBOL: ui-windows
 | 
			
		|||
    ! in the new window when it appears) Factor doesn't get
 | 
			
		||||
    ! confused and send workspace operations to the new window,
 | 
			
		||||
    ! etc.
 | 
			
		||||
    swap 2array ui-windows get-global push
 | 
			
		||||
    ui-windows get-global dup length 1 >
 | 
			
		||||
    swap 2array worlds get-global push
 | 
			
		||||
    worlds get-global dup length 1 >
 | 
			
		||||
    [ [ length 1 - dup 1 - ] keep exchange ] [ drop ] if ;
 | 
			
		||||
 | 
			
		||||
: unregister-window ( handle -- )
 | 
			
		||||
    ui-windows [ [ first = ] with reject ] change-global ;
 | 
			
		||||
    worlds [ [ first = ] with reject ] change-global ;
 | 
			
		||||
 | 
			
		||||
: raised-window ( world -- )
 | 
			
		||||
    ui-windows get-global
 | 
			
		||||
    worlds get-global
 | 
			
		||||
    [ [ second eq? ] with find drop ] keep
 | 
			
		||||
    [ nth ] [ remove-nth! drop ] [ nip ] 2tri push ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +105,7 @@ M: world ungraft*
 | 
			
		|||
    <dlist> \ graft-queue set-global
 | 
			
		||||
    100 <vector> \ layout-queue set-global
 | 
			
		||||
    <dlist> \ gesture-queue set-global
 | 
			
		||||
    V{ } clone ui-windows set-global ;
 | 
			
		||||
    V{ } clone worlds set-global ;
 | 
			
		||||
 | 
			
		||||
: update-hand ( world -- )
 | 
			
		||||
    dup hand-world get-global eq?
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +141,7 @@ SYMBOL: ui-running
 | 
			
		|||
PRIVATE>
 | 
			
		||||
 | 
			
		||||
: find-windows ( quot: ( world -- ? ) -- seq )
 | 
			
		||||
    [ ui-windows get-global values ] dip
 | 
			
		||||
    [ worlds get-global values ] dip
 | 
			
		||||
    '[ dup children>> [ ] [ nip first ] if-empty @ ]
 | 
			
		||||
    filter ; inline
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +205,7 @@ PRIVATE>
 | 
			
		|||
    find-world raise-window* ;
 | 
			
		||||
 | 
			
		||||
: topmost-window ( -- world )
 | 
			
		||||
    ui-windows get-global last second ;
 | 
			
		||||
    worlds get-global last second ;
 | 
			
		||||
 | 
			
		||||
HOOK: close-window ui-backend ( gadget -- )
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue