integrate component% into activity%
This commit is contained in:
parent
b21c80ccc9
commit
36a48ab937
|
@ -25,18 +25,27 @@
|
||||||
;; stock lux gen:word system
|
;; stock lux gen:word system
|
||||||
(define activity%
|
(define activity%
|
||||||
(class object%
|
(class object%
|
||||||
|
(init-field root)
|
||||||
(init-field [fps 0.0])
|
(init-field [fps 0.0])
|
||||||
(super-new)
|
(super-new)
|
||||||
|
|
||||||
;; returns a raart drawing
|
;; returns a raart drawing
|
||||||
(define/public (draw size)
|
(define/public (draw size)
|
||||||
(error "base draw"))
|
(send root draw size))
|
||||||
|
|
||||||
;; returns 'continue 'quit or another activity to start
|
;; returns 'continue 'quit or another activity to start
|
||||||
(define/public (on-event e)
|
(define/public (on-event e)
|
||||||
'continue)
|
'continue)
|
||||||
|
|
||||||
;; same but for fps ticks
|
;; internal top-level on-event which tries to send the event to the component tree first
|
||||||
|
(define/public (internal-on-event e)
|
||||||
|
;; see if the root component consumes the event
|
||||||
|
;; otherwise do the activity on-event handler
|
||||||
|
(if (send root on-event e)
|
||||||
|
'continue
|
||||||
|
(send this on-event e)))
|
||||||
|
|
||||||
|
;; same as on-event but for fps ticks
|
||||||
(define/public (on-tick)
|
(define/public (on-tick)
|
||||||
'continue)
|
'continue)
|
||||||
|
|
||||||
|
@ -58,7 +67,7 @@
|
||||||
(define stack (application-activity-stack word))
|
(define stack (application-activity-stack word))
|
||||||
(define result
|
(define result
|
||||||
(if e
|
(if e
|
||||||
(send (first stack) on-event e)
|
(send (first stack) internal-on-event e)
|
||||||
(send (first stack) on-tick)))
|
(send (first stack) on-tick)))
|
||||||
(match* (result stack)
|
(match* (result stack)
|
||||||
[('continue stack) (struct-copy application word [activity-stack stack])]
|
[('continue stack) (struct-copy application word [activity-stack stack])]
|
||||||
|
|
14
tui.rkt
14
tui.rkt
|
@ -12,7 +12,6 @@
|
||||||
(init-field posts)
|
(init-field posts)
|
||||||
(init-field modtimes)
|
(init-field modtimes)
|
||||||
(init-field forum)
|
(init-field forum)
|
||||||
(super-new)
|
|
||||||
|
|
||||||
(define sorted (sorted-level posts modtimes (list forum)))
|
(define sorted (sorted-level posts modtimes (list forum)))
|
||||||
|
|
||||||
|
@ -32,20 +31,17 @@
|
||||||
[cells entries])])]
|
[cells entries])])]
|
||||||
[footer (new label% [label-text "[JK] navigate | [ENTER] select | [Q] quit"])]))
|
[footer (new label% [label-text "[JK] navigate | [ENTER] select | [Q] quit"])]))
|
||||||
|
|
||||||
(define/override (draw size)
|
(super-new [root root])
|
||||||
(send root draw size))
|
|
||||||
|
|
||||||
(define/override (on-event e)
|
(define/override (on-event e)
|
||||||
(match e
|
(match e
|
||||||
["q" 'quit]
|
["q" 'quit]
|
||||||
[_ (send root on-event e)
|
[_ 'continue]))))
|
||||||
'continue]))))
|
|
||||||
|
|
||||||
(define meowbb-forum-list%
|
(define meowbb-forum-list%
|
||||||
(class activity%
|
(class activity%
|
||||||
(init-field posts)
|
(init-field posts)
|
||||||
(init-field modtimes)
|
(init-field modtimes)
|
||||||
(super-new)
|
|
||||||
|
|
||||||
(define forums (sort (hash-keys posts) string<?))
|
(define forums (sort (hash-keys posts) string<?))
|
||||||
(define entries
|
(define entries
|
||||||
|
@ -61,8 +57,7 @@
|
||||||
[cells entries])])]
|
[cells entries])])]
|
||||||
[footer (new label% [label-text "[JK] navigate | [ENTER] select | [Q] quit"])]))
|
[footer (new label% [label-text "[JK] navigate | [ENTER] select | [Q] quit"])]))
|
||||||
|
|
||||||
(define/override (draw size)
|
(super-new [root root])
|
||||||
(send root draw size))
|
|
||||||
|
|
||||||
(define/override (on-event e)
|
(define/override (on-event e)
|
||||||
(match e
|
(match e
|
||||||
|
@ -70,8 +65,7 @@
|
||||||
[(app-event _ 'selection row)
|
[(app-event _ 'selection row)
|
||||||
(define forum (list-ref forums row))
|
(define forum (list-ref forums row))
|
||||||
(new meowbb-post-list% [posts posts] [modtimes modtimes] [forum forum])]
|
(new meowbb-post-list% [posts posts] [modtimes modtimes] [forum forum])]
|
||||||
[_ (send root on-event e)
|
[_ 'continue]))
|
||||||
'continue]))
|
|
||||||
|
|
||||||
(define/override (on-deactivated)
|
(define/override (on-deactivated)
|
||||||
"bye meow ~")))
|
"bye meow ~")))
|
||||||
|
|
Loading…
Reference in New Issue