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