-
Notifications
You must be signed in to change notification settings - Fork 17
/
UnitFrameLayout.lua
executable file
·1570 lines (1448 loc) · 54.8 KB
/
UnitFrameLayout.lua
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
-- CONSTANTS ----------------------------------------------------------------
-- how many width points the center bars take up if at least one exists
local CENTER_WIDTH_POINTS = 10
-- how many pixels wide to assume a text is
local ASSUMED_TEXT_WIDTH = 40
local BAR_MODULE_TYPES = {
bar = true,
bar_provider = true,
}
local INDICATOR_MODULE_TYPES = {
indicator = true,
}
local TEXT_MODULE_TYPES = {
text_provider = true,
custom_text = true,
}
local DEFAULT_FONT_SIZE = select(2, ChatFontNormal:GetFont())
-----------------------------------------------------------------------------
-- a cache of element-to-scale
local scale_cache = {}
local _G = _G
local PitBull4 = _G.PitBull4
local DEBUG = PitBull4.DEBUG
local expect = PitBull4.expect
local UnitFrame = PitBull4.UnitFrame
local new, del = PitBull4.new, PitBull4.del
local ipairs_with_del
do
local function ipairs_with_del__iter(list, current)
current = current + 1
local value = list[current]
if value == nil then
del(list)
return nil
end
return current, value
end
--- Iterate over a list until nil is hit.
-- @param list a list
-- @return an iterator which returns index, value
-- @usage for i, v in ipairs_with_del({"a", "b", "c"}) do
-- print(i, v)
-- end
-- @usage for i, v in ipairs_with_del({"a", "b", "c", nil, "e"}) do
-- -- same as above, since it stops at i == 4
-- print(i, v)
-- end
function ipairs_with_del(list)
if DEBUG then
expect(list, 'typeof', 'table')
end
return ipairs_with_del__iter, list, 0
end
end
local modules = PitBull4.modules
--- Return the element-specific layout db for the given id and layout.
-- @param id either a module id or a module id, semicolon, and element id.
-- @param layout the name of the layout
-- @return the element db or nil
-- @usage db = get_element_db("CombatText", "Normal")
-- @usage db = get_element_db("DogTagTexts;Name", "Normal")
local function get_element_db(id, layout)
if DEBUG then
expect(id, 'typeof', 'string')
end
local module_id, element_id
if id:match(";") then
module_id, element_id = (";"):split(id, 2)
else
module_id = id
end
if DEBUG then
expect(module_id, 'inset', modules)
end
local module = modules[module_id]
local db = module:GetLayoutDB(layout)
if element_id then
db = rawget(db.elements, element_id)
end
if DEBUG then
expect(db, 'typeof', 'nil;table')
end
return db
end
--- A dictionary of element_id to module_type.
local element_id_to_module_type = setmetatable({}, {
__index = function(self, id)
if DEBUG then
expect(id, 'typeof', 'string')
end
local module_id = id
if module_id:match(";") then
module_id = (";"):split(id, 2)
end
if DEBUG then
expect(module_id, 'inset', modules)
end
local module = modules[module_id]
local module_type = module.module_type
if DEBUG then
expect(module_type, 'typeof', 'string')
end
self[id] = module_type
return module_type
end,
})
local sort_elements_by_position
do
local element_id_to_position = {}
local function sort_elements_by_position__helper(alpha, bravo)
return element_id_to_position[alpha] < element_id_to_position[bravo]
end
--- Sort a list of elements by position for the given layout.
-- @param element_ids a list of element ids
-- @param layout name of the layout
-- @usage element_ids = { "HealthBar", "PowerBar" }
-- sort_elements_by_position(element_ids)
function sort_elements_by_position(element_ids, layout)
if DEBUG then
expect(element_ids, 'typeof', 'table')
expect(layout, 'typeof', 'string')
end
for _, element_id in ipairs(element_ids) do
local db = get_element_db(element_id, layout)
element_id_to_position[element_id] = db and db.position or 0
end
table.sort(element_ids, sort_elements_by_position__helper)
wipe(element_id_to_position)
end
end
--- Return a list of element ids that are on a given side for a given layout.
-- @param element_ids a list of element ids
-- @param layout name of the layout
-- @param side the side to filter on, one of "left", "center", or "right"
-- @return a list of element ids
-- @usage element_ids = filter_elements_for_side({ "HealthBar", "PowerBar" }, "Normal", "center")
local function filter_elements_for_side(element_ids, layout, side)
if DEBUG then
expect(element_ids, 'typeof', 'table')
expect(layout, 'typeof', 'string')
expect(side, 'inset', "left;center;right")
end
local filtered_element_ids = new()
for _, element_id in ipairs(element_ids) do
local db = get_element_db(element_id, layout)
if db and db.side == side then
filtered_element_ids[#filtered_element_ids+1] = element_id
end
end
return filtered_element_ids
end
--- Return lists of all element ids that represent bar-like objects.
-- The resultant lists will be sorted by position.
-- @param frame a unit frame
-- @return a list of all element ids
-- @return a list of element ids where side = 'center'
-- @return a list of element ids where side = 'left'
-- @return a list of element ids where side = 'right'
-- @usage bars, center_bars, left_bars, right_bars = get_all_bars(frame)
local function get_all_bars(frame)
if DEBUG then
expect(frame, 'inset', PitBull4.all_frames)
end
local bars = new()
local layout = frame.layout
for id, module in PitBull4:IterateModulesOfType('bar') do
if frame[id] then
bars[#bars+1] = id
end
end
for id, module in PitBull4:IterateModulesOfType('indicator') do
if frame[id] and module:GetLayoutDB(layout).side then
bars[#bars+1] = id
end
end
for id, module in PitBull4:IterateModulesOfType('bar_provider') do
if frame[id] then
for name in pairs(frame[id]) do
bars[#bars+1] = id .. ";" .. name
end
end
end
sort_elements_by_position(bars, layout)
return bars,
filter_elements_for_side(bars, layout, 'center'),
filter_elements_for_side(bars, layout, 'left'),
filter_elements_for_side(bars, layout, 'right')
end
--- Calculate the sizing points for the various bars given.
-- @param layout the name of the layout
-- @param center_bars a list of bar-like elements where side = 'center'
-- @param left_bars a list of bar-like elements where side = 'left'
-- @param right_bars a list of bar-like elements where side = 'right'
-- @return the number of total width points make up the layout (except for the square indicators on the sides) with the given bars
-- @return the number of total height points make up the layout with the given bars
-- @return the number of square indicators are on the left side
-- @return the number of square indicators are on the right side
-- @usage bar_width_points, bar_height_points, left_exempt_width, right_exempt_width = calculate_width_height_points("Normal", {"HealthBar", "PowerBar"}, {"Portrait"}, {})
local function calculate_width_height_points(layout, center_bars, left_bars, right_bars)
if DEBUG then
expect(layout, 'typeof', 'string')
expect(center_bars, 'typeof', 'table')
expect(left_bars, 'typeof', 'table')
expect(right_bars, 'typeof', 'table')
end
local bar_height_points = 0
local bar_width_points = 0
local left_exempt_width = 0
local right_exempt_width = 0
for _, id in ipairs(center_bars) do
if INDICATOR_MODULE_TYPES[element_id_to_module_type[id]] then
bar_height_points = bar_height_points + get_element_db(id, layout).bar_size
else
bar_height_points = bar_height_points + get_element_db(id, layout).size
end
end
if #center_bars > 0 then
-- the center takes up CENTER_WIDTH_POINTS width points if it exists
bar_width_points = CENTER_WIDTH_POINTS
end
for _, id in ipairs(left_bars) do
if INDICATOR_MODULE_TYPES[element_id_to_module_type[id]] then
left_exempt_width = left_exempt_width + 1
else
bar_width_points = bar_width_points + get_element_db(id, layout).size
end
end
for _, id in ipairs(right_bars) do
if INDICATOR_MODULE_TYPES[element_id_to_module_type[id]] then
right_exempt_width = right_exempt_width + 1
else
bar_width_points = bar_width_points + get_element_db(id, layout).size
end
end
return bar_width_points, bar_height_points, left_exempt_width, right_exempt_width
end
local reverse_ipairs
do
local function reverse_ipairs__iter(t, current)
current = current - 1
if current == 0 then
return
end
return current, t[current]
end
--- Iterate backwards over a list.
-- @param list a list
-- @return an iterator which returns index, value
-- @usage for i, v in reverse_ipairs({"a", "b", "c"}) do
-- -- 3, "c" -- 2, "b", -- 1, "a"
-- end
function reverse_ipairs(list)
if DEBUG then
expect(list, 'typeof', 'table')
end
return reverse_ipairs__iter, list, #list + 1
end
end
--- Position all bar-like objects on the given frame.
-- @param frame a unit frame
-- @usage update_bar_layout(frame)
local function update_bar_layout(frame)
if DEBUG then
expect(frame, 'inset', PitBull4.all_frames)
end
local bars, center_bars, left_bars, right_bars = get_all_bars(frame)
local horizontal_mirror = frame.classification_db.horizontal_mirror
local vertical_mirror = frame.classification_db.vertical_mirror
if horizontal_mirror then
left_bars, right_bars = right_bars, left_bars
end
local frame_width, frame_height = frame:GetWidth(), frame:GetHeight()
local layout = frame.layout
local bar_width_points, bar_height_points, left_exempt_width, right_exempt_width = calculate_width_height_points(layout, center_bars, left_bars, right_bars)
local bar_spacing = frame.layout_db.bar_spacing
local bar_padding = frame.layout_db.bar_padding
local bar_height = frame_height - bar_padding * 2
local total_height_of_bars = frame_height - bar_spacing * (#center_bars - 1) - bar_padding * 2
local num_vertical_bars = #left_bars + #right_bars
if #center_bars > 0 then
-- treat the center bars as a single vertical bar
num_vertical_bars = num_vertical_bars + 1
end
-- this is the width of the frame without the square indicators.
local frame_leftover_width = frame_width - (left_exempt_width + right_exempt_width) * (frame_height + bar_spacing)
local total_width_of_bars = frame_leftover_width - bar_spacing * (num_vertical_bars - 1) - bar_padding * 2
local bar_height_per_point = bar_height_points > 0 and total_height_of_bars / bar_height_points or 0
local bar_width_per_point = bar_width_points > 0 and total_width_of_bars / bar_width_points or 0
-- position all bar-like elements on the left
local last_x = bar_padding
for _, id in ipairs(left_bars) do
local bar = frame[id]
bar:ClearAllPoints()
local bar_width
if INDICATOR_MODULE_TYPES[element_id_to_module_type[id]] then
-- this already has a defined height and width, so we just want to scale it into the right size and position its center
-- but first we need to set a bogus point temporarily so that GetHeight/Width calculate the set size not the effective
-- size after applying the anchor. ClearAllPoints does not reposition the frame/put the size back.
bar:SetPoint("LEFT")
local bar_scale = bar_height / math.max(bar:GetHeight(), bar:GetWidth())
bar:SetScale(bar_scale)
bar_width = bar_height
bar:ClearAllPoints()
bar:SetPoint("CENTER", frame, "LEFT", (last_x + bar_width/2) / bar_scale, 0)
else
bar_width = get_element_db(id, layout).size * bar_width_per_point
bar:SetPoint("TOPLEFT", frame, "TOPLEFT", last_x, -bar_padding)
bar:SetPoint("BOTTOMRIGHT", frame, "BOTTOMLEFT", last_x + bar_width, bar_padding)
end
last_x = last_x + bar_width + bar_spacing
if bar.SetOrientation then
bar:SetOrientation("VERTICAL")
end
end
local left = last_x
-- position all bar-like elements on the right
last_x = -bar_padding
for _, id in ipairs(right_bars) do
local bar = frame[id]
bar:ClearAllPoints()
local bar_width
if INDICATOR_MODULE_TYPES[element_id_to_module_type[id]] then
-- this already has a defined height and width, so we just want to scale it into the right size and position its center
-- but first we need to set a bogus point temporarily so that GetHeight/Width calculate the set size not the effective
-- size after applying the anchor. ClearAllPoints does not reposition the frame/put the size back.
bar:SetPoint("RIGHT")
local bar_scale = bar_height / math.max(bar:GetHeight(), bar:GetWidth())
bar:SetScale(bar_scale)
bar_width = bar_height
bar:ClearAllPoints()
bar:SetPoint("CENTER", frame, "RIGHT", (last_x - bar_width/2) / bar_scale, 0)
else
bar_width = get_element_db(id, layout).size * bar_width_per_point
bar:SetPoint("TOPRIGHT", frame, "TOPRIGHT", last_x, -bar_padding)
bar:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT", last_x - bar_width, bar_padding)
end
last_x = last_x - bar_width - bar_spacing
if bar.SetOrientation then
bar:SetOrientation("VERTICAL")
end
end
local right = last_x
-- now position all the center bars between the left and right bars
local last_y = -bar_padding
for i, id in (not vertical_mirror and ipairs or reverse_ipairs)(center_bars) do
local bar = frame[id]
bar:ClearAllPoints()
local bar_size
if INDICATOR_MODULE_TYPES[element_id_to_module_type[id]] then
bar:SetScale(1)
bar_size = get_element_db(id, layout).bar_size
else
bar_size = get_element_db(id, layout).size
end
bar:SetPoint("TOPLEFT", frame, "TOPLEFT", left, last_y)
local bar_height = bar_size * bar_height_per_point
last_y = last_y - bar_height
bar:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", right, last_y)
last_y = last_y - bar_spacing
if bar.SetOrientation then
bar:SetOrientation("HORIZONTAL")
end
end
-- set various information on the bars
for _, id in ipairs(bars) do
if not INDICATOR_MODULE_TYPES[element_id_to_module_type[id]] then
local bar = frame[id]
local bar_layout_db = get_element_db(id, layout)
local reverse = bar_layout_db.reverse
if bar_layout_db.side == "center" then
if horizontal_mirror then
reverse = not reverse
end
else
if vertical_mirror then
reverse = not reverse
end
end
bar:SetReverse(reverse)
bar:SetDeficit(bar_layout_db.deficit)
end
end
bars = del(bars)
center_bars = del(center_bars)
left_bars = del(left_bars)
right_bars = del(right_bars)
end
--- Return lists of all element ids that represent non-bar-like indicators and texts.
-- The resultant list will be sorted by position.
-- @param frame a unit frame
-- @return a list of all element ids
-- @usage elements = get_all_indicators_and_texts(frame)
local function get_all_indicators_and_texts(frame)
local indicators_and_texts = new()
local layout = frame.layout
for id, module in PitBull4:IterateModulesOfType('indicator', 'custom_text') do
if frame[id] and not module:GetLayoutDB(layout).side then
indicators_and_texts[#indicators_and_texts+1] = id
end
end
for id, module in PitBull4:IterateModulesOfType('text_provider') do
if frame[id] then
for name in pairs(frame[id]) do
indicators_and_texts[#indicators_and_texts+1] = id .. ";" .. name
end
end
end
sort_elements_by_position(indicators_and_texts, layout)
return indicators_and_texts
end
--- Return an estimated half-width of elements in a given location on a frame.
-- @param frame a unit frame
-- @param indicators_and_texts a list of element ids to estimate the width of.
-- @return the estimated number of pixels that make up half the width.
-- @usage local width = get_half_width(frame, { "CombatText", "HappinessIcon" })
local function get_half_width(frame, indicators_and_texts)
local num = 0
local layout = frame.layout
local layout_db = frame.layout_db
for _, id in ipairs(indicators_and_texts) do
local element = frame[id]
local element_db = get_element_db(id, layout)
local scale = scale_cache[element]
if element.SetJustifyH then
-- a text
num = num + scale * ASSUMED_TEXT_WIDTH * (element_db and element_db.size or 1)
else
-- an indicator
num = num + scale * (element_db and element_db.size or 1) * layout_db.indicator_size * element:GetWidth() / element:GetHeight() * (element.height or 1)
end
end
num = num + (#indicators_and_texts - 1) * layout_db.indicator_spacing
return num / 2
end
-- a dictionary of location to function for the initial indicator to be placed on the unit frame.
local position_indicator_on_root = {}
-- a dictionary of location to function for the initial indicator to be placed on a bar on the unit frame.
local position_indicator_on_bar = {}
-- a dictionary of location to function for a non-starting indicator to be placed on the unit frame
local position_next_indicator_on_root = {}
-- a dictionary of location to function for a non-starting indicator to be placed on a bar on the unit frame
local position_next_indicator_on_bar = {}
function position_indicator_on_root:out_top_left(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -self.layout_db.indicator_root_outside_margin / scale, self.layout_db.indicator_root_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_root:out_top_right(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", self.layout_db.indicator_root_outside_margin / scale, self.layout_db.indicator_root_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_root:out_top(indicator, _, _, indicators_and_texts)
local scale = scale_cache[indicator]
if #indicators_and_texts == 1 then
indicator:SetPoint("BOTTOM", self, "TOP", 0, self.layout_db.indicator_root_outside_margin / scale)
else
indicator:SetPoint("BOTTOMLEFT", self, "TOP", -get_half_width(self, indicators_and_texts) / scale, self.layout_db.indicator_root_outside_margin / scale)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_root:out_bottom_left(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -self.layout_db.indicator_root_outside_margin / scale, -self.layout_db.indicator_root_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_root:out_bottom_right(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPRIGHT", self, "BOTTOMRIGHT", self.layout_db.indicator_root_outside_margin / scale, -self.layout_db.indicator_root_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_root:out_bottom(indicator, _, _, indicators_and_texts)
local scale = scale_cache[indicator]
if #indicators_and_texts == 1 then
indicator:SetPoint("TOP", self, "BOTTOM", 0, -self.layout_db.indicator_root_outside_margin / scale)
else
indicator:SetPoint("TOPLEFT", self, "BOTTOM", -get_half_width(self, indicators_and_texts) / scale, -self.layout_db.indicator_root_outside_margin / scale)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_root:out_left_top(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPRIGHT", self, "TOPLEFT", -self.layout_db.indicator_root_outside_margin / scale, self.layout_db.indicator_root_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_root:out_left(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("RIGHT", self, "LEFT", -self.layout_db.indicator_root_outside_margin / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_root:out_left_bottom(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMRIGHT", self, "BOTTOMLEFT", -self.layout_db.indicator_root_outside_margin / scale, -self.layout_db.indicator_root_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_root:out_right_top(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPLEFT", self, "TOPRIGHT", self.layout_db.indicator_root_outside_margin / scale, self.layout_db.indicator_root_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_root:out_right(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("LEFT", self, "RIGHT", self.layout_db.indicator_root_outside_margin / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_root:out_right_bottom(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMLEFT", self, "BOTTOMRIGHT", self.layout_db.indicator_root_outside_margin / scale, -self.layout_db.indicator_root_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_root:in_center(indicator, _, _, indicators_and_texts)
if #indicators_and_texts == 1 then
indicator:SetPoint("CENTER", self, "CENTER", 0, 0)
else
local scale = scale_cache[indicator]
indicator:SetPoint("LEFT", self, "CENTER", -get_half_width(self, indicators_and_texts) / scale, 0)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_root:in_top_left(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPLEFT", self, "TOPLEFT", self.layout_db.indicator_root_inside_horizontal_padding / scale, -self.layout_db.indicator_root_inside_vertical_padding / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_root:in_top(indicator, _, _, indicators_and_texts)
local scale = scale_cache[indicator]
if #indicators_and_texts == 1 then
indicator:SetPoint("TOP", self, "TOP", 0, -self.layout_db.indicator_root_inside_vertical_padding / scale)
else
indicator:SetPoint("TOPLEFT", self, "TOP", -get_half_width(self, indicators_and_texts) / scale, -self.layout_db.indicator_root_inside_vertical_padding / scale)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_root:in_top_right(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPRIGHT", self, "TOPRIGHT", -self.layout_db.indicator_root_inside_horizontal_padding / scale, -self.layout_db.indicator_root_inside_vertical_padding / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_root:in_bottom_left(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", self.layout_db.indicator_root_inside_horizontal_padding / scale, self.layout_db.indicator_root_inside_vertical_padding / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_root:in_bottom(indicator, _, _, indicators_and_texts)
local scale = scale_cache[indicator]
if #indicators_and_texts == 1 then
indicator:SetPoint("BOTTOM", self, "BOTTOM", 0, self.layout_db.indicator_root_inside_vertical_padding / scale)
else
indicator:SetPoint("BOTTOMLEFT", self, "BOTTOM", -get_half_width(self, indicators_and_texts) / scale, self.layout_db.indicator_root_inside_vertical_padding / scale)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_root:in_bottom_right(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -self.layout_db.indicator_root_inside_horizontal_padding / scale, self.layout_db.indicator_root_inside_vertical_padding / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_root:in_left(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("LEFT", self, "LEFT", self.layout_db.indicator_root_inside_horizontal_padding / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_root:in_right(indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("RIGHT", self, "RIGHT", -self.layout_db.indicator_root_inside_horizontal_padding / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_root:edge_top_left(indicator)
if indicator.SetJustifyH then
indicator:SetPoint("LEFT", self, "TOPLEFT", 0, 0)
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
else
indicator:SetPoint("CENTER", self, "TOPLEFT", 0, 0)
end
end
function position_indicator_on_root:edge_top(indicator, _, _, indicators_and_texts)
if #indicators_and_texts == 1 then
indicator:SetPoint("CENTER", self, "TOP", 0, 0)
else
local scale = scale_cache[indicator]
indicator:SetPoint("LEFT", self, "TOP", -get_half_width(self, indicators_and_texts) / scale, 0)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_root:edge_top_right(indicator)
if indicator.SetJustifyH then
indicator:SetPoint("RIGHT", self, "TOPRIGHT", 0, 0)
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
else
indicator:SetPoint("CENTER", self, "TOPRIGHT", 0, 0)
end
end
function position_indicator_on_root:edge_left(indicator)
if indicator.SetJustifyH then
indicator:SetPoint("RIGHT", self, "LEFT", 0, 0)
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
else
indicator:SetPoint("CENTER", self, "LEFT", 0, 0)
end
end
function position_indicator_on_root:edge_right(indicator)
if indicator.SetJustifyH then
indicator:SetPoint("LEFT", self, "RIGHT", 0, 0)
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
else
indicator:SetPoint("CENTER", self, "RIGHT", 0, 0)
end
end
function position_indicator_on_root:edge_bottom_left(indicator)
if indicator.SetJustifyH then
indicator:SetPoint("LEFT", self, "BOTTOMLEFT", 0, 0)
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
else
indicator:SetPoint("CENTER", self, "BOTTOMLEFT", 0, 0)
end
end
function position_indicator_on_root:edge_bottom(indicator, _, _, indicators_and_texts)
if #indicators_and_texts == 1 then
indicator:SetPoint("CENTER", self, "BOTTOM", 0, 0)
else
local scale = scale_cache[indicator]
indicator:SetPoint("LEFT", self, "BOTTOM", -get_half_width(self, indicators_and_texts) / scale, 0)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_root:edge_bottom_right(indicator)
if indicator.SetJustifyH then
indicator:SetPoint("RIGHT", self, "BOTTOMRIGHT", 0, 0)
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
else
indicator:SetPoint("CENTER", self, "BOTTOMRIGHT", 0, 0)
end
end
function position_indicator_on_bar:left(indicator, bar)
local attach
if bar.icon then
if bar.reverse then
attach = bar.bg
else
attach = bar.fg
end
end
if not attach then
attach = bar
end
local scale = scale_cache[indicator]
indicator:SetPoint("LEFT", attach, "LEFT", self.layout_db.indicator_bar_inside_horizontal_padding / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_bar:center(indicator, bar, _, indicators_and_texts)
if #indicators_and_texts == 1 then
indicator:SetPoint("CENTER", bar, "CENTER", 0, 0)
else
local scale = scale_cache[indicator]
indicator:SetPoint("LEFT", bar, "CENTER", -get_half_width(self, indicators_and_texts) / scale, 0)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_bar:right(indicator, bar)
local attach
if bar.icon then
if bar.reverse then
attach = bar.fg
else
attach = bar.bg
end
end
if not attach then
attach = bar
end
local scale = scale_cache[indicator]
indicator:SetPoint("RIGHT", attach, "RIGHT", -self.layout_db.indicator_bar_inside_horizontal_padding / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_bar:top(indicator, bar, _, indicators_and_texts)
local attach
if bar.icon then
if bar.reverse then
attach = bar.fg
else
attach = bar.bg
end
end
if not attach then
attach = bar
end
if #indicators_and_texts == 1 then
indicator:SetPoint("TOP", attach, "TOP", 0, 0)
else
local scale = scale_cache[indicator]
indicator:SetPoint("TOPLEFT", attach, "TOP", -get_half_width(self, indicators_and_texts) / scale, -self.layout_db.indicator_bar_inside_vertical_padding / scale)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_bar:bottom(indicator, bar, _, indicators_and_texts)
local attach
if bar.icon then
if bar.reverse then
attach = bar.bg
else
attach = bar.fg
end
end
if not attach then
attach = bar
end
if #indicators_and_texts == 1 then
indicator:SetPoint("BOTTOM", attach, "BOTTOM", 0, 0)
else
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMLEFT", attach, "BOTTOM", -get_half_width(self, indicators_and_texts) / scale, self.layout_db.indicator_bar_inside_vertical_padding / scale)
end
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_bar:top_left(indicator, bar)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPLEFT", bar, "TOPLEFT", self.layout_db.indicator_bar_inside_horizontal_padding / scale, -self.layout_db.indicator_bar_inside_vertical_padding / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_bar:top_right(indicator, bar)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPRIGHT", bar, "TOPRIGHT", -self.layout_db.indicator_bar_inside_horizontal_padding / scale, -self.layout_db.indicator_bar_inside_vertical_padding / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_bar:bottom_left(indicator, bar)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT", self.layout_db.indicator_bar_inside_horizontal_padding / scale, self.layout_db.indicator_bar_inside_vertical_padding / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_bar:bottom_right(indicator, bar)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT", -self.layout_db.indicator_bar_inside_horizontal_padding / scale, self.layout_db.indicator_bar_inside_vertical_padding / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_indicator_on_bar:out_right(indicator, bar)
local scale = scale_cache[indicator]
indicator:SetPoint("LEFT", bar, "RIGHT", self.layout_db.indicator_bar_outside_margin / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_bar:out_left(indicator, bar)
local scale = scale_cache[indicator]
indicator:SetPoint("RIGHT", bar, "LEFT", -self.layout_db.indicator_bar_outside_margin / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("RIGHT")
indicator:SetJustifyV("MIDDLE")
end
end
function position_indicator_on_bar:out_top(indicator, bar)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOM", bar, "TOP", 0, self.layout_db.indicator_bar_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("TOP")
end
end
function position_indicator_on_bar:out_bottom(indicator, bar)
local scale = scale_cache[indicator]
indicator:SetPoint("TOP", bar, "BOTTOM", 0, -self.layout_db.indicator_bar_outside_margin / scale)
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("BOTTOM")
end
end
function position_next_indicator_on_root:out_top_left(indicator, _, last_indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMLEFT", last_indicator, "BOTTOMRIGHT", self.layout_db.indicator_spacing / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("BOTTOM")
end
end
function position_next_indicator_on_root:out_top(indicator, _, last_indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("BOTTOMLEFT", last_indicator, "BOTTOMRIGHT", self.layout_db.indicator_spacing / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("BOTTOM")
end
end
function position_next_indicator_on_root:out_bottom_left(indicator, _, last_indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPLEFT", last_indicator, "TOPRIGHT", self.layout_db.indicator_spacing / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("LEFT")
indicator:SetJustifyV("TOP")
end
end
function position_next_indicator_on_root:out_bottom(indicator, _, last_indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPLEFT", last_indicator, "TOPRIGHT", self.layout_db.indicator_spacing / scale, 0)
if indicator.SetJustifyH then
indicator:SetJustifyH("CENTER")
indicator:SetJustifyV("TOP")
end
end
function position_next_indicator_on_root:out_right_top(indicator, _, last_indicator)
local scale = scale_cache[indicator]
indicator:SetPoint("TOPLEFT", last_indicator, "TOPRIGHT", self.layout_db.indicator_spacing / scale, 0)
if indicator.SetJustifyH then