eufon

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit b34a43897aba904dca342651afc83877e1b99a69
parent bd18a20251663774e7b0b63f8dd3e1c289efb547
Author: Daniel Barlow <dan@telent.net>
Date:   Sun,  3 Jul 2022 15:36:48 +0100

remove many hard-coded co-ordinates

Diffstat:
Mrc.fnl | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 69 insertions(+), 30 deletions(-)

diff --git a/rc.fnl b/rc.fnl @@ -17,6 +17,58 @@ (when (string.find (output:name) "^WL-") (output:set_mode 360 720 0))) +(fn kill-window [] + (print "DIE") + true) + +(fn launch [] + (print "WHOOSH") + true) + +(fn carousel [] + (print "spin spin sugar") + true) + +(fn placements [output] + (let [(width height) (output:size) + bar-height (/ height 15)] + { + + :application { + :x 0 + :y 0 + :w width + :h (- height (* bar-height 1.1)) + } + :bar { + :x 0 + :y (- height (* bar-height 1.1)) + :w width + :h (* bar-height 1.1) + } + :kill { + :x (- (* width 0.25) (/ bar-height 2)) + :y (- height bar-height) + :w bar-height + :h bar-height + :on-press kill-window + } + :launch { + :x (- (* width 0.5) (/ bar-height 2)) + :y (- height bar-height) + :w bar-height + :h bar-height + :on-press launch + } + :overview { + :x (- (* width 0.75) (/ bar-height 2)) + :y (- height bar-height) + :w bar-height + :h bar-height + :on-press carousel + } + })) + (kiwmi:on "output" (fn [output] @@ -28,57 +80,44 @@ spinner (texture.from-file r "carousel.png")] (output:on "render" (fn [{: output : renderer}] - (let [bar-height (/ height 15)] - (renderer:draw_rect :#00000077 - 0 (- height bar-height) - width bar-height) + (let [buttons (placements output)] + (renderer:draw_rect :#77000077 + buttons.bar.x buttons.bar.y + buttons.bar.w buttons.bar.h) (renderer:draw_texture kill matrix.identity - 30 (- height bar-height) + buttons.kill.x buttons.kill.y 0.7) (renderer:draw_texture launch matrix.identity - (- (/ width 2) (/ bar-height 2)) (- height bar-height) + buttons.launch.x buttons.launch.y 0.7) (renderer:draw_texture spinner matrix.identity - (- width 30 bar-height) (- height bar-height) + buttons.overview.x buttons.overview.y 0.7))))))) -(fn kill-window [] - (print "DIE") - true) - -(fn launch [] - (print "WHOOSH") - true) - -(fn carousel [] - (print "spin spin sugar") - true) (let [cursor (kiwmi:cursor)] (cursor:on "button_down" (fn [button] (let [(x y) (cursor:pos)] - (if (> y 680) - (if (< x 70) - (kill-window) - (and (< 150 x) (< x 190)) - (launch) - (and (< 285 x) (< x 330)) - (carousel) - false)))))) - + (each [name attribs (pairs (placements (kiwmi:active_output)))] + (if (and + (<= attribs.x x) + (< x (+ attribs.x attribs.w)) + (<= attribs.y y) + (< y (+ attribs.y attribs.h))) + (if attribs.on-press (attribs.on-press)))))))) (kiwmi:on "view" (fn [view] - (let [(w h) (: (kiwmi:active_output) :size)] - (view:resize w h) - (view:move 0 0)) + (let [geom (placements (kiwmi:active_output))] + (view:resize geom.application.w geom.application.h) + (view:move geom.application.x geom.application.y)) (view:focus) (view:show) (view:on "request_move" #(view:imove))