/
e07_extra_props.clj
213 lines (202 loc) · 7.68 KB
/
e07_extra_props.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
(ns e07-extra-props
(:require [cljfx.api :as fx]))
(def anchor-pane
{:fx/type :anchor-pane
:children [{:fx/type :label
:anchor-pane/left 10
:anchor-pane/bottom 10
:text "bottom-left"}
{:fx/type :label
:anchor-pane/top 10
:anchor-pane/right 10
:text "top-right"}
{:fx/type :label
:anchor-pane/left 100
:anchor-pane/top 100
:anchor-pane/right 100
:anchor-pane/bottom 100
:style {:-fx-background-color :lightgray
:-fx-alignment :center}
:text "Try resizing window too!"}]})
(def border-pane
{:fx/type :border-pane
:top {:fx/type :label
:border-pane/alignment :center
:border-pane/margin 10
:text "top header"}
:left {:fx/type :label
:border-pane/margin 10
:text "left sidebar"}
:right {:fx/type :label
:border-pane/margin 10
:text "right sidebar"}
:center {:fx/type :label
:border-pane/margin 10
:text "center content"}
:bottom {:fx/type :label
:border-pane/margin 10
:text "bottom footer"}})
(def flow-pane
{:fx/type :flow-pane
:vgap 5
:hgap 5
:padding 5
:children (repeat 100 {:fx/type :rectangle :width 25 :height 25})})
(def grid-pane
{:fx/type :grid-pane
:children (concat
(for [i (range 16)]
{:fx/type :label
:grid-pane/column i
:grid-pane/row i
:grid-pane/hgrow :always
:grid-pane/vgrow :always
:text "boop"})
[{:fx/type :label
:grid-pane/row 2
:grid-pane/column 3
:grid-pane/column-span 2
:text "I am a long label spanning 2 columns"}])})
(def h-box
{:fx/type :h-box
:spacing 5
:children [{:fx/type :label
:text "just label"}
{:fx/type :label
:h-box/hgrow :always
:max-width Double/MAX_VALUE
:style {:-fx-background-color :lightgray}
:text "expanded label"}
{:fx/type :label
:h-box/margin 100
:text "label with big margin"}]})
(def stack-pane
{:fx/type :stack-pane
:children [{:fx/type :rectangle
:width 200
:height 200
:fill :lightgray}
{:fx/type :label
:stack-pane/alignment :bottom-left
:stack-pane/margin 5
:text "stacked label"}
{:fx/type :text-field
:stack-pane/alignment :top-right
:stack-pane/margin 5
:max-width 300
:text "Text field in top-right corner"}]})
(defn- tile-image [{:keys [url]}]
{:fx/type :image-view
:image {:url url
:requested-width 310
:preserve-ratio true
:background-loading true}})
(def tile-pane
{:fx/type :scroll-pane
:fit-to-width true
:content {:fx/type :tile-pane
:pref-columns 3
:hgap 5
:vgap 5
:children [{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.imgur.com/oy91jyx.gif"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.imgur.com/B4DdoER.png"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.imgur.com/mQOeSe5.png"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.redd.it/6906qzxo55711.png"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.redd.it/810g0l3sgis01.gif"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.redd.it/rpkzzc0awr411.gif"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "http://i.imgur.com/G3dVZpk.jpg"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.redd.it/k4hax2x5yyhy.png"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.imgur.com/PRxRkne.png"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.redd.it/zusrb3sxsz211.gif"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.redd.it/fagm2fhxv1yz.gif"}
{:fx/type tile-image
:tile-pane/alignment :bottom-center
:url "https://i.redd.it/w49wc60kys401.gif"}]}})
(def v-box
{:fx/type :v-box
:spacing 5
:fill-width true
:alignment :top-center
:children [{:fx/type :label :text "just label"}
{:fx/type :label
:v-box/vgrow :always
:style {:-fx-background-color :lightgray}
:max-height Double/MAX_VALUE
:max-width Double/MAX_VALUE
:text "expanded label"}]})
(def button-bar
{:fx/type :button-bar
:button-min-width 100
:buttons [{:fx/type :button
:button-bar/button-data :yes
:text "Yes"}
{:fx/type :button
:button-bar/button-data :no
:text "No"}]})
(fx/on-fx-thread
(fx/create-component
{:fx/type :stage
:showing true
:title "Pane examples"
:scene {:fx/type :scene
:root {:fx/type :tab-pane
:pref-width 960
:pref-height 540
:tabs [{:fx/type :tab
:text "Anchor Pane"
:closable false
:content anchor-pane}
{:fx/type :tab
:text "Border Pane"
:closable false
:content border-pane}
{:fx/type :tab
:text "Flow Pane"
:closable false
:content flow-pane}
{:fx/type :tab
:text "Grid Pane"
:closable false
:content grid-pane}
{:fx/type :tab
:text "HBox"
:closable false
:content h-box}
{:fx/type :tab
:text "Stack Pane"
:closable false
:content stack-pane}
{:fx/type :tab
:text "Tile Pane"
:closable false
:content tile-pane}
{:fx/type :tab
:text "VBox"
:closable false
:content v-box}
{:fx/type :tab
:text "Button Bar"
:closable false
:content button-bar}]}}}))