From 1f6273f334e9c5c9a77630f3662d836ebc9894aa Mon Sep 17 00:00:00 2001 From: "Robert C. Martin" Date: Tue, 8 Mar 2022 11:27:24 -0600 Subject: [PATCH] Added the edit window. Non-functional. --- issues | 5 ++++ src/more_speech/ui/application.clj | 41 +++++++++++++++++++++--------- src/more_speech/ui/config.clj | 23 ++++++++++++----- src/more_speech/ui/edit_window.clj | 14 ++++++++++ 4 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 issues create mode 100644 src/more_speech/ui/edit_window.clj diff --git a/issues b/issues new file mode 100644 index 0000000..79c95e1 --- /dev/null +++ b/issues @@ -0,0 +1,5 @@ +* Something is wrong with threading, articles appear more than once. + This makes the up and down arrow selection malfunction. + +* Layout Manager. A better way of computing window positions and sizes. + diff --git a/src/more_speech/ui/application.clj b/src/more_speech/ui/application.clj index 6eba0bf..39a133b 100644 --- a/src/more_speech/ui/application.clj +++ b/src/more_speech/ui/application.clj @@ -23,6 +23,7 @@ [more-speech.ui.header-window :refer [->header-window-controls]] [more-speech.ui.article-window :refer [->article-window-controls]] [more-speech.ui.author-window :refer [->author-window-controls]] + [more-speech.ui.edit-window :refer [->edit-window-controls]] [more-speech.ui.graphics :as g] [more-speech.nostr.events :as events] [more-speech.ui.config :as config])) @@ -76,10 +77,18 @@ article-window-height (- screen-height article-window-top config/article-window-bottom-margin) - author-window-top-margin (:top-margin config/author-window-dimensions) + author-window-top (:top-margin config/author-window-dimensions) author-window-left-margin (:left-margin config/author-window-dimensions) author-window-width (:width config/author-window-dimensions) - author-window-height (* screen-height (:height-fraction config/author-window-dimensions))] + author-window-height (* screen-height (:height-fraction config/author-window-dimensions)) + author-window-left (+ header-window-left author-window-left-margin header-window-width) + author-window-width (g/pos-width graphics author-window-width) + + edit-window-top (+ author-window-top author-window-height (:top-margin config/edit-window-dimensions)) + edit-window-left author-window-left + edit-window-width (g/pos-width graphics (:width config/edit-window-dimensions)) + edit-window-height (- screen-height edit-window-top (:bottom-margin config/edit-window-dimensions)) + ] (assoc application :this-update #{} @@ -91,13 +100,13 @@ :text-event-map {} :open-thread #{} :header-window (map->text-window - {:title "Article Headers" - :x header-window-left - :y header-window-top - :w header-window-width - :h header-window-height - :controls (->header-window-controls) - }) + {:title "Article Headers" + :x header-window-left + :y header-window-top + :w header-window-width + :h header-window-height + :controls (->header-window-controls) + }) :article-window (map->text-window {:title "Selected Article" @@ -109,11 +118,19 @@ :author-window (map->text-window {:title "Authors" - :x (+ header-window-left author-window-left-margin header-window-width) - :y author-window-top-margin - :w (g/pos-width graphics author-window-width) + :x author-window-left + :y author-window-top + :w author-window-width :h author-window-height :controls (->author-window-controls)}) + + :edit-window (map->text-window + {:title "Compose an article." + :x edit-window-left + :y edit-window-top + :w edit-window-width + :h edit-window-height + :controls (->edit-window-controls)}) ) )) diff --git a/src/more_speech/ui/config.clj b/src/more_speech/ui/config.clj index ba6259c..40abd57 100644 --- a/src/more_speech/ui/config.clj +++ b/src/more_speech/ui/config.clj @@ -22,18 +22,22 @@ (def header-window-dimensions {:x 20 :y 10 - :width 105 ;window width in chars - :text-width 95 ;header text width in chars + :width 100 ;window width in chars + :text-width 90 ;header text width in chars :left-margin 20 ;px :height-fraction 5/8 ;of screen }) +(def header-lines 2) +(def header-top-margin 2) +(def header-bottom-margin 2) + (def article-window-top-margin 10) (def article-window-bottom-margin 10) (def article-window-dimensions { - :text-width 98 + :text-width 90 }) (def author-window-dimensions @@ -45,6 +49,13 @@ :height-fraction 1/4 }) -(def header-lines 2) -(def header-top-margin 2) -(def header-bottom-margin 2) +(def edit-window-dimensions + { + :left-margin 10 + :top-margin 10 + :width 100 + :text-width 90 + :bottom-margin 10 + }) + + diff --git a/src/more_speech/ui/edit_window.clj b/src/more_speech/ui/edit_window.clj new file mode 100644 index 0000000..582cd89 --- /dev/null +++ b/src/more_speech/ui/edit_window.clj @@ -0,0 +1,14 @@ +(ns more-speech.ui.edit-window + (:require [more-speech.ui.text-window :refer [text-window-controls]])) + +(defrecord edit-window-controls [] + text-window-controls + (get-element-height [_controls _state] + 1) + (draw-elements [_controls state _frame] + state) + (update-elements [_controls state _frame] + state) + (key-pressed [_controls state _frame _key] + state) + )