honeylisp/presentation/commands.fnl
2021-06-21 22:09:09 -04:00

32 lines
1,006 B
Fennel

(local util (require :lib.util))
(local core (require :core))
(local command (require :core.command))
(local keymap (require :core.keymap))
(local SlideshowView (require :presentation.engine))
(fn set-scale [multiplier]
(set _G.SCALE (* (love.graphics.getDPIScale) multiplier))
(util.hotswap :core.style))
(command.add nil {
"presentation:start" (fn []
(let [node (core.root_view:get_active_node)]
(node:add_view (SlideshowView (util.reload :presentation.slides))))
)
"presentation:scale-up" #(set-scale 2)
"presentation:restore-scale" #(set-scale 1)
})
(command.add :presentation.engine {
"presentation:next" #(core.active_view:advance)
"presentation:prev" #(core.active_view:back)
"presentation:next-slide" #(core.active_view:next-slide)
"presentation:prev-slide" #(core.active_view:prev-slide)
})
(keymap.add {
"left" "presentation:prev"
"right" "presentation:next"
"ctrl+left" "presentation:prev-slide"
"ctrl+right" "presentation:next-slide"
})