mirror of
https://github.com/unclebob/more-speech.git
synced 2024-09-30 02:21:02 +00:00
Prune unused code.
This commit is contained in:
parent
cbc94c1ac3
commit
417d6e4ce4
@ -20,9 +20,7 @@
|
|||||||
[more-speech.ui.text-window :refer [map->text-window]]
|
[more-speech.ui.text-window :refer [map->text-window]]
|
||||||
[more-speech.ui.text-frame :refer [map->text-frame]]
|
[more-speech.ui.text-frame :refer [map->text-frame]]
|
||||||
[more-speech.ui.header-frame-functions :refer [->header-controls]]
|
[more-speech.ui.header-frame-functions :refer [->header-controls]]
|
||||||
[more-speech.ui.author-window :refer [map->author-window
|
[more-speech.ui.author-window :refer [->author-window-controls]]
|
||||||
draw-author-window
|
|
||||||
->author-window-controls]]
|
|
||||||
[more-speech.ui.graphics :as g]
|
[more-speech.ui.graphics :as g]
|
||||||
[more-speech.nostr.events :as events]
|
[more-speech.nostr.events :as events]
|
||||||
[more-speech.ui.config :as config]))
|
[more-speech.ui.config :as config]))
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
(declare get-author-height
|
(declare get-author-height
|
||||||
draw-authors
|
draw-authors
|
||||||
scroll-authors
|
|
||||||
update-authors)
|
update-authors)
|
||||||
|
|
||||||
(defrecord author-window-controls []
|
(defrecord author-window-controls []
|
||||||
@ -20,26 +19,13 @@
|
|||||||
(draw-authors state frame))
|
(draw-authors state frame))
|
||||||
(update-elements [_c state frame]
|
(update-elements [_c state frame]
|
||||||
(update-authors state frame))
|
(update-authors state frame))
|
||||||
(scroll-elements [_c state frame delta]
|
)
|
||||||
(scroll-authors state frame delta)))
|
|
||||||
|
|
||||||
(defn get-author-height [state]
|
(defn get-author-height [state]
|
||||||
(let [graphics (get-in state [:application :graphics])
|
(let [graphics (get-in state [:application :graphics])
|
||||||
line-height (g/line-height graphics)]
|
line-height (g/line-height graphics)]
|
||||||
line-height))
|
line-height))
|
||||||
|
|
||||||
(declare draw-author-window)
|
|
||||||
|
|
||||||
(defrecord author-window [x y w h fonts]
|
|
||||||
widget
|
|
||||||
(setup-widget [widget _state]
|
|
||||||
widget)
|
|
||||||
(update-widget [_widget state]
|
|
||||||
state)
|
|
||||||
(draw-widget [widget state]
|
|
||||||
(draw-author-window state widget))
|
|
||||||
)
|
|
||||||
|
|
||||||
(defn draw-author [frame cursor author]
|
(defn draw-author [frame cursor author]
|
||||||
(let [g (:graphics cursor)]
|
(let [g (:graphics cursor)]
|
||||||
(g/text-align g [:left])
|
(g/text-align g [:left])
|
||||||
@ -62,30 +48,9 @@
|
|||||||
(if (empty? authors)
|
(if (empty? authors)
|
||||||
cursor
|
cursor
|
||||||
(recur (draw-author frame cursor (first authors))
|
(recur (draw-author frame cursor (first authors))
|
||||||
(rest authors)))))
|
(rest authors))))))
|
||||||
)
|
|
||||||
|
|
||||||
(defn update-authors [state frame]
|
(defn update-authors [state frame]
|
||||||
(let [frame-path (:path frame)
|
(let [frame-path (:path frame)
|
||||||
authors (get-in state [:application :nicknames])]
|
authors (get-in state [:application :nicknames])]
|
||||||
(assoc-in state (concat frame-path [:total-elements]) (count authors))))
|
(assoc-in state (concat frame-path [:total-elements]) (count authors))))
|
||||||
|
|
||||||
(defn scroll-authors [state frame delta]
|
|
||||||
(let [n-authors (count (get-in state [:application :nicknames]))
|
|
||||||
display-position (:display-position frame)
|
|
||||||
display-position (+ display-position delta)
|
|
||||||
display-position (min n-authors display-position)
|
|
||||||
display-position (max 0 display-position)
|
|
||||||
frame (assoc frame :display-position display-position)]
|
|
||||||
frame))
|
|
||||||
|
|
||||||
(defn draw-author-window [state window]
|
|
||||||
(let [application (:application state)
|
|
||||||
g (:graphics application)]
|
|
||||||
(g/with-translation
|
|
||||||
g [(:x window) (:y window)]
|
|
||||||
(fn [g] (g/stroke g [0 0 0])
|
|
||||||
(g/stroke-weight g 2)
|
|
||||||
(g/fill g [255 255 255])
|
|
||||||
(g/rect g [0 0 (:w window) (:h window)])
|
|
||||||
(draw-authors state window)))))
|
|
@ -11,13 +11,11 @@
|
|||||||
[more-speech.ui.text-frame :refer [text-window-controls
|
[more-speech.ui.text-frame :refer [text-window-controls
|
||||||
get-element-height
|
get-element-height
|
||||||
draw-elements
|
draw-elements
|
||||||
update-elements
|
update-elements]]))
|
||||||
scroll-elements]]))
|
|
||||||
|
|
||||||
(declare get-header-height
|
(declare get-header-height
|
||||||
draw-headers
|
draw-headers
|
||||||
update-headers
|
update-headers)
|
||||||
scroll-headers)
|
|
||||||
|
|
||||||
(defrecord header-controls []
|
(defrecord header-controls []
|
||||||
text-window-controls
|
text-window-controls
|
||||||
@ -27,8 +25,6 @@
|
|||||||
(draw-headers state frame))
|
(draw-headers state frame))
|
||||||
(update-elements [_c state frame]
|
(update-elements [_c state frame]
|
||||||
(update-headers state frame))
|
(update-headers state frame))
|
||||||
(scroll-elements [_c state frame delta]
|
|
||||||
(scroll-headers state frame delta))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
(defn get-header-height [state]
|
(defn get-header-height [state]
|
||||||
@ -183,12 +179,4 @@
|
|||||||
(recur (draw-header frame cursor header index)
|
(recur (draw-header frame cursor header index)
|
||||||
(rest headers) (inc index))))))))
|
(rest headers) (inc index))))))))
|
||||||
|
|
||||||
(defn scroll-headers [state frame delta]
|
|
||||||
(let [articles (get-in state [:application :chronological-text-events])
|
|
||||||
display-position (:display-position frame)
|
|
||||||
display-position (+ display-position delta)
|
|
||||||
display-position (min (count articles) display-position)
|
|
||||||
display-position (max 0 display-position)
|
|
||||||
frame (assoc frame :display-position display-position)]
|
|
||||||
frame))
|
|
||||||
|
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
(update-elements [controls state frame]
|
(update-elements [controls state frame]
|
||||||
"Called only if the widget is in [:application :this-update]
|
"Called only if the widget is in [:application :this-update]
|
||||||
sets :total-elements.")
|
sets :total-elements.")
|
||||||
(scroll-elements [controls state frame delta]
|
)
|
||||||
"sets :display-position"))
|
|
||||||
|
|
||||||
(declare setup-text-frame
|
(declare setup-text-frame
|
||||||
update-text-frame
|
update-text-frame
|
||||||
@ -62,11 +61,17 @@
|
|||||||
|
|
||||||
(defn scroll-frame [frame-path state delta]
|
(defn scroll-frame [frame-path state delta]
|
||||||
(let [frame (get-in state frame-path)
|
(let [frame (get-in state frame-path)
|
||||||
controls (:controls frame)
|
display-position (:display-position frame)
|
||||||
state (assoc-in state frame-path (scroll-elements controls state frame delta))
|
total-elements (get frame :total-elements 0)
|
||||||
state (app-util/update-widget state frame)]
|
display-position (+ display-position delta)
|
||||||
|
display-position (min total-elements display-position)
|
||||||
|
display-position (max 0 display-position)
|
||||||
|
frame (assoc frame :display-position display-position)
|
||||||
|
state (assoc-in state frame-path frame)
|
||||||
|
state (app-util/update-widget state frame)
|
||||||
|
]
|
||||||
state))
|
state))
|
||||||
|
|
||||||
(defn mouse-wheel [frame state clicks]
|
(defn mouse-wheel [frame state clicks]
|
||||||
(scroll-frame (:path frame) state clicks))
|
(scroll-frame (:path frame) state clicks))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user