Added the edit window. Non-functional.

This commit is contained in:
Robert C. Martin 2022-03-08 11:27:24 -06:00
parent e9ce907495
commit 1f6273f334
4 changed files with 65 additions and 18 deletions

5
issues Normal file
View File

@ -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.

View File

@ -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)})
)
))

View File

@ -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
})

View File

@ -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)
)