-
-
Notifications
You must be signed in to change notification settings - Fork 290
/
types.jl
1378 lines (1317 loc) · 54.3 KB
/
types.jl
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const Optional{T} = Union{Nothing, T}
struct AxisAspect
aspect::Float32
end
struct DataAspect end
struct Cycler
counters::Dict{Type, Int}
end
Cycler() = Cycler(Dict{Type, Int}())
struct Cycle
cycle::Vector{Pair{Vector{Symbol}, Symbol}}
covary::Bool
end
Cycle(cycle; covary = false) = Cycle(to_cycle(cycle), covary)
to_cycle(single) = [to_cycle_single(single)]
to_cycle(::Nothing) = []
to_cycle(symbolvec::Vector) = map(to_cycle_single, symbolvec)
to_cycle_single(sym::Symbol) = [sym] => sym
to_cycle_single(pair::Pair{Symbol, Symbol}) = [pair[1]] => pair[2]
to_cycle_single(pair::Pair{Vector{Symbol}, Symbol}) = pair
"""
Cycled(i::Int)
If a `Cycled` value is passed as an attribute to a plotting function,
it is replaced with the value from the cycler for this attribute (as
long as there is one defined) at the index `i`.
"""
struct Cycled
i::Int
end
"""
LinearTicks with ideally a number of `n_ideal` tick marks.
"""
struct LinearTicks
n_ideal::Int
function LinearTicks(n_ideal)
if n_ideal <= 0
error("Ideal number of ticks can't be smaller than 0, but is $n_ideal")
end
new(n_ideal)
end
end
struct WilkinsonTicks
k_ideal::Int
k_min::Int
k_max::Int
Q::Vector{Tuple{Float64, Float64}}
granularity_weight::Float64
simplicity_weight::Float64
coverage_weight::Float64
niceness_weight::Float64
min_px_dist::Float64
end
"""
Like LinearTicks but for multiples of `multiple`.
Example where approximately 5 numbers should be found
that are multiples of pi, printed like "1π", "2π", etc.:
```
MultiplesTicks(5, pi, "π")
```
"""
struct MultiplesTicks
n_ideal::Int
multiple::Float64
suffix::String
end
# """
# LogitTicks{T}(linear_ticks::T)
# Wraps any other tick object.
# Used to apply a linear tick searching algorithm on a logit-transformed interval.
# """
# struct LogitTicks{T}
# linear_ticks::T
# end
"""
LogTicks{T}(linear_ticks::T)
Wraps any other tick object.
Used to apply a linear tick searching algorithm on a log-transformed interval.
"""
struct LogTicks{T}
linear_ticks::T
end
"""
IntervalsBetween(n::Int, mirror::Bool = true)
Indicates to create n-1 minor ticks between every pair of adjacent major ticks.
"""
struct IntervalsBetween
n::Int
mirror::Bool
function IntervalsBetween(n::Int, mirror::Bool)
n < 2 && error("You can't have $n intervals (must be at least 2 which means 1 minor tick)")
new(n, mirror)
end
end
IntervalsBetween(n) = IntervalsBetween(n, true)
mutable struct LineAxis
parent::Scene
protrusion::Observable{Float32}
attributes::Attributes
elements::Dict{Symbol, Any}
tickpositions::Observable{Vector{Point2f}}
tickvalues::Observable{Vector{Float32}}
ticklabels::Observable{Vector{AbstractString}}
minortickpositions::Observable{Vector{Point2f}}
minortickvalues::Observable{Vector{Float32}}
end
struct LimitReset end
mutable struct RectangleZoom
callback::Function
active::Observable{Bool}
restrict_x::Bool
restrict_y::Bool
from::Union{Nothing, Point2f}
to::Union{Nothing, Point2f}
rectnode::Observable{Rect2f}
end
function RectangleZoom(callback::Function; restrict_x=false, restrict_y=false)
return RectangleZoom(callback, Observable(false), restrict_x, restrict_y,
nothing, nothing, Observable(Rect2f(0, 0, 1, 1)))
end
struct ScrollZoom
speed::Float32
reset_timer::RefValue{Union{Nothing, Timer}}
prev_xticklabelspace::RefValue{Union{Automatic, Float64}}
prev_yticklabelspace::RefValue{Union{Automatic, Float64}}
reset_delay::Float32
end
function ScrollZoom(speed, reset_delay)
return ScrollZoom(speed, RefValue{Union{Nothing, Timer}}(nothing), RefValue{Union{Automatic, Float64}}(0.0), RefValue{Union{Automatic, Float64}}(0.0), reset_delay)
end
struct DragPan
reset_timer::RefValue{Union{Nothing, Timer}}
prev_xticklabelspace::RefValue{Union{Automatic, Float64}}
prev_yticklabelspace::RefValue{Union{Automatic, Float64}}
reset_delay::Float32
end
function DragPan(reset_delay)
return DragPan(RefValue{Union{Nothing, Timer}}(nothing), RefValue{Union{Automatic, Float64}}(0.0), RefValue{Union{Automatic, Float64}}(0.0), reset_delay)
end
struct DragRotate
end
struct ScrollEvent
x::Float32
y::Float32
end
struct KeysEvent
keys::Set{Makie.Keyboard.Button}
end
@Block Axis begin
scene::Scene
xaxislinks::Vector{Axis}
yaxislinks::Vector{Axis}
targetlimits::Observable{Rect2f}
finallimits::Observable{Rect2f}
cycler::Cycler
palette::Attributes
block_limit_linking::Observable{Bool}
mouseeventhandle::MouseEventHandle
scrollevents::Observable{ScrollEvent}
keysevents::Observable{KeysEvent}
interactions::Dict{Symbol, Tuple{Bool, Any}}
xaxis::LineAxis
yaxis::LineAxis
@attributes begin
"The xlabel string."
xlabel = ""
"The ylabel string."
ylabel = ""
"The axis title string."
title = ""
"The font family of the title."
titlefont = :bold
"The title's font size."
titlesize::Float64 = @inherit(:fontsize, 16f0)
"The gap between axis and title."
titlegap::Float64 = 4f0
"Controls if the title is visible."
titlevisible::Bool = true
"The horizontal alignment of the title."
titlealign::Symbol = :center
"The color of the title"
titlecolor::RGBAf = @inherit(:textcolor, :black)
"The axis title line height multiplier."
titlelineheight::Float64 = 1
"The axis subtitle string."
subtitle = ""
"The font family of the subtitle."
subtitlefont = :regular
"The subtitle's font size."
subtitlesize::Float64 = @inherit(:fontsize, 16f0)
"The gap between subtitle and title."
subtitlegap::Float64 = 0
"Controls if the subtitle is visible."
subtitlevisible::Bool = true
"The color of the subtitle"
subtitlecolor::RGBAf = @inherit(:textcolor, :black)
"The axis subtitle line height multiplier."
subtitlelineheight::Float64 = 1
"The font family of the xlabel."
xlabelfont = :regular
"The font family of the ylabel."
ylabelfont = :regular
"The color of the xlabel."
xlabelcolor::RGBAf = @inherit(:textcolor, :black)
"The color of the ylabel."
ylabelcolor::RGBAf = @inherit(:textcolor, :black)
"The font size of the xlabel."
xlabelsize::Float64 = @inherit(:fontsize, 16f0)
"The font size of the ylabel."
ylabelsize::Float64 = @inherit(:fontsize, 16f0)
"Controls if the xlabel is visible."
xlabelvisible::Bool = true
"Controls if the ylabel is visible."
ylabelvisible::Bool = true
"The padding between the xlabel and the ticks or axis."
xlabelpadding::Float64 = 3f0
"The padding between the ylabel and the ticks or axis."
ylabelpadding::Float64 = 5f0 # xlabels usually have some more visual padding because of ascenders, which are larger than the hadvance gaps of ylabels
"The xlabel rotation in radians."
xlabelrotation = Makie.automatic
"The ylabel rotation in radians."
ylabelrotation = Makie.automatic
"The font family of the xticklabels."
xticklabelfont = :regular
"The font family of the yticklabels."
yticklabelfont = :regular
"The color of xticklabels."
xticklabelcolor::RGBAf = @inherit(:textcolor, :black)
"The color of yticklabels."
yticklabelcolor::RGBAf = @inherit(:textcolor, :black)
"The font size of the xticklabels."
xticklabelsize::Float64 = @inherit(:fontsize, 16f0)
"The font size of the yticklabels."
yticklabelsize::Float64 = @inherit(:fontsize, 16f0)
"Controls if the xticklabels are visible."
xticklabelsvisible::Bool = true
"Controls if the yticklabels are visible."
yticklabelsvisible::Bool = true
"The space reserved for the xticklabels."
xticklabelspace::Union{Makie.Automatic, Float64} = Makie.automatic
"The space reserved for the yticklabels."
yticklabelspace::Union{Makie.Automatic, Float64} = Makie.automatic
"The space between xticks and xticklabels."
xticklabelpad::Float64 = 2f0
"The space between yticks and yticklabels."
yticklabelpad::Float64 = 4f0
"The counterclockwise rotation of the xticklabels in radians."
xticklabelrotation::Float64 = 0f0
"The counterclockwise rotation of the yticklabels in radians."
yticklabelrotation::Float64 = 0f0
"The horizontal and vertical alignment of the xticklabels."
xticklabelalign::Union{Makie.Automatic, Tuple{Symbol, Symbol}} = Makie.automatic
"The horizontal and vertical alignment of the yticklabels."
yticklabelalign::Union{Makie.Automatic, Tuple{Symbol, Symbol}} = Makie.automatic
"The size of the xtick marks."
xticksize::Float64 = 6f0
"The size of the ytick marks."
yticksize::Float64 = 6f0
"Controls if the xtick marks are visible."
xticksvisible::Bool = true
"Controls if the ytick marks are visible."
yticksvisible::Bool = true
"The alignment of the xtick marks relative to the axis spine (0 = out, 1 = in)."
xtickalign::Float64 = 0f0
"The alignment of the ytick marks relative to the axis spine (0 = out, 1 = in)."
ytickalign::Float64 = 0f0
"The width of the xtick marks."
xtickwidth::Float64 = 1f0
"The width of the ytick marks."
ytickwidth::Float64 = 1f0
"The color of the xtick marks."
xtickcolor::RGBAf = RGBf(0, 0, 0)
"The color of the ytick marks."
ytickcolor::RGBAf = RGBf(0, 0, 0)
"Controls if the x ticks and minor ticks are mirrored on the other side of the Axis."
xticksmirrored::Bool = false
"Controls if the y ticks and minor ticks are mirrored on the other side of the Axis."
yticksmirrored::Bool = false
"Locks interactive panning in the x direction."
xpanlock::Bool = false
"Locks interactive panning in the y direction."
ypanlock::Bool = false
"Locks interactive zooming in the x direction."
xzoomlock::Bool = false
"Locks interactive zooming in the y direction."
yzoomlock::Bool = false
"Controls if rectangle zooming affects the x dimension."
xrectzoom::Bool = true
"Controls if rectangle zooming affects the y dimension."
yrectzoom::Bool = true
"The width of the axis spines."
spinewidth::Float64 = 1f0
"Controls if the x grid lines are visible."
xgridvisible::Bool = true
"Controls if the y grid lines are visible."
ygridvisible::Bool = true
"The width of the x grid lines."
xgridwidth::Float64 = 1f0
"The width of the y grid lines."
ygridwidth::Float64 = 1f0
"The color of the x grid lines."
xgridcolor::RGBAf = RGBAf(0, 0, 0, 0.12)
"The color of the y grid lines."
ygridcolor::RGBAf = RGBAf(0, 0, 0, 0.12)
"The linestyle of the x grid lines."
xgridstyle = nothing
"The linestyle of the y grid lines."
ygridstyle = nothing
"Controls if the x minor grid lines are visible."
xminorgridvisible::Bool = false
"Controls if the y minor grid lines are visible."
yminorgridvisible::Bool = false
"The width of the x minor grid lines."
xminorgridwidth::Float64 = 1f0
"The width of the y minor grid lines."
yminorgridwidth::Float64 = 1f0
"The color of the x minor grid lines."
xminorgridcolor::RGBAf = RGBAf(0, 0, 0, 0.05)
"The color of the y minor grid lines."
yminorgridcolor::RGBAf = RGBAf(0, 0, 0, 0.05)
"The linestyle of the x minor grid lines."
xminorgridstyle = nothing
"The linestyle of the y minor grid lines."
yminorgridstyle = nothing
"Controls if the bottom axis spine is visible."
bottomspinevisible::Bool = true
"Controls if the left axis spine is visible."
leftspinevisible::Bool = true
"Controls if the top axis spine is visible."
topspinevisible::Bool = true
"Controls if the right axis spine is visible."
rightspinevisible::Bool = true
"The color of the bottom axis spine."
bottomspinecolor::RGBAf = :black
"The color of the left axis spine."
leftspinecolor::RGBAf = :black
"The color of the top axis spine."
topspinecolor::RGBAf = :black
"The color of the right axis spine."
rightspinecolor::RGBAf = :black
"The forced aspect ratio of the axis. `nothing` leaves the axis unconstrained, `DataAspect()` forces the same ratio as the ratio in data limits between x and y axis, `AxisAspect(ratio)` sets a manual ratio."
aspect = nothing
"The vertical alignment of the axis within its suggested bounding box."
valign = :center
"The horizontal alignment of the axis within its suggested bounding box."
halign = :center
"The width of the axis."
width = nothing
"The height of the axis."
height = nothing
"Controls if the parent layout can adjust to this element's width"
tellwidth::Bool = true
"Controls if the parent layout can adjust to this element's height"
tellheight::Bool = true
"The relative margins added to the autolimits in x direction."
xautolimitmargin::Tuple{Float64, Float64} = (0.05f0, 0.05f0)
"The relative margins added to the autolimits in y direction."
yautolimitmargin::Tuple{Float64, Float64} = (0.05f0, 0.05f0)
"The xticks."
xticks = Makie.automatic
"Format for xticks."
xtickformat = Makie.automatic
"The yticks."
yticks = Makie.automatic
"Format for yticks."
ytickformat = Makie.automatic
"The button for panning."
panbutton::Makie.Mouse.Button = Makie.Mouse.right
"The key for limiting panning to the x direction."
xpankey::Makie.Keyboard.Button = Makie.Keyboard.x
"The key for limiting panning to the y direction."
ypankey::Makie.Keyboard.Button = Makie.Keyboard.y
"The key for limiting zooming to the x direction."
xzoomkey::Makie.Keyboard.Button = Makie.Keyboard.x
"The key for limiting zooming to the y direction."
yzoomkey::Makie.Keyboard.Button = Makie.Keyboard.y
"The position of the x axis (`:bottom` or `:top`)."
xaxisposition::Symbol = :bottom
"The position of the y axis (`:left` or `:right`)."
yaxisposition::Symbol = :left
"Controls if the x spine is limited to the furthest tick marks or not."
xtrimspine::Union{Bool, Tuple{Bool,Bool}} = false
"Controls if the y spine is limited to the furthest tick marks or not."
ytrimspine::Union{Bool, Tuple{Bool,Bool}} = false
"The background color of the axis."
backgroundcolor::RGBAf = :white
"Controls if the ylabel's rotation is flipped."
flip_ylabel::Bool = false
"Constrains the data aspect ratio (`nothing` leaves the ratio unconstrained)."
autolimitaspect = nothing
"The limits that the user has manually set. They are reinstated when calling `reset_limits!` and are set to nothing by `autolimits!`. Can be either a tuple (xlow, xhigh, ylow, high) or a tuple (nothing_or_xlims, nothing_or_ylims). Are set by `xlims!`, `ylims!` and `limits!`."
limits = (nothing, nothing)
"The align mode of the axis in its parent GridLayout."
alignmode = Inside()
"Controls if the y axis goes upwards (false) or downwards (true)"
yreversed::Bool = false
"Controls if the x axis goes rightwards (false) or leftwards (true)"
xreversed::Bool = false
"Controls if minor ticks on the x axis are visible"
xminorticksvisible::Bool = false
"The alignment of x minor ticks on the axis spine"
xminortickalign::Float64 = 0f0
"The tick size of x minor ticks"
xminorticksize::Float64 = 4f0
"The tick width of x minor ticks"
xminortickwidth::Float64 = 1f0
"The tick color of x minor ticks"
xminortickcolor::RGBAf = :black
"The tick locator for the x minor ticks"
xminorticks = IntervalsBetween(2)
"Controls if minor ticks on the y axis are visible"
yminorticksvisible::Bool = false
"The alignment of y minor ticks on the axis spine"
yminortickalign::Float64 = 0f0
"The tick size of y minor ticks"
yminorticksize::Float64 = 4f0
"The tick width of y minor ticks"
yminortickwidth::Float64 = 1f0
"The tick color of y minor ticks"
yminortickcolor::RGBAf = :black
"The tick locator for the y minor ticks"
yminorticks = IntervalsBetween(2)
"The x axis scale"
xscale = identity
"The y axis scale"
yscale = identity
end
end
function RectangleZoom(f::Function, ax::Axis; kw...)
r = RectangleZoom(f; kw...)
selection_vertices = lift(_selection_vertices, Observable(ax.scene), ax.finallimits, r.rectnode)
# manually specify correct faces for a rectangle with a rectangle hole inside
faces = [1 2 5; 5 2 6; 2 3 6; 6 3 7; 3 4 7; 7 4 8; 4 1 8; 8 1 5]
# plot to blockscene, so ax.scene stays exclusive for user plots
# That's also why we need to pass `ax.scene` to _selection_vertices, so it can project to that space
mesh = mesh!(ax.blockscene, selection_vertices, faces, color = (:black, 0.2), shading = false,
inspectable = false, visible=r.active, transparency=true)
# translate forward so selection mesh and frame are never behind data
translate!(mesh, 0, 0, 100)
return r
end
function RectangleZoom(ax::Axis; kw...)
return RectangleZoom(ax; kw...) do newlims
if !(0 in widths(newlims))
ax.targetlimits[] = newlims
end
return
end
end
@Block Colorbar begin
axis::LineAxis
@attributes begin
"The color bar label string."
label = ""
"The label color."
labelcolor = @inherit(:textcolor, :black)
"The label font family."
labelfont = :regular
"The label font size."
labelsize = @inherit(:fontsize, 16f0)
"Controls if the label is visible."
labelvisible = true
"The gap between the label and the ticks."
labelpadding = 5f0
"The label rotation in radians."
labelrotation = 0f0
"The font family of the tick labels."
ticklabelfont = :regular
"The font size of the tick labels."
ticklabelsize = @inherit(:fontsize, 16f0)
"Controls if the tick labels are visible."
ticklabelsvisible = true
"The color of the tick labels."
ticklabelcolor = @inherit(:textcolor, :black)
"The size of the tick marks."
ticksize = 6f0
"Controls if the tick marks are visible."
ticksvisible = true
"The ticks."
ticks = Makie.automatic
"Format for ticks."
tickformat = Makie.automatic
"The space reserved for the tick labels."
ticklabelspace = Makie.automatic
"The gap between tick labels and tick marks."
ticklabelpad = 3f0
"The alignment of the tick marks relative to the axis spine (0 = out, 1 = in)."
tickalign = 0f0
"The line width of the tick marks."
tickwidth = 1f0
"The color of the tick marks."
tickcolor = RGBf(0, 0, 0)
"The horizontal and vertical alignment of the tick labels."
ticklabelalign = Makie.automatic
"The rotation of the ticklabels."
ticklabelrotation = 0f0
"The line width of the spines."
spinewidth = 1f0
"Controls if the top spine is visible."
topspinevisible = true
"Controls if the right spine is visible."
rightspinevisible = true
"Controls if the left spine is visible."
leftspinevisible = true
"Controls if the bottom spine is visible."
bottomspinevisible = true
"The color of the top spine."
topspinecolor = RGBf(0, 0, 0)
"The color of the left spine."
leftspinecolor = RGBf(0, 0, 0)
"The color of the right spine."
rightspinecolor = RGBf(0, 0, 0)
"The color of the bottom spine."
bottomspinecolor = RGBf(0, 0, 0)
"The vertical alignment of the colorbar in its suggested bounding box."
valign = :center
"The horizontal alignment of the colorbar in its suggested bounding box."
halign = :center
"Controls if the colorbar is oriented vertically."
vertical = true
"Flips the axis to the right if vertical and to the top if horizontal."
flipaxis = true
"Flips the colorbar label if the axis is vertical."
flip_vertical_label = false
"The width setting of the colorbar. Use `size` to set width or height relative to colorbar orientation instead."
width = Auto()
"The height setting of the colorbar."
height = Auto()
"Controls if the parent layout can adjust to this element's width"
tellwidth = true
"Controls if the parent layout can adjust to this element's height"
tellheight = true
"The colormap that the colorbar uses."
colormap = @inherit(:colormap, :viridis)
"The range of values depicted in the colorbar."
limits = nothing
"The range of values depicted in the colorbar."
colorrange = nothing
"The align mode of the colorbar in its parent GridLayout."
alignmode = Inside()
"The number of steps in the heatmap underlying the colorbar gradient."
nsteps = 100
"The color of the high clip triangle."
highclip = nothing
"The color of the low clip triangle."
lowclip = nothing
"Controls if minor ticks are visible"
minorticksvisible = false
"The alignment of minor ticks on the axis spine"
minortickalign = 0f0
"The tick size of minor ticks"
minorticksize = 4f0
"The tick width of minor ticks"
minortickwidth = 1f0
"The tick color of minor ticks"
minortickcolor = :black
"The tick locator for the minor ticks"
minorticks = IntervalsBetween(5)
"The axis scale"
scale = identity
"The width or height of the colorbar, depending on if it's vertical or horizontal, unless overridden by `width` / `height`"
size = 16
end
end
@Block Label begin
@attributes begin
"The displayed text string."
text = "Text"
"Controls if the text is visible."
visible::Bool = true
"The color of the text."
color::RGBAf = @inherit(:textcolor, :black)
"The font size of the text."
fontsize::Float32 = @inherit(:fontsize, 16f0)
"The font family of the text."
font = :regular
"The justification of the text (:left, :right, :center)."
justification = :center
"The lineheight multiplier for the text."
lineheight::Float32 = 1.0
"The vertical alignment of the text in its suggested boundingbox"
valign = :center
"The horizontal alignment of the text in its suggested boundingbox"
halign = :center
"The counterclockwise rotation of the text in radians."
rotation::Float32 = 0f0
"The extra space added to the sides of the text boundingbox."
padding = (0f0, 0f0, 0f0, 0f0)
"The height setting of the text."
height = Auto()
"The width setting of the text."
width = Auto()
"Controls if the parent layout can adjust to this element's width"
tellwidth::Bool = true
"Controls if the parent layout can adjust to this element's height"
tellheight::Bool = true
"The align mode of the text in its parent GridLayout."
alignmode = Inside()
"Enable word wrapping to the suggested width of the Label."
word_wrap::Bool = false
end
end
@Block Box begin
@attributes begin
"Controls if the rectangle is visible."
visible = true
"The color of the rectangle."
color = RGBf(0.9, 0.9, 0.9)
"The vertical alignment of the rectangle in its suggested boundingbox"
valign = :center
"The horizontal alignment of the rectangle in its suggested boundingbox"
halign = :center
"The extra space added to the sides of the rectangle boundingbox."
padding = (0f0, 0f0, 0f0, 0f0)
"The line width of the rectangle's border."
strokewidth = 1f0
"Controls if the border of the rectangle is visible."
strokevisible = true
"The color of the border."
strokecolor = RGBf(0, 0, 0)
"The width setting of the rectangle."
width = nothing
"The height setting of the rectangle."
height = nothing
"Controls if the parent layout can adjust to this element's width"
tellwidth = true
"Controls if the parent layout can adjust to this element's height"
tellheight = true
"The align mode of the rectangle in its parent GridLayout."
alignmode = Inside()
end
end
@Block Slider begin
selected_index::Observable{Int}
@attributes begin
"The horizontal alignment of the element in its suggested bounding box."
halign = :center
"The vertical alignment of the element in its suggested bounding box."
valign = :center
"The width setting of the element."
width = Auto()
"The height setting of the element."
height = Auto()
"The range of values that the slider can pick from."
range = 0:0.01:10
"Controls if the parent layout can adjust to this element's width"
tellwidth::Bool = true
"Controls if the parent layout can adjust to this element's height"
tellheight::Bool = true
"The start value of the slider or the value that is closest in the slider range."
startvalue = 0
"The current value of the slider. Don't set this manually, use the function `set_close_to!`."
value = 0
"The width of the slider line"
linewidth::Float32 = 15
"The color of the slider when the mouse hovers over it."
color_active_dimmed::RGBAf = COLOR_ACCENT_DIMMED[]
"The color of the slider when the mouse clicks and drags the slider."
color_active::RGBAf = COLOR_ACCENT[]
"The color of the slider when it is not interacted with."
color_inactive::RGBAf = RGBf(0.94, 0.94, 0.94)
"Controls if the slider has a horizontal orientation or not."
horizontal::Bool = true
"The align mode of the slider in its parent GridLayout."
alignmode = Inside()
"Controls if the button snaps to valid positions or moves freely"
snap::Bool = true
end
end
@Block SliderGrid begin
@forwarded_layout
sliders::Vector{Slider}
valuelabels::Vector{Label}
labels::Vector{Label}
@attributes begin
"The horizontal alignment of the block in its suggested bounding box."
halign = :center
"The vertical alignment of the block in its suggested bounding box."
valign = :center
"The width setting of the block."
width = Auto()
"The height setting of the block."
height = Auto()
"Controls if the parent layout can adjust to this block's width"
tellwidth::Bool = true
"Controls if the parent layout can adjust to this block's height"
tellheight::Bool = true
"The align mode of the block in its parent GridLayout."
alignmode = Inside()
"The width of the value label column. If `automatic`, the width is determined by sampling a few values from the slider ranges and picking the largest label size found."
value_column_width = automatic
end
end
@Block IntervalSlider begin
selected_indices::Observable{Tuple{Int, Int}}
displayed_sliderfractions::Observable{Tuple{Float64, Float64}}
@attributes begin
"The horizontal alignment of the slider in its suggested bounding box."
halign = :center
"The vertical alignment of the slider in its suggested bounding box."
valign = :center
"The width setting of the slider."
width = Auto()
"The height setting of the slider."
height = Auto()
"The range of values that the slider can pick from."
range = 0:0.01:10
"Controls if the parent layout can adjust to this element's width"
tellwidth::Bool = true
"Controls if the parent layout can adjust to this element's height"
tellheight::Bool = true
"The start values of the slider or the values that are closest in the slider range."
startvalues = Makie.automatic
"The current interval of the slider. Don't set this manually, use the function `set_close_to!`."
interval = (0, 0)
"The width of the slider line"
linewidth::Float64 = 15.0
"The color of the slider when the mouse hovers over it."
color_active_dimmed::RGBAf = COLOR_ACCENT_DIMMED[]
"The color of the slider when the mouse clicks and drags the slider."
color_active::RGBAf = COLOR_ACCENT[]
"The color of the slider when it is not interacted with."
color_inactive::RGBAf = RGBf(0.94, 0.94, 0.94)
"Controls if the slider has a horizontal orientation or not."
horizontal::Bool = true
"The align mode of the slider in its parent GridLayout."
alignmode = Inside()
"Controls if the buttons snap to valid positions or move freely"
snap::Bool = true
end
end
@Block Button begin
@attributes begin
"The horizontal alignment of the button in its suggested boundingbox"
halign = :center
"The vertical alignment of the button in its suggested boundingbox"
valign = :center
"The extra space added to the sides of the button label's boundingbox."
padding = (10f0, 10f0, 10f0, 10f0)
"The font size of the button label."
fontsize = @inherit(:fontsize, 16f0)
"The text of the button label."
label = "Button"
"The font family of the button label."
font = :regular
"The width setting of the button."
width = Auto()
"The height setting of the button."
height = Auto()
"Controls if the parent layout can adjust to this element's width"
tellwidth = true
"Controls if the parent layout can adjust to this element's height"
tellheight = true
"The radius of the rounded corners of the button."
cornerradius = 4
"The number of poly segments used for each rounded corner."
cornersegments = 10
"The line width of the button border."
strokewidth = 2f0
"The color of the button border."
strokecolor = :transparent
"The color of the button."
buttoncolor = RGBf(0.94, 0.94, 0.94)
"The color of the label."
labelcolor = @inherit(:textcolor, :black)
"The color of the label when the mouse hovers over the button."
labelcolor_hover = :black
"The color of the label when the mouse clicks the button."
labelcolor_active = :white
"The color of the button when the mouse clicks the button."
buttoncolor_active = COLOR_ACCENT[]
"The color of the button when the mouse hovers over the button."
buttoncolor_hover = COLOR_ACCENT_DIMMED[]
"The number of clicks that have been registered by the button."
clicks = 0
"The align mode of the button in its parent GridLayout."
alignmode = Inside()
end
end
@Block Toggle begin
@attributes begin
"The horizontal alignment of the toggle in its suggested bounding box."
halign = :center
"The vertical alignment of the toggle in its suggested bounding box."
valign = :center
"The width of the toggle."
width = 60
"The height of the toggle."
height = 28
"Controls if the parent layout can adjust to this element's width"
tellwidth = true
"Controls if the parent layout can adjust to this element's height"
tellheight = true
"The number of poly segments in each rounded corner."
cornersegments = 15
# strokewidth = 2f0
# strokecolor = :transparent
"The color of the border when the toggle is inactive."
framecolor_inactive = RGBf(0.94, 0.94, 0.94)
"The color of the border when the toggle is hovered."
framecolor_active = COLOR_ACCENT_DIMMED[]
# buttoncolor = RGBf(0.2, 0.2, 0.2)
"The color of the toggle button."
buttoncolor = COLOR_ACCENT[]
"Indicates if the toggle is active or not."
active = false
"The duration of the toggle animation."
toggleduration = 0.15
"The border width as a fraction of the toggle height "
rimfraction = 0.33
"The align mode of the toggle in its parent GridLayout."
alignmode = Inside()
end
end
@Block Menu begin
@attributes begin
"The height setting of the menu."
height = Auto()
"The width setting of the menu."
width = nothing
"Controls if the parent layout can adjust to this element's width"
tellwidth = true
"Controls if the parent layout can adjust to this element's height"
tellheight = true
"The horizontal alignment of the menu in its suggested bounding box."
halign = :center
"The vertical alignment of the menu in its suggested bounding box."
valign = :center
"The alignment of the menu in its suggested bounding box."
alignmode = Inside()
"Index of selected item. Should not be set by the user."
i_selected = 0
"Selected item value. This is the output observable that you should listen to to react to menu interaction. Should not be set by the user."
selection = nothing
"Is the menu showing the available options"
is_open = false
"Cell color when hovered"
cell_color_hover = COLOR_ACCENT_DIMMED[]
"Cell color when active"
cell_color_active = COLOR_ACCENT[]
"Cell color when inactive even"
cell_color_inactive_even = RGBf(0.97, 0.97, 0.97)
"Cell color when inactive odd"
cell_color_inactive_odd = RGBf(0.97, 0.97, 0.97)
"Selection cell color when inactive"
selection_cell_color_inactive = RGBf(0.94, 0.94, 0.94)
"Color of the dropdown arrow"
dropdown_arrow_color = (:black, 0.2)
"Size of the dropdown arrow"
dropdown_arrow_size = 20
"The list of options selectable in the menu. This can be any iterable of a mixture of strings and containers with one string and one other value. If an entry is just a string, that string is both label and selection. If an entry is a container with one string and one other value, the string is the label and the other value is the selection."
options = ["no options"]
"Font size of the cell texts"
fontsize = @inherit(:fontsize, 16f0)
"Padding of entry texts"
textpadding = (10, 10, 10, 10)
"Color of entry texts"
textcolor = :black
"The opening direction of the menu (:up or :down)"
direction = automatic
"The default message prompting a selection when i == 0"
prompt = "Select..."
end
end
abstract type LegendElement end
struct LineElement <: LegendElement
attributes::Attributes
end
struct MarkerElement <: LegendElement
attributes::Attributes
end
struct PolyElement <: LegendElement
attributes::Attributes
end
struct LegendEntry
elements::Vector{LegendElement}
attributes::Attributes
end
const EntryGroup = Tuple{Optional{<:AbstractString}, Vector{LegendEntry}}
@Block Legend begin
entrygroups::Observable{Vector{EntryGroup}}
_tellheight::Observable{Bool}
_tellwidth::Observable{Bool}
grid::GridLayout
@attributes begin
"The horizontal alignment of the legend in its suggested bounding box."
halign = :center
"The vertical alignment of the legend in its suggested bounding box."
valign = :center
"The width setting of the legend."
width = Auto()
"The height setting of the legend."
height = Auto()
"Controls if the parent layout can adjust to this element's width"
tellwidth = automatic
"Controls if the parent layout can adjust to this element's height"
tellheight = automatic
"The font family of the legend group titles."
titlefont = :bold
"The font size of the legend group titles."
titlesize = @inherit(:fontsize, 16f0)
"The horizontal alignment of the legend group titles."
titlehalign = :center
"The vertical alignment of the legend group titles."
titlevalign = :center
"Controls if the legend titles are visible."
titlevisible = true
"The color of the legend titles"
titlecolor = @inherit(:textcolor, :black)
"The group title positions relative to their groups. Can be `:top` or `:left`."
titleposition = :top
"The font size of the entry labels."
labelsize = @inherit(:fontsize, 16f0)
"The font family of the entry labels."
labelfont = :regular
"The color of the entry labels."
labelcolor = @inherit(:textcolor, :black)
"The horizontal alignment of the entry labels."
labelhalign = :left
"The justification of the label text. Default is `automatic`, which will set the justification to labelhalign."
labeljustification = automatic
"The vertical alignment of the entry labels."
labelvalign = :center
"The additional space between the legend content and the border."
padding = (10f0, 10f0, 8f0, 8f0)
"The additional space between the legend and its suggested boundingbox."
margin = (0f0, 0f0, 0f0, 0f0)
"The background color of the legend."
bgcolor = :white
"The color of the legend border."
framecolor = :black
"The line width of the legend border."
framewidth = 1f0
"Controls if the legend border is visible."
framevisible = true
"The size of the rectangles containing the legend markers."
patchsize = (20f0, 20f0)
"The color of the border of the patches containing the legend markers."
patchstrokecolor = :transparent
"The line width of the border of the patches containing the legend markers."
patchstrokewidth = 1f0
"The color of the patches containing the legend markers."
patchcolor = :transparent