Skip to content

Commit 3cc4cbd

Browse files
committed
Make screen size conditional on debug?
1 parent 6f565df commit 3cc4cbd

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/fruit_economy/core.clj

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,22 +418,38 @@
418418
(when changed?
419419
(window/request-frame window))))
420420

421+
(defn screen-sized-window [window {:keys [width height right y] :as _work-area}]
422+
(let [window-width width
423+
window-height height
424+
window-left (- right window-width)
425+
window-top (-> y
426+
(+ height)
427+
(- (/ window-height 2)))]
428+
(doto window
429+
(window/set-window-size window-width window-height)
430+
(window/set-window-position window-left window-top))))
431+
432+
(defn small-window [window {:keys [width height right y] :as _work-area}]
433+
(let [window-width (/ width 2)
434+
window-height (/ height 2)
435+
window-left (- right window-width)
436+
window-top (-> y
437+
(+ (/ height 2))
438+
(- (/ window-height 2)))]
439+
(doto window
440+
(window/set-window-size window-width window-height)
441+
(window/set-window-position window-left window-top))))
442+
421443
(defn make-window []
422444
(let [{:keys [work-area]} (hui/primary-screen)
423-
window-width (/ (:width work-area) 2)
424-
window-height (/ (:height work-area) 2)
425-
window-left (- (:right work-area) window-width)
426-
window-top (-> (:y work-area)
427-
(+ (/ (:height work-area) 2))
428-
(- (/ window-height 2)))]
445+
window-size-fn (if (debug?) small-window screen-sized-window)]
429446
(doto
430447
(window/make
431448
{:on-close (if (debug?) #(reset! *window nil) #(System/exit 0))
432449
:on-paint #'on-paint
433450
:on-event #'on-event})
434451
(window/set-title "Fruit Economy 👋")
435-
(window/set-window-size window-width window-height)
436-
(window/set-window-position window-left window-top)
452+
(window-size-fn work-area)
437453
(window/set-visible true)
438454
(window/set-z-order :floating))))
439455

0 commit comments

Comments
 (0)