Created
January 19, 2014 12:36
-
-
Save whilo/8504314 to your computer and use it in GitHub Desktop.
Windowing/layout experiments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns slide.window | |
(:use [dommy.core :only [set-style!]] | |
[dommy.template :only [PElement]])) | |
(defprotocol PWindow | |
(parent [this]) | |
(position [this]) | |
(size [this]) | |
#_(set-parent! [this par]) | |
#_(set-position! [this pos]) | |
#_(set-size! [this s])) | |
(defprotocol PTransparentWindow | |
(opacity [this]) | |
(set-opacity! [this s])) | |
(defn size-to-css [v] | |
(cond (integer? v) (str v "px") | |
(= v :auto) "auto")) | |
(extend-protocol PWindow | |
js/HTMLDivElement | |
(parent [this] (.-parentNode this)) | |
(position [this] {:top (.-clientTop this) :left (.-clientLeft this)}) | |
(size [this] {:width (.-clientWidth this) :height (.-clientHeight this)}) | |
js/HTMLBodyElement | |
(parent [this] nil) | |
(position [this] {:top (.-clientTop this) :left (.-clientLeft this)}) | |
(size [this] {:width (.-clientWidth this) :height (.-clientHeight this)})) | |
; responsible for position and browsing of level-order | |
(defprotocol PWindowManager | |
(root-window [this]) | |
(cycle-children [this])) | |
(defprotocol PInputHandler | |
(on-focus [this]) | |
(on-unfocus [this])) | |
(defrecord SingleWindowManager [root-window decorator] | |
PWindowManager | |
(root-window [this] root-window) | |
(cycle-children [this] nil)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment