git.fiddlerwoaroof.com
Browse code

feature: splash screen, custom font

Edward Langley authored on 08/10/2019 20:46:22
Showing 7 changed files
... ...
@@ -1,10 +1,16 @@
1
-CJAWSAccess.app: app.icns deliver.lisp src/*.lisp aws-access.asd accounts.json AuthorizeShell.scpt
2
-	/Applications/LispWorks\ 7.1\ \(64-bit\)/LispWorks\ \(64-bit\).app/Contents/MacOS/lispworks-7-1-0-amd64-darwin -build deliver.lisp
3
-	cp AuthorizeShell.scpt CJAWSAccess.app/Contents/Resources/
1
+ASSET_DIRS = $(shell find assets/ -type d)
2
+ASSET_FILES = $(shell find assets/ -type f)
3
+
4
+all: app.icns CJAWSAccess.app accounts.json $(ASSET_DIRS) $(ASSET_FILES)
5
+	rsync -arvh assets/ CJAWSAccess.app/Contents/Resources/
4 6
 	cp accounts.json CJAWSAccess.app/Contents/Resources/accounts.json
5 7
 	cp app.icns CJAWSAccess.app/Contents/Resources/app.icns
6 8
 	touch CJAWSAccess.app
7 9
 
10
+CJAWSAccess.app: deliver.lisp src/*.lisp aws-access.asd addFonts.patch
11
+	/Applications/LispWorks\ 7.1\ \(64-bit\)/LispWorks\ \(64-bit\).app/Contents/MacOS/lispworks-7-1-0-amd64-darwin -build deliver.lisp
12
+	patch -N -p0 < addFonts.patch
13
+
8 14
 accounts.json: accounts.yml
9 15
 	./flip-yaml.lisp accounts.yml
10 16
 
11 17
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+--- CJAWSAccess.app/Contents/Info.plist	2019-10-08 12:04:02.442213658 -0700
2
+@@ -24,5 +24,7 @@
3
+ 	<string>7.1.2</string>
4
+ 	<key>NSPrincipalClass</key>
5
+ 	<string>NSApplication</string>
6
++   <key>ATSApplicationFontsPath</key>
7
++   <string>Fonts/</string>
8
+ </dict>
9
+ </plist>
0 10
similarity index 100%
1 11
rename from AuthorizeShell.scpt
2 12
rename to assets/AuthorizeShell.scpt
3 13
new file mode 100644
4 14
Binary files /dev/null and b/assets/Fonts/LispM-Monospace.ttf differ
5 15
new file mode 100644
6 16
Binary files /dev/null and b/assets/splash.png differ
... ...
@@ -148,7 +148,46 @@
148 148
   (interface :default-account 
149 149
              (ubiquitous:value :default-account)))
150 150
 
151
+
152
+(defun show-splash (&optional (image (bundle-resource "splash.png")))
153
+  (let* ((image (make-instance 'capi:image-pinboard-object
154
+                               :x 0 :y 0
155
+                               :image image
156
+                               :graphics-args '(:background :gray)))
157
+         (text (make-instance 'capi:item-pinboard-object
158
+                              :x 90 :y 450
159
+                              :text (format nil "( Cloud Access )")
160
+                              :graphics-args '(:font #s(graphics-ports:font
161
+                                                        :font-description #s(graphics-ports:font-description
162
+                                                                             :attributes (:name "LispM-Monospace"
163
+                                                                                          :family "LispM"
164
+                                                                                          :size 36.0d0
165
+                                                                                          :weight :demi
166
+                                                                                          :slant :roman
167
+                                                                                          :pitch :fixed))
168
+                                                        :device-font nil)
169
+                                               :background :transparent)))
170
+         (interface (destructuring-bind ((_ __ width height))
171
+                        (capi:screen-monitor-geometries (capi:convert-to-screen))
172
+                      (declare (ignore _ __))
173
+                      (make-instance 'capi:interface
174
+                                     :best-x (floor (- width 512) 2)
175
+                                     :best-y (floor (- height 512) 2)
176
+                                     :layout (make-instance 'capi:pinboard-layout
177
+                                                            :description (list image text))
178
+                                     :window-styles '(:borderless :internal-borderless :shadowed
179
+                                                      :movable-by-window-background :textured-background)))))
180
+
181
+
182
+    (prog1 (capi:display interface)
183
+      (mp:process-run-function "foo" ()
184
+                               (lambda ()
185
+                                 (sleep 2)
186
+                                 (capi:apply-in-pane-process interface
187
+                                                             'capi:destroy interface))))))
188
+
151 189
 (defun main ()
190
+  (show-splash)
152 191
   (setf *debugger-hook* 'debugging
153 192
         *print-readably* nil
154 193
         *accounts* (reprocess-accounts (load-accounts)))
... ...
@@ -7,6 +7,10 @@
7 7
                                     (objc:invoke "NSBundle" "mainBundle") 
8 8
                                     "pathForResource:ofType:" "app" "icns"))))
9 9
 
10
+(defun bundle-resource (relpath)
11
+  (merge-pathnames relpath
12
+                   (bundle-resource-root)))
13
+
10 14
 (defun clear-cookies ()
11 15
   (let ((cookie-storage (objc:invoke "NSHTTPCookieStorage" "sharedHTTPCookieStorage")))
12 16
     (map nil