summaryrefslogtreecommitdiff
path: root/test-subject/text-box.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2021-04-25 14:51:00 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2021-04-25 14:51:00 -0400
commit8fc01b81e0f95c8ea187d179b6f6a6b9afc4e79e (patch)
tree3ff4f1250699e4006d584b8562992499e9643d4a /test-subject/text-box.scm
parent4ea611de4efe34a0f193572979c20372d4202b9f (diff)
Break code up into modules.
Diffstat (limited to 'test-subject/text-box.scm')
-rw-r--r--test-subject/text-box.scm37
1 files changed, 37 insertions, 0 deletions
diff --git a/test-subject/text-box.scm b/test-subject/text-box.scm
new file mode 100644
index 0000000..e46b396
--- /dev/null
+++ b/test-subject/text-box.scm
@@ -0,0 +1,37 @@
+(define-module (test-subject text-box)
+ #:use-module (chickadee graphics font)
+ #:use-module (chickadee math vector)
+ #:use-module (oop goops)
+ #:use-module (starling asset)
+ #:use-module (starling gui)
+ #:use-module (starling node)
+ #:use-module (starling node-2d)
+ #:duplicates (merge-generics replace warn-override-core warn last)
+ #:export (<text-box>
+ text-box-text))
+
+(define-class <text-box> (<widget>)
+ (text #:accessor text-box-text #:init-keyword #:text #:init-value "" #:watch? #t))
+
+(define-method (on-change (text-box <text-box>) slot-name old new)
+ (case slot-name
+ ((text)
+ (let ((l (& text-box text)))
+ (when l
+ (set! (text l) new))))
+ (else
+ (next-method))))
+
+(define-method (apply-theme (text-box <text-box>))
+ (next-method)
+ (replace text-box
+ (make <label>
+ #:name 'text
+ #:rank 1
+ #:font (font text-box)
+ #:text (text-box-text text-box)
+ #:position (vec2 6.0
+ (- (height text-box)
+ (font-line-height
+ (asset-ref
+ (font text-box))))))))